/* if is embedded in a block area */
if (area instanceof BlockArea) {
/* temporarily end the block area */
- area.end();
+// area.end();
}
if(this.areaCurrent == null) {
this.areaCurrent =
- new ForeignObjectArea(fs, area.getAllocationWidth(), area.spaceLeft());
+ new ForeignObjectArea(fs, area.getAllocationWidth());
this.areaCurrent.start();
areaCurrent.setWidth(this.width);
}
}
+ if (area instanceof BlockArea) {
+ BlockArea ba = (BlockArea)area;
+ LineArea la = ba.getCurrentLineArea();
+ la.addPending();
+ if(areaCurrent.getEffectiveWidth() > la.getRemainingWidth()) {
+ la = ba.createNextLineArea();
+ if(la == null) {
+ return new Status(Status.AREA_FULL_NONE);
+ }
+ }
+ la.addInlineArea(areaCurrent);
+ } else {
+ area.addChild(areaCurrent);
+ area.increaseHeight(areaCurrent.getEffectiveHeight());
+ }
+
if (this.isInLabel) {
startIndent += bodyIndent;
/* endIndent += (areaCurrent.getEffectiveWidth()
/* if there is a space-before */
if (spaceBefore != 0) {
/* add a display space */
- area.addDisplaySpace(spaceBefore);
+// area.addDisplaySpace(spaceBefore);
}
/* add the SVG area to the containing area */
- area.addChild(areaCurrent);
+// area.addChild(areaCurrent);
areaCurrent.setPage(area.getPage());
/* increase the height of the containing area accordingly */
- area.increaseHeight(areaCurrent.getEffectiveHeight());
+// area.increaseHeight(areaCurrent.getEffectiveHeight());
/* if there is a space-after */
if (spaceAfter != 0) {
/* add a display space */
- area.addDisplaySpace(spaceAfter);
+// area.addDisplaySpace(spaceAfter);
}
/* if is embedded in a block area */
if (area instanceof BlockArea) {
/* re-start the block area */
- area.start();
+// area.start();
}
if (breakAfter == BreakAfter.PAGE) {
new PageNumberInlineArea(currentFontState, this.red,
this.green, this.blue, refid, width);
+ pia.setYOffset(placementOffset);
pendingAreas.addElement(pia);
pendingWidth += width;
wordWidth = 0;
this.red, this.green, this.blue,
new String(data, wordStart,
wordLength), wordWidth);
+ ia.setYOffset(placementOffset);
ia.setUnderlined(ul);
addChild(ia);
if (ls != null) {
this.green, this.blue,
new String(data, wordStart, wordLength), wordWidth);
+ pia.setYOffset(placementOffset);
pia.setUnderlined(ul);
if (ls != null) {
new LeaderArea(fontState, red, green, blue, "",
leaderLength, leaderPattern, ruleThickness,
ruleStyle);
+ leaderArea.setYOffset(placementOffset);
pendingAreas.addElement(leaderArea);
break;
case LeaderPattern.DOTS:
new WordArea(currentFontState, this.red,
this.green, this.blue, new String ("."),
this.currentFontState.width(46));
+ leaderPatternArea.setYOffset(placementOffset);
int dotsFactor = (int) Math.floor (
((double) leaderLength) /
((double) leaderPatternWidth));
}
}
+ /**
+ * Balance (vertically) the inline areas within this line.
+ */
+ public void verticalAlign()
+ {
+ int superHeight = -this.placementOffset;
+ int maxHeight = this.allocationHeight;
+ Enumeration e = children.elements();
+ while (e.hasMoreElements()) {
+ Box b = (Box) e.nextElement();
+ if(b instanceof InlineArea) {
+ InlineArea ia = (InlineArea)b;
+ if(ia.getHeight() > maxHeight) {
+ maxHeight = ia.getHeight();
+ }
+ int vert = ia.getVerticalAlign();
+/* if(vert == VerticalAlign.SUPER) {
+ int tbe = fontState.getAscender();
+ ia.setYOffset(placementOffset - (tbe - h));
+ }*/
+ } else {
+ }
+ }
+ this.allocationHeight = maxHeight;
+ }
+
public void changeColor(float red, float green, float blue) {
this.red = red;
this.green = green;
}
public boolean isEmpty() {
- return (prev == 0);
+ return !(pendingAreas.size() > 0 || children.size() > 0);
+// return (prev == 0);
}
public Vector getPendingAreas() {
WordArea leaderPatternArea =
new WordArea(currentFontState, this.red, this.green,
this.blue, new String (leaderChars), leaderLength);
+ leaderPatternArea.setYOffset(placementOffset);
return leaderPatternArea;
}
return width;
}
+ public int getRemainingWidth()
+ {
+ return this.getContentWidth() - this.getCurrentXPosition();
+ }
+
+ public void addInlineArea(Area box)
+ {
+ addPending();
+ addChild(box);
+ prev = TEXT;
+ finalWidth += box.getContentWidth();
+ }
/** adds a single character to the line area tree*/
public int addCharacter (char data, LinkSet ls, boolean ul) {
ia = new WordArea(currentFontState,
this.red, this.green, this.blue,
new Character(data).toString(),width);
+ ia.setYOffset(placementOffset);
ia.setUnderlined(ul);
pendingAreas.addElement(ia);
if (Character.isSpaceChar(data)) {
hia = new WordArea(currentFontState,
this.red, this.green, this.blue,
new Character(startChar).toString(),1);
+ hia.setYOffset(placementOffset);
this.addChild(hia);
}
int wordWidth = this.getWordWidth(word);
hia = new WordArea(currentFontState,
this.red, this.green, this.blue,
word,word.length());
+ hia.setYOffset(placementOffset);
this.addChild(hia);
//calculate the space needed
import java.util.Vector;
import java.util.Enumeration;
-public class ForeignObjectArea extends Area {
-
+public class ForeignObjectArea extends InlineArea {
+
protected int xOffset = 0;
/* text-align of contents */
protected int align;
protected int aheight;
/* width */
protected int width;
- /* height */
- protected int height;
boolean wauto;
boolean hauto;
boolean cwauto;
boolean chauto;
int overflow;
- public ForeignObjectArea(FontState fontState, int width,
- int height) {
- super(fontState, width, height);
+ public ForeignObjectArea(FontState fontState, int width) {
+ super(fontState, width, 0, 0, 0);
}
public void render(Renderer renderer) {
renderer.renderForeignObjectArea(this);
}
+ /**
+ * This is NOT the content width of the instream-foreign-object.
+ * This is the content width for a Box.
+ */
+ public int getContentWidth()
+ {
+ return getEffectiveWidth();
+ }
+
+ /**
+ * This is NOT the content height of the instream-foreign-object.
+ * This is the content height for a Box.
+ */
+ public int getHeight()
+ {
+ return getEffectiveHeight();
+ }
+
public int getXOffset()
{
return this.xOffset;