}
/**
- * @param list the list to which the layout manager(s) should be added
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
if (endIndex - startIndex > 0) {
}
/**
- * @param list the list to which the layout manager(s) should be added
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
if (getChildNodes() != null) {
package org.apache.fop.fo.flow;
+// Java
+import java.util.List;
+
// XML
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
// FOP
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.InlineParent;
+import org.apache.fop.area.LinkResolver;
+import org.apache.fop.area.PageViewport;
+import org.apache.fop.area.Trait;
import org.apache.fop.fo.FOElementMapping;
import org.apache.fop.fo.FONode;
-import org.apache.fop.layoutmgr.AddLMVisitor;
+import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.LMiter;
+import org.apache.fop.layoutmgr.InlineStackingLayoutManager;
import org.apache.fop.fo.properties.CommonAccessibility;
import org.apache.fop.fo.properties.CommonAural;
import org.apache.fop.fo.properties.CommonBorderAndPadding;
import org.apache.fop.fo.properties.CommonBackground;
import org.apache.fop.fo.properties.CommonMarginInline;
import org.apache.fop.fo.properties.CommonRelativePosition;
-import org.apache.fop.fo.LMVisited;
/**
* The basic link.
* This sets the basic link trait on the inline parent areas
* that are created by the fo element.
*/
-public class BasicLink extends Inline implements LMVisited {
+public class BasicLink extends Inline {
private String link = null;
private boolean external = false;
getFOInputHandler().endLink();
}
- /**
- * @return the String value of the link
- */
- public String getLink() {
- return link;
- }
-
- /**
- * @return true if the link is external, false otherwise
- */
- public boolean getExternal() {
- return external;
- }
-
- public String getName() {
- return "fo:basic-link";
- }
-
/**
* @return true (BasicLink can contain Markers)
*/
}
/**
- * This is a hook for the AddLMVisitor class to be able to access
- * this object.
- * @param aLMV the AddLMVisitor object that can access this object.
- */
- public void acceptVisitor(AddLMVisitor aLMV) {
- aLMV.serveBasicLink(this);
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
+ * @todo create a subclass for InlineStackingLayoutManager, moving the formatting
+ * logic to the layoutmgr package
+ */
+ public void addLayoutManager(List list) {
+ InlineStackingLayoutManager lm;
+ lm = new InlineStackingLayoutManager(this) {
+ protected InlineParent createArea() {
+ InlineParent area = super.createArea();
+ setupBasicLinkArea(parentLM, area);
+ return area;
+ }
+ };
+ lm.setLMiter(new LMiter(lm, getChildNodes()));
+ list.add(lm);
+ }
+
+ protected void setupBasicLinkArea(LayoutManager parentLM,
+ InlineParent area) {
+ if (link == null) {
+ return;
+ }
+ if (external) {
+ area.addTrait(Trait.EXTERNAL_LINK, link);
+ } else {
+ PageViewport page = parentLM.resolveRefID(link);
+ if (page != null) {
+ area.addTrait(Trait.INTERNAL_LINK, page.getKey());
+ } else {
+ LinkResolver res = new LinkResolver(link, area);
+ parentLM.addUnresolvedArea(link, res);
+ }
+ }
+ }
+
+ public String getName() {
+ return "fo:basic-link";
}
}
}
/**
- * This is a hook for the AddLMVisitor class to be able to access
- * this object.
- * @param aLMV the AddLMVisitor object that can access this object.
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
if (false) {
}
/**
- * @param list the list to which the layout manager(s) should be added
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
BlockLayoutManager blm = new BlockLayoutManager(this);
}
/**
- * @param list the list to which the layout manager(s) should be added
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
BlockContainerLayoutManager blm = new BlockContainerLayoutManager(this);
package org.apache.fop.fo.flow;
// Java
+import java.util.List;
import java.awt.geom.Rectangle2D;
// XML
import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
+import org.apache.fop.area.inline.Image;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.Viewport;
import org.apache.fop.datatypes.Length;
+import org.apache.fop.fo.properties.CommonBorderAndPadding;
+import org.apache.fop.fo.properties.CommonBackground;
import org.apache.fop.fo.FONode;
-import org.apache.fop.layoutmgr.AddLMVisitor;
import org.apache.fop.fo.FObj;
import org.apache.fop.image.FopImage;
import org.apache.fop.image.ImageFactory;
-import org.xml.sax.Attributes;
-import org.apache.fop.fo.LMVisited;
+import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
+import org.apache.fop.layoutmgr.TraitSetter;
/**
* External graphic formatting object.
* This FO node handles the external graphic. It creates an image
* inline area that can be added to the area tree.
*/
-public class ExternalGraphic extends FObj implements LMVisited {
+public class ExternalGraphic extends FObj {
private String url;
private int breakAfter;
private int breakBefore;
* This gets the sizes for the image and the dimensions and clipping.
*/
private void setup() {
+ setupID();
url = this.propertyList.get(PR_SRC).getString();
if (url == null) {
return;
}
/**
- * This is a hook for the AddLMVisitor class to be able to access
- * this object.
- * @param aLMV the AddLMVisitor object that can access this object.
- */
- public void acceptVisitor(AddLMVisitor aLMV) {
- setup();
- aLMV.serveExternalGraphic(this);
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
+ */
+ public void addLayoutManager(List list) {
+ setup();
+ InlineArea area = getExternalGraphicInlineArea();
+ if (area != null) {
+ LeafNodeLayoutManager lm = new LeafNodeLayoutManager(this);
+ lm.setCurrentArea(area);
+ lm.setAlignment(getProperty(PR_VERTICAL_ALIGN).getEnum());
+ lm.setLead(getViewHeight());
+ list.add(lm);
+ }
}
+
+ /**
+ * Get the inline area for this external grpahic.
+ * This creates the image area and puts it inside a viewport.
+ *
+ * @return the viewport containing the image area
+ * @todo see if can move to LM classes.
+ */
+ public InlineArea getExternalGraphicInlineArea() {
+ if (getURL() == null) {
+ return null;
+ }
+ Image imArea = new Image(getURL());
+ Viewport vp = new Viewport(imArea);
+ vp.setWidth(getViewWidth());
+ vp.setHeight(getViewHeight());
+ vp.setClip(getClip());
+ vp.setContentPosition(getPlacement());
+ vp.setOffset(0);
+
+ // Common Border, Padding, and Background Properties
+ CommonBorderAndPadding bap = getPropertyManager().getBorderAndPadding();
+ CommonBackground bProps = getPropertyManager().getBackgroundProps();
+ TraitSetter.addBorders(vp, bap);
+ TraitSetter.addBackground(vp, bProps);
+
+ return vp;
+ }
+
}
}
/**
- * @param list the list to which the layout manager(s) should be added
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
if (getInlineFO() == null) {
}
/**
- * @param list the list to which the layout manager(s) should be added
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
ArrayList childList = new ArrayList();
}
/**
- * @param list the list to which the layout manager(s) should be added
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
ListBlockLayoutManager lm = new ListBlockLayoutManager(this);
package org.apache.fop.fo.flow;
+// Java
+import java.util.List;
+
// XML
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.FONode;
-import org.apache.fop.layoutmgr.AddLMVisitor;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.properties.CommonAccessibility;
import org.apache.fop.fo.properties.CommonAural;
import org.apache.fop.fo.properties.CommonMarginInline;
import org.apache.fop.fo.properties.CommonRelativePosition;
import org.apache.fop.fonts.Font;
-import org.apache.fop.fo.LMVisited;
-
+import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.LayoutManager;
+import org.apache.fop.layoutmgr.LeafNodeLayoutManager;
+import org.apache.fop.layoutmgr.PositionIterator;
+import org.apache.fop.area.PageViewport;
+import org.apache.fop.area.Resolveable;
+import org.apache.fop.area.Trait;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.UnresolvedPageNumber;
+import org.apache.fop.area.inline.TextArea;
/**
* Class modelling the fo:page-number-citation object. See Sec. 6.6.11 of the
* The page number used is the page that contains the start of the
* block referenced with the ref-id attribute.
*/
-public class PageNumberCitation extends FObj implements LMVisited {
+public class PageNumberCitation extends FObj {
/** Fontstate for this object **/
protected Font fontState;
CommonRelativePosition mRelProps =
propMgr.getRelativePositionProps();
- // this.propertyList.get("alignment-adjust");
- // this.propertyList.get("alignment-baseline");
- // this.propertyList.get("baseline-shift");
- // this.propertyList.get("dominant-baseline");
setupID();
- // this.propertyList.get("keep-with-next");
- // this.propertyList.get("keep-with-previous");
- // this.propertyList.get("letter-spacing");
- // this.propertyList.get("line-height");
- // this.propertyList.get("line-height-shift-adjustment");
- // this.propertyList.get("ref-id");
- // this.propertyList.get("score-spaces");
- // this.propertyList.get("text-decoration");
- // this.propertyList.get("text-shadow");
- // this.propertyList.get("text-transform");
- // this.propertyList.get("word-spacing");
ColorType c = this.propertyList.get(PR_COLOR).getColorType();
this.red = c.getRed();
return "fo:page-number-citation";
}
- public void acceptVisitor(AddLMVisitor aLMV) {
- setup();
- aLMV.servePageNumberCitation(this);
+ /**
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
+ * @todo create a subclass for LeafNodeLayoutManager, moving the formatting
+ * logic to the layoutmgr package
+ */
+ public void addLayoutManager(List list) {
+ setup();
+ LayoutManager lm;
+ lm = new LeafNodeLayoutManager(this) {
+ public InlineArea get(LayoutContext context) {
+ curArea = getPageNumberCitationInlineArea(parentLM);
+ return curArea;
+ }
+
+ public void addAreas(PositionIterator posIter,
+ LayoutContext context) {
+ super.addAreas(posIter, context);
+ if (getUnresolved()) {
+ parentLM.addUnresolvedArea(getRefId(),
+ (Resolveable) curArea);
+ }
+ }
+
+ protected void offsetArea(LayoutContext context) {
+ curArea.setOffset(context.getBaseline());
+ }
+ };
+ list.add(lm);
}
+
+ // if id can be resolved then simply return a word, otherwise
+ // return a resolveable area
+ public InlineArea getPageNumberCitationInlineArea(LayoutManager parentLM) {
+ if (getRefId().equals("")) {
+ getLogger().error("page-number-citation must contain \"ref-id\"");
+ return null;
+ }
+ PageViewport page = parentLM.resolveRefID(getRefId());
+ InlineArea inline = null;
+ if (page != null) {
+ String str = page.getPageNumber();
+ // get page string from parent, build area
+ TextArea text = new TextArea();
+ inline = text;
+ int width = getStringWidth(str);
+ text.setTextArea(str);
+ inline.setIPD(width);
+ inline.setHeight(getFontState().getAscender()
+ - getFontState().getDescender());
+ inline.setOffset(getFontState().getAscender());
+
+ inline.addTrait(Trait.FONT_NAME, getFontState().getFontName());
+ inline.addTrait(Trait.FONT_SIZE,
+ new Integer(getFontState().getFontSize()));
+ setUnresolved(false);
+ } else {
+ setUnresolved(true);
+ inline = new UnresolvedPageNumber(getRefId());
+ String str = "MMM"; // reserve three spaces for page number
+ int width = getStringWidth(str);
+ inline.setIPD(width);
+ inline.setHeight(getFontState().getAscender()
+ - getFontState().getDescender());
+ inline.setOffset(getFontState().getAscender());
+
+ inline.addTrait(Trait.FONT_NAME, getFontState().getFontName());
+ inline.addTrait(Trait.FONT_SIZE,
+ new Integer(getFontState().getFontSize()));
+ }
+ return inline;
+ }
}
}
/**
- * @param list the list to which the layout manager(s) should be added
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
Cell clm = new Cell(this);
}
/**
- * @param list the list to which the layout manager(s) should be added
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
Row rlm = new Row(this);
}
/**
- * @param list the list to which the layout manager(s) should be added
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
public void addLayoutManager(List list) {
FlowLayoutManager lm = new FlowLayoutManager(this);
import java.util.List;
import java.util.ListIterator;
-import org.apache.fop.area.LinkResolver;
-import org.apache.fop.area.PageViewport;
-import org.apache.fop.area.Resolveable;
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.FilledArea;
import org.apache.fop.area.inline.ForeignObject;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.XMLObj;
-import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.Character;
-import org.apache.fop.fo.flow.ExternalGraphic;
import org.apache.fop.fo.flow.Inline;
import org.apache.fop.fo.flow.InstreamForeignObject;
import org.apache.fop.fo.flow.Leader;
import org.apache.fop.fo.flow.ListItemBody;
import org.apache.fop.fo.flow.ListItemLabel;
import org.apache.fop.fo.flow.PageNumber;
-import org.apache.fop.fo.flow.PageNumberCitation;
import org.apache.fop.fo.flow.RetrieveMarker;
import org.apache.fop.fo.flow.Table;
import org.apache.fop.fo.flow.TableAndCaption;
}
/**
- * Add start and end properties for the link
+ * @param node Wrapper object to process
*/
- public void serveBasicLink(final BasicLink node) {
- InlineStackingLayoutManager lm;
- lm = new InlineStackingLayoutManager(node) {
- protected InlineParent createArea() {
- InlineParent area = super.createArea();
- setupBasicLinkArea(node, parentLM, area);
- return area;
+ public void serveWrapper(Wrapper node) {
+ ListIterator baseIter;
+ baseIter = node.getChildNodes();
+ if (baseIter == null) return;
+ while (baseIter.hasNext()) {
+ FObj child = (FObj) baseIter.next();
+ if (child instanceof LMVisited) {
+ ((LMVisited) child).acceptVisitor(this);
+ } else {
+ child.addLayoutManager(currentLMList);
}
- };
- lm.setLMiter(new LMiter(lm, node.getChildNodes()));
- currentLMList.add(lm);
+ }
}
- protected void setupBasicLinkArea(BasicLink node, LayoutManager parentLM,
- InlineParent area) {
- if (node.getLink() == null) {
- return;
- }
- if (node.getExternal()) {
- area.addTrait(Trait.EXTERNAL_LINK, node.getLink());
- } else {
- PageViewport page = parentLM.resolveRefID(node.getLink());
- if (page != null) {
- area.addTrait(Trait.INTERNAL_LINK, page.getKey());
- } else {
- LinkResolver res = new LinkResolver(node.getLink(), area);
- parentLM.addUnresolvedArea(node.getLink(), res);
- }
- }
- }
-
public void serveLeader(final Leader node) {
LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node) {
public InlineArea get(LayoutContext context) {
return null;
}
- /**
- * This adds a leafnode layout manager that deals with the
- * created viewport/image area.
- */
- public void serveExternalGraphic(ExternalGraphic node) {
- InlineArea area = getExternalGraphicInlineArea(node);
- if (area != null) {
- node.setupID();
- LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node);
- lm.setCurrentArea(area);
- lm.setAlignment(node.getProperty(Constants.PR_VERTICAL_ALIGN).getEnum());
- lm.setLead(node.getViewHeight());
- currentLMList.add(lm);
- }
- }
-
- /**
- * Get the inline area for this external grpahic.
- * This creates the image area and puts it inside a viewport.
- *
- * @return the viewport containing the image area
- */
- public InlineArea getExternalGraphicInlineArea(ExternalGraphic node) {
- if (node.getURL() == null) {
- return null;
- }
- Image imArea = new Image(node.getURL());
- Viewport vp = new Viewport(imArea);
- vp.setWidth(node.getViewWidth());
- vp.setHeight(node.getViewHeight());
- vp.setClip(node.getClip());
- vp.setContentPosition(node.getPlacement());
- vp.setOffset(0);
-
- // Common Border, Padding, and Background Properties
- CommonBorderAndPadding bap = node.getPropertyManager().getBorderAndPadding();
- CommonBackground bProps = node.getPropertyManager().getBackgroundProps();
- TraitSetter.addBorders(vp, bap);
- TraitSetter.addBackground(vp, bProps);
-
- return vp;
- }
-
public void serveInstreamForeignObject(InstreamForeignObject node) {
Viewport areaCurrent = getInstreamForeignObjectInlineArea(node);
if (areaCurrent != null) {
currentLMList.add(lm);
}
- public void servePageNumberCitation(final PageNumberCitation node) {
- LayoutManager lm;
- lm = new LeafNodeLayoutManager(node) {
- public InlineArea get(LayoutContext context) {
- curArea = getPageNumberCitationInlineArea(node, parentLM);
- return curArea;
- }
-
- public void addAreas(PositionIterator posIter,
- LayoutContext context) {
- super.addAreas(posIter, context);
- if (node.getUnresolved()) {
- parentLM.addUnresolvedArea(node.getRefId(),
- (Resolveable) curArea);
- }
- }
-
- protected void offsetArea(LayoutContext context) {
- curArea.setOffset(context.getBaseline());
- }
- };
- currentLMList.add(lm);
- }
-
- // if id can be resolved then simply return a word, otherwise
- // return a resolveable area
- public InlineArea getPageNumberCitationInlineArea(PageNumberCitation node,
- LayoutManager parentLM) {
- if (node.getRefId().equals("")) {
- node.getLogger().error("page-number-citation must contain \"ref-id\"");
- return null;
- }
- PageViewport page = parentLM.resolveRefID(node.getRefId());
- InlineArea inline = null;
- if (page != null) {
- String str = page.getPageNumber();
- // get page string from parent, build area
- TextArea text = new TextArea();
- inline = text;
- int width = node.getStringWidth(str);
- text.setTextArea(str);
- inline.setIPD(width);
- inline.setHeight(node.getFontState().getAscender()
- - node.getFontState().getDescender());
- inline.setOffset(node.getFontState().getAscender());
-
- inline.addTrait(Trait.FONT_NAME, node.getFontState().getFontName());
- inline.addTrait(Trait.FONT_SIZE,
- new Integer(node.getFontState().getFontSize()));
- node.setUnresolved(false);
- } else {
- node.setUnresolved(true);
- inline = new UnresolvedPageNumber(node.getRefId());
- String str = "MMM"; // reserve three spaces for page number
- int width = node.getStringWidth(str);
- inline.setIPD(width);
- inline.setHeight(node.getFontState().getAscender()
- - node.getFontState().getDescender());
- inline.setOffset(node.getFontState().getAscender());
-
- inline.addTrait(Trait.FONT_NAME, node.getFontState().getFontName());
- inline.addTrait(Trait.FONT_SIZE,
- new Integer(node.getFontState().getFontSize()));
- }
- return inline;
- }
-
public void serveTable(Table node) {
TableLayoutManager tlm = new TableLayoutManager(node);
ArrayList columns = node.getColumns();
public void serveTableHeader(TableHeader node) {
serveTableBody((TableBody)node);
}
-
- /**
- * @param node Wrapper object to process
- */
- public void serveWrapper(Wrapper node) {
- ListIterator baseIter;
- baseIter = node.getChildNodes();
- if (baseIter == null) return;
- while (baseIter.hasNext()) {
- FObj child = (FObj) baseIter.next();
- if (child instanceof LMVisited) {
- ((LMVisited) child).acceptVisitor(this);
- } else {
- child.addLayoutManager(currentLMList);
- }
- }
- }
}