diff options
author | Jeremias Maerki <jeremias@apache.org> | 2011-01-18 08:54:08 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2011-01-18 08:54:08 +0000 |
commit | 992d7e9d1d3a71209ae689eb60b5e3c15295fe2d (patch) | |
tree | 7fc8445564597ae49eb9b1a082d7f8498409a4bf /src/java/org/apache/fop/area | |
parent | ce6d9e1eeef5f7b17fada9f07145e7e430586bf1 (diff) | |
parent | 5a367c3b12e19af7a66fc923d7149bf22cdfb596 (diff) | |
download | xmlgraphics-fop-992d7e9d1d3a71209ae689eb60b5e3c15295fe2d.tar.gz xmlgraphics-fop-992d7e9d1d3a71209ae689eb60b5e3c15295fe2d.zip |
Merge from Trunk, revisions 965390 to 1060234.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_Color@1060241 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/area')
39 files changed, 292 insertions, 214 deletions
diff --git a/src/java/org/apache/fop/area/Area.java b/src/java/org/apache/fop/area/Area.java index ddf2f5198..f94c68454 100644 --- a/src/java/org/apache/fop/area/Area.java +++ b/src/java/org/apache/fop/area/Area.java @@ -38,6 +38,9 @@ import org.apache.fop.traits.BorderProps; * Base object for all areas. */ public class Area extends AreaTreeObject implements Serializable { + + private static final long serialVersionUID = 6342888466142626492L; + // stacking directions /** * Stacking left to right @@ -134,7 +137,7 @@ public class Area extends AreaTreeObject implements Serializable { /** * logging instance */ - protected static Log log = LogFactory.getLog(Area.class); + protected static final Log log = LogFactory.getLog(Area.class); /** diff --git a/src/java/org/apache/fop/area/AreaEventProducer.java b/src/java/org/apache/fop/area/AreaEventProducer.java index 325367199..c4f5a7a35 100644 --- a/src/java/org/apache/fop/area/AreaEventProducer.java +++ b/src/java/org/apache/fop/area/AreaEventProducer.java @@ -30,7 +30,10 @@ public interface AreaEventProducer extends EventProducer { /** * Provider class for the event producer. */ - class Provider { + static final class Provider { + + private Provider() { + } /** * Returns an event producer. diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java index 298cf263b..87c681ed6 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.java @@ -305,6 +305,7 @@ public class AreaTreeHandler extends FOEventHandler { model.handleOffDocumentItem(data); } } + idTracker.signalIDProcessed(rootFObj.getId()); } model.endDocument(); diff --git a/src/java/org/apache/fop/area/AreaTreeModel.java b/src/java/org/apache/fop/area/AreaTreeModel.java index e5f6db17b..8659b4cca 100644 --- a/src/java/org/apache/fop/area/AreaTreeModel.java +++ b/src/java/org/apache/fop/area/AreaTreeModel.java @@ -42,7 +42,7 @@ public class AreaTreeModel { protected PageSequence currentPageSequence; // private List offDocumentItems = new java.util.ArrayList(); /** logger instance */ - protected static Log log = LogFactory.getLog(AreaTreeModel.class); + protected static final Log log = LogFactory.getLog(AreaTreeModel.class); /** * Create a new store pages model diff --git a/src/java/org/apache/fop/area/AreaTreeParser.java b/src/java/org/apache/fop/area/AreaTreeParser.java index e41f5e873..ae7c0a7c3 100644 --- a/src/java/org/apache/fop/area/AreaTreeParser.java +++ b/src/java/org/apache/fop/area/AreaTreeParser.java @@ -98,7 +98,7 @@ import org.apache.fop.util.XMLUtil; public class AreaTreeParser { /** Logger instance */ - protected static Log log = LogFactory.getLog(AreaTreeParser.class); + protected static final Log log = LogFactory.getLog(AreaTreeParser.class); private static SAXTransformerFactory tFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance(); @@ -228,8 +228,13 @@ public class AreaTreeParser { if (areaStack.size() > 0) { int pos = areaStack.size() - 1; Object obj = null; - while (pos >= 0 && !(clazz.isInstance(obj = areaStack.get(pos)))) { - pos--; + while ( pos >= 0 ) { + obj = areaStack.get(pos); + if ( clazz.isInstance ( obj ) ) { + break; + } else { + pos--; + } } if (pos >= 0) { return (Area)obj; diff --git a/src/java/org/apache/fop/area/BeforeFloat.java b/src/java/org/apache/fop/area/BeforeFloat.java index 490476368..b64eff556 100644 --- a/src/java/org/apache/fop/area/BeforeFloat.java +++ b/src/java/org/apache/fop/area/BeforeFloat.java @@ -25,6 +25,9 @@ package org.apache.fop.area; * See fo:region-body definition in the XSL Rec for more information. */ public class BeforeFloat extends BlockParent { + + private static final long serialVersionUID = 4101415711488333380L; + // this is an optional block area that will be rendered // as the separator only if there are float areas private Block separator = null; diff --git a/src/java/org/apache/fop/area/Block.java b/src/java/org/apache/fop/area/Block.java index 5faec9f7a..423dcfafa 100644 --- a/src/java/org/apache/fop/area/Block.java +++ b/src/java/org/apache/fop/area/Block.java @@ -32,6 +32,9 @@ package org.apache.fop.area; * It holds child block areas such as other blocks or lines. */ public class Block extends BlockParent { + + private static final long serialVersionUID = 6843727817993665788L; + /** * Normally stacked with other blocks. */ @@ -58,6 +61,7 @@ public class Block extends BlockParent { private int stacking = TB; private int positioning = STACK; + /** if true, allow BPD update */ protected transient boolean allowBPDUpdate = true; // a block with may contain the dominant styling info in @@ -126,7 +130,7 @@ public class Block extends BlockParent { */ public int getStartIndent() { Integer startIndent = (Integer)getTrait(Trait.START_INDENT); - return (startIndent != null ? startIndent.intValue() : 0); + return (startIndent != null ? startIndent : 0); } } diff --git a/src/java/org/apache/fop/area/BlockParent.java b/src/java/org/apache/fop/area/BlockParent.java index 1be0b785d..18f9056da 100644 --- a/src/java/org/apache/fop/area/BlockParent.java +++ b/src/java/org/apache/fop/area/BlockParent.java @@ -27,6 +27,8 @@ import java.util.List; */ public class BlockParent extends Area { + private static final long serialVersionUID = 7076916890348533805L; + // this position is used for absolute position // or as an indent // this has the size in the block progression dimension diff --git a/src/java/org/apache/fop/area/BlockViewport.java b/src/java/org/apache/fop/area/BlockViewport.java index 60bf1fb22..032b39f95 100644 --- a/src/java/org/apache/fop/area/BlockViewport.java +++ b/src/java/org/apache/fop/area/BlockViewport.java @@ -25,6 +25,9 @@ package org.apache.fop.area; * The block-container creates this area. */ public class BlockViewport extends Block { + + private static final long serialVersionUID = -7840580922580735157L; + // clipping for this viewport private boolean clip = false; // transform if rotated or absolute diff --git a/src/java/org/apache/fop/area/BodyRegion.java b/src/java/org/apache/fop/area/BodyRegion.java index 7b183a188..2dd8a9a7c 100644 --- a/src/java/org/apache/fop/area/BodyRegion.java +++ b/src/java/org/apache/fop/area/BodyRegion.java @@ -30,6 +30,9 @@ import org.apache.fop.fo.pagination.RegionBody; * See fo:region-body definition in the XSL Rec for more information. */ public class BodyRegion extends RegionReference { + + private static final long serialVersionUID = -1848872997724078080L; + private BeforeFloat beforeFloat; // optional private MainReference mainReference; // mandatory private Footnote footnote; // optional diff --git a/src/java/org/apache/fop/area/CTM.java b/src/java/org/apache/fop/area/CTM.java index 099ab38fa..eb6207c42 100644 --- a/src/java/org/apache/fop/area/CTM.java +++ b/src/java/org/apache/fop/area/CTM.java @@ -34,6 +34,8 @@ import org.apache.fop.fo.Constants; */ public class CTM implements Serializable { + private static final long serialVersionUID = -8743287485623778341L; + private double a, b, c, d, e, f; private static final CTM CTM_LRTB = new CTM(1, 0, 0, 1, 0, 0); diff --git a/src/java/org/apache/fop/area/DestinationData.java b/src/java/org/apache/fop/area/DestinationData.java index cb2d6eccb..f8d906b91 100644 --- a/src/java/org/apache/fop/area/DestinationData.java +++ b/src/java/org/apache/fop/area/DestinationData.java @@ -98,7 +98,7 @@ public class DestinationData extends AbstractOffDocumentItem implements Resolvab * object that corresponds to the IDRef * * {@inheritDoc} List) - * @todo check to make sure it works if multiple bookmark-items + * TODO check to make sure it works if multiple bookmark-items * have the same idref */ public void resolveIDRef(String id, List pages) { diff --git a/src/java/org/apache/fop/area/Footnote.java b/src/java/org/apache/fop/area/Footnote.java index a25f5467e..72b9f2ed0 100644 --- a/src/java/org/apache/fop/area/Footnote.java +++ b/src/java/org/apache/fop/area/Footnote.java @@ -27,6 +27,9 @@ package org.apache.fop.area; * See fo:region-body definition in the XSL Rec for more information. */ public class Footnote extends BlockParent { + + private static final long serialVersionUID = -7907428219886367161L; + private Block separator = null; // footnote has an optional separator diff --git a/src/java/org/apache/fop/area/IDTracker.java b/src/java/org/apache/fop/area/IDTracker.java index b55ed7983..829c8c58d 100644 --- a/src/java/org/apache/fop/area/IDTracker.java +++ b/src/java/org/apache/fop/area/IDTracker.java @@ -34,7 +34,7 @@ import org.apache.commons.logging.LogFactory; */ public class IDTracker { - private static final Log log = LogFactory.getLog(IDTracker.class); + private static final Log LOG = LogFactory.getLog(IDTracker.class); // HashMap of ID's whose area is located on one or more consecutive // PageViewports. Each ID has an arraylist of PageViewports that @@ -58,8 +58,8 @@ public class IDTracker { * @param pv a page viewport that contains the area with this ID */ public void associateIDWithPageViewport(String id, PageViewport pv) { - if (log.isDebugEnabled()) { - log.debug("associateIDWithPageViewport(" + id + ", " + pv + ")"); + if (LOG.isDebugEnabled()) { + LOG.debug("associateIDWithPageViewport(" + id + ", " + pv + ")"); } List pvList = (List) idLocations.get(id); if (pvList == null) { // first time ID located @@ -92,8 +92,8 @@ public class IDTracker { * @param id the id of the object being processed */ public void signalPendingID(String id) { - if (log.isDebugEnabled()) { - log.debug("signalPendingID(" + id + ")"); + if (LOG.isDebugEnabled()) { + LOG.debug("signalPendingID(" + id + ")"); } unfinishedIDs.add(id); } @@ -106,8 +106,8 @@ public class IDTracker { * @param id the id of the formatting object which was just finished */ public void signalIDProcessed(String id) { - if (log.isDebugEnabled()) { - log.debug("signalIDProcessed(" + id + ")"); + if (LOG.isDebugEnabled()) { + LOG.debug("signalIDProcessed(" + id + ")"); } alreadyResolvedIDs.add(id); diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index bbf947499..b33b5da14 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.java @@ -19,25 +19,30 @@ package org.apache.fop.area; -import org.apache.fop.area.inline.InlineArea; -import org.apache.fop.fo.Constants; - import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.fo.Constants; + /** * The line area. * This is a line area that contains inline areas. */ public class LineArea extends Area { + private static final long serialVersionUID = 7670235908329290684L; + /** * this class stores information about line width and potential adjustments * that can be used in order to re-compute adjustement and / or indents when a * page-number or a page-number-citation is resolved */ - private class LineAdjustingInfo implements Serializable { + private final class LineAdjustingInfo implements Serializable { + + private static final long serialVersionUID = -6103629976229458273L; + private int lineAlignment; private int difference; private int availableStretch; @@ -54,6 +59,15 @@ public class LineArea extends Area { variationFactor = 1.0; bAddedToAreaTree = false; } + + /** {@inheritDoc} */ + public String toString() { + return getClass().getSimpleName() + + ": diff=" + difference + + ", variation=" + variationFactor + + ", stretch=" + availableStretch + + ", shrink=" + availableShrink; + } } private LineAdjustingInfo adjustingInfo = null; @@ -194,6 +208,9 @@ public class LineArea extends Area { */ public void finalise() { if (adjustingInfo.lineAlignment == Constants.EN_JUSTIFY) { + if (log.isTraceEnabled()) { + log.trace("Applying variation factor to justified line: " + adjustingInfo); + } // justified line: apply the variation factor boolean bUnresolvedAreasPresent = false; // recursively apply variation factor to descendant areas diff --git a/src/java/org/apache/fop/area/LinkResolver.java b/src/java/org/apache/fop/area/LinkResolver.java index 51a952ddc..70bdfdf91 100644 --- a/src/java/org/apache/fop/area/LinkResolver.java +++ b/src/java/org/apache/fop/area/LinkResolver.java @@ -33,6 +33,9 @@ import org.apache.fop.area.Area; * Link resolving for resolving internal links. */ public class LinkResolver implements Resolvable, Serializable { + + private static final long serialVersionUID = -7102134165192960718L; + private boolean resolved = false; private String idRef; private Area area; diff --git a/src/java/org/apache/fop/area/MainReference.java b/src/java/org/apache/fop/area/MainReference.java index dd53113af..87e594169 100644 --- a/src/java/org/apache/fop/area/MainReference.java +++ b/src/java/org/apache/fop/area/MainReference.java @@ -31,6 +31,8 @@ import java.util.List; */ public class MainReference extends Area { + private static final long serialVersionUID = 7635126485620012448L; + private BodyRegion parent; private List spanAreas = new java.util.ArrayList(); private boolean isEmpty = true; diff --git a/src/java/org/apache/fop/area/NormalFlow.java b/src/java/org/apache/fop/area/NormalFlow.java index 5e0192389..3daf2dafd 100644 --- a/src/java/org/apache/fop/area/NormalFlow.java +++ b/src/java/org/apache/fop/area/NormalFlow.java @@ -25,6 +25,9 @@ package org.apache.fop.area; * See fo:region-body definition in the XSL Rec for more information. */ public class NormalFlow extends BlockParent { + + private static final long serialVersionUID = -3753538631016929004L; + /** * Constructor. * @param ipd of Normal flow object diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java index 4607dfb74..715bcfe85 100644 --- a/src/java/org/apache/fop/area/Page.java +++ b/src/java/org/apache/fop/area/Page.java @@ -47,6 +47,9 @@ import org.apache.fop.layoutmgr.TraitSetter; * the top level page and regions. */ public class Page extends AreaTreeObject implements Serializable, Cloneable { + + private static final long serialVersionUID = 6272157047421543866L; + // contains before, start, body, end and after regions private RegionViewport regionBefore = null; private RegionViewport regionStart = null; @@ -120,7 +123,7 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { for (Iterator regenum = spm.getRegions().values().iterator(); regenum.hasNext();) { Region r = (Region)regenum.next(); - RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM, spm); + RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM); if (r.getNameId() == Constants.FO_REGION_BODY) { rr = new BodyRegion((RegionBody) r, rvp); } else { @@ -135,7 +138,7 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { setRegionReferencePosition(rr, r, rvp.getViewArea()); rvp.setRegionReference(rr); setRegionViewport(r.getNameId(), rvp); - } + } } /** @@ -150,12 +153,10 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { * @param r the region the viewport is to be created for * @param reldims relative dimensions * @param pageCTM page coordinate transformation matrix - * @param spm the simple-page-master for this page * @return the new region viewport */ - private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM, - SimplePageMaster spm) { - Rectangle2D relRegionRect = r.getViewportRectangle(reldims, spm); + private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM) { + Rectangle2D relRegionRect = r.getViewportRectangle(reldims); Rectangle2D absRegionRect = pageCTM.transform(relRegionRect); // Get the region viewport rectangle in absolute coords by // transforming it using the page CTM diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java index 63740386e..a4fcb61a8 100644 --- a/src/java/org/apache/fop/area/PageViewport.java +++ b/src/java/org/apache/fop/area/PageViewport.java @@ -87,7 +87,7 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl /** * logging instance */ - protected static Log log = LogFactory.getLog(PageViewport.class); + protected static final Log log = LogFactory.getLog(PageViewport.class); /** * Create a page viewport. @@ -95,8 +95,10 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl * @param pageNumber the page number * @param pageStr String representation of the page number * @param blank true if this is a blank page + * @param spanAll true if the first span area spans all columns */ - public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, boolean blank) { + public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, + boolean blank, boolean spanAll) { this.simplePageMasterName = spm.getMasterName(); setExtensionAttachments(spm.getExtensionAttachments()); setForeignAttributes(spm.getForeignAttributes()); @@ -107,7 +109,18 @@ public class PageViewport extends AreaTreeObject implements Resolvable, Cloneabl this.pageNumberString = pageStr; this.viewArea = new Rectangle(0, 0, pageWidth, pageHeight); this.page = new Page(spm); - createSpan(false); + createSpan(spanAll); + } + + /** + * Create a page viewport. + * @param spm SimplePageMaster indicating the page and region dimensions + * @param pageNumber the page number + * @param pageStr String representation of the page number + * @param blank true if this is a blank page + */ + public PageViewport(SimplePageMaster spm, int pageNumber, String pageStr, boolean blank) { + this(spm, pageNumber, pageStr, blank, false); } /** diff --git a/src/java/org/apache/fop/area/RegionReference.java b/src/java/org/apache/fop/area/RegionReference.java index 200f0bff3..a727f9029 100644 --- a/src/java/org/apache/fop/area/RegionReference.java +++ b/src/java/org/apache/fop/area/RegionReference.java @@ -31,17 +31,16 @@ import org.apache.fop.fo.pagination.Region; */ public class RegionReference extends Area implements Cloneable { - /** Reference to the region FO. */ - //protected Region regionFO; + private static final long serialVersionUID = -298980963268244238L; + private int regionClass; private String regionName; private CTM ctm; - // the list of block areas from the static flow private ArrayList blocks = new ArrayList(); - /** the parent RegionViewport for this object */ + /** the parent {@link RegionViewport} for this object */ protected RegionViewport regionViewport; /** diff --git a/src/java/org/apache/fop/area/RegionViewport.java b/src/java/org/apache/fop/area/RegionViewport.java index d55ecefbb..0654c5f6b 100644 --- a/src/java/org/apache/fop/area/RegionViewport.java +++ b/src/java/org/apache/fop/area/RegionViewport.java @@ -30,6 +30,9 @@ import java.util.HashMap; * in the fo:region-body description in the XSL Recommendation. */ public class RegionViewport extends Area implements Cloneable { + + private static final long serialVersionUID = 505781815165102572L; + // this rectangle is relative to the page private RegionReference regionReference; private Rectangle2D viewArea; diff --git a/src/java/org/apache/fop/area/Span.java b/src/java/org/apache/fop/area/Span.java index 69b37f4b3..e2ef90432 100644 --- a/src/java/org/apache/fop/area/Span.java +++ b/src/java/org/apache/fop/area/Span.java @@ -30,6 +30,9 @@ import java.util.List; * See fo:region-body definition in the XSL Rec for more information. */ public class Span extends Area { + + private static final long serialVersionUID = -5551430053660081549L; + // the list of flow reference areas in this span area private List flowAreas; private int colCount; diff --git a/src/java/org/apache/fop/area/Trait.java b/src/java/org/apache/fop/area/Trait.java index 27ce39252..a8e1db186 100644 --- a/src/java/org/apache/fop/area/Trait.java +++ b/src/java/org/apache/fop/area/Trait.java @@ -34,169 +34,121 @@ import org.apache.fop.util.ColorUtil; * Area traits used for rendering. * This class represents an area trait that specifies a value for rendering. */ -public class Trait implements Serializable { +public final class Trait implements Serializable { - /** - * Id reference line, not resolved. - * not sure if this is needed. - */ + private static final long serialVersionUID = 3234280285391611437L; + + private Trait() { + } + + /** Id reference line, not resolved. (not sure if this is needed.) */ //public static final Integer ID_LINK = new Integer(0); /** * Internal link trait. * Contains the PageViewport key and the PROD_ID of the target area */ - public static final Integer INTERNAL_LINK = new Integer(1); + public static final Integer INTERNAL_LINK = 1; - /** - * External link. A URL link to an external resource. - */ - public static final Integer EXTERNAL_LINK = new Integer(2); + /** * External link. A URL link to an external resource. */ + public static final Integer EXTERNAL_LINK = 2; - /** - * The font triplet for the current font. - */ - public static final Integer FONT = new Integer(3); + /** The font triplet for the current font. */ + public static final Integer FONT = 3; - /** - * Font size for the current font. - */ - public static final Integer FONT_SIZE = new Integer(4); + /** Font size for the current font. */ + public static final Integer FONT_SIZE = 4; - /** - * The current color. - */ - public static final Integer COLOR = new Integer(7); + /** The current color. */ + public static final Integer COLOR = 7; - /** - * The ID of the FO that produced an area. - */ - public static final Integer PROD_ID = new Integer(8); + /** The ID of the FO that produced an area. */ + public static final Integer PROD_ID = 8; - /** - * Background trait for an area. - */ - public static final Integer BACKGROUND = new Integer(9); + /** Background trait for an area. */ + public static final Integer BACKGROUND = 9; - /** - * Underline trait used when rendering inline parent. - */ - public static final Integer UNDERLINE = new Integer(10); + /** Underline trait used when rendering inline parent. */ + public static final Integer UNDERLINE = 10; - /** - * Overline trait used when rendering inline parent. - */ - public static final Integer OVERLINE = new Integer(11); + /** Overline trait used when rendering inline parent. */ + public static final Integer OVERLINE = 11; - /** - * Linethrough trait used when rendering inline parent. - */ - public static final Integer LINETHROUGH = new Integer(12); + /** Linethrough trait used when rendering inline parent. */ + public static final Integer LINETHROUGH = 12; - /** - * Shadow offset. - */ + /** Shadow offset. */ //public static final Integer OFFSET = new Integer(13); - /** - * The shadow for text. - */ + /** The shadow for text. */ //public static final Integer SHADOW = new Integer(14); - /** - * The border start. - */ - public static final Integer BORDER_START = new Integer(15); + /** The border start. */ + public static final Integer BORDER_START = 15; - /** - * The border end. - */ - public static final Integer BORDER_END = new Integer(16); + /** The border end. */ + public static final Integer BORDER_END = 16; - /** - * The border before. - */ - public static final Integer BORDER_BEFORE = new Integer(17); + /** The border before. */ + public static final Integer BORDER_BEFORE = 17; - /** - * The border after. - */ - public static final Integer BORDER_AFTER = new Integer(18); + /** The border after. */ + public static final Integer BORDER_AFTER = 18; - /** - * The padding start. - */ - public static final Integer PADDING_START = new Integer(19); + /** The padding start. */ + public static final Integer PADDING_START = 19; - /** - * The padding end. - */ - public static final Integer PADDING_END = new Integer(20); + /** The padding end. */ + public static final Integer PADDING_END = 20; - /** - * The padding before. - */ - public static final Integer PADDING_BEFORE = new Integer(21); + /** The padding before. */ + public static final Integer PADDING_BEFORE = 21; - /** - * The padding after. - */ - public static final Integer PADDING_AFTER = new Integer(22); + /** The padding after. */ + public static final Integer PADDING_AFTER = 22; - /** - * The space start. - */ - public static final Integer SPACE_START = new Integer(23); + /** The space start. */ + public static final Integer SPACE_START = 23; - /** - * The space end. - */ - public static final Integer SPACE_END = new Integer(24); + /** The space end. */ + public static final Integer SPACE_END = 24; - /** - * break before - */ + /** break before */ //public static final Integer BREAK_BEFORE = new Integer(25); - /** - * break after - */ + /** break after */ //public static final Integer BREAK_AFTER = new Integer(26); - /** - * The start-indent trait. - */ - public static final Integer START_INDENT = new Integer(27); + /** The start-indent trait. */ + public static final Integer START_INDENT = 27; - /** - * The end-indent trait. - */ - public static final Integer END_INDENT = new Integer(28); + /** The end-indent trait. */ + public static final Integer END_INDENT = 28; /** The space-before trait. */ - public static final Integer SPACE_BEFORE = new Integer(29); + public static final Integer SPACE_BEFORE = 29; /** The space-after trait. */ - public static final Integer SPACE_AFTER = new Integer(30); + public static final Integer SPACE_AFTER = 30; /** The is-reference-area trait. */ - public static final Integer IS_REFERENCE_AREA = new Integer(31); + public static final Integer IS_REFERENCE_AREA = 31; /** The is-viewport-area trait. */ - public static final Integer IS_VIEWPORT_AREA = new Integer(32); + public static final Integer IS_VIEWPORT_AREA = 32; /** Blinking trait used when rendering inline parent. */ - public static final Integer BLINK = new Integer(33); + public static final Integer BLINK = 33; /** Trait for color of underline decorations when rendering inline parent. */ - public static final Integer UNDERLINE_COLOR = new Integer(34); + public static final Integer UNDERLINE_COLOR = 34; /** Trait for color of overline decorations when rendering inline parent. */ - public static final Integer OVERLINE_COLOR = new Integer(35); + public static final Integer OVERLINE_COLOR = 35; /** Trait for color of linethrough decorations when rendering inline parent. */ - public static final Integer LINETHROUGH_COLOR = new Integer(36); - + public static final Integer LINETHROUGH_COLOR = 36; + /** The ptr trait. Used for accessibility */ - public static final Integer PTR = new Integer(37); + public static final Integer PTR = 37; /** Maximum value used by trait keys */ public static final int MAX_TRAIT_KEY = 37; @@ -222,65 +174,47 @@ public class Trait implements Serializable { } private static void put(Integer key, TraitInfo info) { - TRAIT_INFO[key.intValue()] = info; + TRAIT_INFO[key] = info; } static { // Create a hashmap mapping trait code to name for external representation //put(ID_LINK, new TraitInfo("id-link", String.class)); - put(PTR, new TraitInfo("ptr", String.class)); - put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class)); - put(EXTERNAL_LINK, new TraitInfo("external-link", ExternalLink.class)); - put(FONT, new TraitInfo("font", FontTriplet.class)); - put(FONT_SIZE, new TraitInfo("font-size", Integer.class)); - put(COLOR, new TraitInfo("color", Color.class)); - put(PROD_ID, new TraitInfo("prod-id", String.class)); - put(BACKGROUND, new TraitInfo("background", Background.class)); - put(UNDERLINE, new TraitInfo("underline-score", Boolean.class)); + put(PTR, new TraitInfo("ptr", String.class)); + put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class)); + put(EXTERNAL_LINK, new TraitInfo("external-link", ExternalLink.class)); + put(FONT, new TraitInfo("font", FontTriplet.class)); + put(FONT_SIZE, new TraitInfo("font-size", Integer.class)); + put(COLOR, new TraitInfo("color", Color.class)); + put(PROD_ID, new TraitInfo("prod-id", String.class)); + put(BACKGROUND, new TraitInfo("background", Background.class)); + put(UNDERLINE, new TraitInfo("underline-score", Boolean.class)); put(UNDERLINE_COLOR, new TraitInfo("underline-score-color", Color.class)); - put(OVERLINE, new TraitInfo("overline-score", Boolean.class)); + put(OVERLINE, new TraitInfo("overline-score", Boolean.class)); put(OVERLINE_COLOR, new TraitInfo("overline-score-color", Color.class)); - put(LINETHROUGH, new TraitInfo("through-score", Boolean.class)); + put(LINETHROUGH, new TraitInfo("through-score", Boolean.class)); put(LINETHROUGH_COLOR, new TraitInfo("through-score-color", Color.class)); - put(BLINK, new TraitInfo("blink", Boolean.class)); - //put(OFFSET, new TraitInfo("offset", Integer.class)); - //put(SHADOW, new TraitInfo("shadow", Integer.class)); - put(BORDER_START, - new TraitInfo("border-start", BorderProps.class)); - put(BORDER_END, - new TraitInfo("border-end", BorderProps.class)); - put(BORDER_BEFORE, - new TraitInfo("border-before", BorderProps.class)); - put(BORDER_AFTER, - new TraitInfo("border-after", BorderProps.class)); - put(PADDING_START, - new TraitInfo("padding-start", Integer.class)); - put(PADDING_END, - new TraitInfo("padding-end", Integer.class)); - put(PADDING_BEFORE, - new TraitInfo("padding-before", Integer.class)); - put(PADDING_AFTER, - new TraitInfo("padding-after", Integer.class)); - put(SPACE_START, - new TraitInfo("space-start", Integer.class)); - put(SPACE_END, - new TraitInfo("space-end", Integer.class)); - //put(BREAK_BEFORE, - // new TraitInfo("break-before", Integer.class)); - //put(BREAK_AFTER, - // new TraitInfo("break-after", Integer.class)); - put(START_INDENT, - new TraitInfo("start-indent", Integer.class)); - put(END_INDENT, - new TraitInfo("end-indent", Integer.class)); - put(SPACE_BEFORE, - new TraitInfo("space-before", Integer.class)); - put(SPACE_AFTER, - new TraitInfo("space-after", Integer.class)); - put(IS_REFERENCE_AREA, - new TraitInfo("is-reference-area", Boolean.class)); - put(IS_VIEWPORT_AREA, - new TraitInfo("is-viewport-area", Boolean.class)); + put(BLINK, new TraitInfo("blink", Boolean.class)); + //put(OFFSET, new TraitInfo("offset", Integer.class)); + //put(SHADOW, new TraitInfo("shadow", Integer.class)); + put(BORDER_START, new TraitInfo("border-start", BorderProps.class)); + put(BORDER_END, new TraitInfo("border-end", BorderProps.class)); + put(BORDER_BEFORE, new TraitInfo("border-before", BorderProps.class)); + put(BORDER_AFTER, new TraitInfo("border-after", BorderProps.class)); + put(PADDING_START, new TraitInfo("padding-start", Integer.class)); + put(PADDING_END, new TraitInfo("padding-end", Integer.class)); + put(PADDING_BEFORE, new TraitInfo("padding-before", Integer.class)); + put(PADDING_AFTER, new TraitInfo("padding-after", Integer.class)); + put(SPACE_START, new TraitInfo("space-start", Integer.class)); + put(SPACE_END, new TraitInfo("space-end", Integer.class)); + //put(BREAK_BEFORE, new TraitInfo("break-before", Integer.class)); + //put(BREAK_AFTER, new TraitInfo("break-after", Integer.class)); + put(START_INDENT, new TraitInfo("start-indent", Integer.class)); + put(END_INDENT, new TraitInfo("end-indent", Integer.class)); + put(SPACE_BEFORE, new TraitInfo("space-before", Integer.class)); + put(SPACE_AFTER, new TraitInfo("space-after", Integer.class)); + put(IS_REFERENCE_AREA, new TraitInfo("is-reference-area", Boolean.class)); + put(IS_VIEWPORT_AREA, new TraitInfo("is-viewport-area", Boolean.class)); } @@ -291,7 +225,7 @@ public class Trait implements Serializable { * @return the trait name */ public static String getTraitName(Object traitCode) { - return TRAIT_INFO[((Integer)traitCode).intValue()].getName(); + return TRAIT_INFO[(Integer)traitCode].getName(); } /** @@ -301,7 +235,7 @@ public class Trait implements Serializable { * @return the class type for the trait */ public static Class getTraitClass(Object traitCode) { - return TRAIT_INFO[((Integer)traitCode).intValue()].getClazz(); + return TRAIT_INFO[(Integer)traitCode].getClazz(); } /** @@ -310,6 +244,8 @@ public class Trait implements Serializable { */ public static class InternalLink implements Serializable { + private static final long serialVersionUID = -8993505060996723039L; + /** The unique key of the PageViewport. */ private String pvKey; @@ -444,6 +380,8 @@ public class Trait implements Serializable { */ public static class ExternalLink implements Serializable { + private static final long serialVersionUID = -3720707599232620946L; + private String destination; private boolean newWindow; @@ -473,7 +411,7 @@ public class Trait implements Serializable { if (v.startsWith("dest=")) { dest = v.substring(5); } else if (v.startsWith("newWindow=")) { - newWindow = Boolean.valueOf(v.substring(10)).booleanValue(); + newWindow = Boolean.valueOf(v.substring(10)); } else { throw new IllegalArgumentException( "Malformed trait value for Trait.ExternalLink: " + traitValue); @@ -517,6 +455,8 @@ public class Trait implements Serializable { */ public static class Background implements Serializable { + private static final long serialVersionUID = 8452078676273242870L; + /** The background color if any. */ private Color color = null; diff --git a/src/java/org/apache/fop/area/inline/AbstractTextArea.java b/src/java/org/apache/fop/area/inline/AbstractTextArea.java index e73a8355c..08997a817 100644 --- a/src/java/org/apache/fop/area/inline/AbstractTextArea.java +++ b/src/java/org/apache/fop/area/inline/AbstractTextArea.java @@ -24,6 +24,8 @@ package org.apache.fop.area.inline; */ public abstract class AbstractTextArea extends InlineParent { + private static final long serialVersionUID = -1246306443569094371L; + /** * this class stores information about spaces and potential adjustments * that can be used in order to re-compute adjustments when a @@ -31,6 +33,8 @@ public abstract class AbstractTextArea extends InlineParent { */ protected class TextAdjustingInfo extends InlineAdjustingInfo { + private static final long serialVersionUID = -2412095162983479947L; + /** difference between the optimal width of a space * and the default width of a space according to the font * (this is equivalent to the property word-spacing.optimum) @@ -140,12 +144,14 @@ public abstract class AbstractTextArea extends InlineParent { if (textWordSpaceAdjust < 0) { // from a negative adjustment to a positive one balancingFactor - = ((double) textAdjustingInfo.availableStretch / textAdjustingInfo.availableShrink) + = ((double) textAdjustingInfo.availableStretch + / textAdjustingInfo.availableShrink) * ((double) lineShrink / lineStretch); } else { // from a positive adjustment to a negative one balancingFactor - = ((double) textAdjustingInfo.availableShrink / textAdjustingInfo.availableStretch) + = ((double) textAdjustingInfo.availableShrink + / textAdjustingInfo.availableStretch) * ((double) lineStretch / lineShrink); } } diff --git a/src/java/org/apache/fop/area/inline/Anchor.java b/src/java/org/apache/fop/area/inline/Anchor.java index ec6dbbcfb..8ad663111 100644 --- a/src/java/org/apache/fop/area/inline/Anchor.java +++ b/src/java/org/apache/fop/area/inline/Anchor.java @@ -25,6 +25,8 @@ package org.apache.fop.area.inline; */ public class Anchor extends InlineArea { + private static final long serialVersionUID = 5227798744787823499L; + // has a keep with adjacent area // has reference to associated footnote or float out-of-line area diff --git a/src/java/org/apache/fop/area/inline/Container.java b/src/java/org/apache/fop/area/inline/Container.java index 98c0aaef0..f6dbf3a15 100644 --- a/src/java/org/apache/fop/area/inline/Container.java +++ b/src/java/org/apache/fop/area/inline/Container.java @@ -32,6 +32,9 @@ import java.util.ArrayList; * This allows an inline area to have blocks as children. */ public class Container extends Area { + + private static final long serialVersionUID = 5256423939348189260L; + /** * The list of block areas stacked inside this container */ diff --git a/src/java/org/apache/fop/area/inline/FilledArea.java b/src/java/org/apache/fop/area/inline/FilledArea.java index 7df62e79b..06d0d3aa3 100644 --- a/src/java/org/apache/fop/area/inline/FilledArea.java +++ b/src/java/org/apache/fop/area/inline/FilledArea.java @@ -34,6 +34,9 @@ import java.util.Iterator; * this as a normal inline parent. */ public class FilledArea extends InlineParent { + + private static final long serialVersionUID = 8586584705587017474L; + private int unitWidth; /** diff --git a/src/java/org/apache/fop/area/inline/Image.java b/src/java/org/apache/fop/area/inline/Image.java index 7d802db49..e6e355254 100644 --- a/src/java/org/apache/fop/area/inline/Image.java +++ b/src/java/org/apache/fop/area/inline/Image.java @@ -27,8 +27,11 @@ import org.apache.fop.area.Area; * The url of the image is used as a key to reference the image cache. */ public class Image extends Area { + + private static final long serialVersionUID = 4800834714349695386L; + private String url; - + /** * Create a new image with the given url. * diff --git a/src/java/org/apache/fop/area/inline/InlineArea.java b/src/java/org/apache/fop/area/inline/InlineArea.java index 5106fd5bc..3450b99be 100644 --- a/src/java/org/apache/fop/area/inline/InlineArea.java +++ b/src/java/org/apache/fop/area/inline/InlineArea.java @@ -32,12 +32,17 @@ import org.apache.fop.area.Trait; */ public class InlineArea extends Area { + private static final long serialVersionUID = -8940066479810170980L; + /** * this class stores information about potential adjustments * that can be used in order to re-compute adjustments when a * page-number or a page-number-citation is resolved */ protected class InlineAdjustingInfo implements Serializable { + + private static final long serialVersionUID = -5601387735459712149L; + /** stretch of the inline area */ protected int availableStretch; /** shrink of the inline area */ @@ -218,7 +223,16 @@ public class InlineArea extends Area { return false; } + /** + * Apply IPD variation. + * @param ipdVariation the variation + */ public void handleIPDVariation(int ipdVariation) { + if (log.isTraceEnabled()) { + log.trace("Handling IPD variation for " + getClass().getSimpleName() + + ": increase by " + ipdVariation + " mpt."); + } + increaseIPD(ipdVariation); notifyIPDVariation(ipdVariation); } diff --git a/src/java/org/apache/fop/area/inline/InlineBlockParent.java b/src/java/org/apache/fop/area/inline/InlineBlockParent.java index e580b1667..fe024ac0f 100644 --- a/src/java/org/apache/fop/area/inline/InlineBlockParent.java +++ b/src/java/org/apache/fop/area/inline/InlineBlockParent.java @@ -29,6 +29,9 @@ import org.apache.fop.area.Block; */ public class InlineBlockParent extends InlineArea { + + private static final long serialVersionUID = -3661746143321407377L; + /** * The list of inline areas added to this inline parent. */ diff --git a/src/java/org/apache/fop/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java index cbc5b578c..db8f2f056 100644 --- a/src/java/org/apache/fop/area/inline/InlineParent.java +++ b/src/java/org/apache/fop/area/inline/InlineParent.java @@ -19,20 +19,22 @@ package org.apache.fop.area.inline; -import org.apache.fop.area.Area; - import java.util.List; -import java.util.ArrayList; + +import org.apache.fop.area.Area; /** * Inline parent area. * This is an inline area that can have other inlines as children. */ public class InlineParent extends InlineArea { + + private static final long serialVersionUID = -3047168298770354813L; + /** * The list of inline areas added to this inline parent. */ - protected List inlines = new ArrayList(); + protected List<InlineArea> inlines = new java.util.ArrayList<InlineArea>(); /** Controls whether the IPD is automatically adjusted based on the area's children. */ protected transient boolean autoSize; @@ -48,13 +50,14 @@ public class InlineParent extends InlineArea { * * @param childArea the child area to add */ + @Override public void addChildArea(Area childArea) { if (inlines.size() == 0) { autoSize = (getIPD() == 0); } if (childArea instanceof InlineArea) { InlineArea inlineChildArea = (InlineArea) childArea; - inlines.add(childArea); + inlines.add(inlineChildArea); // set the parent area for the child area inlineChildArea.setParentArea(this); if (autoSize) { @@ -68,7 +71,7 @@ public class InlineParent extends InlineArea { * * @return the list of child areas */ - public List getChildAreas() { + public List<InlineArea> getChildAreas() { return inlines; } @@ -79,15 +82,21 @@ public class InlineParent extends InlineArea { * @param lineShrink the total shrink of the line * @return true if there is an UnresolvedArea descendant */ + @Override public boolean applyVariationFactor(double variationFactor, int lineStretch, int lineShrink) { - boolean bUnresolvedAreasPresent = false; + boolean hasUnresolvedAreas = false; + int cumulativeIPD = 0; // recursively apply variation factor to descendant areas for (int i = 0, len = inlines.size(); i < len; i++) { - bUnresolvedAreasPresent |= ((InlineArea)inlines.get(i)) - .applyVariationFactor(variationFactor, lineStretch, lineShrink); + InlineArea inline = inlines.get(i); + hasUnresolvedAreas |= inline.applyVariationFactor( + variationFactor, lineStretch, lineShrink); + cumulativeIPD += inline.getIPD(); //Update this area's IPD based on changes to children } - return bUnresolvedAreasPresent; + setIPD(cumulativeIPD); + + return hasUnresolvedAreas; } } diff --git a/src/java/org/apache/fop/area/inline/Leader.java b/src/java/org/apache/fop/area/inline/Leader.java index cd7b2e9f3..ff8ba12b0 100644 --- a/src/java/org/apache/fop/area/inline/Leader.java +++ b/src/java/org/apache/fop/area/inline/Leader.java @@ -32,6 +32,9 @@ public class Leader extends InlineArea { // if space replaced with a space // otherwise this is a holder for a line + + private static final long serialVersionUID = -8011373048313956301L; + private int ruleStyle = Constants.EN_SOLID; private int ruleThickness = 1000; diff --git a/src/java/org/apache/fop/area/inline/Space.java b/src/java/org/apache/fop/area/inline/Space.java index 9a24de0d3..bf683bb22 100644 --- a/src/java/org/apache/fop/area/inline/Space.java +++ b/src/java/org/apache/fop/area/inline/Space.java @@ -25,4 +25,6 @@ package org.apache.fop.area.inline; */ public class Space extends InlineArea { + private static final long serialVersionUID = -8748265505356839796L; + } diff --git a/src/java/org/apache/fop/area/inline/SpaceArea.java b/src/java/org/apache/fop/area/inline/SpaceArea.java index 287f09dfc..9c698b305 100644 --- a/src/java/org/apache/fop/area/inline/SpaceArea.java +++ b/src/java/org/apache/fop/area/inline/SpaceArea.java @@ -16,6 +16,7 @@ */ /* $Id$ */ + package org.apache.fop.area.inline; /** @@ -23,10 +24,12 @@ package org.apache.fop.area.inline; */ public class SpaceArea extends InlineArea { + private static final long serialVersionUID = 2218803009825411416L; + /** * The space for this space area */ - protected String space; + protected char space; /** * Is this space adjustable? @@ -40,7 +43,7 @@ public class SpaceArea extends InlineArea { * @param a is this space adjustable? */ public SpaceArea(char s, int o, boolean a) { - space = new String() + s; + space = s; offset = o; isAdjustable = a; } @@ -49,7 +52,7 @@ public class SpaceArea extends InlineArea { * @return Returns the space. */ public String getSpace() { - return new String(space); + return String.valueOf(space); } /** @return true if the space is adjustable (WRT word-space processing) */ diff --git a/src/java/org/apache/fop/area/inline/TextArea.java b/src/java/org/apache/fop/area/inline/TextArea.java index f736b894c..8fb9455ad 100644 --- a/src/java/org/apache/fop/area/inline/TextArea.java +++ b/src/java/org/apache/fop/area/inline/TextArea.java @@ -24,6 +24,8 @@ package org.apache.fop.area.inline; */ public class TextArea extends AbstractTextArea { + private static final long serialVersionUID = 7315900267242540809L; + /** * Create a text inline area */ diff --git a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java index 43a995670..3457ad698 100644 --- a/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java +++ b/src/java/org/apache/fop/area/inline/UnresolvedPageNumber.java @@ -32,6 +32,9 @@ import java.util.List; */ public class UnresolvedPageNumber extends TextArea implements Resolvable { + + private static final long serialVersionUID = -1758090835371647980L; + private boolean resolved = false; private String pageIDRef; private String text; diff --git a/src/java/org/apache/fop/area/inline/Viewport.java b/src/java/org/apache/fop/area/inline/Viewport.java index 489f5afda..206a965e2 100644 --- a/src/java/org/apache/fop/area/inline/Viewport.java +++ b/src/java/org/apache/fop/area/inline/Viewport.java @@ -32,6 +32,9 @@ import java.util.HashMap; * holds the area and positions it. */ public class Viewport extends InlineArea { + + private static final long serialVersionUID = 813338534627918689L; + // contents could be container, foreign object or image private Area content; // clipping for the viewport diff --git a/src/java/org/apache/fop/area/inline/WordArea.java b/src/java/org/apache/fop/area/inline/WordArea.java index 70d10ef9b..8bb6888ce 100644 --- a/src/java/org/apache/fop/area/inline/WordArea.java +++ b/src/java/org/apache/fop/area/inline/WordArea.java @@ -16,6 +16,7 @@ */ /* $Id$ */ + package org.apache.fop.area.inline; /** @@ -23,6 +24,8 @@ package org.apache.fop.area.inline; */ public class WordArea extends InlineArea { + private static final long serialVersionUID = 6444644662158970942L; + /** The text for this word area */ protected String word; |