* LayoutManager for the fo:external-graphic formatting object
*/
public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager {
-
- ExternalGraphic graphic = null;
+ private ExternalGraphic fobj;
private String url;
private int breakAfter;
*/
public ExternalGraphicLayoutManager(ExternalGraphic node) {
super(node);
-
- graphic = node;
+ fobj = node;
setup();
InlineArea area = getExternalGraphicInlineArea();
setCurrentArea(area);
- setAlignment(graphic.getVerticalAlign());
+ setAlignment(fobj.getVerticalAlign());
setLead(viewHeight);
}
* @todo see if can simplify property handling logic
*/
private void setup() {
- url = ImageFactory.getURL(graphic.getSrc());
+ url = ImageFactory.getURL(fobj.getSrc());
// assume lr-tb for now and just use the .optimum value of the range
- Length ipd = graphic.getPropertyList().get(PR_INLINE_PROGRESSION_DIMENSION).
+ Length ipd = fobj.getPropertyList().get(PR_INLINE_PROGRESSION_DIMENSION).
getLengthRange().getOptimum().getLength();
if (!ipd.isAuto()) {
viewWidth = ipd.getValue();
} else {
- ipd = graphic.getPropertyList().get(PR_WIDTH).getLength();
+ ipd = fobj.getPropertyList().get(PR_WIDTH).getLength();
if (!ipd.isAuto()) {
viewWidth = ipd.getValue();
}
}
- Length bpd = graphic.getPropertyList().get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange().getOptimum().getLength();
+ Length bpd = fobj.getPropertyList().get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange().getOptimum().getLength();
if (!bpd.isAuto()) {
viewHeight = bpd.getValue();
} else {
- bpd = graphic.getPropertyList().get(PR_HEIGHT).getLength();
+ bpd = fobj.getPropertyList().get(PR_HEIGHT).getLength();
if (!bpd.isAuto()) {
viewHeight = bpd.getValue();
}
int cwidth = -1;
int cheight = -1;
- Length ch = graphic.getPropertyList().get(PR_CONTENT_HEIGHT).getLength();
+ Length ch = fobj.getPropertyList().get(PR_CONTENT_HEIGHT).getLength();
if (!ch.isAuto()) {
/*if (ch.scaleToFit()) {
if (viewHeight != -1) {
} else {*/
cheight = ch.getValue();
}
- Length cw = graphic.getPropertyList().get(PR_CONTENT_WIDTH).getLength();
+ Length cw = fobj.getPropertyList().get(PR_CONTENT_WIDTH).getLength();
if (!cw.isAuto()) {
/*if (cw.scaleToFit()) {
if (viewWidth != -1) {
cwidth = cw.getValue();
}
- int scaling = graphic.getScaling();
+ int scaling = fobj.getScaling();
if ((scaling == Scaling.UNIFORM) || (cwidth == -1) || cheight == -1) {
ImageFactory fact = ImageFactory.getInstance();
- fopimage = fact.getImage(url, graphic.getUserAgent());
+ fopimage = fact.getImage(url, fobj.getUserAgent());
if (fopimage == null) {
// error
url = null;
}
if (cwidth > viewWidth || cheight > viewHeight) {
- int overflow = graphic.getOverflow();
+ int overflow = fobj.getOverflow();
if (overflow == Overflow.HIDDEN) {
clip = true;
} else if (overflow == Overflow.ERROR_IF_OVERFLOW) {
- graphic.getLogger().error("Image: " + url
+ fobj.getLogger().error("Image: " + url
+ " overflows the viewport, clipping to viewport");
clip = true;
}
int xoffset = 0;
int yoffset = 0;
- switch(graphic.getDisplayAlign()) {
+ switch(fobj.getDisplayAlign()) {
case DisplayAlign.BEFORE:
break;
case DisplayAlign.AFTER:
break;
}
- switch(graphic.getTextAlign()) {
+ switch(fobj.getTextAlign()) {
case TextAlign.CENTER:
xoffset = (viewWidth - cwidth) / 2;
break;
* @return the viewport containing the image area
*/
public InlineArea getExternalGraphicInlineArea() {
- Image imArea = new Image(graphic.getSrc());
+ Image imArea = new Image(fobj.getSrc());
Viewport vp = new Viewport(imArea);
vp.setIPD(viewWidth);
vp.setBPD(viewHeight);
vp.setOffset(0);
// Common Border, Padding, and Background Properties
- TraitSetter.addBorders(vp, graphic.getCommonBorderPaddingBackground());
- TraitSetter.addBackground(vp, graphic.getCommonBorderPaddingBackground());
+ TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground());
+ TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground());
return vp;
}
protected void addId() {
- addID(graphic.getId());
+ addID(fobj.getId());
}
}
* LayoutManager for the fo:basic-link formatting object
*/
public class InstreamForeignObjectLM extends LeafNodeLayoutManager {
-
- InstreamForeignObject ifoNode;
+ private InstreamForeignObject fobj;
/**
* Constructor
*/
public InstreamForeignObjectLM(InstreamForeignObject node) {
super(node);
- ifoNode = node;
+ fobj = node;
Viewport areaCurrent = getInlineArea();
setCurrentArea(areaCurrent);
setAlignment(node.getVerticalAlign());
* @return the viewport inline area
*/
private Viewport getInlineArea() {
- XMLObj child = (XMLObj) ifoNode.childNodes.get(0);
+ XMLObj child = (XMLObj) fobj.childNodes.get(0);
// viewport size is determined by block-progression-dimension
// and inline-progression-dimension
int ipd = -1;
boolean bpdauto = false;
if (hasLH) {
- bpd = ifoNode.getLineHeight().getValue();
+ bpd = fobj.getLineHeight().getValue();
} else {
// this property does not apply when the line-height applies
// isn't the block-progression-dimension always in the same
// direction as the line height?
- len = ifoNode.getBlockProgressionDimension().getOptimum().getLength();
+ len = fobj.getBlockProgressionDimension().getOptimum().getLength();
if (!len.isAuto()) {
bpd = len.getValue();
} else {
- len = ifoNode.getHeight();
+ len = fobj.getHeight();
if (!len.isAuto()) {
bpd = len.getValue();
}
}
}
- len = ifoNode.getInlineProgressionDimension().getOptimum().getLength();
+ len = fobj.getInlineProgressionDimension().getOptimum().getLength();
if (!len.isAuto()) {
ipd = len.getValue();
} else {
- len = ifoNode.getWidth();
+ len = fobj.getWidth();
if (!len.isAuto()) {
ipd = len.getValue();
}
// to the content-height and content-width
int cwidth = -1;
int cheight = -1;
- len = ifoNode.getContentWidth();
+ len = fobj.getContentWidth();
if (!len.isAuto()) {
/*if(len.scaleToFit()) {
if(ipd != -1) {
} else {*/
cwidth = len.getValue();
}
- len = ifoNode.getContentHeight();
+ len = fobj.getContentHeight();
if (!len.isAuto()) {
/*if(len.scaleToFit()) {
if(bpd != -1) {
if (cheight == -1) {
cheight = (int)size.getY() * 1000;
}
- int scaling = ifoNode.getScaling();
+ int scaling = fobj.getScaling();
if (scaling == Scaling.UNIFORM) {
// adjust the larger
double rat1 = cwidth / (size.getX() * 1000f);
boolean clip = false;
if (cwidth > ipd || cheight > bpd) {
- int overflow = ifoNode.getOverflow();
+ int overflow = fobj.getOverflow();
if (overflow == Overflow.HIDDEN) {
clip = true;
} else if (overflow == Overflow.ERROR_IF_OVERFLOW) {
- ifoNode.getLogger().error("Instream foreign object overflows the viewport: clipping");
+ fobj.getLogger().error("Instream foreign object overflows the viewport: clipping");
clip = true;
}
}
- int xoffset = ifoNode.computeXOffset(ipd, cwidth);
- int yoffset = ifoNode.computeYOffset(bpd, cheight);
+ int xoffset = fobj.computeXOffset(ipd, cwidth);
+ int yoffset = fobj.computeYOffset(bpd, cheight);
Rectangle2D placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight);
org.w3c.dom.Document doc = child.getDOMDocument();
String ns = child.getDocumentNamespace();
- ifoNode.childNodes = null;
+ fobj.childNodes = null;
ForeignObject foreign = new ForeignObject(doc, ns);
Viewport areaCurrent = new Viewport(foreign);
}
protected void addId() {
- addID(ifoNode.getId());
+ addID(fobj.getId());
}
}
* LayoutManager for the fo:leader formatting object
*/
public class LeaderLayoutManager extends LeafNodeLayoutManager {
-
- Leader ldrNode;
+ private Leader fobj;
Font font = null;
/**
*/
public LeaderLayoutManager(Leader node) {
super(node);
- ldrNode = node;
+ fobj = node;
font = node.getFontState();
setAlignment(node.getLeaderAlignment());
}
private MinOptMax getLeaderAllocIPD(int ipd) {
// length of the leader
fobj.setLayoutDimension(PercentBase.BLOCK_IPD, ipd);
- int opt = ldrNode.getLeaderLength().getOptimum().getLength().getValue();
- int min = ldrNode.getLeaderLength().getMinimum().getLength().getValue();
- int max = ldrNode.getLeaderLength().getMaximum().getLength().getValue();
+ int opt = fobj.getLeaderLength().getOptimum().getLength().getValue();
+ int min = fobj.getLeaderLength().getMinimum().getLength().getValue();
+ int max = fobj.getLeaderLength().getMaximum().getLength().getValue();
return new MinOptMax(min, opt, max);
}
private InlineArea getLeaderInlineArea() {
InlineArea leaderArea = null;
- if (ldrNode.getLeaderPattern() == LeaderPattern.RULE) {
+ if (fobj.getLeaderPattern() == LeaderPattern.RULE) {
org.apache.fop.area.inline.Leader leader =
new org.apache.fop.area.inline.Leader();
- leader.setRuleStyle(ldrNode.getRuleStyle());
- leader.setRuleThickness(ldrNode.getRuleThickness());
+ leader.setRuleStyle(fobj.getRuleStyle());
+ leader.setRuleThickness(fobj.getRuleThickness());
leaderArea = leader;
- } else if (ldrNode.getLeaderPattern() == LeaderPattern.SPACE) {
+ } else if (fobj.getLeaderPattern() == LeaderPattern.SPACE) {
leaderArea = new Space();
- } else if (ldrNode.getLeaderPattern() == LeaderPattern.DOTS) {
+ } else if (fobj.getLeaderPattern() == LeaderPattern.DOTS) {
TextArea t = new TextArea();
char dot = '.'; // userAgent.getLeaderDotCharacter();
t.setOffset(font.getAscender());
int width = font.getCharWidth(dot);
Space spacer = null;
- if (ldrNode.getPatternWidth() > width) {
+ if (fobj.getPatternWidth() > width) {
spacer = new Space();
- spacer.setIPD(ldrNode.getPatternWidth() - width);
- width = ldrNode.getPatternWidth();
+ spacer.setIPD(fobj.getPatternWidth() - width);
+ width = fobj.getPatternWidth();
}
FilledArea fa = new FilledArea();
fa.setUnitWidth(width);
fa.setBPD(font.getAscender());
leaderArea = fa;
- } else if (ldrNode.getLeaderPattern() == LeaderPattern.USECONTENT) {
- if (ldrNode.getChildNodes() == null) {
- ldrNode.getLogger().error("Leader use-content with no content");
+ } else if (fobj.getLeaderPattern() == LeaderPattern.USECONTENT) {
+ if (fobj.getChildNodes() == null) {
+ fobj.getLogger().error("Leader use-content with no content");
return null;
}
FilledArea fa = new FilledArea();
ContentLayoutManager clm = new ContentLayoutManager(fa);
- clm.setUserAgent(ldrNode.getUserAgent());
+ clm.setUserAgent(fobj.getUserAgent());
addChildLM(clm);
InlineStackingLayoutManager lm;
- lm = new InlineStackingLayoutManager(ldrNode);
+ lm = new InlineStackingLayoutManager(fobj);
clm.addChildLM(lm);
clm.fillArea(lm);
int width = clm.getStackingSize();
Space spacer = null;
- if (ldrNode.getPatternWidth() > width) {
+ if (fobj.getPatternWidth() > width) {
spacer = new Space();
- spacer.setIPD(ldrNode.getPatternWidth() - width);
- width = ldrNode.getPatternWidth();
+ spacer.setIPD(fobj.getPatternWidth() - width);
+ width = fobj.getPatternWidth();
}
fa.setUnitWidth(width);
if (spacer != null) {
}
protected void addId() {
- addID(ldrNode.getId());
+ addID(fobj.getId());
}
}
* It manages all page-related layout.
*/
public class PageSequenceLayoutManager extends AbstractLayoutManager implements Runnable {
+ private PageSequence fobj;
private static class BlockBreakPosition extends LeafPosition {
protected BreakPoss breakps;
*/
private AreaTreeHandler areaTreeHandler;
private AreaTreeModel areaTreeModel;
- private PageSequence pageSequence;
/**
* This is the SimplePageMaster that should be used to create the page. It
*/
public PageSequenceLayoutManager(AreaTreeHandler areaTreeHandler, PageSequence pageseq) {
super(pageseq);
+ fobj = pageseq;
this.areaTreeHandler = areaTreeHandler;
areaTreeModel = areaTreeHandler.getAreaTreeModel();
- pageSequence = pageseq;
- if (pageSequence.getPageSequenceMaster() != null) {
- pageSequence.getPageSequenceMaster().reset();
+ if (fobj.getPageSequenceMaster() != null) {
+ fobj.getPageSequenceMaster().reset();
}
}
* rendering process can also run in a parallel thread.
*/
public void run() {
- pageSequence.initPageNumber();
- setPageCounting(pageSequence.getCurrentPageNumber(),
- pageSequence.getPageNumberGenerator());
+ fobj.initPageNumber();
+ setPageCounting(fobj.getCurrentPageNumber(),
+ fobj.getPageNumberGenerator());
LineArea title = null;
- if (pageSequence.getTitleFO() != null) {
- title = getTitleArea(pageSequence.getTitleFO());
+ if (fobj.getTitleFO() != null) {
+ title = getTitleArea(fobj.getTitleFO());
}
areaTreeModel.startPageSequence(title);
if (region == null) {
return;
}
- StaticContent flow = pageSequence.getStaticContent(region.getRegionName());
+ StaticContent flow = fobj.getStaticContent(region.getRegionName());
if (flow == null) {
return;
}
throws FOPException {
currentSimplePageMaster = getSimplePageMasterToUse(bIsBlank);
Region body = currentSimplePageMaster.getRegion(FO_REGION_BODY);
- if (!pageSequence.getMainFlow().getFlowName().equals(body.getRegionName())) {
- throw new FOPException("Flow '" + pageSequence.getMainFlow().getFlowName()
+ if (!fobj.getMainFlow().getFlowName().equals(body.getRegionName())) {
+ throw new FOPException("Flow '" + fobj.getMainFlow().getFlowName()
+ "' does not map to the region-body in page-master '"
+ currentSimplePageMaster.getMasterName() + "'");
}
private SimplePageMaster getSimplePageMasterToUse(boolean bIsBlank)
throws FOPException {
- if (pageSequence.getPageSequenceMaster() == null) {
- return pageSequence.getSimplePageMaster();
+ if (fobj.getPageSequenceMaster() == null) {
+ return fobj.getSimplePageMaster();
}
boolean isOddPage = ((pageCount % 2) == 1);
- return pageSequence.getPageSequenceMaster()
+ return fobj.getPageSequenceMaster()
.getNextSimplePageMaster(isOddPage, isFirstPage, bIsBlank);
}
if (lm != null) {
return lm;
}
- lm = new StaticContentLayoutManager();
- lm.setFObj(sc);
+ lm = new StaticContentLayoutManager(sc);
staticContentLMs.put(sc.getFlowName(), lm);
return lm;
}