Browse Source

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
tags/Alt-Design-integration-base
Keiron Liddle 21 years ago
parent
commit
9409dc3a4d

+ 2
- 1
src/org/apache/fop/area/Area.java View File



import java.io.Serializable; import java.io.Serializable;


import java.util.Map;
import java.util.HashMap; import java.util.HashMap;


// If the area appears more than once in the output // If the area appears more than once in the output
* *
* @return the map of traits * @return the map of traits
*/ */
public HashMap getTraits() {
public Map getTraits() {
return this.props; return this.props;
} }



+ 20
- 18
src/org/apache/fop/area/AreaTree.java View File



import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.Set;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;


private AreaTreeModel model; private AreaTreeModel model;


// hashmap of arraylists containing pages with id area // 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 // 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. * Create a render pages area tree model.
} }
list.add(pv); list.add(pv);


HashSet todo = (HashSet)resolve.get(id);
Set todo = (Set)resolve.get(id);
if (todo != null) { if (todo != null) {
for (Iterator iter = todo.iterator(); iter.hasNext();) { for (Iterator iter = todo.iterator(); iter.hasNext();) {
Resolveable res = (Resolveable)iter.next(); Resolveable res = (Resolveable)iter.next();
* @param res the Resolveable object to resolve * @param res the Resolveable object to resolve
*/ */
public void addUnresolvedID(String id, Resolveable res) { public void addUnresolvedID(String id, Resolveable res) {
HashSet todo = (HashSet)resolve.get(id);
Set todo = (Set)resolve.get(id);
if (todo == null) { if (todo == null) {
todo = new HashSet(); todo = new HashSet();
resolve.put(id, todo); resolve.put(id, todo);
String[] ids = res.getIDs(); String[] ids = res.getIDs();
for (int count = 0; count < ids.length; count++) { for (int count = 0; count < ids.length; count++) {
if (idLocations.containsKey(ids[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 { } else {
HashSet todo = (HashSet)resolve.get(ids[count]);
Set todo = (Set)resolve.get(ids[count]);
if (todo == null) { if (todo == null) {
todo = new HashSet(); todo = new HashSet();
resolve.put(ids[count], todo); resolve.put(ids[count], todo);
public void endDocument() { public void endDocument() {
for (Iterator iter = resolve.keySet().iterator(); iter.hasNext();) { for (Iterator iter = resolve.keySet().iterator(); iter.hasNext();) {
String id = (String)iter.next(); String id = (String)iter.next();
HashSet list = (HashSet)resolve.get(id);
Set list = (Set)resolve.get(id);
for (Iterator resIter = list.iterator(); resIter.hasNext();) { for (Iterator resIter = list.iterator(); resIter.hasNext();) {
Resolveable res = (Resolveable)resIter.next(); Resolveable res = (Resolveable)resIter.next();
if (!res.isResolved()) { if (!res.isResolved()) {
* The pages are stored and can be retrieved in any order. * The pages are stored and can be retrieved in any order.
*/ */
public static class StorePagesModel extends AreaTreeModel { 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 * Create a new store pages model
* @return returns the number of pages in a page sequence * @return returns the number of pages in a page sequence
*/ */
public int getPageCount(int seq) { public int getPageCount(int seq) {
ArrayList sequence = (ArrayList) pageSequence.get(seq);
List sequence = (List) pageSequence.get(seq);
return sequence.size(); return sequence.size();
} }


* @return the PageViewport for the particular page * @return the PageViewport for the particular page
*/ */
public PageViewport getPage(int seq, int count) { public PageViewport getPage(int seq, int count) {
ArrayList sequence = (ArrayList) pageSequence.get(seq);
List sequence = (List) pageSequence.get(seq);
return (PageViewport) sequence.get(count); return (PageViewport) sequence.get(count);
} }


/** /**
* Pages that have been prepared but not rendered yet. * 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. * Create a new render pages model with the given renderer.
} }
} }


private void renderExtensions(ArrayList list) {
private void renderExtensions(List list) {
for (int count = 0; count < list.size(); count++) { for (int count = 0; count < list.size(); count++) {
TreeExt ext = (TreeExt)list.get(count); TreeExt ext = (TreeExt)list.get(count);
renderer.renderExtension(ext); renderer.renderExtension(ext);

+ 1
- 1
src/org/apache/fop/area/BlockParent.java View File

/** /**
* The children of this block parent area. * The children of this block parent area.
*/ */
protected ArrayList children = null;
protected List children = null;


// orientation if reference area // orientation if reference area
private int orientation = ORIENT_0; private int orientation = ORIENT_0;

+ 2
- 1
src/org/apache/fop/area/CachedRenderPagesModel.java View File



import org.apache.fop.render.Renderer; import org.apache.fop.render.Renderer;


import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;


* the contents a reloaded. * the contents a reloaded.
*/ */
public class CachedRenderPagesModel extends AreaTree.RenderPagesModel { 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. * Create a new render pages model with the given renderer.

+ 1
- 1
src/org/apache/fop/area/LineArea.java View File

// 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


private ArrayList inlineAreas = new ArrayList();
private List inlineAreas = new ArrayList();


/** /**
* Set the height of this line area. * Set the height of this line area.

+ 6
- 5
src/org/apache/fop/area/Page.java View File

package org.apache.fop.area; package org.apache.fop.area;


import java.io.Serializable; import java.io.Serializable;
import java.util.Map;
import java.util.HashMap; import java.util.HashMap;


/** /**


// 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
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 // temporary map of unresolved objects used when serializing the page
private HashMap unresolved = null;
private Map unresolved = null;


/** /**
* Set the region on this page. * Set the region on this page.
* *
* @param unres the map of unresolved objects * @param unres the map of unresolved objects
*/ */
public void setUnresolvedReferences(HashMap unres) {
public void setUnresolvedReferences(Map unres) {
unresolved = unres; unresolved = unres;
} }


* *
* @return the de-serialized map of unresolved objects * @return the de-serialized map of unresolved objects
*/ */
public HashMap getUnresolvedReferences() {
public Map getUnresolvedReferences() {
return unresolved; return unresolved;
} }
} }

+ 4
- 3
src/org/apache/fop/area/PageViewport.java View File

import java.io.ObjectInputStream; import java.io.ObjectInputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;


private String pageNumber = null; private String pageNumber = null;


// list of id references and the rectangle on the page // 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 // this keeps a list of currently unresolved areas or extensions
// once the thing is resolved it is removed // once the thing is resolved it is removed
// when this is empty the page can be rendered // 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. * Create a page viewport.

+ 1
- 1
src/org/apache/fop/area/RegionReference.java View File

private int regionClass = BEFORE; private int regionClass = BEFORE;
private CTM ctm; private CTM ctm;
// the list of block areas from the static flow // 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. * Create a new region reference area.

+ 1
- 0
src/org/apache/fop/area/RegionViewport.java View File

return rv; return rv;
} }
} }


+ 2
- 1
src/org/apache/fop/area/Span.java View File



package org.apache.fop.area; package org.apache.fop.area;


import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;


// 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
private ArrayList flowAreas;
private List flowAreas;
private int height; private int height;


public Span(int cols) { public Span(int cols) {

+ 1
- 0
src/org/apache/fop/area/Title.java View File

*/ */
public class Title extends LineArea { public class Title extends LineArea {
} }


+ 97
- 3
src/org/apache/fop/area/Trait.java View File

public static final Integer LINETHROUGH = new Integer(12); public static final Integer LINETHROUGH = new Integer(12);


/** /**
*
* Shadow offset.
*/ */
public static final Integer OFFSET = new Integer(13); public static final Integer OFFSET = new Integer(13);


* The border start. * The border start.
*/ */
public static final Integer BORDER_START = new Integer(15); public static final Integer BORDER_START = new Integer(15);

/**
* The border end.
*/
public static final Integer BORDER_END = new Integer(16); public static final Integer BORDER_END = new Integer(16);

/**
* The border before.
*/
public static final Integer BORDER_BEFORE = new Integer(17); public static final Integer BORDER_BEFORE = new Integer(17);

/**
* The border after.
*/
public static final Integer BORDER_AFTER = new Integer(18); public static final Integer BORDER_AFTER = new Integer(18);

/**
* The padding start.
*/
public static final Integer PADDING_START = new Integer(19); public static final Integer PADDING_START = new Integer(19);

/**
* The padding end.
*/
public static final Integer PADDING_END = new Integer(20); public static final Integer PADDING_END = new Integer(20);

/**
* The padding before.
*/
public static final Integer PADDING_BEFORE = new Integer(21); public static final Integer PADDING_BEFORE = new Integer(21);

/**
* The padding after.
*/
public static final Integer PADDING_AFTER = new Integer(22); public static final Integer PADDING_AFTER = new Integer(22);


static HashMap shmTraitInfo;
private static final Map shmTraitInfo = new HashMap();


private static class TraitInfo { private static class TraitInfo {
String sName; String sName;


static { static {
// Create a hashmap mapping trait code to name for external representation // 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(ID_LINK, new TraitInfo("id-link", String.class));
shmTraitInfo.put(INTERNAL_LINK, shmTraitInfo.put(INTERNAL_LINK,
new TraitInfo("internal-link", String.class)); new TraitInfo("internal-link", String.class));
new TraitInfo("padding-after", Integer.class)); 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) { public static String getTraitName(Object traitCode) {
Object obj = shmTraitInfo.get(traitCode); Object obj = shmTraitInfo.get(traitCode);
if (obj != null) { if (obj != null) {
} }
} }


/**
* 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) { public static Object getTraitCode(String sTraitName) {
Iterator iter = shmTraitInfo.entrySet().iterator(); Iterator iter = shmTraitInfo.entrySet().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
return null; 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) { private static Class getTraitClass(Object oTraitCode) {
TraitInfo ti = (TraitInfo) shmTraitInfo.get(oTraitCode); TraitInfo ti = (TraitInfo) shmTraitInfo.get(oTraitCode);
return (ti != null ? ti.sClass : null); return (ti != null ? ti.sClass : null);
} }


/**
* The type of trait for an area.
*/
public Object propType; public Object propType;

/**
* The data value of the trait.
*/
public Object data; public Object data;


/**
* Create a new emty trait.
*/
public Trait() { public Trait() {
this.propType = null; this.propType = null;
this.data = 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) { public Trait(Object propType, Object data) {
this.propType = propType; this.propType = propType;
this.data = data; this.data = data;
} }


/**
* Return the string for debugging.
*
* @param the string from the data value
*/
public String toString() { public String toString() {
return data.toString(); return data.toString();
} }


/**
* Make a trait value.
*
* @param oCode
*/
public static Object makeTraitValue(Object oCode, String sTraitValue) { public static Object makeTraitValue(Object oCode, String sTraitValue) {
// Get the code from the name // Get the code from the name
// See what type of object it is // See what type of object it is
return null; return null;
} }


/**
* Background trait structure.
* Used for storing back trait information which are related.
*/
public static class Background implements Serializable { public static class Background implements Serializable {
/**
* The background color if any.
*/
public ColorType color = null; public ColorType color = null;

/**
* The background image url if any.
*/
public String url = null; public String url = null;

/**
* Background repeat enum for images.
*/
public int repeat; public int repeat;

/**
* Background horizontal offset for images.
*/
public int horiz; public int horiz;

/**
* Background vertical offset for images.
*/
public int vertical; public int vertical;
} }



+ 1
- 0
src/org/apache/fop/area/inline/Anchor.java View File

// has reference to associated footnote or float out-of-line area // has reference to associated footnote or float out-of-line area


} }


+ 2
- 4
src/org/apache/fop/area/inline/Character.java View File



/** /**
* Single character inline area. * Single character inline area.
* This inline area holds a single characater.
* This inline area holds a single character.
*/ */
public class Character extends InlineArea { public class Character extends InlineArea {
private char character; private char character;
character = ch; character = ch;
} }


// character info: font, char spacing, colour, baseline

/** /**
* Render this inline area. * Render this inline area.
* *
public char getChar() { public char getChar() {
return character; return character;
} }

} }


+ 34
- 8
src/org/apache/fop/area/inline/Container.java View File

import java.util.List; import java.util.List;
import java.util.ArrayList; 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 { 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) { public void addBlock(Block block) {
blocks.add(block); blocks.add(block);
} }


/**
* Get the block areas stacked inside this container area.
*
* @return the list of block areas
*/
public List getBlocks() { public List getBlocks() {
return blocks; return blocks;
} }


/**
* Get the width of this container area.
*
* @return the width
*/
public int getWidth() { public int getWidth() {
return width; return width;
} }

} }


+ 1
- 1
src/org/apache/fop/area/inline/FilledArea.java View File

*/ */
public List getChildAreas() { public List getChildAreas() {
int units = (int)(getWidth() / unitWidth); int units = (int)(getWidth() / unitWidth);
ArrayList newList = new ArrayList();
List newList = new ArrayList();
for (int count = 0; count < units; count++) { for (int count = 0; count < units; count++) {
newList.addAll(inlines); newList.addAll(inlines);
} }

+ 1
- 1
src/org/apache/fop/area/inline/Image.java View File

public String getURL() { public String getURL() {
return url; return url;
} }

} }


+ 28
- 5
src/org/apache/fop/area/inline/InlineArea.java View File

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 java.util.ArrayList;

/** /**
* Inline Area * Inline Area
* This area is for all inline areas that can be placed * This area is for all inline areas that can be placed
// 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
private ArrayList props = null;

/** /**
* Render this inline area. * Render this inline area.
* Inline areas that extend this class are expected * Inline areas that extend this class are expected
public void render(Renderer renderer) { 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) { public void setWidth(int w) {
contentIPD = w; contentIPD = w;
} }


/**
* Get the width of this inline area.
* Currently gets the ipd.
*
* @return the width
*/
public int getWidth() { public int getWidth() {
return contentIPD; return contentIPD;
} }
return iBP; 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) { public void setOffset(int v) {
verticalPosition = 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() { public int getOffset() {
return verticalPosition; return verticalPosition;
} }

+ 1
- 1
src/org/apache/fop/area/inline/InlineParent.java View File

/** /**
* The list of inline areas added to this inline parent. * 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 * An inline parent is a reference area somay have clipping

+ 1
- 2
src/org/apache/fop/area/inline/Leader.java View File

*/ */
public class Leader extends InlineArea { public class Leader extends InlineArea {


// pattern, length min opt max

// in the case of use content or dots this is replaced // in the case of use content or dots this is replaced
// with the set of inline areas // with the set of inline areas
// if space replaced with a space // if space replaced with a space
renderer.renderLeader(this); renderer.renderLeader(this);
} }
} }


+ 2
- 2
src/org/apache/fop/area/inline/Viewport.java View File

out.writeFloat((float) contentPosition.getHeight()); out.writeFloat((float) contentPosition.getHeight());
} }
out.writeBoolean(clip); out.writeBoolean(clip);
//out.writeObject(props);
out.writeObject(props);
out.writeObject(content); out.writeObject(content);
} }


in.readFloat()); in.readFloat());
} }
clip = in.readBoolean(); clip = in.readBoolean();
//props = (HashMap) in.readObject();
props = (HashMap) in.readObject();
content = (Area) in.readObject(); content = (Area) in.readObject();
} }



+ 31
- 1
src/org/apache/fop/area/inline/Word.java View File

import org.apache.fop.render.Renderer; import org.apache.fop.render.Renderer;


public class Word extends InlineArea { public class Word extends InlineArea {
// character info: font, char spacing, colour, baseline
/** /**
* The word for this word area. * The word for this word area.
*/ */
protected String word; protected String word;
private int iWSadjust = 0; 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) { public void render(Renderer renderer) {
renderer.renderWord(this); renderer.renderWord(this);
} }


/**
* Set the word.
*
* @param w the word string
*/
public void setWord(String w) { public void setWord(String w) {
word = w; word = w;
} }


/**
* Get the word string.
*
* @return the word string
*/
public String getWord() { public String getWord() {
return word; return word;
} }


/**
* Get word space adjust.
*
* @return the word space adjustment
*/
public int getWSadjust() { public int getWSadjust() {
return iWSadjust; return iWSadjust;
} }


/**
* Set word space adjust.
*
* @param iWSadjust the word space adjustment
*/
public void setWSadjust(int iWSadjust) { public void setWSadjust(int iWSadjust) {
this.iWSadjust = iWSadjust; this.iWSadjust = iWSadjust;
} }

Loading…
Cancel
Save