removed parent and min/opt/max from area tree, layout managers can handle all this fixed a number of style errors git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195220 13f79535-47bb-0310-9956-ffa450edef68pull/30/head
private int areaClass = CLASS_NORMAL; | private int areaClass = CLASS_NORMAL; | ||||
private int ipd; | private int ipd; | ||||
private HashMap props = null; | |||||
protected Area parent = null; // Doesn't need to be saved in serialization | |||||
/** | |||||
* Get the area class of this area. | |||||
* | |||||
* @return the area class | |||||
*/ | |||||
public int getAreaClass() { | public int getAreaClass() { | ||||
return areaClass; | return areaClass; | ||||
} | } | ||||
/** | |||||
* Set the area class of this area. | |||||
* | |||||
* @param areaClass the area class | |||||
*/ | |||||
public void setAreaClass(int areaClass) { | public void setAreaClass(int areaClass) { | ||||
this.areaClass = areaClass; | this.areaClass = areaClass; | ||||
} | } | ||||
public void setIPD(int i) { | |||||
ipd = i; | |||||
} | |||||
public int getIPD() { | |||||
return ipd; | |||||
} | |||||
/** | /** | ||||
* Return a length range describing the minimum, optimum and maximum | |||||
* lengths available for content in the block-progression-direction. | |||||
* This is calculated from the theoretical maximum size of the area | |||||
* and its current content. | |||||
* Set the inline progression dimension of this area. | |||||
* | |||||
* @param i the new inline progression dimension | |||||
*/ | */ | ||||
public MinOptMax getAvailBPD() { | |||||
return MinOptMax.subtract(getMaxBPD(), getContentBPD()); | |||||
public void setIPD(int i) { | |||||
ipd = i; | |||||
} | } | ||||
/** | /** | ||||
* Return a length range describing the theoretical maximum size of an | |||||
* area in the block-progression-direction. | |||||
* For areas holding normal flowing or floating content in paged media, | |||||
* this depends on the size of the body. In general the answer is the | |||||
* gotten from the parent. At the body level, the calculation accounts | |||||
* for the sizes of the conditional areas. | |||||
* Get the inline progression dimension of this area. | |||||
* | |||||
* @return the inline progression dimension | |||||
*/ | */ | ||||
public MinOptMax getMaxBPD() { | |||||
if (parent != null) { | |||||
return parent.getMaxBPD(); | |||||
} else { | |||||
return new MinOptMax(); | |||||
} | |||||
public int getIPD() { | |||||
return ipd; | |||||
} | } | ||||
/** | /** | ||||
* Return a length range describing the minimum, optimum and maximum | |||||
* lengths of all area content in the block-progression-direction. | |||||
* This is based on the allocation rectangles of all content in | |||||
* the area. | |||||
* Add a child to this area. | |||||
* The default is to do nothing. Subclasses must override | |||||
* to do something if they can have child areas. | |||||
* | |||||
* @param child the child area to add | |||||
*/ | */ | ||||
public MinOptMax getContentBPD() { | |||||
return new MinOptMax(); | |||||
public void addChild(Area child) { | |||||
} | } | ||||
/** | /** | ||||
* Return a length range describing the minimum, optimum and maximum | |||||
* lengths of the area's allocation rectangle | |||||
* in the block-progression-direction. | |||||
* This is based on the allocation rectangles of all content in | |||||
* the area. | |||||
* The default implementation simply returns the same as the content BPD. | |||||
* If an Area has before or after border and padding, these contribute | |||||
* to the allocation BPD, depending on conditionality. | |||||
* Add a trait property to this area. | |||||
* | |||||
* @param prop the Trait to add | |||||
*/ | */ | ||||
public MinOptMax getAllocationBPD() { | |||||
return getContentBPD(); | |||||
} | |||||
public void setParent(Area parent) { | |||||
this.parent = parent; | |||||
} | |||||
// Do nothing! Let subclasses do something if they can have child areas. | |||||
public void addChild(Area child) { | |||||
} | |||||
HashMap props = null; | |||||
public void addTrait(Trait prop) { | public void addTrait(Trait prop) { | ||||
if (props == null) { | if (props == null) { | ||||
props = new HashMap(20); | props = new HashMap(20); | ||||
props.put(prop.propType, prop.data); | props.put(prop.propType, prop.data); | ||||
} | } | ||||
/** | |||||
* Add a trait to this area. | |||||
* | |||||
* @param traitCode the trait key | |||||
* @param prop the value of the trait | |||||
*/ | |||||
public void addTrait(Object traitCode, Object prop) { | public void addTrait(Object traitCode, Object prop) { | ||||
if (props == null) { | if (props == null) { | ||||
props = new HashMap(20); | props = new HashMap(20); | ||||
props.put(traitCode, prop); | props.put(traitCode, prop); | ||||
} | } | ||||
/** | |||||
* Get the map of all traits on this area. | |||||
* | |||||
* @return the map of traits | |||||
*/ | |||||
public HashMap getTraits() { | public HashMap getTraits() { | ||||
return this.props; | return this.props; | ||||
} | } | ||||
/** | |||||
* Get a trait from this area. | |||||
* | |||||
* @param oTraitCode the trait key | |||||
* @return the trait value | |||||
*/ | |||||
public Object getTrait(Object oTraitCode) { | public Object getTrait(Object oTraitCode) { | ||||
return (props != null ? props.get(oTraitCode) : null); | return (props != null ? props.get(oTraitCode) : null); | ||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area; | package org.apache.fop.area; | ||||
import java.util.List; | |||||
import java.util.ArrayList; | |||||
/** | |||||
* The before float area. | |||||
* This is used to place the before float areas. | |||||
* It has an optional separator and before float block children. | |||||
*/ | |||||
public class BeforeFloat extends BlockParent { | public class BeforeFloat extends BlockParent { | ||||
// this is an optional block area that will be rendered | // this is an optional block area that will be rendered | ||||
// as the separator only if there are float areas | // as the separator only if there are float areas | ||||
Block separator = null; | |||||
// before float area | |||||
// has an optional separator | |||||
// and a list of sub block areas | |||||
ArrayList blocks = null; | |||||
public void addBlock(Block block) { | |||||
if (blocks == null) { | |||||
blocks = new ArrayList(); | |||||
} | |||||
blocks.add(block); | |||||
} | |||||
private Block separator = null; | |||||
/** | |||||
* Set the separator area for this before float. | |||||
* | |||||
* @param sep the before float separator area | |||||
*/ | |||||
public void setSeparator(Block sep) { | public void setSeparator(Block sep) { | ||||
separator = sep; | separator = sep; | ||||
} | } | ||||
public List getBlocks() { | |||||
return blocks; | |||||
} | |||||
/** | |||||
* Get the separator area for this before float. | |||||
* | |||||
* @return the before float separator area | |||||
*/ | |||||
public Block getSeparator() { | public Block getSeparator() { | ||||
return separator; | return separator; | ||||
} | } | ||||
/** | |||||
* Get the height of this before float. | |||||
* It gets the height of the children and if there is a | |||||
* separator its height is also added. | |||||
* | |||||
* @return the height of the before float including separator | |||||
*/ | |||||
public int getHeight() { | public int getHeight() { | ||||
if (blocks == null) { | |||||
return 0; | |||||
int h = super.getHeight(); | |||||
if (separator != null) { | |||||
h += separator.getHeight(); | |||||
} | } | ||||
int h = 0; | |||||
return h; | return h; | ||||
} | } | ||||
public MinOptMax getMaxBPD() { | |||||
MinOptMax maxbpd = parent.getMaxBPD(); | |||||
BodyRegion body = (BodyRegion)parent; | |||||
Area a = body.getMainReference(); | |||||
if (a != null) { | |||||
maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD()); | |||||
} | |||||
if ((a=body.getFootnote()) != null) { | |||||
maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD()); | |||||
} | |||||
return maxbpd; | |||||
} | |||||
} | } | ||||
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
import java.io.Serializable; | import java.io.Serializable; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | |||||
import java.util.Iterator; | |||||
import java.awt.geom.Rectangle2D; | |||||
// block areas hold either more block areas or line | // block areas hold either more block areas or line | ||||
// areas can also be used as a block spacer | // areas can also be used as a block spacer | ||||
// or by relative to the parent for floats, tables and lists | // or by relative to the parent for floats, tables and lists | ||||
// cacheable object | // cacheable object | ||||
// has id information | // has id information | ||||
/** | |||||
* This is the block area class. | |||||
* It holds child block areas such as other blocks or lines. | |||||
*/ | |||||
public class Block extends BlockParent implements Serializable { | public class Block extends BlockParent implements Serializable { | ||||
// normally stacked with other blocks | |||||
/** | |||||
* Normally stacked with other blocks. | |||||
*/ | |||||
public static final int STACK = 0; | public static final int STACK = 0; | ||||
// placed relative to the parent area | |||||
/** | |||||
* Placed relative to the flow position. | |||||
* This effects the flow placement of stacking normally. | |||||
*/ | |||||
public static final int RELATIVE = 1; | public static final int RELATIVE = 1; | ||||
/** | /** | ||||
public static final int ABSOLUTE = 2; | public static final int ABSOLUTE = 2; | ||||
private int stacking = TB; | private int stacking = TB; | ||||
// list of marker fo objects that are associated with this area | |||||
// if a retrieve marker resolves this area it will format the | |||||
// available markers, markers are discarded once page complete | |||||
private ArrayList markers = null; | |||||
private int positioning = STACK; | |||||
// a block with may contain the dominant styling info in | // a block with may contain the dominant styling info in | ||||
// terms of most lines or blocks with info | // terms of most lines or blocks with info | ||||
int positioning = STACK; | |||||
/** | |||||
* Add the block to this block area. | |||||
* | |||||
* @param block the block area to add | |||||
*/ | |||||
public void addBlock(Block block) { | public void addBlock(Block block) { | ||||
if (children == null) { | if (children == null) { | ||||
children = new ArrayList(); | children = new ArrayList(); | ||||
children.add(block); | children.add(block); | ||||
} | } | ||||
/** | |||||
* Add the line area to this block area. | |||||
* | |||||
* @param line the line area to add | |||||
*/ | |||||
public void addLineArea(LineArea line) { | public void addLineArea(LineArea line) { | ||||
if (children == null) { | if (children == null) { | ||||
children = new ArrayList(); | children = new ArrayList(); | ||||
children.add(line); | children.add(line); | ||||
} | } | ||||
public MinOptMax getContentBPD() { | |||||
MinOptMax bpd = new MinOptMax(); | |||||
if(children != null) { | |||||
for(Iterator iter = children.iterator(); iter.hasNext(); ) { | |||||
Area area = (Area)iter.next(); | |||||
MinOptMax mom = area.getContentBPD(); | |||||
bpd.add(mom); | |||||
} | |||||
} | |||||
return bpd; | |||||
} | |||||
/** | |||||
* Set the positioning of this area. | |||||
* | |||||
* @param pos the positioning to use when rendering this area | |||||
*/ | |||||
public void setPositioning(int pos) { | public void setPositioning(int pos) { | ||||
positioning = pos; | positioning = pos; | ||||
} | } | ||||
/** | |||||
* Get the positioning of this area. | |||||
* | |||||
* @return the positioning to use when rendering this area | |||||
*/ | |||||
public int getPositioning() { | public int getPositioning() { | ||||
return positioning; | return positioning; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
import java.io.Serializable; | import java.io.Serializable; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import java.awt.geom.Rectangle2D; | |||||
/** | /** | ||||
* A BlockParent holds block-level areas. | * A BlockParent holds block-level areas. | ||||
// this position is used for absolute position | // this position is used for absolute position | ||||
// or as an indent | // or as an indent | ||||
// this has the size in the block progression dimension | // this has the size in the block progression dimension | ||||
/** | |||||
* The x offset position of this block parent. | |||||
* Used for relative and absolute positioning. | |||||
*/ | |||||
protected int xOffset = 0; | protected int xOffset = 0; | ||||
/** | |||||
* The y offset position of this block parent. | |||||
* Used for relative and absolute positioning. | |||||
*/ | |||||
protected int yOffset = 0; | protected int yOffset = 0; | ||||
/** | |||||
* The width of this block parent. | |||||
*/ | |||||
protected int width = 0; | protected int width = 0; | ||||
/** | |||||
* The height of this block parent. | |||||
*/ | |||||
protected int height = 0; | protected int height = 0; | ||||
ArrayList children = null; | |||||
/** | |||||
* The children of this block parent area. | |||||
*/ | |||||
protected ArrayList children = null; | |||||
// orientation if reference area | // orientation if reference area | ||||
int orientation = ORIENT_0; | |||||
private int orientation = ORIENT_0; | |||||
/** | |||||
* Add the block area to this block parent. | |||||
* | |||||
* @param block the child block area to add | |||||
*/ | |||||
public void addBlock(Block block) { | public void addBlock(Block block) { | ||||
if (children == null) { | if (children == null) { | ||||
children = new ArrayList(); | children = new ArrayList(); | ||||
children.add(block); | children.add(block); | ||||
} | } | ||||
/** | |||||
* Get the list of child areas for this block area. | |||||
* | |||||
* @return the list of child areas | |||||
*/ | |||||
public List getChildAreas() { | public List getChildAreas() { | ||||
return children; | return children; | ||||
} | } | ||||
/** | |||||
* Set the X offset of this block parent area. | |||||
* | |||||
* @param off the x offset of the block parent area | |||||
*/ | |||||
public void setXOffset(int off) { | public void setXOffset(int off) { | ||||
xOffset = off; | xOffset = off; | ||||
} | } | ||||
/** | |||||
* Set the Y offset of this block parent area. | |||||
* | |||||
* @param off the y offset of the block parent area | |||||
*/ | |||||
public void setYOffset(int off) { | public void setYOffset(int off) { | ||||
yOffset = off; | yOffset = off; | ||||
} | } | ||||
/** | |||||
* Set the width of this block parent area. | |||||
* | |||||
* @param w the width of the area | |||||
*/ | |||||
public void setWidth(int w) { | public void setWidth(int w) { | ||||
width = w; | width = w; | ||||
} | } | ||||
/** | |||||
* Set the height of this block parent area. | |||||
* | |||||
* @param h the height of the block parent area | |||||
*/ | |||||
public void setHeight(int h) { | public void setHeight(int h) { | ||||
height = h; | height = h; | ||||
} | } | ||||
/** | |||||
* Get the X offset of this block parent area. | |||||
* | |||||
* @return the x offset of the block parent area | |||||
*/ | |||||
public int getXOffset() { | public int getXOffset() { | ||||
return xOffset; | return xOffset; | ||||
} | } | ||||
/** | |||||
* Get the Y offset of this block parent area. | |||||
* | |||||
* @return the y offset of the block parent area | |||||
*/ | |||||
public int getYOffset() { | public int getYOffset() { | ||||
return yOffset; | return yOffset; | ||||
} | } | ||||
/** | |||||
* Get the width of this block parent area. | |||||
* | |||||
* @return the width of the area | |||||
*/ | |||||
public int getWidth() { | public int getWidth() { | ||||
return width; | return width; | ||||
} | } | ||||
/** | |||||
* Get the height of this block parent area. | |||||
* | |||||
* @return the height of the block parent area | |||||
*/ | |||||
public int getHeight() { | public int getHeight() { | ||||
return height; | return height; | ||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area; | package org.apache.fop.area; | ||||
import java.awt.geom.Rectangle2D; | |||||
/** | /** | ||||
* A BlockViewport. | * A BlockViewport. | ||||
* This is used for block level Viewport/reference pairs. | * This is used for block level Viewport/reference pairs. | ||||
*/ | */ | ||||
public class BlockViewport extends Block { | public class BlockViewport extends Block { | ||||
// clipping for this viewport | // clipping for this viewport | ||||
boolean clip = false; | |||||
CTM viewportCTM; | |||||
private boolean clip = false; | |||||
// transform if rotated or absolute | |||||
private CTM viewportCTM; | |||||
/** | |||||
* Create a new block viewport area. | |||||
*/ | |||||
public BlockViewport() { | public BlockViewport() { | ||||
} | } | ||||
/** | |||||
* Set the transform of this viewport. | |||||
* If the viewport is rotated or has an absolute positioning | |||||
* this transform will do the work. | |||||
* | |||||
* @param ctm the transformation | |||||
*/ | |||||
public void setCTM(CTM ctm) { | public void setCTM(CTM ctm) { | ||||
viewportCTM = ctm; | viewportCTM = ctm; | ||||
} | } | ||||
/** | |||||
* Get the transform of this block viewport. | |||||
* | |||||
* @return the transformation of this viewport | |||||
* or null if normally stacked without rotation | |||||
*/ | |||||
public CTM getCTM() { | public CTM getCTM() { | ||||
return viewportCTM; | return viewportCTM; | ||||
} | } | ||||
/** | |||||
* Set the clipping for this viewport. | |||||
* | |||||
* @param cl the clipping for the viewport | |||||
*/ | |||||
public void setClip(boolean cl) { | public void setClip(boolean cl) { | ||||
clip = cl; | clip = cl; | ||||
} | } | ||||
/** | |||||
* Get the clipping for this viewport. | |||||
* | |||||
* @return the clipping for the viewport | |||||
* true if the contents should be clipped for this viewport | |||||
*/ | |||||
public boolean getClip() { | public boolean getClip() { | ||||
return clip; | return clip; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area; | package org.apache.fop.area; | ||||
import java.awt.geom.Rectangle2D; | |||||
/** | |||||
* The body region area. | |||||
* This area contains a main reference area and optionally a | |||||
* before float and footnote area. | |||||
*/ | |||||
public class BodyRegion extends RegionReference { | public class BodyRegion extends RegionReference { | ||||
BeforeFloat beforeFloat; | |||||
MainReference mainReference; | |||||
Footnote footnote; | |||||
private BeforeFloat beforeFloat; | |||||
private MainReference mainReference; | |||||
private Footnote footnote; | |||||
private int columnGap; | private int columnGap; | ||||
private int columnCount; | private int columnCount; | ||||
/** Maximum block progression dimension. Note: min=opt=max */ | |||||
private MinOptMax maxBPD; | |||||
/** Referenc inline progression dimension for the body. */ | /** Referenc inline progression dimension for the body. */ | ||||
private int refIPD; | private int refIPD; | ||||
/** | |||||
* Create a new body region area. | |||||
* This sets the region reference area class to BODY. | |||||
*/ | |||||
public BodyRegion() { | public BodyRegion() { | ||||
super(BODY); | super(BODY); | ||||
} | } | ||||
// Number of columns when not spanning | // Number of columns when not spanning | ||||
public void setColumnCount(int colCount) { | public void setColumnCount(int colCount) { | ||||
this.columnCount = colCount; | |||||
this.columnCount = colCount; | |||||
} | } | ||||
// Number of columns when not spanning | // Number of columns when not spanning | ||||
public int getColumnCount() { | public int getColumnCount() { | ||||
return this.columnCount ; | |||||
return this.columnCount; | |||||
} | } | ||||
// A length (mpoints) | // A length (mpoints) | ||||
public void setColumnGap(int colGap) { | public void setColumnGap(int colGap) { | ||||
this.columnGap = colGap; | |||||
} | |||||
public void setParent(Area area) { | |||||
super.setParent(area); | |||||
// Only if not scrolling or overflow !!! | |||||
Rectangle2D refRect = ((RegionViewport)area).getViewArea(); | |||||
maxBPD = new MinOptMax((int)refRect.getHeight()); | |||||
refIPD = (int)refRect.getWidth(); | |||||
this.columnGap = colGap; | |||||
} | } | ||||
public void setBeforeFloat(BeforeFloat bf) { | public void setBeforeFloat(BeforeFloat bf) { | ||||
beforeFloat = bf; | beforeFloat = bf; | ||||
beforeFloat.setParent(this); | |||||
} | } | ||||
public void setMainReference(MainReference mr) { | public void setMainReference(MainReference mr) { | ||||
mainReference = mr; | mainReference = mr; | ||||
mainReference.setParent(this); | |||||
} | } | ||||
public void setFootnote(Footnote foot) { | public void setFootnote(Footnote foot) { | ||||
footnote = foot; | footnote = foot; | ||||
footnote.setParent(this); | |||||
} | } | ||||
return footnote; | return footnote; | ||||
} | } | ||||
public MinOptMax getMaxBPD() { | |||||
return maxBPD; | |||||
} | |||||
public Object clone() { | public Object clone() { | ||||
BodyRegion br = new BodyRegion(); | BodyRegion br = new BodyRegion(); | ||||
br.setCTM(getCTM()); | br.setCTM(getCTM()); |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area; | package org.apache.fop.area; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
// this is a normal flow reference area | |||||
// it containts a list of block areas from the flow | |||||
/** | |||||
* The normal flow reference area class. | |||||
* This area contains a list of block areas from the flow | |||||
*/ | |||||
public class Flow extends BlockParent { | public class Flow extends BlockParent { | ||||
// the list of blocks created from the flow | // the list of blocks created from the flow | ||||
ArrayList blocks = new ArrayList(); | |||||
int stacking = TB; | |||||
int width; | |||||
public void addBlock(Block block) { | |||||
blocks.add(block); | |||||
} | |||||
public List getBlocks() { | |||||
return blocks; | |||||
} | |||||
/** | |||||
* Maximum block progression dimension for a Flow is | |||||
* the same as that of its parent Span. | |||||
*/ | |||||
public MinOptMax getMaxBPD() { | |||||
return parent.getMaxBPD(); | |||||
} | |||||
private int stacking = TB; | |||||
private int width; | |||||
} | } | ||||
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area; | package org.apache.fop.area; | ||||
import java.io.Serializable; | |||||
import java.util.List; | |||||
import java.util.ArrayList; | |||||
// may combine with before float into a conditional area | // may combine with before float into a conditional area | ||||
/** | |||||
* Footnote reference area. | |||||
* This areas holds footnote areas and an optional separator area. | |||||
*/ | |||||
public class Footnote extends BlockParent { | public class Footnote extends BlockParent { | ||||
Block separator = null; | |||||
private Block separator = null; | |||||
// footnote has an optional separator | // footnote has an optional separator | ||||
// and a list of sub block areas that can be added/removed | // and a list of sub block areas that can be added/removed | ||||
// this is the relative position of the footnote inside | // this is the relative position of the footnote inside | ||||
// the body region | // the body region | ||||
int top; | |||||
ArrayList blocks = null; | |||||
private int top; | |||||
/** | |||||
* Set the separator area for this footnote. | |||||
* | |||||
* @param sep the separator area | |||||
*/ | |||||
public void setSeparator(Block sep) { | public void setSeparator(Block sep) { | ||||
separator = sep; | separator = sep; | ||||
} | } | ||||
public void addBlock(Block block) { | |||||
if (blocks == null) { | |||||
blocks = new ArrayList(); | |||||
} | |||||
blocks.add(block); | |||||
} | |||||
/** | |||||
* Get the separator area for this footnote area. | |||||
* | |||||
* @return the separator area | |||||
*/ | |||||
public Block getSeparator() { | public Block getSeparator() { | ||||
return separator; | return separator; | ||||
} | } | ||||
public List getBlocks() { | |||||
return blocks; | |||||
} | |||||
public MinOptMax getMaxBPD() { | |||||
MinOptMax maxbpd = parent.getMaxBPD(); | |||||
BodyRegion body = (BodyRegion)parent; | |||||
Area a = body.getMainReference(); | |||||
if (a != null) { | |||||
maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD()); | |||||
} | |||||
if ((a=body.getBeforeFloat()) != null) { | |||||
maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD()); | |||||
} | |||||
return maxbpd; | |||||
} | |||||
} | } | ||||
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Iterator; | |||||
// a line area can contain information in ranges of child inline | |||||
// areas that have properties such as | |||||
// links, background, underline, bold, id areas | |||||
/** | |||||
* The line area. | |||||
* This is a line area that contains inline areas. | |||||
*/ | |||||
public class LineArea extends Area { | public class LineArea extends Area { | ||||
int stacking = LR; | |||||
private int stacking = LR; | |||||
// contains inline areas | // contains inline areas | ||||
// has start indent and length, dominant baseline, height | // has start indent and length, dominant baseline, height | ||||
int startIndent; | |||||
int length; | |||||
private int startIndent; | |||||
private int length; | |||||
int lineHeight; | |||||
private int lineHeight; | |||||
// this is the offset for the dominant baseline | // this is the offset for the dominant baseline | ||||
int baseLine; | |||||
private int baseLine; | |||||
// this class can contain the dominant char styling info | // this class can contain the dominant char styling info | ||||
// this means that many renderers can optimise a bit | // this means that many renderers can optimise a bit | ||||
ArrayList inlineAreas = new ArrayList(); | |||||
private ArrayList inlineAreas = new ArrayList(); | |||||
/** | |||||
* Set the height of this line area. | |||||
* | |||||
* @param height the height of the line area | |||||
*/ | |||||
public void setHeight(int height) { | public void setHeight(int height) { | ||||
lineHeight = height; | lineHeight = height; | ||||
} | } | ||||
/** | |||||
* Get the height of this line area. | |||||
* | |||||
* @return the height of the line area | |||||
*/ | |||||
public int getHeight() { | public int getHeight() { | ||||
return lineHeight; | return lineHeight; | ||||
} | } | ||||
public MinOptMax getContentBPD() { | |||||
return new MinOptMax(lineHeight); | |||||
} | |||||
/** | |||||
* Add a child area to this line area. | |||||
* | |||||
* @param childArea the inline child area to add | |||||
*/ | |||||
public void addChild(Area childArea) { | public void addChild(Area childArea) { | ||||
if (childArea instanceof InlineArea) { | if (childArea instanceof InlineArea) { | ||||
addInlineArea((InlineArea)childArea); | addInlineArea((InlineArea)childArea); | ||||
} | } | ||||
} | } | ||||
/** | |||||
* Add an inline child area to this line area. | |||||
* | |||||
* @param area the inline child area to add | |||||
*/ | |||||
public void addInlineArea(InlineArea area) { | public void addInlineArea(InlineArea area) { | ||||
inlineAreas.add(area); | inlineAreas.add(area); | ||||
} | } | ||||
/** | |||||
* Get the inline child areas of this line area. | |||||
* | |||||
* @return the list of inline areas | |||||
*/ | |||||
public List getInlineAreas() { | public List getInlineAreas() { | ||||
return inlineAreas; | return inlineAreas; | ||||
} | } | ||||
/** | |||||
* Set the start indent of this line area. | |||||
* The start indent is used for offsetting the start of | |||||
* the inline areas for alignment or other indents. | |||||
* | |||||
* @param si the start indent value | |||||
*/ | |||||
public void setStartIndent(int si) { | public void setStartIndent(int si) { | ||||
startIndent = si; | startIndent = si; | ||||
} | } | ||||
/** | |||||
* Get the start indent of this line area. | |||||
* The start indent is used for offsetting the start of | |||||
* the inline areas for alignment or other indents. | |||||
* | |||||
* @return the start indent value | |||||
*/ | |||||
public int getStartIndent() { | public int getStartIndent() { | ||||
return startIndent; | return startIndent; | ||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area; | package org.apache.fop.area; | ||||
/** | |||||
* Traits for a range of areas in a line. | |||||
* Not sure if this is needed. | |||||
*/ | |||||
public class LineTrait extends Trait { | public class LineTrait extends Trait { | ||||
int[] range; | |||||
private int[] range; | |||||
} | } | ||||
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area; | package org.apache.fop.area; | ||||
import java.io.Serializable; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
// the area that contains the flow via the span areas | |||||
public class MainReference extends Area implements Serializable { | |||||
List spanAreas = new ArrayList(); | |||||
int columnGap; | |||||
int width; | |||||
/** | |||||
* The main body reference area. | |||||
* This area that contains the flow via the span areas. | |||||
*/ | |||||
public class MainReference extends Area { | |||||
private List spanAreas = new ArrayList(); | |||||
private int columnGap; | |||||
private int width; | |||||
/** | |||||
* Add a span area to this area. | |||||
* | |||||
* @param span the span area to add | |||||
*/ | |||||
public void addSpan(Span span) { | public void addSpan(Span span) { | ||||
spanAreas.add(span); | spanAreas.add(span); | ||||
span.setParent(this); | |||||
} | } | ||||
/** | |||||
* Get the span areas from this area. | |||||
* | |||||
* @return the list of span areas | |||||
*/ | |||||
public List getSpans() { | public List getSpans() { | ||||
return spanAreas; | return spanAreas; | ||||
} | } | ||||
/** | |||||
* Get the column gap in millipoints. | |||||
* | |||||
* @return the column gap in millioints | |||||
*/ | |||||
public int getColumnGap() { | public int getColumnGap() { | ||||
return columnGap; | return columnGap; | ||||
} | } | ||||
/** | |||||
* Get the width of this reference area. | |||||
* | |||||
* @return the width | |||||
*/ | |||||
public int getWidth() { | public int getWidth() { | ||||
return width; | return width; | ||||
} | } | ||||
public MinOptMax getMaxBPD() { | |||||
MinOptMax maxbpd = parent.getMaxBPD(); | |||||
BodyRegion body = (BodyRegion)parent; | |||||
Area a = body.getBeforeFloat(); | |||||
if (a != null) { | |||||
maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD()); | |||||
} | |||||
if ((a=body.getFootnote()) != null) { | |||||
maxbpd = MinOptMax.subtract(maxbpd, a.getContentBPD()); | |||||
} | |||||
return maxbpd; | |||||
} | |||||
} | } | ||||
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
* MinOptMax values are used during layout calculations. The instance | * MinOptMax values are used during layout calculations. The instance | ||||
* variables are package visible. | * variables are package visible. | ||||
*/ | */ | ||||
public class MinOptMax implements java.io.Serializable, Cloneable { | public class MinOptMax implements java.io.Serializable, Cloneable { | ||||
/** Publicly visible min(imum), opt(imum) and max(imum) values.*/ | /** Publicly visible min(imum), opt(imum) and max(imum) values.*/ | ||||
public int max; | public int max; | ||||
public MinOptMax() { | public MinOptMax() { | ||||
this(0); | |||||
this(0); | |||||
} | } | ||||
public MinOptMax(int val) { | public MinOptMax(int val) { | ||||
this(val, val, val); | |||||
this(val, val, val); | |||||
} | } | ||||
public MinOptMax(int min, int opt, int max) { | public MinOptMax(int min, int opt, int max) { | ||||
this.min = min; | |||||
this.opt = opt; | |||||
this.max = max; | |||||
this.min = min; | |||||
this.opt = opt; | |||||
this.max = max; | |||||
} | } | ||||
public Object clone() { | public Object clone() { | ||||
try { | |||||
return super.clone(); | |||||
} catch (CloneNotSupportedException ex) { | |||||
// SHOULD NEVER OCCUR - all members are primitive types! | |||||
return null; | |||||
} | |||||
try { | |||||
return super.clone(); | |||||
} catch (CloneNotSupportedException ex) { | |||||
// SHOULD NEVER OCCUR - all members are primitive types! | |||||
return null; | |||||
} | |||||
} | } | ||||
public static MinOptMax subtract(MinOptMax op1, MinOptMax op2) { | public static MinOptMax subtract(MinOptMax op1, MinOptMax op2) { | ||||
return new MinOptMax(op1.min - op2.max, op1.opt - op2.opt, | |||||
op1.max - op2.min); | |||||
return new MinOptMax(op1.min - op2.max, op1.opt - op2.opt, | |||||
op1.max - op2.min); | |||||
} | } | ||||
public static MinOptMax add(MinOptMax op1, MinOptMax op2) { | public static MinOptMax add(MinOptMax op1, MinOptMax op2) { | ||||
return new MinOptMax(op1.min + op2.min, op1.opt + op2.opt, | |||||
op1.max + op2.max); | |||||
return new MinOptMax(op1.min + op2.min, op1.opt + op2.opt, | |||||
op1.max + op2.max); | |||||
} | } | ||||
public static MinOptMax multiply(MinOptMax op1, double mult) { | public static MinOptMax multiply(MinOptMax op1, double mult) { | ||||
return new MinOptMax((int)(op1.min * mult), | |||||
(int)(op1.opt * mult), | |||||
(int)(op1.max * mult)); | |||||
return new MinOptMax((int)(op1.min * mult), | |||||
(int)(op1.opt * mult), (int)(op1.max * mult)); | |||||
} | } | ||||
public void add(MinOptMax op) { | public void add(MinOptMax op) { | ||||
min += op.min; | |||||
opt += op.opt; | |||||
max += op.max; | |||||
min += op.min; | |||||
opt += op.opt; | |||||
max += op.max; | |||||
} | } | ||||
public void subtract(MinOptMax op) { | public void subtract(MinOptMax op) { | ||||
min -= op.max; | |||||
opt -= op.opt; | |||||
max -= op.min; | |||||
min -= op.max; | |||||
opt -= op.opt; | |||||
max -= op.min; | |||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
*/ | */ | ||||
public class Page implements Serializable, Cloneable { | public class Page implements Serializable, Cloneable { | ||||
// contains before, start, body, end and after regions | // contains before, start, body, end and after regions | ||||
RegionViewport regionBefore = null; | |||||
RegionViewport regionStart = null; | |||||
RegionViewport regionBody = null; | |||||
RegionViewport regionEnd = null; | |||||
RegionViewport regionAfter = null; | |||||
private RegionViewport regionBefore = null; | |||||
private RegionViewport regionStart = null; | |||||
private RegionViewport regionBody = null; | |||||
private RegionViewport regionEnd = null; | |||||
private RegionViewport regionAfter = null; | |||||
// hashmap of markers for this page | // hashmap of markers for this page | ||||
// start and end are added by the fo that contains the markers | // start and end are added by the fo that contains the markers | ||||
HashMap markerStart = null; | |||||
HashMap markerEnd = null; | |||||
private HashMap markerStart = null; | |||||
private HashMap markerEnd = null; | |||||
// temporary map of unresolved objects used when serializing the page | |||||
private HashMap unresolved = null; | private HashMap unresolved = null; | ||||
/** | |||||
* Set the region on this page. | |||||
* | |||||
* @param areaclass the area class of the region to set | |||||
* @param port the region viewport to set | |||||
*/ | |||||
public void setRegion(int areaclass, RegionViewport port) { | public void setRegion(int areaclass, RegionViewport port) { | ||||
if (areaclass == RegionReference.BEFORE) { | if (areaclass == RegionReference.BEFORE) { | ||||
regionBefore = port; | regionBefore = port; | ||||
} | } | ||||
} | } | ||||
/** | |||||
* Get the region from this page. | |||||
* | |||||
* @param areaclass the region area class | |||||
* @return the region viewport or null if none | |||||
*/ | |||||
public RegionViewport getRegion(int areaclass) { | public RegionViewport getRegion(int areaclass) { | ||||
if (areaclass == RegionReference.BEFORE) { | if (areaclass == RegionReference.BEFORE) { | ||||
return regionBefore; | return regionBefore; | ||||
return null; | return null; | ||||
} | } | ||||
/** | |||||
* Clone this page. | |||||
* This returns a new page with a clone of all the regions. | |||||
* | |||||
* @return a new clone of this page | |||||
*/ | |||||
public Object clone() { | public Object clone() { | ||||
Page p = new Page(); | Page p = new Page(); | ||||
if(regionBefore != null) | |||||
if (regionBefore != null) { | |||||
p.regionBefore = (RegionViewport)regionBefore.clone(); | p.regionBefore = (RegionViewport)regionBefore.clone(); | ||||
if(regionStart != null) | |||||
} | |||||
if (regionStart != null) { | |||||
p.regionStart = (RegionViewport)regionStart.clone(); | p.regionStart = (RegionViewport)regionStart.clone(); | ||||
if(regionBody != null) | |||||
} | |||||
if (regionBody != null) { | |||||
p.regionBody = (RegionViewport)regionBody.clone(); | p.regionBody = (RegionViewport)regionBody.clone(); | ||||
if(regionEnd != null) | |||||
} | |||||
if (regionEnd != null) { | |||||
p.regionEnd = (RegionViewport)regionEnd.clone(); | p.regionEnd = (RegionViewport)regionEnd.clone(); | ||||
if(regionAfter != null) | |||||
} | |||||
if (regionAfter != null) { | |||||
p.regionAfter = (RegionViewport)regionAfter.clone(); | p.regionAfter = (RegionViewport)regionAfter.clone(); | ||||
} | |||||
return p; | return p; | ||||
} | } | ||||
/** | |||||
* Set the unresolved references on this page for serializing. | |||||
* | |||||
* @param unres the map of unresolved objects | |||||
*/ | |||||
public void setUnresolvedReferences(HashMap unres) { | public void setUnresolvedReferences(HashMap unres) { | ||||
unresolved = unres; | unresolved = unres; | ||||
} | } | ||||
/** | |||||
* Get the map unresolved references from this page. | |||||
* This should be called after deserializing to retrieve | |||||
* the map of unresolved references that were serialized. | |||||
* | |||||
* @return the de-serialized map of unresolved objects | |||||
*/ | |||||
public HashMap getUnresolvedReferences() { | public HashMap getUnresolvedReferences() { | ||||
return unresolved; | return unresolved; | ||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
/** | |||||
* This is a region reference area for the page regions. | |||||
* This area represents a region on the page. It is cloneable | |||||
* so the page master can make copies from the original page and regions. | |||||
*/ | |||||
public class RegionReference extends Area implements Serializable, Cloneable { | public class RegionReference extends Area implements Serializable, Cloneable { | ||||
/** | |||||
* The before region. | |||||
*/ | |||||
public static final int BEFORE = 0; | public static final int BEFORE = 0; | ||||
/** | |||||
* The start region. | |||||
*/ | |||||
public static final int START = 1; | public static final int START = 1; | ||||
/** | |||||
* The body region. | |||||
*/ | |||||
public static final int BODY = 2; | public static final int BODY = 2; | ||||
/** | |||||
* The end region. | |||||
*/ | |||||
public static final int END = 3; | public static final int END = 3; | ||||
/** | |||||
* The after region. | |||||
*/ | |||||
public static final int AFTER = 4; | public static final int AFTER = 4; | ||||
int regionClass = BEFORE; | |||||
private int regionClass = BEFORE; | |||||
private CTM ctm; | private CTM ctm; | ||||
// the list of block areas from the static flow | |||||
private ArrayList blocks = new ArrayList(); | |||||
/** | |||||
* Create a new region reference area. | |||||
* | |||||
* @param type the region class type | |||||
*/ | |||||
public RegionReference(int type) { | public RegionReference(int type) { | ||||
regionClass = type; | regionClass = type; | ||||
} | } | ||||
* terms of "start" and "before" into coordinates in a system which | * terms of "start" and "before" into coordinates in a system which | ||||
* is positioned in "absolute" directions (with origin at lower left of | * is positioned in "absolute" directions (with origin at lower left of | ||||
* the region reference area. | * the region reference area. | ||||
* | |||||
* @param ctm the current transform to position this region | |||||
*/ | */ | ||||
public void setCTM(CTM ctm) { | public void setCTM(CTM ctm) { | ||||
this.ctm = ctm; | this.ctm = ctm; | ||||
} | } | ||||
/** | |||||
* Get the current transform of this region. | |||||
* | |||||
* @return ctm the current transform to position this region | |||||
*/ | |||||
public CTM getCTM() { | public CTM getCTM() { | ||||
return this.ctm; | return this.ctm; | ||||
} | } | ||||
// the list of block areas from the static flow | |||||
ArrayList blocks = new ArrayList(); | |||||
/** | |||||
* Get the block in this region. | |||||
* | |||||
* @return the list of blocks in this region | |||||
*/ | |||||
public List getBlocks() { | public List getBlocks() { | ||||
return blocks; | return blocks; | ||||
} | } | ||||
/** | |||||
* Get the region class of this region. | |||||
* | |||||
* @return the region class | |||||
*/ | |||||
public int getRegionClass() { | public int getRegionClass() { | ||||
return regionClass; | return regionClass; | ||||
} | } | ||||
/** | |||||
* Add a block area to this region reference area. | |||||
* | |||||
* @param block the block area to add | |||||
*/ | |||||
public void addBlock(Block block) { | public void addBlock(Block block) { | ||||
blocks.add(block); | blocks.add(block); | ||||
} | } | ||||
/** | |||||
* Clone this region. | |||||
* This is used when cloning the page by the page master. | |||||
* The blocks are not copied since the master will have no blocks. | |||||
* | |||||
* @return a copy of this region reference area | |||||
*/ | |||||
public Object clone() { | public Object clone() { | ||||
RegionReference rr = new RegionReference(regionClass); | RegionReference rr = new RegionReference(regionClass); | ||||
rr.ctm = ctm; | rr.ctm = ctm; |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area; | package org.apache.fop.area; | ||||
import java.awt.geom.Rectangle2D; | import java.awt.geom.Rectangle2D; | ||||
import java.io.Serializable; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
public class RegionViewport extends Area implements Serializable, Cloneable { | |||||
/** | |||||
* Region Viewport reference area. | |||||
* This area is the viewport for a region and contains a region area. | |||||
*/ | |||||
public class RegionViewport extends Area implements Cloneable { | |||||
// this rectangle is relative to the page | // this rectangle is relative to the page | ||||
RegionReference region; | |||||
Rectangle2D viewArea; | |||||
boolean clip = false; | |||||
private RegionReference region; | |||||
private Rectangle2D viewArea; | |||||
private boolean clip = false; | |||||
/** | |||||
* Create a new region viewport. | |||||
* | |||||
* @param viewArea the view area of this viewport | |||||
*/ | |||||
public RegionViewport(Rectangle2D viewArea) { | public RegionViewport(Rectangle2D viewArea) { | ||||
this.viewArea = viewArea; | this.viewArea = viewArea; | ||||
} | } | ||||
/** | |||||
* Set the region for this region viewport. | |||||
* | |||||
* @param reg the child region inside this viewport | |||||
*/ | |||||
public void setRegion(RegionReference reg) { | public void setRegion(RegionReference reg) { | ||||
region = reg; | region = reg; | ||||
region.setParent(this); | |||||
} | } | ||||
/** | |||||
* Get the region for this region viewport. | |||||
* | |||||
* @return the child region inside this viewport | |||||
*/ | |||||
public RegionReference getRegion() { | public RegionReference getRegion() { | ||||
return region; | return region; | ||||
} | } | ||||
/** | |||||
* Set the clipping for this region viewport. | |||||
* | |||||
* @param c the clipping value | |||||
*/ | |||||
public void setClip(boolean c) { | public void setClip(boolean c) { | ||||
clip = c; | clip = c; | ||||
} | } | ||||
/** | |||||
* Get the view area of this viewport. | |||||
* | |||||
* @return the viewport rectangle area | |||||
*/ | |||||
public Rectangle2D getViewArea() { | public Rectangle2D getViewArea() { | ||||
return viewArea; | return viewArea; | ||||
} | } | ||||
private void readObject(java.io.ObjectInputStream in) | private void readObject(java.io.ObjectInputStream in) | ||||
throws IOException, ClassNotFoundException { | throws IOException, ClassNotFoundException { | ||||
viewArea = new Rectangle2D.Float(in.readFloat(), in.readFloat(), | viewArea = new Rectangle2D.Float(in.readFloat(), in.readFloat(), | ||||
in.readFloat(), in.readFloat()); | |||||
in.readFloat(), in.readFloat()); | |||||
clip = in.readBoolean(); | clip = in.readBoolean(); | ||||
setRegion( (RegionReference) in.readObject()); | |||||
setRegion((RegionReference) in.readObject()); | |||||
} | } | ||||
/** | |||||
* Clone this region viewport. | |||||
* Used when creating a copy from the page master. | |||||
* | |||||
* @return a new copy of this region viewport | |||||
*/ | |||||
public Object clone() { | public Object clone() { | ||||
RegionViewport rv = new RegionViewport((Rectangle2D)viewArea.clone()); | RegionViewport rv = new RegionViewport((Rectangle2D)viewArea.clone()); | ||||
rv.region = (RegionReference)region.clone(); | rv.region = (RegionReference)region.clone(); | ||||
rv.region.setParent(rv); | |||||
return rv; | return rv; | ||||
} | } | ||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
*/ | */ | ||||
public interface Resolveable { | public interface Resolveable { | ||||
public boolean isResolved(); | |||||
/** | |||||
* Check if this area has been resolved. | |||||
* | |||||
* @return true once this area is resolved | |||||
*/ | |||||
boolean isResolved(); | |||||
public String[] getIDs(); | |||||
/** | |||||
* Get the array of id references of this resolveable object. | |||||
* If this object contains child resolveables that are | |||||
* resolved through this then it should return the id's of | |||||
* the child also. | |||||
* | |||||
* @return the id references for resolving this object | |||||
*/ | |||||
String[] getIDs(); | |||||
/** | /** | ||||
* This resolves reference with a list of pages. | * This resolves reference with a list of pages. | ||||
* @param pages the list of pages with the id area | * @param pages the list of pages with the id area | ||||
* may be null if not found | * may be null if not found | ||||
*/ | */ | ||||
public void resolve(String id, List pages); | |||||
void resolve(String id, List pages); | |||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area; | package org.apache.fop.area; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.Iterator; | |||||
// this is a reference area block area with 0 border and padding | // this is a reference area block area with 0 border and padding | ||||
public class Span extends Area { | public class Span extends Area { | ||||
// the list of flow reference areas in this span area | // the list of flow reference areas in this span area | ||||
ArrayList flowAreas; | |||||
int height; | |||||
private ArrayList flowAreas; | |||||
private int height; | |||||
public Span(int cols) { | public Span(int cols) { | ||||
flowAreas = new ArrayList(cols); | flowAreas = new ArrayList(cols); | ||||
public void addFlow(Flow flow) { | public void addFlow(Flow flow) { | ||||
flowAreas.add(flow); | flowAreas.add(flow); | ||||
flow.setParent(this); | |||||
} | } | ||||
public int getColumnCount() { | public int getColumnCount() { | ||||
return (Flow) flowAreas.get(count); | return (Flow) flowAreas.get(count); | ||||
} | } | ||||
/** | |||||
* Maximum available BPD for a Span is the maxBPD for its containing | |||||
* MainReference less the content BPD of any previous spans | |||||
*/ | |||||
public MinOptMax getMaxBPD() { | |||||
MinOptMax maxbpd = parent.getMaxBPD(); | |||||
MainReference mainref = (MainReference)parent; | |||||
Iterator spanIter = mainref.getSpans().iterator(); | |||||
while (spanIter.hasNext()) { | |||||
Span s = (Span)spanIter.next(); | |||||
if (s == this) break; | |||||
maxbpd = MinOptMax.subtract(maxbpd, s.getContentBPD()); | |||||
} | |||||
return maxbpd; | |||||
} | |||||
} | } | ||||
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area; | package org.apache.fop.area; | ||||
/** | |||||
* The title area. | |||||
* This area holds the inline areas from the page-sequence | |||||
* title element. | |||||
*/ | |||||
public class Title extends LineArea { | public class Title extends LineArea { | ||||
} | } |
import java.util.Iterator; | import java.util.Iterator; | ||||
// properties should be serialized by the holder | // properties should be serialized by the holder | ||||
/** | |||||
* Area traits used for rendering. | |||||
* This class represents an area trait that specifies a value for rendering. | |||||
*/ | |||||
public class Trait implements Serializable { | public class Trait implements Serializable { | ||||
/** | |||||
* Id reference line, not resolved. | |||||
* not sure if this is needed. | |||||
*/ | |||||
public static final Integer ID_LINK = new Integer(0); | public static final Integer ID_LINK = new Integer(0); | ||||
/** | |||||
* Internal link trait. | |||||
* This is resolved and provides a link to an internal area. | |||||
*/ | |||||
public static final Integer INTERNAL_LINK = new Integer(1); //resolved | public static final Integer INTERNAL_LINK = new Integer(1); //resolved | ||||
/** | |||||
* External link. A URL link to an external resource. | |||||
*/ | |||||
public static final Integer EXTERNAL_LINK = new Integer(2); | public static final Integer EXTERNAL_LINK = new Integer(2); | ||||
/** | |||||
* The font name from the font setup. | |||||
*/ | |||||
public static final Integer FONT_NAME = new Integer(3); | public static final Integer FONT_NAME = new Integer(3); | ||||
/** | |||||
* Font size for the current font. | |||||
*/ | |||||
public static final Integer FONT_SIZE = new Integer(4); | public static final Integer FONT_SIZE = new Integer(4); | ||||
/** | |||||
* The current colour. | |||||
*/ | |||||
public static final Integer COLOR = new Integer(7); | public static final Integer COLOR = new Integer(7); | ||||
/** | |||||
* Don't think this is necessary. | |||||
*/ | |||||
public static final Integer ID_AREA = new Integer(8); | public static final Integer ID_AREA = new Integer(8); | ||||
/** | |||||
* Background trait for an area. | |||||
*/ | |||||
public static final Integer BACKGROUND = new Integer(9); | public static final Integer BACKGROUND = new Integer(9); | ||||
/** | |||||
* Underline trait used when rendering inline parent. | |||||
*/ | |||||
public static final Integer UNDERLINE = new Integer(10); | public static final Integer UNDERLINE = new Integer(10); | ||||
/** | |||||
* Overline trait used when rendering inline parent. | |||||
*/ | |||||
public static final Integer OVERLINE = new Integer(11); | public static final Integer OVERLINE = new Integer(11); | ||||
/** | |||||
* Linethrough trait used when rendering inline parent. | |||||
*/ | |||||
public static final Integer LINETHROUGH = new Integer(12); | public static final Integer LINETHROUGH = new Integer(12); | ||||
/** | |||||
* | |||||
*/ | |||||
public static final Integer OFFSET = new Integer(13); | public static final Integer OFFSET = new Integer(13); | ||||
/** | |||||
* The shadow for text. | |||||
*/ | |||||
public static final Integer SHADOW = new Integer(14); | public static final Integer SHADOW = new Integer(14); | ||||
/** | |||||
* The border start. | |||||
*/ | |||||
public static final Integer BORDER_START = new Integer(15); | public static final Integer BORDER_START = new Integer(15); | ||||
public static final Integer BORDER_END = new Integer(16); | public static final Integer BORDER_END = new Integer(16); | ||||
public static final Integer BORDER_BEFORE = new Integer(17); | public static final Integer BORDER_BEFORE = new Integer(17); |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area; | package org.apache.fop.area; | ||||
/** | /** | ||||
* Area tree extension interface. | |||||
* This interface is used by area tree extensions that are handled | |||||
* by the renderer. | |||||
* When this extension is handled by the area tree it is rendered | |||||
* according to the three possibilities, IMMEDIATELY, AFTER_PAGE | |||||
* or END_OF_DOC. | |||||
*/ | */ | ||||
public interface TreeExt { | public interface TreeExt { | ||||
public final static int IMMEDIATELY = 0; | |||||
public final static int AFTER_PAGE = 1; | |||||
public final static int END_OF_DOC = 2; | |||||
/** | |||||
* Render this extension immediately when | |||||
* being handled by the area tree. | |||||
*/ | |||||
public static final int IMMEDIATELY = 0; | |||||
public boolean isResolveable(); | |||||
public String getMimeType(); | |||||
public String getName(); | |||||
/** | |||||
* Render this extension after the next page is rendered | |||||
* or prepared when being handled by the area tree. | |||||
*/ | |||||
public static final int AFTER_PAGE = 1; | |||||
/** | |||||
* Render this extension at the end of the document once | |||||
* all pages have been fully rendered. | |||||
*/ | |||||
public static final int END_OF_DOC = 2; | |||||
/** | |||||
* Check if this tree extension is also resolveable so that | |||||
* the area tree can do id reference resolution when the | |||||
* extension is added to the area tree. | |||||
* | |||||
* @return true if this also implements resolveable | |||||
*/ | |||||
boolean isResolveable(); | |||||
/** | |||||
* Get the mime type for the document that this area tree | |||||
* extension applies. | |||||
* | |||||
* @return the mime type of the document where this applies | |||||
*/ | |||||
String getMimeType(); | |||||
/** | |||||
* Get the name of this extension. | |||||
* | |||||
* @return the name of this extension | |||||
*/ | |||||
String getName(); | |||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area.inline; | package org.apache.fop.area.inline; | ||||
/** | |||||
* Anchor area for footnote or float. | |||||
* Not sure if this is needed. | |||||
*/ | |||||
public class Anchor extends InlineArea { | public class Anchor extends InlineArea { | ||||
// has a keep with adjacent area | // has a keep with adjacent area |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
import org.apache.fop.render.Renderer; | import org.apache.fop.render.Renderer; | ||||
/** | |||||
* Single character inline area. | |||||
* This inline area holds a single characater. | |||||
*/ | |||||
public class Character extends InlineArea { | public class Character extends InlineArea { | ||||
char character; | |||||
private char character; | |||||
/** | |||||
* Create a new characater inline area with the given character. | |||||
* | |||||
* @param ch the character for this inline area | |||||
*/ | |||||
public Character(char ch) { | public Character(char ch) { | ||||
character = ch; | character = ch; | ||||
} | } | ||||
// character info: font, char spacing, colour, baseline | // character info: font, char spacing, colour, baseline | ||||
/** | |||||
* Render this inline area. | |||||
* | |||||
* @param renderer the renderer to render this character area | |||||
*/ | |||||
public void render(Renderer renderer) { | public void render(Renderer renderer) { | ||||
renderer.renderCharacter(this); | renderer.renderCharacter(this); | ||||
} | } | ||||
/** | |||||
* Get the character for this inline character area. | |||||
* | |||||
* @return the character | |||||
*/ | |||||
public char getChar() { | public char getChar() { | ||||
return character; | return character; | ||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
package org.apache.fop.area.inline; | package org.apache.fop.area.inline; | ||||
import org.apache.fop.area.MinOptMax; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
* When the renderer gets the child areas to render | * When the renderer gets the child areas to render | ||||
* the inline areas are repeated to fill the ipd of | * the inline areas are repeated to fill the ipd of | ||||
* this inline parent. | * this inline parent. | ||||
* This extends InlineParent so that the renderer will render | |||||
* this as a normal inline parent. | |||||
*/ | */ | ||||
public class FilledArea extends InlineParent { | public class FilledArea extends InlineParent { | ||||
private int unitWidth; | private int unitWidth; | ||||
/** | |||||
* Create a new filled area. | |||||
*/ | |||||
public FilledArea() { | public FilledArea() { | ||||
} | } | ||||
/** | |||||
* Set the unit width for the areas to fill the full width. | |||||
* | |||||
* @param w the unit width | |||||
*/ | |||||
public void setUnitWidth(int w) { | public void setUnitWidth(int w) { | ||||
unitWidth = w; | unitWidth = w; | ||||
} | } | ||||
/** | |||||
* Get the child areas for this filed area. | |||||
* This copies the references of the inline areas so that | |||||
* it fills the total width of the area a whole number of times | |||||
* for the unit width. | |||||
* | |||||
* @return the list of child areas copied to fill the width | |||||
*/ | |||||
public List getChildAreas() { | public List getChildAreas() { | ||||
int units = (int)(getWidth() / unitWidth); | int units = (int)(getWidth() / unitWidth); | ||||
ArrayList newList = new ArrayList(); | ArrayList newList = new ArrayList(); |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
import org.w3c.dom.Document; | import org.w3c.dom.Document; | ||||
// cacheable object | // cacheable object | ||||
/** | |||||
* Foreign object inline area. | |||||
* This inline area represents an instream-foreign object. | |||||
* This holds an xml document and the associated namespace. | |||||
*/ | |||||
public class ForeignObject extends Area { | public class ForeignObject extends Area { | ||||
Document doc; | |||||
String namespace; | |||||
// dom object | |||||
// height, width | |||||
private Document doc; | |||||
private String namespace; | |||||
/** | |||||
* Create a new foreign object with the given dom and namespace. | |||||
* | |||||
* @param d the xml document | |||||
* @param ns the namespace of the document | |||||
*/ | |||||
public ForeignObject(Document d, String ns) { | public ForeignObject(Document d, String ns) { | ||||
doc = d; | doc = d; | ||||
namespace = ns; | namespace = ns; | ||||
} | } | ||||
/** | |||||
* Get the document for this foreign object. | |||||
* | |||||
* @return the xml document | |||||
*/ | |||||
public Document getDocument() { | public Document getDocument() { | ||||
return doc; | return doc; | ||||
} | } | ||||
/** | |||||
* Get the namespace of this foreign object. | |||||
* | |||||
* @return the namespace of this document | |||||
*/ | |||||
public String getNameSpace() { | public String getNameSpace() { | ||||
return namespace; | return namespace; | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
import org.apache.fop.area.Area; | import org.apache.fop.area.Area; | ||||
// cacheable object | |||||
// image object, mime type, url | |||||
// an image only needs to be loaded to get the size if not specified | |||||
// and when rendering to the output | |||||
/** | |||||
* Image area for external-graphic. | |||||
* This area holds information for rendering an image. | |||||
* The url of the image is used as a key to reference the image cache. | |||||
*/ | |||||
public class Image extends Area { | public class Image extends Area { | ||||
String url; | |||||
private String url; | |||||
/** | |||||
* Create a new image with the given url. | |||||
* | |||||
* @param u the url of the image | |||||
*/ | |||||
public Image(String u) { | public Image(String u) { | ||||
url = u; | url = u; | ||||
} | } | ||||
/** | |||||
* Get the url of this image. | |||||
* This url is used as a key to locate the actual image data. | |||||
* | |||||
* @return the url of this image | |||||
*/ | |||||
public String getURL() { | public String getURL() { | ||||
return url; | return url; | ||||
} | } |
package org.apache.fop.area.inline; | package org.apache.fop.area.inline; | ||||
import org.apache.fop.area.Area; | import org.apache.fop.area.Area; | ||||
import org.apache.fop.area.MinOptMax; | |||||
import org.apache.fop.area.Trait; | import org.apache.fop.area.Trait; | ||||
import org.apache.fop.render.Renderer; | import org.apache.fop.render.Renderer; | ||||
import org.apache.fop.traits.BorderProps; | import org.apache.fop.traits.BorderProps; | ||||
import org.apache.fop.fo.properties.VerticalAlign; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
*/ | */ | ||||
public class InlineArea extends Area { | public class InlineArea extends Area { | ||||
// int width; | // int width; | ||||
int height; | |||||
private int height; | |||||
protected int contentIPD = 0; | protected int contentIPD = 0; | ||||
// offset position from top of parent area | // offset position from top of parent area | ||||
int verticalPosition = 0; | int verticalPosition = 0; | ||||
// store properties in array list, need better solution | // store properties in array list, need better solution | ||||
ArrayList props = null; | |||||
// inline areas are expected to implement this method | |||||
// to render themselves | |||||
private ArrayList props = null; | |||||
/** | |||||
* Render this inline area. | |||||
* Inline areas that extend this class are expected | |||||
* to implement this method to render themselves in | |||||
* the renderer. | |||||
* | |||||
* @param renderer the renderer to render this inline area | |||||
*/ | |||||
public void render(Renderer renderer) { | public void render(Renderer renderer) { | ||||
} | } | ||||
public void setWidth(int w) { | public void setWidth(int w) { | ||||
return iBP; | return iBP; | ||||
} | } | ||||
public MinOptMax getAllocationIPD() { | |||||
return new MinOptMax(getAllocIPD()); | |||||
} | |||||
public void setOffset(int v) { | public void setOffset(int v) { | ||||
verticalPosition = v; | verticalPosition = v; | ||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
* This is an inline area that can have other inlines as children. | * This is an inline area that can have other inlines as children. | ||||
*/ | */ | ||||
public class InlineParent extends InlineArea { | public class InlineParent extends InlineArea { | ||||
/** | |||||
* The list of inline areas added to this inline parent. | |||||
*/ | |||||
protected ArrayList inlines = new ArrayList(); | protected ArrayList inlines = new ArrayList(); | ||||
/** | |||||
* Create a new inline parent to add areas to. | |||||
*/ | |||||
public InlineParent() { | public InlineParent() { | ||||
} | } | ||||
/** | /** | ||||
* Render this area. | * Render this area. | ||||
* | |||||
* @param renderer the renderer to render this area in | * @param renderer the renderer to render this area in | ||||
*/ | */ | ||||
public void render(Renderer renderer) { | public void render(Renderer renderer) { | ||||
/** | /** | ||||
* Override generic Area method. | * Override generic Area method. | ||||
* | |||||
* @param childArea the child area to add | |||||
*/ | */ | ||||
public void addChild(Area childArea) { | public void addChild(Area childArea) { | ||||
if (childArea instanceof InlineArea) { | |||||
inlines.add(childArea); | |||||
increaseIPD( ((InlineArea)childArea).getAllocIPD()); | |||||
} | |||||
if (childArea instanceof InlineArea) { | |||||
inlines.add(childArea); | |||||
increaseIPD(((InlineArea) childArea).getAllocIPD()); | |||||
} | |||||
} | } | ||||
/** | |||||
* Get the child areas for this inline parent. | |||||
* | |||||
* @return the list of child areas | |||||
*/ | |||||
public List getChildAreas() { | public List getChildAreas() { | ||||
return inlines; | return inlines; | ||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
import org.apache.fop.render.Renderer; | import org.apache.fop.render.Renderer; | ||||
import org.apache.fop.fo.properties.RuleStyle; | import org.apache.fop.fo.properties.RuleStyle; | ||||
public class Leader extends Stretch { | |||||
/** | |||||
* This is a leader inline area. | |||||
* This class is only used for leader with leader-pattern of rule. | |||||
*/ | |||||
public class Leader extends InlineArea { | |||||
// pattern, length min opt max | // pattern, length min opt max | ||||
// if space replaced with a space | // if space replaced with a space | ||||
// otherwise this is a holder for a line | // otherwise this is a holder for a line | ||||
int ruleStyle = RuleStyle.SOLID; | |||||
int ruleThickness = 1000; | |||||
private int ruleStyle = RuleStyle.SOLID; | |||||
private int ruleThickness = 1000; | |||||
/** | |||||
* Create a new leader area. | |||||
*/ | |||||
public Leader() { | public Leader() { | ||||
} | } | ||||
/** | |||||
* Set the rule style of this leader area. | |||||
* | |||||
* @param style the rule style for the leader line | |||||
*/ | |||||
public void setRuleStyle(int style) { | public void setRuleStyle(int style) { | ||||
ruleStyle = style; | ruleStyle = style; | ||||
} | } | ||||
/** | |||||
* Set the rule thickness of the rule in miilipoints. | |||||
* | |||||
* @param rt the rule thickness in millipoints | |||||
*/ | |||||
public void setRuleThickness(int rt) { | public void setRuleThickness(int rt) { | ||||
ruleThickness = rt; | ruleThickness = rt; | ||||
} | } | ||||
/** | |||||
* Get the rule style of this leader. | |||||
* | |||||
* @return the rule style | |||||
*/ | |||||
public int getRuleStyle() { | public int getRuleStyle() { | ||||
return ruleStyle; | return ruleStyle; | ||||
} | } | ||||
/** | |||||
* Get the rule thickness of the rule in miilipoints. | |||||
* | |||||
* @return the rule thickness in millipoints | |||||
*/ | |||||
public int getRuleThickness() { | public int getRuleThickness() { | ||||
return ruleThickness; | return ruleThickness; | ||||
} | } | ||||
/** | |||||
* Render this leader in the current renderer. | |||||
* | |||||
* @param renderer the renderer to render this inline area | |||||
*/ | |||||
public void render(Renderer renderer) { | public void render(Renderer renderer) { | ||||
renderer.renderLeader(this); | renderer.renderLeader(this); | ||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
import org.apache.fop.render.Renderer; | import org.apache.fop.render.Renderer; | ||||
public class Space extends Stretch { | |||||
/** | |||||
* Inline space area. | |||||
* This is used for adding a inline space to the output. | |||||
*/ | |||||
public class Space extends InlineArea { | |||||
/** | |||||
* Render this inlien space area. | |||||
* | |||||
* @param renderer the renderer to render this inline area | |||||
*/ | |||||
public void render(Renderer renderer) { | public void render(Renderer renderer) { | ||||
renderer.renderInlineSpace(this); | renderer.renderInlineSpace(this); | ||||
} | } |
/* | |||||
* $Id$ | |||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | |||||
* LICENSE file included with these sources. | |||||
*/ | |||||
package org.apache.fop.area.inline; | |||||
import org.apache.fop.area.MinOptMax; | |||||
public class Stretch extends InlineArea { | |||||
MinOptMax contentIPD = null; | |||||
public void setAllocationIPD(MinOptMax mom) { | |||||
contentIPD = mom; | |||||
} | |||||
public MinOptMax getAllocationIPD() { | |||||
// Should also account for any borders and padding in the | |||||
// inline progression dimension | |||||
if (contentIPD != null) { | |||||
return contentIPD; | |||||
} | |||||
return super.getAllocationIPD(); | |||||
} | |||||
} |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
import java.util.List; | import java.util.List; | ||||
/** | |||||
* Unresolveable page number area. | |||||
* This is a word area that resolves itself to a page number | |||||
* from an id reference. | |||||
*/ | |||||
public class UnresolvedPageNumber extends Word implements Resolveable { | public class UnresolvedPageNumber extends Word implements Resolveable { | ||||
private boolean resolved = false; | private boolean resolved = false; | ||||
private String pageRefId; | private String pageRefId; | ||||
/** | |||||
* Create a new unresolveable page number. | |||||
* | |||||
* @param id the id reference for resolving this | |||||
*/ | |||||
public UnresolvedPageNumber(String id) { | public UnresolvedPageNumber(String id) { | ||||
pageRefId = id; | pageRefId = id; | ||||
word = "?"; | word = "?"; | ||||
} | } | ||||
/** | |||||
* Get the id references for this area. | |||||
* | |||||
* @return the id reference for this unresolved page number | |||||
*/ | |||||
public String[] getIDs() { | public String[] getIDs() { | ||||
return new String[] {pageRefId}; | return new String[] {pageRefId}; | ||||
} | } | ||||
/** | |||||
* Resolve this page number reference. | |||||
* This resolves the reference by getting the page number | |||||
* string from the first page in the list of pages that apply | |||||
* for the id reference. The word string is then set to the | |||||
* page number string. | |||||
* | |||||
* @param id the id reference being resolved | |||||
* @param pages the list of pages for the id reference | |||||
*/ | |||||
public void resolve(String id, List pages) { | public void resolve(String id, List pages) { | ||||
resolved = true; | resolved = true; | ||||
if(pages != null) { | |||||
if (pages != null) { | |||||
PageViewport page = (PageViewport)pages.get(0); | PageViewport page = (PageViewport)pages.get(0); | ||||
String str = page.getPageNumber(); | String str = page.getPageNumber(); | ||||
word = str; | word = str; | ||||
} | } | ||||
} | } | ||||
/** | |||||
* Check if this is resolved. | |||||
* | |||||
* @return true when this has been resolved | |||||
*/ | |||||
public boolean isResolved() { | public boolean isResolved() { | ||||
return resolved; | return resolved; | ||||
} | } |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.awt.geom.Rectangle2D; | import java.awt.geom.Rectangle2D; | ||||
/** | |||||
* Inline viewport area. | |||||
* This is an inline-level viewport area for inline container, | |||||
* external graphic and instream foreign object. This viewport | |||||
* holds the area and positions it. | |||||
*/ | |||||
public class Viewport extends InlineArea { | public class Viewport extends InlineArea { | ||||
// contents could be container, foreign object or image | // contents could be container, foreign object or image | ||||
Area content; | |||||
// an inline-level viewport area for graphic and instream foreign object | |||||
boolean clip = false; | |||||
// position relative to this area | |||||
Rectangle2D contentPosition; | |||||
private Area content; | |||||
// clipping for the viewport | |||||
private boolean clip = false; | |||||
// position of the cild area relative to this area | |||||
private Rectangle2D contentPosition; | |||||
/** | |||||
* Create a new viewport area with the content area. | |||||
* | |||||
* @param child the child content area of this viewport | |||||
*/ | |||||
public Viewport(Area child) { | public Viewport(Area child) { | ||||
content = child; | content = child; | ||||
} | } | ||||
/** | |||||
* Set the clip of this viewport. | |||||
* | |||||
* @param c true if this viewport should clip | |||||
*/ | |||||
public void setClip(boolean c) { | public void setClip(boolean c) { | ||||
clip = c; | clip = c; | ||||
} | } | ||||
/** | |||||
* Get the clip of this viewport. | |||||
* | |||||
* @return true if this viewport should clip | |||||
*/ | |||||
public boolean getClip() { | public boolean getClip() { | ||||
return clip; | return clip; | ||||
} | } | ||||
/** | |||||
* Set the position and size of the content of this viewport. | |||||
* | |||||
* @param cp the position and size to place the content | |||||
*/ | |||||
public void setContentPosition(Rectangle2D cp) { | public void setContentPosition(Rectangle2D cp) { | ||||
contentPosition = cp; | contentPosition = cp; | ||||
} | } | ||||
/** | |||||
* Get the position and size of the content of this viewport. | |||||
* | |||||
* @return the position and size to place the content | |||||
*/ | |||||
public Rectangle2D getContentPosition() { | public Rectangle2D getContentPosition() { | ||||
return contentPosition; | return contentPosition; | ||||
} | } | ||||
/** | |||||
* Get the content area for this viewport. | |||||
* | |||||
* @return the content area | |||||
*/ | |||||
public Area getContent() { | public Area getContent() { | ||||
return content; | return content; | ||||
} | } | ||||
/** | |||||
* Render this inline area. | |||||
* | |||||
* @param renderer the renderer to render this inline area | |||||
*/ | |||||
public void render(Renderer renderer) { | public void render(Renderer renderer) { | ||||
renderer.renderViewport(this); | renderer.renderViewport(this); | ||||
} | } | ||||
throws IOException, ClassNotFoundException { | throws IOException, ClassNotFoundException { | ||||
if (in.readBoolean()) { | if (in.readBoolean()) { | ||||
contentPosition = new Rectangle2D.Float(in.readFloat(), | contentPosition = new Rectangle2D.Float(in.readFloat(), | ||||
in.readFloat(), in.readFloat(), in.readFloat()); | |||||
in.readFloat(), | |||||
in.readFloat(), | |||||
in.readFloat()); | |||||
} | } | ||||
clip = in.readBoolean(); | clip = in.readBoolean(); | ||||
content = (Area) in.readObject(); | content = (Area) in.readObject(); |
/* | /* | ||||
* $Id$ | * $Id$ | ||||
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved. | |||||
* Copyright (C) 2001-2002 The Apache Software Foundation. All rights reserved. | |||||
* For details on use and redistribution please refer to the | * For details on use and redistribution please refer to the | ||||
* LICENSE file included with these sources. | * LICENSE file included with these sources. | ||||
*/ | */ | ||||
public class Word extends InlineArea { | public class Word extends InlineArea { | ||||
// character info: font, char spacing, colour, baseline | // character info: font, char spacing, colour, baseline | ||||
String word; | |||||
int iWSadjust = 0; | |||||
private String word; | |||||
private int iWSadjust = 0; | |||||
public void render(Renderer renderer) { | public void render(Renderer renderer) { | ||||
renderer.renderWord(this); | renderer.renderWord(this); | ||||
this.iWSadjust = iWSadjust; | this.iWSadjust = iWSadjust; | ||||
} | } | ||||
} | } | ||||