From: Keiron Liddle Date: Thu, 14 Nov 2002 11:13:33 +0000 (+0000) Subject: a bit of a cleanup of collections and comments X-Git-Tag: Alt-Design-integration-base~330 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9409dc3a4d491ef98bc616d5d8d7a952b963a901;p=xmlgraphics-fop.git a bit of a cleanup of collections and comments git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@195535 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/area/Area.java b/src/org/apache/fop/area/Area.java index 9c312f988..06b907e7d 100644 --- a/src/org/apache/fop/area/Area.java +++ b/src/org/apache/fop/area/Area.java @@ -9,6 +9,7 @@ package org.apache.fop.area; import java.io.Serializable; +import java.util.Map; import java.util.HashMap; // If the area appears more than once in the output @@ -187,7 +188,7 @@ public class Area implements Serializable { * * @return the map of traits */ - public HashMap getTraits() { + public Map getTraits() { return this.props; } diff --git a/src/org/apache/fop/area/AreaTree.java b/src/org/apache/fop/area/AreaTree.java index 8d03f6a0f..58c2a8b33 100644 --- a/src/org/apache/fop/area/AreaTree.java +++ b/src/org/apache/fop/area/AreaTree.java @@ -11,7 +11,9 @@ import org.apache.fop.render.Renderer; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.HashMap; +import java.util.Set; import java.util.HashSet; import java.util.Iterator; @@ -38,10 +40,10 @@ public class AreaTree { private AreaTreeModel model; // hashmap of arraylists containing pages with id area - private HashMap idLocations = new HashMap(); + private Map idLocations = new HashMap(); // list of id's yet to be resolved and arraylists of pages - private HashMap resolve = new HashMap(); - private ArrayList treeExtensions = new ArrayList(); + private Map resolve = new HashMap(); + private List treeExtensions = new ArrayList(); /** * Create a render pages area tree model. @@ -100,7 +102,7 @@ public class AreaTree { } list.add(pv); - HashSet todo = (HashSet)resolve.get(id); + Set todo = (Set)resolve.get(id); if (todo != null) { for (Iterator iter = todo.iterator(); iter.hasNext();) { Resolveable res = (Resolveable)iter.next(); @@ -125,7 +127,7 @@ public class AreaTree { * @param res the Resolveable object to resolve */ public void addUnresolvedID(String id, Resolveable res) { - HashSet todo = (HashSet)resolve.get(id); + Set todo = (Set)resolve.get(id); if (todo == null) { todo = new HashSet(); resolve.put(id, todo); @@ -146,9 +148,9 @@ public class AreaTree { String[] ids = res.getIDs(); for (int count = 0; count < ids.length; count++) { if (idLocations.containsKey(ids[count])) { - res.resolve(ids[count], (ArrayList)idLocations.get(ids[count])); + res.resolve(ids[count], (List)idLocations.get(ids[count])); } else { - HashSet todo = (HashSet)resolve.get(ids[count]); + Set todo = (Set)resolve.get(ids[count]); if (todo == null) { todo = new HashSet(); resolve.put(ids[count], todo); @@ -180,7 +182,7 @@ public class AreaTree { public void endDocument() { for (Iterator iter = resolve.keySet().iterator(); iter.hasNext();) { String id = (String)iter.next(); - HashSet list = (HashSet)resolve.get(id); + Set list = (Set)resolve.get(id); for (Iterator resIter = list.iterator(); resIter.hasNext();) { Resolveable res = (Resolveable)resIter.next(); if (!res.isResolved()) { @@ -228,10 +230,10 @@ public class AreaTree { * The pages are stored and can be retrieved in any order. */ public static class StorePagesModel extends AreaTreeModel { - private ArrayList pageSequence = null; - private ArrayList titles = new ArrayList(); - private ArrayList currSequence; - private ArrayList extensions = new ArrayList(); + private List pageSequence = null; + private List titles = new ArrayList(); + private List currSequence; + private List extensions = new ArrayList(); /** * Create a new store pages model @@ -284,7 +286,7 @@ public class AreaTree { * @return returns the number of pages in a page sequence */ public int getPageCount(int seq) { - ArrayList sequence = (ArrayList) pageSequence.get(seq); + List sequence = (List) pageSequence.get(seq); return sequence.size(); } @@ -295,7 +297,7 @@ public class AreaTree { * @return the PageViewport for the particular page */ public PageViewport getPage(int seq, int count) { - ArrayList sequence = (ArrayList) pageSequence.get(seq); + List sequence = (List) pageSequence.get(seq); return (PageViewport) sequence.get(count); } @@ -363,9 +365,9 @@ public class AreaTree { /** * Pages that have been prepared but not rendered yet. */ - protected ArrayList prepared = new ArrayList(); - private ArrayList pendingExt = new ArrayList(); - private ArrayList endDocExt = new ArrayList(); + protected List prepared = new ArrayList(); + private List pendingExt = new ArrayList(); + private List endDocExt = new ArrayList(); /** * Create a new render pages model with the given renderer. @@ -488,7 +490,7 @@ public class AreaTree { } } - private void renderExtensions(ArrayList list) { + private void renderExtensions(List list) { for (int count = 0; count < list.size(); count++) { TreeExt ext = (TreeExt)list.get(count); renderer.renderExtension(ext); diff --git a/src/org/apache/fop/area/BlockParent.java b/src/org/apache/fop/area/BlockParent.java index 5352efffc..ca2bd9a47 100644 --- a/src/org/apache/fop/area/BlockParent.java +++ b/src/org/apache/fop/area/BlockParent.java @@ -44,7 +44,7 @@ public class BlockParent extends Area { /** * The children of this block parent area. */ - protected ArrayList children = null; + protected List children = null; // orientation if reference area private int orientation = ORIENT_0; diff --git a/src/org/apache/fop/area/CachedRenderPagesModel.java b/src/org/apache/fop/area/CachedRenderPagesModel.java index 43c35f91b..c5afd0f03 100644 --- a/src/org/apache/fop/area/CachedRenderPagesModel.java +++ b/src/org/apache/fop/area/CachedRenderPagesModel.java @@ -9,6 +9,7 @@ package org.apache.fop.area; import org.apache.fop.render.Renderer; +import java.util.Map; import java.util.HashMap; import java.util.Iterator; @@ -27,7 +28,7 @@ import java.io.BufferedInputStream; * the contents a reloaded. */ public class CachedRenderPagesModel extends AreaTree.RenderPagesModel { - private HashMap pageMap = new HashMap(); + private Map pageMap = new HashMap(); /** * Create a new render pages model with the given renderer. diff --git a/src/org/apache/fop/area/LineArea.java b/src/org/apache/fop/area/LineArea.java index e3e99a2f5..0ba14320b 100644 --- a/src/org/apache/fop/area/LineArea.java +++ b/src/org/apache/fop/area/LineArea.java @@ -30,7 +30,7 @@ public class LineArea extends Area { // this class can contain the dominant char styling info // this means that many renderers can optimise a bit - private ArrayList inlineAreas = new ArrayList(); + private List inlineAreas = new ArrayList(); /** * Set the height of this line area. diff --git a/src/org/apache/fop/area/Page.java b/src/org/apache/fop/area/Page.java index cae3873b8..0362a4ff6 100644 --- a/src/org/apache/fop/area/Page.java +++ b/src/org/apache/fop/area/Page.java @@ -8,6 +8,7 @@ package org.apache.fop.area; import java.io.Serializable; +import java.util.Map; import java.util.HashMap; /** @@ -31,11 +32,11 @@ public class Page implements Serializable, Cloneable { // hashmap of markers for this page // start and end are added by the fo that contains the markers - private HashMap markerStart = null; - private HashMap markerEnd = null; + private Map markerStart = null; + private Map markerEnd = null; // temporary map of unresolved objects used when serializing the page - private HashMap unresolved = null; + private Map unresolved = null; /** * Set the region on this page. @@ -110,7 +111,7 @@ public class Page implements Serializable, Cloneable { * * @param unres the map of unresolved objects */ - public void setUnresolvedReferences(HashMap unres) { + public void setUnresolvedReferences(Map unres) { unresolved = unres; } @@ -121,7 +122,7 @@ public class Page implements Serializable, Cloneable { * * @return the de-serialized map of unresolved objects */ - public HashMap getUnresolvedReferences() { + public Map getUnresolvedReferences() { return unresolved; } } diff --git a/src/org/apache/fop/area/PageViewport.java b/src/org/apache/fop/area/PageViewport.java index aaf495d14..0ce0239b9 100644 --- a/src/org/apache/fop/area/PageViewport.java +++ b/src/org/apache/fop/area/PageViewport.java @@ -12,6 +12,7 @@ import java.io.ObjectOutputStream; import java.io.ObjectInputStream; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.HashMap; import java.util.Iterator; @@ -30,14 +31,14 @@ public class PageViewport implements Resolveable, Cloneable { private String pageNumber = null; // list of id references and the rectangle on the page - private HashMap idReferences = null; + private Map idReferences = null; // this keeps a list of currently unresolved areas or extensions // once the thing is resolved it is removed // when this is empty the page can be rendered - private HashMap unresolved = null; + private Map unresolved = null; - private HashMap pendingResolved = null; + private Map pendingResolved = null; /** * Create a page viewport. diff --git a/src/org/apache/fop/area/RegionReference.java b/src/org/apache/fop/area/RegionReference.java index 1af0386c2..f94d12495 100644 --- a/src/org/apache/fop/area/RegionReference.java +++ b/src/org/apache/fop/area/RegionReference.java @@ -44,7 +44,7 @@ public class RegionReference extends Area implements Cloneable { private int regionClass = BEFORE; private CTM ctm; // the list of block areas from the static flow - private ArrayList blocks = new ArrayList(); + private List blocks = new ArrayList(); /** * Create a new region reference area. diff --git a/src/org/apache/fop/area/RegionViewport.java b/src/org/apache/fop/area/RegionViewport.java index f368d8882..cbcbe50fe 100644 --- a/src/org/apache/fop/area/RegionViewport.java +++ b/src/org/apache/fop/area/RegionViewport.java @@ -101,3 +101,4 @@ public class RegionViewport extends Area implements Cloneable { return rv; } } + diff --git a/src/org/apache/fop/area/Span.java b/src/org/apache/fop/area/Span.java index 0f563d481..01a7bb1ff 100644 --- a/src/org/apache/fop/area/Span.java +++ b/src/org/apache/fop/area/Span.java @@ -7,12 +7,13 @@ package org.apache.fop.area; +import java.util.List; import java.util.ArrayList; // this is a reference area block area with 0 border and padding public class Span extends Area { // the list of flow reference areas in this span area - private ArrayList flowAreas; + private List flowAreas; private int height; public Span(int cols) { diff --git a/src/org/apache/fop/area/Title.java b/src/org/apache/fop/area/Title.java index 7dba2f535..f0729058c 100644 --- a/src/org/apache/fop/area/Title.java +++ b/src/org/apache/fop/area/Title.java @@ -14,3 +14,4 @@ package org.apache.fop.area; */ public class Title extends LineArea { } + diff --git a/src/org/apache/fop/area/Trait.java b/src/org/apache/fop/area/Trait.java index a8943e577..62b771a2b 100644 --- a/src/org/apache/fop/area/Trait.java +++ b/src/org/apache/fop/area/Trait.java @@ -80,7 +80,7 @@ public class Trait implements Serializable { public static final Integer LINETHROUGH = new Integer(12); /** - * + * Shadow offset. */ public static final Integer OFFSET = new Integer(13); @@ -93,15 +93,43 @@ public class Trait implements Serializable { * The border start. */ public static final Integer BORDER_START = new Integer(15); + + /** + * The border end. + */ public static final Integer BORDER_END = new Integer(16); + + /** + * The border before. + */ public static final Integer BORDER_BEFORE = new Integer(17); + + /** + * The border after. + */ public static final Integer BORDER_AFTER = new Integer(18); + + /** + * The padding start. + */ public static final Integer PADDING_START = new Integer(19); + + /** + * The padding end. + */ public static final Integer PADDING_END = new Integer(20); + + /** + * The padding before. + */ public static final Integer PADDING_BEFORE = new Integer(21); + + /** + * The padding after. + */ public static final Integer PADDING_AFTER = new Integer(22); - static HashMap shmTraitInfo; + private static final Map shmTraitInfo = new HashMap(); private static class TraitInfo { String sName; @@ -114,7 +142,6 @@ public class Trait implements Serializable { static { // Create a hashmap mapping trait code to name for external representation - shmTraitInfo = new HashMap(); shmTraitInfo.put(ID_LINK, new TraitInfo("id-link", String.class)); shmTraitInfo.put(INTERNAL_LINK, new TraitInfo("internal-link", String.class)); @@ -154,6 +181,12 @@ public class Trait implements Serializable { new TraitInfo("padding-after", Integer.class)); } + /** + * Get the trait name for a trait code. + * + * @param traitCode the trait code to get the name for + * @return the trait name + */ public static String getTraitName(Object traitCode) { Object obj = shmTraitInfo.get(traitCode); if (obj != null) { @@ -163,6 +196,12 @@ public class Trait implements Serializable { } } + /** + * Get the trait code for a trait name. + * + * @param sTraitName the name of the trait to find + * @return the trait code object + */ public static Object getTraitCode(String sTraitName) { Iterator iter = shmTraitInfo.entrySet().iterator(); while (iter.hasNext()) { @@ -175,28 +214,60 @@ public class Trait implements Serializable { return null; } + /** + * Get the data storage class for the trait. + * + * @param oTraitCode the trait code to lookup + * @return the class type for the trait + */ private static Class getTraitClass(Object oTraitCode) { TraitInfo ti = (TraitInfo) shmTraitInfo.get(oTraitCode); return (ti != null ? ti.sClass : null); } + /** + * The type of trait for an area. + */ public Object propType; + + /** + * The data value of the trait. + */ public Object data; + /** + * Create a new emty trait. + */ public Trait() { this.propType = null; this.data = null; } + /** + * Create a trait with the value and type. + * + * @param propType the type of trait + * @param data the data value + */ public Trait(Object propType, Object data) { this.propType = propType; this.data = data; } + /** + * Return the string for debugging. + * + * @param the string from the data value + */ public String toString() { return data.toString(); } + /** + * Make a trait value. + * + * @param oCode + */ public static Object makeTraitValue(Object oCode, String sTraitValue) { // Get the code from the name // See what type of object it is @@ -229,11 +300,34 @@ public class Trait implements Serializable { return null; } + /** + * Background trait structure. + * Used for storing back trait information which are related. + */ public static class Background implements Serializable { + /** + * The background color if any. + */ public ColorType color = null; + + /** + * The background image url if any. + */ public String url = null; + + /** + * Background repeat enum for images. + */ public int repeat; + + /** + * Background horizontal offset for images. + */ public int horiz; + + /** + * Background vertical offset for images. + */ public int vertical; } diff --git a/src/org/apache/fop/area/inline/Anchor.java b/src/org/apache/fop/area/inline/Anchor.java index ea3026b2a..114608c29 100644 --- a/src/org/apache/fop/area/inline/Anchor.java +++ b/src/org/apache/fop/area/inline/Anchor.java @@ -17,3 +17,4 @@ public class Anchor extends InlineArea { // has reference to associated footnote or float out-of-line area } + diff --git a/src/org/apache/fop/area/inline/Character.java b/src/org/apache/fop/area/inline/Character.java index a7e5f2aa3..b2eebe3f9 100644 --- a/src/org/apache/fop/area/inline/Character.java +++ b/src/org/apache/fop/area/inline/Character.java @@ -11,7 +11,7 @@ import org.apache.fop.render.Renderer; /** * Single character inline area. - * This inline area holds a single characater. + * This inline area holds a single character. */ public class Character extends InlineArea { private char character; @@ -25,8 +25,6 @@ public class Character extends InlineArea { character = ch; } - // character info: font, char spacing, colour, baseline - /** * Render this inline area. * @@ -44,5 +42,5 @@ public class Character extends InlineArea { public char getChar() { return character; } - } + diff --git a/src/org/apache/fop/area/inline/Container.java b/src/org/apache/fop/area/inline/Container.java index daf347fff..40ceb188c 100644 --- a/src/org/apache/fop/area/inline/Container.java +++ b/src/org/apache/fop/area/inline/Container.java @@ -14,28 +14,54 @@ import org.apache.fop.render.Renderer; import java.util.List; import java.util.ArrayList; -// this is an inline area that can have blocks as children +/** + * Container area for inline container. + * This area should be placed in a viewport as a result of the + * inline container formatting object. + * This allows an inline area to have blocks as children. + */ public class Container extends Area { - ArrayList blocks = new ArrayList(); - int width; + /** + * The list of block areas stacked inside this container + */ + protected List blocks = new ArrayList(); - public Container() { - } + /** + * The width of this container + */ + protected int width; - public void render(Renderer renderer) { - renderer.renderContainer(this); + /** + * Create a new container area + */ + public Container() { } + /** + * Add the block to this area. + * + * @param block the block area to add + */ public void addBlock(Block block) { blocks.add(block); } + /** + * Get the block areas stacked inside this container area. + * + * @return the list of block areas + */ public List getBlocks() { return blocks; } + /** + * Get the width of this container area. + * + * @return the width + */ public int getWidth() { return width; } - } + diff --git a/src/org/apache/fop/area/inline/FilledArea.java b/src/org/apache/fop/area/inline/FilledArea.java index 38ce5d9b4..9be048f88 100644 --- a/src/org/apache/fop/area/inline/FilledArea.java +++ b/src/org/apache/fop/area/inline/FilledArea.java @@ -47,7 +47,7 @@ public class FilledArea extends InlineParent { */ public List getChildAreas() { int units = (int)(getWidth() / unitWidth); - ArrayList newList = new ArrayList(); + List newList = new ArrayList(); for (int count = 0; count < units; count++) { newList.addAll(inlines); } diff --git a/src/org/apache/fop/area/inline/Image.java b/src/org/apache/fop/area/inline/Image.java index 7705227d6..fdfd926a4 100644 --- a/src/org/apache/fop/area/inline/Image.java +++ b/src/org/apache/fop/area/inline/Image.java @@ -35,5 +35,5 @@ public class Image extends Area { public String getURL() { return url; } - } + diff --git a/src/org/apache/fop/area/inline/InlineArea.java b/src/org/apache/fop/area/inline/InlineArea.java index 701f98c09..b0452a8cf 100644 --- a/src/org/apache/fop/area/inline/InlineArea.java +++ b/src/org/apache/fop/area/inline/InlineArea.java @@ -12,8 +12,6 @@ import org.apache.fop.area.Trait; import org.apache.fop.render.Renderer; import org.apache.fop.traits.BorderProps; -import java.util.ArrayList; - /** * Inline Area * This area is for all inline areas that can be placed @@ -29,9 +27,6 @@ public class InlineArea extends Area { // offset position from top of parent area int verticalPosition = 0; - // store properties in array list, need better solution - private ArrayList props = null; - /** * Render this inline area. * Inline areas that extend this class are expected @@ -43,10 +38,22 @@ public class InlineArea extends Area { public void render(Renderer renderer) { } + /** + * Set the width of this inline area. + * Currently sets the ipd. + * + * @param w the width + */ public void setWidth(int w) { contentIPD = w; } + /** + * Get the width of this inline area. + * Currently gets the ipd. + * + * @return the width + */ public int getWidth() { return contentIPD; } @@ -90,10 +97,26 @@ public class InlineArea extends Area { return iBP; } + /** + * Set the offset of this inline area. + * This is used to set the offset of the inline area + * which is normally relative to the top of the line + * or the baseline. + * + * @param v the offset + */ public void setOffset(int v) { verticalPosition = v; } + /** + * Get the offset of this inline area. + * This returns the offset of the inline area + * which is normally relative to the top of the line + * or the baseline. + * + * @return the offset + */ public int getOffset() { return verticalPosition; } diff --git a/src/org/apache/fop/area/inline/InlineParent.java b/src/org/apache/fop/area/inline/InlineParent.java index 3f5b9d69e..d05f98b46 100644 --- a/src/org/apache/fop/area/inline/InlineParent.java +++ b/src/org/apache/fop/area/inline/InlineParent.java @@ -22,7 +22,7 @@ public class InlineParent extends InlineArea { /** * The list of inline areas added to this inline parent. */ - protected ArrayList inlines = new ArrayList(); + protected List inlines = new ArrayList(); /** * An inline parent is a reference area somay have clipping diff --git a/src/org/apache/fop/area/inline/Leader.java b/src/org/apache/fop/area/inline/Leader.java index 587c02c25..0a2e0ac77 100644 --- a/src/org/apache/fop/area/inline/Leader.java +++ b/src/org/apache/fop/area/inline/Leader.java @@ -16,8 +16,6 @@ import org.apache.fop.fo.properties.RuleStyle; */ public class Leader extends InlineArea { - // pattern, length min opt max - // in the case of use content or dots this is replaced // with the set of inline areas // if space replaced with a space @@ -77,3 +75,4 @@ public class Leader extends InlineArea { renderer.renderLeader(this); } } + diff --git a/src/org/apache/fop/area/inline/Viewport.java b/src/org/apache/fop/area/inline/Viewport.java index c3753e7fb..779ee381c 100644 --- a/src/org/apache/fop/area/inline/Viewport.java +++ b/src/org/apache/fop/area/inline/Viewport.java @@ -101,7 +101,7 @@ public class Viewport extends InlineArea { out.writeFloat((float) contentPosition.getHeight()); } out.writeBoolean(clip); - //out.writeObject(props); + out.writeObject(props); out.writeObject(content); } @@ -114,7 +114,7 @@ public class Viewport extends InlineArea { in.readFloat()); } clip = in.readBoolean(); - //props = (HashMap) in.readObject(); + props = (HashMap) in.readObject(); content = (Area) in.readObject(); } diff --git a/src/org/apache/fop/area/inline/Word.java b/src/org/apache/fop/area/inline/Word.java index a5e68c91a..4b3ca7b8c 100644 --- a/src/org/apache/fop/area/inline/Word.java +++ b/src/org/apache/fop/area/inline/Word.java @@ -10,29 +10,59 @@ package org.apache.fop.area.inline; import org.apache.fop.render.Renderer; public class Word extends InlineArea { - // character info: font, char spacing, colour, baseline /** * The word for this word area. */ protected String word; private int iWSadjust = 0; + /** + * Create a word area. + */ + public Word() { + } + + /** + * Render the word to the renderer. + * + * @param renderer the renderer to render this word + */ public void render(Renderer renderer) { renderer.renderWord(this); } + /** + * Set the word. + * + * @param w the word string + */ public void setWord(String w) { word = w; } + /** + * Get the word string. + * + * @return the word string + */ public String getWord() { return word; } + /** + * Get word space adjust. + * + * @return the word space adjustment + */ public int getWSadjust() { return iWSadjust; } + /** + * Set word space adjust. + * + * @param iWSadjust the word space adjustment + */ public void setWSadjust(int iWSadjust) { this.iWSadjust = iWSadjust; }