From: Peter Bernard West Date: Tue, 27 Aug 2002 15:33:04 +0000 (+0000) Subject: Changes to handling of MAPPED_NUMERIC X-Git-Tag: Alt-Design_pre_Properties_split~144 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2f0c49272c9ab223e1580c75f56b3c237f08dd87;p=xmlgraphics-fop.git Changes to handling of MAPPED_NUMERIC git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@195121 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/fo/FOTree.java b/src/org/apache/fop/fo/FOTree.java index d182ae580..1c7d3a012 100644 --- a/src/org/apache/fop/fo/FOTree.java +++ b/src/org/apache/fop/fo/FOTree.java @@ -82,10 +82,21 @@ public class FOTree extends Tree implements Runnable { protected LinkedList[] propertyStacks; /** - * A HashMap of arrays of Numeric[] keyed on the - * index of properties which support MAPPED_NUMERIC data types. + * An FONode identifier. This is available to be incremented for + * each FONode created. The only requirement is that active FONodes + * have a unique identifier. An accessor function is defined, but the + * responsibility for calling it rests with FONode. */ - private HashMap mappedNumericArrays = new HashMap(); + private int nodeID = 0; + + /** + * Get the next node identifier. There is no need to synchronize this + * as FONodes are created within a single thread. + * @return the next node identifier + */ + public int nextNodeID() { + return ++nodeID; + } /** * @param xmlevents the buffer from which XMLEvents from the @@ -141,27 +152,6 @@ public class FOTree extends Tree implements Runnable { } } - // Initialise the Numeric arrays for properties with - // MAPPED_NUMERIC datatypes - for (int i = 0; i <= PropNames.LAST_PROPERTY_INDEX; i++ ) { - if ((PropertyConsts.dataTypes.get(i) - & Properties.MAPPED_NUMERIC) != 0) { - try { - Numeric[] numarray = - (Numeric[]) - ((Method) ( - PropertyConsts.mappedNumMethods - .get(Ints.consts.get(i)) - )) - .invoke(null, null); - mappedNumericArrays.put(Ints.consts.get(i),numarray); - } catch (IllegalAccessException e) { - throw new PropertyException(e.getMessage()); - } catch (InvocationTargetException e) { - throw new PropertyException(e.getMessage()); - } - } - } } /** @@ -195,21 +185,6 @@ public class FOTree extends Tree implements Runnable { (new PropertyTriplet(property, value)); } - /** - * @param property int property index - * @param enumIndex int enumerated value index into array - * of mapped Numeric values - * @return Numeric corresponding to the MAPPED_NUMERIC - * enumeration token for this property - */ - public Numeric getMappedNumArrayValue(int property, int enumIndex) - { - return - ((Numeric[]) - (mappedNumericArrays.get(Ints.consts.get(property))) - )[enumIndex]; - } - /** * @return a TextDecorations object containing the current * text decorations diff --git a/src/org/apache/fop/fo/PropertyConsts.java b/src/org/apache/fop/fo/PropertyConsts.java index b16524787..718757aab 100644 --- a/src/org/apache/fop/fo/PropertyConsts.java +++ b/src/org/apache/fop/fo/PropertyConsts.java @@ -27,6 +27,7 @@ import org.apache.fop.fo.FOTree; import org.apache.fop.fo.PropNames; import org.apache.fop.fo.Properties; import org.apache.fop.fo.expr.PropertyException; +import org.apache.fop.datatypes.Numeric; import org.apache.fop.datatypes.Ints; import org.apache.fop.datastructs.ROIntArray; import org.apache.fop.datastructs.ROStringArray; @@ -145,6 +146,26 @@ public class PropertyConsts { } } + public static Numeric getMappedNumeric(int property, int enum) + throws PropertyException + { + Method method; + if ((method = + (Method)(mappednummethods.get(Ints.consts.get(property)))) + == null) + throw new PropertyException("No mappedLength method in " + + classes[property].getName()); + try { + return (Numeric) + (method.invoke + (null, new Object[] {Ints.consts.get(enum)})); + } catch (IllegalAccessException iae) { + throw new PropertyException(iae.getMessage()); + } catch (InvocationTargetException ite) { + throw new PropertyException(ite.getMessage()); + } + } + /** * @param property String name of the FO property * @return int type of inheritance for this property @@ -542,10 +563,11 @@ public class PropertyConsts { ("refineParsing", new Class[] {org.apache.fop.fo.FOTree.class, PropertyValue.class}); - if ((datatypes[i] & Properties.MAPPED_NUMERIC) != 0) + if ((datatypes[i] & Properties.MAPPED_LENGTH) != 0) mappednummethods.put(Ints.consts.get(i), classes[i].getMethod - ("getMappedNumArray", new Class[] {})); + ("getMappedLength", new Class[] + {Integer.class})); } catch (NoSuchFieldException e) { throw new RuntimeException(