[FOray-commit] SF.net SVN: foray: [8444] trunk/foray/foray-fotree/src/java/org/foray/ fotree
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-10-28 19:04:16
|
Revision: 8444
http://svn.sourceforge.net/foray/?rev=8444&view=rev
Author: victormote
Date: 2006-10-28 12:04:07 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Clean up some more properties with numeric values.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AudioDial.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSizeAdjust.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LineHeight.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SpeechRate.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Volume.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtNumber.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java 2006-10-28 14:48:53 UTC (rev 8443)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java 2006-10-28 19:04:07 UTC (rev 8444)
@@ -174,7 +174,7 @@
if (integerOnly) {
if (pv instanceof DtNumber) {
// Only integers wanted, so convert to one here.
- final double value = ((DtNumber) pv).getValue();
+ final double value = ((DtNumber) pv).getNumericValue();
return new DtInteger((int) Math.round(value));
}
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AudioDial.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AudioDial.java 2006-10-28 14:48:53 UTC (rev 8443)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AudioDial.java 2006-10-28 19:04:07 UTC (rev 8444)
@@ -33,7 +33,7 @@
import org.foray.fotree.Property;
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
-import org.foray.fotree.value.DtNumber;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -64,13 +64,13 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
- pv = DtNumber.makeNumberDT(value);
- if (pv != null) {
- final double number = ((DtNumber) pv).getValue();
+ if (pv instanceof ExprNumeric) {
+ final double number = ((ExprNumeric) pv).getNumericValue();
if (number >= 0 && number <= WKConstants.PERCENT_CONVERSION) {
return pv;
}
@@ -79,8 +79,8 @@
}
public double getValue(final FOContext context, final FObj fobj) {
- if (value() instanceof DtNumber) {
- return ((DtNumber) value()).getValue();
+ if (value() instanceof ExprNumeric) {
+ return ((ExprNumeric) value()).getNumericValue();
}
if (value() instanceof PropertyKeyword) {
final short keyword = ((PropertyKeyword) value()).getValue();
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSizeAdjust.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSizeAdjust.java 2006-10-28 14:48:53 UTC (rev 8443)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSizeAdjust.java 2006-10-28 19:04:07 UTC (rev 8444)
@@ -32,7 +32,7 @@
import org.foray.fotree.Property;
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
-import org.foray.fotree.value.DtNumber;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -65,20 +65,20 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
- pv = DtNumber.makeNumberDT(value);
- if (pv != null) {
+ if (pv instanceof ExprNumeric) {
return pv;
}
throw unexpectedValue(value, propertyList);
}
public double getValue(final FOContext context, final FObj fobj) {
- if (value() instanceof DtNumber) {
- return ((DtNumber) value()).getValue();
+ if (value() instanceof ExprNumeric) {
+ return ((ExprNumeric) value()).getNumericValue();
}
if (value() instanceof PropertyKeyword) {
final short keyword = ((PropertyKeyword) value()).getValue();
@@ -90,7 +90,6 @@
return -1;
}
}
- return ((DtNumber) value()).getValue();
}
return getValueNoInstance(context, fobj);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LineHeight.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LineHeight.java 2006-10-28 14:48:53 UTC (rev 8443)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LineHeight.java 2006-10-28 19:04:07 UTC (rev 8444)
@@ -33,8 +33,6 @@
import org.foray.fotree.Property;
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
-import org.foray.fotree.value.DtLength;
-import org.foray.fotree.value.DtNumber;
import org.foray.fotree.value.DtPercentage;
import org.foray.fotree.value.DtSpace;
import org.foray.fotree.value.ExprNumeric;
@@ -84,12 +82,6 @@
final String value) throws PropertyException {
final PropertyValue pv = standardParse(propertyList, value, false,
false);
- if (pv instanceof DtNumber) {
- if (((DtNumber) pv).getValue() < 0) {
- throw unexpectedValue(value, propertyList);
- }
- return pv;
- }
if (pv instanceof DtPercentage) {
if (((DtPercentage) pv).getValue() < 0) {
throw unexpectedValue(value, propertyList);
@@ -141,10 +133,6 @@
}
}
}
- if (value() instanceof DtLength) {
- final int fontSize = fobj.traitFontSize(context);
- return ((DtLength) value()).getValue(fontSize, 0);
- }
if (value() instanceof DtPercentage) {
final int base = fobj.traitFontSize(context);
final DtPercentage percentageDT = (DtPercentage) value();
@@ -152,9 +140,14 @@
return Math.round(percentage * base /
WKConstants.PERCENT_CONVERSION);
}
- if (value() instanceof DtNumber) {
- return (int) Math.round(((DtNumber) value()).getValue()
- * fobj.traitFontSize(context));
+ if (value() instanceof ExprNumeric) {
+ final ExprNumeric numeric = (ExprNumeric) value();
+ final int fontSize = fobj.traitFontSize(context);
+ if (numeric.canEvaluateLength()) {
+ return numeric.getLength(fontSize, 0);
+ } else {
+ return (int) Math.round(numeric.getNumericValue() * fontSize);
+ }
}
if (value() instanceof DtSpace) {
final DtSpace space = (DtSpace) value();
@@ -186,23 +179,21 @@
}
}
}
- if (value() instanceof DtLength) {
- /*
- * It is possible that this value should be inferred as the
- * Length value divided by font-size.
- */
- return 1.0F;
- }
if (value() instanceof DtPercentage) {
- /*
- * Not sure from the spec whether percentages are inherited or
- * not. It is possible we should return a value of 1.0F here.
- */
+ /* Not sure from the spec whether percentages are inherited or
+ * not. It is possible we should return a value of 1.0F here. */
return ((DtPercentage) value()).getValue()
/ WKConstants.PERCENT_CONVERSION;
}
- if (value() instanceof DtNumber) {
- return (float) ((DtNumber) value()).getValue();
+ if (value() instanceof ExprNumeric) {
+ final ExprNumeric numeric = (ExprNumeric) value();
+ if (numeric.canEvaluateLength()) {
+ /* It is possible that this value should be inferred as the
+ * Length value divided by font-size. */
+ return 1.0f;
+ } else {
+ return (float) numeric.getNumericValue();
+ }
}
return 0;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SpeechRate.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SpeechRate.java 2006-10-28 14:48:53 UTC (rev 8443)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SpeechRate.java 2006-10-28 19:04:07 UTC (rev 8444)
@@ -32,7 +32,7 @@
import org.foray.fotree.Property;
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
-import org.foray.fotree.value.DtNumber;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -78,20 +78,23 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
- pv = DtNumber.makeNumberDT(value);
- if (pv != null) {
- return pv;
+ if (pv instanceof ExprNumeric) {
+ final ExprNumeric numeric = (ExprNumeric) pv;
+ if (numeric.getUnitPower() == ExprNumeric.UNIT_POWER_NUMERIC) {
+ return pv;
+ }
}
throw unexpectedValue(value, propertyList);
}
public double getValue(final FOContext context, final FObj fobj) {
- if (value() instanceof DtNumber) {
- return ((DtNumber) value()).getValue();
+ if (value() instanceof ExprNumeric) {
+ return ((ExprNumeric) value()).getNumericValue();
}
if (value() instanceof PropertyKeyword) {
final short keyword = ((PropertyKeyword) value()).getValue();
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Volume.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Volume.java 2006-10-28 14:48:53 UTC (rev 8443)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Volume.java 2006-10-28 19:04:07 UTC (rev 8444)
@@ -33,8 +33,8 @@
import org.foray.fotree.Property;
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
-import org.foray.fotree.value.DtNumber;
import org.foray.fotree.value.DtPercentage;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -75,29 +75,28 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
- pv = DtNumber.makeNumberDT(value);
- if (pv != null) {
- final double number = ((DtNumber) pv).getValue();
- if (number >= 0 && number <= WKConstants.PERCENT_CONVERSION) {
+ if (pv instanceof DtPercentage) {
+ return pv;
+ }
+ if (pv instanceof ExprNumeric) {
+ final ExprNumeric numeric = (ExprNumeric) pv;
+ final double number = numeric.getNumericValue();
+ if (numeric.getUnitPower() == ExprNumeric.UNIT_POWER_NUMERIC
+ && number >= 0
+ && number <= WKConstants.PERCENT_CONVERSION) {
return pv;
}
throw unexpectedValue(value, propertyList);
}
- pv = DtPercentage.makePercentageDT(value);
- if (pv != null) {
- return pv;
- }
throw unexpectedValue(value, propertyList);
}
public double getValue(final FOContext context, final FObj fobj) {
- if (value() instanceof DtNumber) {
- return ((DtNumber) value()).getValue();
- }
if (value() instanceof DtPercentage) {
final double base = getInheritedValue(context, fobj);
if (base < 0) {
@@ -110,6 +109,9 @@
product = Math.min(product, WKConstants.PERCENT_CONVERSION);
return product;
}
+ if (value() instanceof ExprNumeric) {
+ return ((ExprNumeric) value()).getNumericValue();
+ }
if (value() instanceof PropertyKeyword) {
final short keyword = ((PropertyKeyword) value()).getValue();
switch (keyword) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtNumber.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtNumber.java 2006-10-28 14:48:53 UTC (rev 8443)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtNumber.java 2006-10-28 19:04:07 UTC (rev 8444)
@@ -45,13 +45,6 @@
this.value = value;
}
- /**
- * @return The value of this number.
- */
- public double getValue() {
- return value;
- }
-
public double getNumericValue() {
return value;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|