foray-commit Mailing List for FOray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
(139) |
Apr
(98) |
May
(250) |
Jun
(394) |
Jul
(84) |
Aug
(13) |
Sep
(420) |
Oct
(186) |
Nov
(1) |
Dec
(3) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(108) |
Feb
(202) |
Mar
(291) |
Apr
(247) |
May
(374) |
Jun
(227) |
Jul
(231) |
Aug
(60) |
Sep
(31) |
Oct
(45) |
Nov
(18) |
Dec
|
| 2008 |
Jan
(38) |
Feb
(71) |
Mar
(142) |
Apr
|
May
(59) |
Jun
(6) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
(12) |
Feb
(4) |
Mar
(88) |
Apr
(121) |
May
(17) |
Jun
(30) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2010 |
Jan
(11) |
Feb
(76) |
Mar
(11) |
Apr
|
May
(11) |
Jun
|
Jul
|
Aug
(44) |
Sep
(14) |
Oct
(7) |
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(9) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(10) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(4) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(168) |
| 2017 |
Jan
(77) |
Feb
(11) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(1) |
Apr
(6) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
(88) |
Mar
(118) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(141) |
| 2021 |
Jan
(170) |
Feb
(20) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(62) |
Nov
(189) |
Dec
(162) |
| 2022 |
Jan
(201) |
Feb
(118) |
Mar
(8) |
Apr
|
May
(2) |
Jun
(47) |
Jul
(19) |
Aug
(14) |
Sep
(3) |
Oct
|
Nov
(28) |
Dec
(235) |
| 2023 |
Jan
(112) |
Feb
(23) |
Mar
(2) |
Apr
(2) |
May
|
Jun
(1) |
Jul
|
Aug
(70) |
Sep
(92) |
Oct
(20) |
Nov
(1) |
Dec
(1) |
| 2024 |
Jan
|
Feb
|
Mar
(1) |
Apr
(1) |
May
(14) |
Jun
(11) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2025 |
Jan
(10) |
Feb
(29) |
Mar
|
Apr
(162) |
May
(245) |
Jun
(83) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
1
|
2
(4) |
3
(7) |
4
|
5
(1) |
6
(40) |
7
(33) |
|
8
(3) |
9
(2) |
10
(14) |
11
(1) |
12
(2) |
13
(5) |
14
|
|
15
|
16
|
17
(1) |
18
|
19
(1) |
20
(15) |
21
(29) |
|
22
(1) |
23
(2) |
24
(2) |
25
|
26
(2) |
27
(11) |
28
(10) |
|
29
|
30
|
31
|
|
|
|
|
|
From: <vic...@us...> - 2006-10-28 23:43:37
|
Revision: 8451
http://svn.sourceforge.net/foray/?rev=8451&view=rev
Author: victormote
Date: 2006-10-28 16:43:14 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Progress toward using more standardized code.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LetterSpacing.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Role.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Script.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Size.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SourceDocument.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Src.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SwitchTo.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TableLayout.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetPresentationContext.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetProcessingContext.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetStylesheet.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlign.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlignLast.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAltitude.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextDepth.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextShadow.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TreatAsWordSpace.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/VoiceFamily.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Widows.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/WordSpacing.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ZIndex.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/xml/prop/Lang.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 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -189,11 +189,6 @@
protected abstract short[] getValidKeywords();
- protected PropertyKeyword checkKeywords(final String possibleKeyword) {
- /* TODO: Remove this method! */
- return checkKeywords(this.getValidKeywords(), possibleKeyword);
- }
-
protected PropertyKeyword checkKeywords(final short[] validKeywords,
final String possibleKeyword) {
final short kwIndex = getKeywordIndex(possibleKeyword, validKeywords);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LetterSpacing.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LetterSpacing.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LetterSpacing.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -35,7 +35,6 @@
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtSpace;
-import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -76,9 +75,7 @@
return pv;
}
if (pv.validLength()) {
- final ExprNumeric length = (ExprNumeric) pv;
- return new DtSpace(length, length, length, Constants.FOVAL_DISCARD,
- 0);
+ return pv;
}
throw unexpectedValue(value, propertyList);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Role.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Role.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Role.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -59,8 +59,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
pv = DtURI.makeUriDT(value);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Script.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Script.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Script.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -62,8 +62,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
if (DtScript.validScript(value)) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Size.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Size.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Size.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -69,7 +69,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SourceDocument.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SourceDocument.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SourceDocument.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -61,7 +61,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Src.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Src.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Src.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -61,7 +61,7 @@
if (pv != null) {
return pv;
}
- pv = checkKeywords(value);
+ pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SwitchTo.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SwitchTo.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/SwitchTo.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -60,7 +60,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
+ PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TableLayout.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TableLayout.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TableLayout.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -56,7 +56,7 @@
public PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetPresentationContext.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetPresentationContext.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetPresentationContext.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -33,6 +33,7 @@
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtURI;
+import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
import org.axsl.common.Constants;
@@ -55,8 +56,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
pv = DtURI.makeUriDT(value);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetProcessingContext.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetProcessingContext.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetProcessingContext.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -32,6 +32,7 @@
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtURI;
+import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
import org.axsl.common.Constants;
@@ -55,8 +56,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
pv = DtURI.makeUriDT(value);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetStylesheet.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetStylesheet.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TargetStylesheet.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -32,6 +32,7 @@
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtURI;
+import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
import org.axsl.common.Constants;
@@ -55,8 +56,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
pv = DtURI.makeUriDT(value);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlign.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlign.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlign.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -65,8 +65,9 @@
public PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
if (value.length() != 0) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlignLast.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlignLast.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlignLast.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -66,7 +66,7 @@
public PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAltitude.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAltitude.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAltitude.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -33,7 +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.DtPercentage;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -61,15 +60,15 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -90,10 +89,6 @@
}
}
}
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
/*
* The standard says that percentages "refer to the font's
@@ -107,6 +102,9 @@
return Math.round(percentage * base
/ WKConstants.PERCENT_CONVERSION);
}
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
+ }
return getValueNoInstance(fobj, context);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextDepth.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextDepth.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextDepth.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -33,7 +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.DtPercentage;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -60,15 +59,15 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -89,10 +88,6 @@
}
}
}
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
/*
* The standard says that percentages "refer to the font's
@@ -106,6 +101,9 @@
return Math.round(percentage * base
/ WKConstants.PERCENT_CONVERSION);
}
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
+ }
return getValueNoInstance(fobj, context);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -33,9 +33,7 @@
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.DtPercentage;
-import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -60,23 +58,17 @@
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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
- if (pv instanceof ExprNumeric) {
- final ExprNumeric expression = (ExprNumeric) pv;
- if (expression.canEvaluateLength()) {
- return pv;
- }
- }
throw unexpectedValue(value, propertyList);
}
@@ -90,20 +82,14 @@
}
}
}
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
final DtPercentage percentageDT = (DtPercentage) value();
final float percentage = percentageDT.getValue();
return Math.round(percentage * widthContainingBlock
/ WKConstants.PERCENT_CONVERSION);
}
- if (value() instanceof ExprNumeric) {
- final ExprNumeric expression = (ExprNumeric) value();
- return expression.getLength(fobj.traitFontSize(context),
- widthContainingBlock);
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
}
return 0;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextShadow.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextShadow.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextShadow.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -59,7 +59,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
+ PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TreatAsWordSpace.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TreatAsWordSpace.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TreatAsWordSpace.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -60,7 +60,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/VoiceFamily.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/VoiceFamily.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/VoiceFamily.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -64,7 +64,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Widows.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Widows.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Widows.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -57,11 +57,11 @@
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 = standardParse(propertyList, value, false, false);
if (pv instanceof DtInteger) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/WordSpacing.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/WordSpacing.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/WordSpacing.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -67,15 +67,13 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
- final DtLength length = (DtLength) pv;
- return new DtSpace(length, length, length, Constants.FOVAL_DISCARD,
- 0);
+ if (pv.validLength()) {
+ return pv;
}
throw unexpectedValue(value, propertyList);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ZIndex.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ZIndex.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ZIndex.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -58,11 +58,11 @@
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 = standardParse(propertyList, value, false, true);
if (pv instanceof DtInteger) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/xml/prop/Lang.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/xml/prop/Lang.java 2006-10-28 23:23:39 UTC (rev 8450)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/xml/prop/Lang.java 2006-10-28 23:43:14 UTC (rev 8451)
@@ -64,7 +64,7 @@
final String propertyFullName, final String value)
throws PropertyException {
final PropertyCollection collection = new PropertyCollection();
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
collection.addItem(new Country(propertyList,
Constants.FOPROP_FONT_STYLE, pv));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-28 23:23:54
|
Revision: 8450
http://svn.sourceforge.net/foray/?rev=8450&view=rev
Author: victormote
Date: 2006-10-28 16:23:39 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Steps toward more standard logic.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderPatternWidth.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LetterSpacing.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/MaximumRepeats.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Name.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Orphans.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Padding.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/PageDimension.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Pause.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Pitch.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/PlayDuring.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ProvDistanceBetween.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ProvLabelSeparation.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RefId.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeDimension.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderPatternWidth.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderPatternWidth.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderPatternWidth.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -33,7 +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.DtPercentage;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -61,15 +60,15 @@
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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -88,16 +87,15 @@
}
}
}
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
final DtPercentage percentageDT = (DtPercentage) value();
final float percentage = percentageDT.getValue();
return Math.round(percentage * ipdCRParent /
WKConstants.PERCENT_CONVERSION);
}
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
+ }
return 0;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LetterSpacing.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LetterSpacing.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LetterSpacing.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -35,6 +35,7 @@
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtSpace;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -69,13 +70,13 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
- final DtLength length = (DtLength) pv;
+ if (pv.validLength()) {
+ final ExprNumeric length = (ExprNumeric) pv;
return new DtSpace(length, length, length, Constants.FOVAL_DISCARD,
0);
}
@@ -113,9 +114,8 @@
}
}
}
- if (value() instanceof DtLength) {
- final DtLength length = (DtLength) value();
- return length.getValue(fobj.traitFontSize(context), 0);
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
}
if (value() instanceof PropertyKeyword) {
final short keyword = ((PropertyKeyword) value()).getValue();
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -34,9 +34,7 @@
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
import org.foray.fotree.fo.obj.SimplePageMaster;
-import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
-import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyCollection;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -76,21 +74,15 @@
private PropertyValue createSimpleValue(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 = standardParse(propertyList, value, false, false);
- if (pv instanceof ExprNumeric) {
- final ExprNumeric expression = (ExprNumeric) pv;
- if (expression.canEvaluateLength()) {
- return pv;
- }
- }
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -121,12 +113,6 @@
return getKeywordValue(context, direction, fobj,
widthContainingBlock);
}
- if (value() instanceof DtLength) {
- final DtLength length = (DtLength) value();
- final int lengthValue = length.getValue(fobj.traitFontSize(context),
- 0);
- return Math.max(lengthValue, 0);
- }
if (value() instanceof DtPercentage) {
int base = 0;
if (fobj instanceof SimplePageMaster) {
@@ -139,6 +125,10 @@
return Math.round(base * percent.getValue()
/ WKConstants.PERCENT_CONVERSION);
}
+ if (value().validLength()) {
+ final int length = value().asLength(fobj, context);
+ return Math.max(length, 0);
+ }
// This is an error that should already be caught.
return getValueNoInstance();
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/MaximumRepeats.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/MaximumRepeats.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/MaximumRepeats.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -61,11 +61,11 @@
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 = standardParse(propertyList, value, true, false);
if (pv instanceof DtInteger) {
((DtInteger) pv).setMinimumValue(0);
return pv;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Name.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Name.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Name.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -57,11 +57,11 @@
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 = standardParse(propertyList, value, false, false);
if (pv instanceof DtName) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Orphans.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Orphans.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Orphans.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -57,11 +57,11 @@
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 = standardParse(propertyList, value, false, false);
if (pv instanceof DtInteger) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Padding.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Padding.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Padding.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -73,12 +73,12 @@
private PropertyValue createSimpleValue(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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv.validLength()) {
return pv;
}
if (pv instanceof DtLengthConditional) {
@@ -118,11 +118,9 @@
if (value() instanceof PropertyKeyword) {
return getKeywordValue(context, direction, fobj, isOuterEdge);
}
- if (value() instanceof DtLength) {
- final DtLength length = (DtLength) value();
- final int lengthValue = length.getValue(fobj.traitFontSize(context),
- 0);
- return Math.max(lengthValue, 0);
+ if (value().validLength()) {
+ final int length = value().asLength(fobj, context);
+ return Math.max(length, 0);
}
if (value() instanceof DtLengthConditional
&& direction >= Constants.DIRECTION_START
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/PageDimension.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/PageDimension.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/PageDimension.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -33,7 +33,6 @@
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
import org.foray.fotree.fo.obj.SimplePageMaster;
-import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -61,12 +60,12 @@
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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -113,9 +112,8 @@
}
}
}
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
}
return 0;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Pause.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Pause.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Pause.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -71,16 +71,15 @@
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 = DtTime.makeTimeDT(value);
- if (pv != null) {
+ if (pv instanceof DtTime) {
return pv;
}
- pv = DtPercentage.makePercentageDT(value);
- if (pv != null) {
+ if (pv instanceof DtPercentage) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -88,7 +87,7 @@
private PropertyValue createShorthandValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Pitch.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Pitch.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Pitch.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -65,8 +65,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
pv = DtFrequency.makeFrequencyDT(value);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/PlayDuring.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/PlayDuring.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/PlayDuring.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -67,7 +67,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ProvDistanceBetween.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ProvDistanceBetween.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ProvDistanceBetween.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -33,7 +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.DtPercentage;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -62,15 +61,15 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -88,10 +87,6 @@
}
}
}
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
final int base = ipdNearestBlockAreaNotLineArea;
final DtPercentage percentageDT = (DtPercentage) value();
@@ -99,6 +94,9 @@
return Math.round(percentage * base /
WKConstants.PERCENT_CONVERSION);
}
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
+ }
return INITIAL_VALUE;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ProvLabelSeparation.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ProvLabelSeparation.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ProvLabelSeparation.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -33,7 +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.DtPercentage;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -62,15 +61,15 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -88,10 +87,6 @@
}
}
}
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
final int base = ipdNearestBlockAreaNotLineArea;
final DtPercentage percentageDT = (DtPercentage) value();
@@ -99,6 +94,9 @@
return Math.round(percentage * base
/ WKConstants.PERCENT_CONVERSION);
}
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
+ }
return INITIAL_VALUE;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RefId.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RefId.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RefId.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -57,11 +57,11 @@
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 = standardParse(propertyList, value, false, false);
if (pv instanceof DtName) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeDimension.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeDimension.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeDimension.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -62,18 +62,18 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLengthRange) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtLength) {
+ if (pv instanceof DtLengthRange) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -107,10 +107,6 @@
}
return length.getLength(fobj.traitFontSize(context), 0);
}
- if (value() instanceof DtLength) {
- final DtLength length = (DtLength) value();
- return length.getValue(fobj.traitFontSize(context), 0);
- }
if (value() instanceof DtPercentage) {
if (parentAreaCRDimension < 0) {
return Constants.DIMENSION_AUTO;
@@ -118,6 +114,9 @@
final DtPercentage percentage = (DtPercentage) value();
return Math.round(percentage.getValue() * parentAreaCRDimension);
}
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
+ }
if (value() instanceof PropertyKeyword) {
final PropertyKeyword kw = (PropertyKeyword) value();
if (kw.getValue() == Constants.FOVAL_AUTO) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java 2006-10-28 22:57:49 UTC (rev 8449)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java 2006-10-28 23:23:39 UTC (rev 8450)
@@ -70,18 +70,11 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof ExprNumeric) {
- final ExprNumeric expr = (ExprNumeric) pv;
- if (expr.canEvaluateLength()) {
- return new DtSpace(expr, expr, expr, Constants.FOVAL_DISCARD,
- 0);
- }
- }
if (pv instanceof DtPercentage) {
switch (getPropertyType()) {
case Constants.FOPROP_SPACE_START:
@@ -90,6 +83,11 @@
}
}
}
+ if (pv.validLength()) {
+ final ExprNumeric length = pv.asNumeric();
+ return new DtSpace(length, length, length, Constants.FOVAL_DISCARD,
+ 0);
+ }
throw unexpectedValue(value, propertyList);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-28 22:58:15
|
Revision: 8449
http://svn.sourceforge.net/foray/?rev=8449&view=rev
Author: victormote
Date: 2006-10-28 15:57:49 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Convert more properties to standard logic.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Font.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontFamily.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontStretch.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontStyle.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontVariant.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontWeight.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ForcePageCount.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/GlyphOrientation.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphLadderCount.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphPushCharCount.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphRemainCharCount.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/InitialPageNumber.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Keep.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Language.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderLength.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeDimension.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthRange.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Font.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Font.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Font.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -72,7 +72,7 @@
final String propertyFullName, final String value)
throws PropertyException {
final PropertyCollection collection = new PropertyCollection();
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
collection.addItem(new FontStyle(propertyList,
Constants.FOPROP_FONT_STYLE, pv));
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontFamily.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontFamily.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontFamily.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -73,7 +73,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontStretch.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontStretch.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontStretch.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -72,8 +72,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontStyle.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontStyle.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontStyle.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -65,8 +65,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontVariant.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontVariant.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontVariant.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -63,8 +63,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontWeight.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontWeight.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontWeight.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -68,11 +68,11 @@
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 = standardParse(propertyList, value, false, false);
if (pv instanceof DtInteger) {
final int integer = ((DtInteger) pv).getValue();
switch (integer) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ForcePageCount.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ForcePageCount.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ForcePageCount.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -63,8 +63,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/GlyphOrientation.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/GlyphOrientation.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/GlyphOrientation.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -76,7 +76,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
+ PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphLadderCount.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphLadderCount.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphLadderCount.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -61,11 +61,11 @@
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 = standardParse(propertyList, value, false, true);
if (pv instanceof DtInteger) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphPushCharCount.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphPushCharCount.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphPushCharCount.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -58,11 +58,11 @@
public 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 = standardParse(propertyList, value, true, false);
if (pv instanceof DtInteger) {
((DtInteger) pv).setMinimumValue(1);
return pv;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphRemainCharCount.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphRemainCharCount.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/HyphRemainCharCount.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -58,11 +58,11 @@
public 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 = standardParse(propertyList, value, true, false);
if (pv instanceof DtInteger) {
((DtInteger) pv).setMinimumValue(1);
return pv;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -63,12 +63,12 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv.validLength()) {
return pv;
}
if (pv instanceof DtPercentage) {
@@ -98,16 +98,15 @@
ipdContainingRA);
}
}
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
final DtPercentage percentageDT = (DtPercentage) value();
final float percentage = percentageDT.getValue();
return Math.round(percentage * ipdContainingRA /
WKConstants.PERCENT_CONVERSION);
}
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
+ }
if (value() instanceof FnLabelEnd
&& direction == Constants.DIRECTION_END) {
final FnLabelEnd function = (FnLabelEnd) value();
@@ -120,11 +119,6 @@
final DtLength lengthDT = function.eval(fobj, ipdContainingRA);
return lengthDT.getValue(fobj.traitFontSize(context), 0);
}
- if (value() instanceof ExprNumeric) {
- final ExprNumeric expression = (ExprNumeric) value();
- return expression.getLength(fobj.traitFontSize(context),
- ipdContainingRA);
- }
return getValueNoInstance(context, fobj, direction, ipdContainingRA);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/InitialPageNumber.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/InitialPageNumber.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/InitialPageNumber.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -61,11 +61,11 @@
public 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 = standardParse(propertyList, value, true, false);
if (pv instanceof DtInteger) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Keep.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Keep.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Keep.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -80,11 +80,11 @@
public 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 = standardParse(propertyList, value, false, false);
if (pv instanceof DtInteger) {
final int integer = ((DtInteger) pv).getValue();
return new DtKeep(integer, integer, integer);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Language.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Language.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Language.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -64,8 +64,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
if (ISO639.validLanguage(value)) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -33,9 +33,8 @@
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.DtPercentage;
-import org.foray.fotree.value.ExprNumeric;
+import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
import org.axsl.common.Constants;
@@ -60,41 +59,30 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
- if (pv instanceof ExprNumeric) {
- if (((ExprNumeric) pv).canEvaluateLength()) {
- return pv;
- }
- throw unexpectedValue(value, propertyList);
- }
throw unexpectedValue(value, propertyList);
}
public int getValue(final FOContext context, final FObj fobj,
final int ipdAncestorBANotLA) {
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
final DtPercentage percentageDT = (DtPercentage) value();
final float percentage = percentageDT.getValue();
return Math.round(percentage * ipdAncestorBANotLA /
WKConstants.PERCENT_CONVERSION);
}
- if (value() instanceof ExprNumeric) {
- final int fontSize = fobj.traitFontSize(context);
- return ((ExprNumeric) value()).getLength(fontSize, 0);
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
}
return getValueNoInstance(context, fobj, ipdAncestorBANotLA);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderLength.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderLength.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderLength.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -37,6 +37,7 @@
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtLengthRange;
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,18 +76,18 @@
public 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 = standardParse(propertyList, value, false, true);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
+ return pv;
+ }
+ if (pv.validLength()) {
final DtLength length = (DtLength) pv;
return new DtLengthRange(length, length, length);
}
- if (pv instanceof DtPercentage) {
- return pv;
- }
throw unexpectedValue(value, propertyList);
}
@@ -106,7 +107,7 @@
final FObj fobj, final int parentAreaCRIPD) {
if (value() instanceof DtLengthRange) {
final DtLengthRange lengthRange = (DtLengthRange) value();
- DtLength length = null;
+ ExprNumeric length = null;
switch (subProperty) {
case MINIMUM: {
length = lengthRange.getLengthMinimum();
@@ -127,7 +128,7 @@
if (length == null) {
return 0;
}
- return length.getValue(fobj.traitFontSize(context),
+ return length.getLength(fobj.traitFontSize(context),
parentAreaCRIPD);
}
if (value() instanceof PropertyKeyword) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeDimension.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeDimension.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeDimension.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -34,6 +34,7 @@
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtLengthRange;
import org.foray.fotree.value.DtPercentage;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -83,7 +84,7 @@
final FObj fobj, final int parentAreaCRDimension) {
if (value() instanceof DtLengthRange) {
final DtLengthRange lengthRange = (DtLengthRange) value();
- DtLength length = null;
+ ExprNumeric length = null;
switch (subProperty) {
case MINIMUM: {
length = lengthRange.getLengthMinimum();
@@ -104,7 +105,7 @@
if (length == null) {
return Constants.DIMENSION_AUTO;
}
- return length.getValue(fobj.traitFontSize(context), 0);
+ return length.getLength(fobj.traitFontSize(context), 0);
}
if (value() instanceof DtLength) {
final DtLength length = (DtLength) value();
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthRange.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthRange.java 2006-10-28 21:31:59 UTC (rev 8448)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthRange.java 2006-10-28 22:57:49 UTC (rev 8449)
@@ -28,47 +28,77 @@
package org.foray.fotree.value;
+import org.foray.fotree.PropertyException;
+
/**
* A length-range datatype in XSL.
* This datatype is described in the XSL-FO Standard 1.0, at Section 5.11.
*/
public class DtLengthRange extends Datatype {
- private DtLength lengthMinimum;
- private DtLength lengthOptimum;
- private DtLength lengthMaximum;
+ private ExprNumeric lengthMinimum;
+ private ExprNumeric lengthOptimum;
+ private ExprNumeric lengthMaximum;
/**
* Constructor.
*/
- public DtLengthRange(final DtLength lengthMinimum,
- final DtLength lengthOptimum, final DtLength lengthMaximum) {
+ public DtLengthRange(final ExprNumeric lengthMinimum,
+ final ExprNumeric lengthOptimum, final ExprNumeric lengthMaximum)
+ throws PropertyException {
+ if (! lengthOptimum.canEvaluateLength()) {
+ throw new PropertyException("Optimum value must evaluate to a " +
+ "length.");
+ }
+ if (! lengthMinimum.canEvaluateLength()) {
+ throw new PropertyException("Minimum value must evaluate to a " +
+ "length.");
+ }
+ if (! lengthMaximum.canEvaluateLength()) {
+ throw new PropertyException("Maximum value must evaluate to a " +
+ "length.");
+ }
this.lengthMinimum = lengthMinimum;
this.lengthOptimum = lengthOptimum;
this.lengthMaximum = lengthMaximum;
}
- public void setLengthMinimum(final DtLength lengthMinimum) {
+ public void setLengthMinimum(final ExprNumeric lengthMinimum)
+ throws PropertyException {
+ if (! lengthMinimum.canEvaluateLength()) {
+ throw new PropertyException("Minimum value must evaluate to a " +
+ "length.");
+ }
this.lengthMinimum = lengthMinimum;
}
- public void setLengthOptimum(final DtLength lengthOptimum) {
+ public void setLengthOptimum(final DtLength lengthOptimum)
+ throws PropertyException {
+ if (! lengthOptimum.canEvaluateLength()) {
+ throw new PropertyException("Optimum value must evaluate to a " +
+ "length.");
+ }
this.lengthOptimum = lengthOptimum;
}
- public void setLengthMaximum(final DtLength lengthMaximum) {
+ public void setLengthMaximum(final DtLength lengthMaximum)
+ throws PropertyException {
+ if (! lengthMaximum.canEvaluateLength()) {
+ throw new PropertyException("Maximum value must evaluate to a " +
+ "length.");
+ }
this.lengthMaximum = lengthMaximum;
}
- public DtLength getLengthMinimum() {
+ public ExprNumeric getLengthMinimum() {
return this.lengthMinimum;
}
- public DtLength getLengthOptimum() {
+ public ExprNumeric getLengthOptimum() {
return this.lengthOptimum;
}
- public DtLength getLengthMaximum() {
+ public ExprNumeric getLengthMaximum() {
return this.lengthMaximum;
}
@@ -80,7 +110,7 @@
* @return True if successful, false if the subPropertyName is not valid.
*/
public boolean setComponent(final String subPropertyName,
- final DtLength length) {
+ final DtLength length) throws PropertyException {
if (subPropertyName.equals("minimum")) {
setLengthMinimum(length);
return true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-28 21:32:14
|
Revision: 8448
http://svn.sourceforge.net/foray/?rev=8448&view=rev
Author: victormote
Date: 2006-10-28 14:31:59 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Use new convenience methods where possible.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteOffset.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentAdjust.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BaselineShift.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSeparation.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSpacing.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderWidth.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnGap.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnWidth.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentDimension.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DestinationPlacementOffset.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthBPIPDirection.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteOffset.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteOffset.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteOffset.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -71,11 +71,8 @@
if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof ExprNumeric) {
- final ExprNumeric numeric = (ExprNumeric) pv;
- if (numeric.canEvaluateLength()) {
- return pv;
- }
+ if (pv.validLength()) {
+ return pv;
}
throw unexpectedValue(value, propertyList);
}
@@ -103,15 +100,12 @@
/ WKConstants.PERCENT_CONVERSION);
}
if (value() instanceof ExprNumeric) {
- final ExprNumeric numeric = (ExprNumeric) value();
- final int fontSize = fobj.traitFontSize(context);
/*
* The XSL-FO Standard 1.0 does not specify whether negative values
* are allowed or not, but the CSS2 standard says that they are
* allowed.
*/
- final int lengthValue = numeric.getLength(fontSize, 0);
- return lengthValue;
+ return value().asLength(fobj, context);
}
/* This is an error that should already be caught. */
return getValueNoInstance();
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentAdjust.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentAdjust.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentAdjust.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -35,9 +35,7 @@
import org.foray.fotree.fo.obj.Character;
import org.foray.fotree.fo.obj.ExternalGraphic;
import org.foray.fotree.fo.obj.InstreamForeignObject;
-import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
-import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -83,11 +81,8 @@
if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof ExprNumeric) {
- final ExprNumeric numeric = (ExprNumeric) pv;
- if (numeric.canEvaluateLength()) {
- return pv;
- }
+ if (pv.validLength()) {
+ return pv;
}
throw unexpectedValue(value, propertyList);
}
@@ -105,7 +100,7 @@
}
}
}
- if (value() instanceof DtLength) {
+ if (value().validLength()) {
return Constants.FOVAL_NOT_A_KEYWORD;
}
if (value() instanceof DtPercentage) {
@@ -116,10 +111,6 @@
public int traitValueAmount(final FOContext context, final FObj fobj,
final int areaHeight) {
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
int base = 0;
if (fobj instanceof ExternalGraphic
@@ -132,6 +123,9 @@
base = fobj.getPropertyList().getLineHeight(context, OPTIMUM);
return (int) ((DtPercentage) value()).getValue() * base;
}
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
+ }
return traitValueAmountNoInstance();
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -35,7 +35,6 @@
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
-import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyCollection;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -94,11 +93,8 @@
if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof ExprNumeric) {
- final ExprNumeric numeric = (ExprNumeric) pv;
- if (numeric.canEvaluateLength()) {
- return pv;
- }
+ if (pv.validLength()) {
+ return pv;
}
throw unexpectedValue(value, propertyList);
}
@@ -196,10 +192,8 @@
* (paddingRectangleDimension
- backgroundImageDimension));
}
- if (value() instanceof ExprNumeric) {
- final ExprNumeric numeric = (ExprNumeric) value();
- final int fontSize = fobj.traitFontSize(context);
- return numeric.getLength(fontSize, 0);
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
}
if (value() instanceof PropertyKeyword) {
final short keyword = ((PropertyKeyword) value()).getValue();
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BaselineShift.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BaselineShift.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BaselineShift.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -33,7 +33,6 @@
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtPercentage;
-import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -111,9 +110,7 @@
/* The spec specifically points out percentages as being relative
* to the parent-area's line-height, so we assume here that any
* relative length is relative to the current object. */
- final ExprNumeric numeric = value().asNumeric();
- final int fontSize = fobj.traitFontSize(context);
- return numeric.getLength(fontSize, 0);
+ return value().asLength(fobj, context);
}
return traitValueNoInstance();
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -32,7 +32,6 @@
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtColor;
-import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.PropertyCollection;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -121,7 +120,7 @@
// Now try using the standard parse
final PropertyValue pv = standardParse(propertyList, token, false,
false);
- if (pv instanceof DtLength) {
+ if (pv.validLength()) {
return new BorderWidth(Constants.FOPROP_BORDER_WIDTH, pv);
}
if (pv instanceof DtColor) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSeparation.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSeparation.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSeparation.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -34,6 +34,7 @@
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtLengthBPIPDirection;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -96,16 +97,16 @@
if (value() instanceof DtLengthBPIPDirection) {
final DtLengthBPIPDirection lengthDir = (DtLengthBPIPDirection)
value();
+ ExprNumeric numeric = null;
+ final int fontSize = fobj.traitFontSize(context);
switch (axis) {
case Constants.AXIS_BP: {
- return lengthDir.getBPDLength().getValue(fobj.traitFontSize(
- context),
- 0);
+ numeric = lengthDir.getBPDLength();
+ return numeric.getLength(fontSize, 0);
}
case Constants.AXIS_IP: {
- return lengthDir.getIPDLength().getValue(fobj.traitFontSize(
- context),
- 0);
+ numeric = lengthDir.getIPDLength();
+ return numeric.getLength(fontSize, 0);
}
}
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSpacing.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSpacing.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSpacing.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -30,8 +30,8 @@
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
-import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtLengthBPIPDirection;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyValue;
import org.axsl.common.Constants;
@@ -69,22 +69,22 @@
switch (st.countTokens()) {
case 1: {
pv = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
- final DtLength length = (DtLength) pv;
+ if (pv.validLength()) {
+ final ExprNumeric length = pv.asNumeric();
return new DtLengthBPIPDirection(length, length);
}
}
case 2: {
pv = standardParse(propertyList, st.nextToken(), false, false);
- if (! (pv instanceof DtLength)) {
+ if (! (pv.validLength())) {
break;
}
- final DtLength length1 = (DtLength) pv;
+ final ExprNumeric length1 = (ExprNumeric) pv;
pv = standardParse(propertyList, st.nextToken(), false, false);
- if (! (pv instanceof DtLength)) {
+ if (! (pv.validLength())) {
break;
}
- final DtLength length2 = (DtLength) pv;
+ final ExprNumeric length2 = (ExprNumeric) pv;
return new DtLengthBPIPDirection(length2, length1);
}
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderWidth.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderWidth.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderWidth.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -95,7 +95,7 @@
if (pv instanceof PropertyKeyword) {
return pv;
}
- if (pv instanceof DtLength) {
+ if (pv.validLength()) {
return pv;
}
if (pv instanceof DtLengthConditional) {
@@ -126,11 +126,9 @@
if (value() instanceof PropertyKeyword) {
return getKeywordValue(context, direction, fobj, isOuterEdge);
}
- if (value() instanceof DtLength) {
- final DtLength length = (DtLength) value();
- final int lengthValue = length.getValue(fobj.traitFontSize(context),
- 0);
- return Math.max(lengthValue, 0);
+ if (value().validLength()) {
+ final int length = value().asLength(fobj, context);
+ return Math.max(length, 0);
}
if (value() instanceof DtLengthConditional
&& direction >= Constants.DIRECTION_START
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnGap.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnGap.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnGap.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -35,7 +35,6 @@
import org.foray.fotree.PropertyList;
import org.foray.fotree.fo.obj.RegionBody;
import org.foray.fotree.value.DtPercentage;
-import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -103,9 +102,7 @@
/ WKConstants.PERCENT_CONVERSION);
}
if (value().validLength()) {
- final ExprNumeric numeric = value().asNumeric();
- final int fontSize = fobj.traitFontSize(context);
- return numeric.getLength(fontSize, 0);
+ return value().asLength(fobj, context);
}
return 0;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnWidth.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnWidth.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnWidth.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -32,7 +32,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.DtPercentage;
import org.foray.fotree.value.FnProportionalColWidth;
import org.foray.fotree.value.PropertyValue;
@@ -55,10 +54,10 @@
final String value) throws PropertyException {
final PropertyValue pv = standardParse(propertyList, value, false,
false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
if (pv instanceof FnProportionalColWidth) {
@@ -70,15 +69,14 @@
public int getValue(final FOContext context, final FObj fobj,
final int tableWidth) {
- if (value() instanceof DtLength) {
- final int fontSize = fobj.traitFontSize(context);
- return ((DtLength) value()).getValue(fontSize, 0);
- }
if (value() instanceof DtPercentage) {
final DtPercentage percentageDT = (DtPercentage) value();
final float percentage = percentageDT.getValue();
return Math.round(percentage * tableWidth);
}
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
+ }
/*
* It could also be a proportional width, which is stored as a NumberDT,
* and is processed in getValueProportional.
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentDimension.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentDimension.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentDimension.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -34,7 +34,6 @@
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtPercentage;
-import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -132,9 +131,7 @@
return percentage / WKConstants.PERCENT_CONVERSION;
}
if (value().validLength()) {
- final ExprNumeric numeric = value().asNumeric();
- final int fontSize = fobj.traitFontSize(context);
- final float length = numeric.getLength(fontSize, 0);
+ final int length = value().asLength(fobj, context);
return length / intrinsicContentDimension;
}
return getValueNoInstance();
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DestinationPlacementOffset.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DestinationPlacementOffset.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DestinationPlacementOffset.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -32,7 +32,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.PropertyValue;
import org.axsl.foR.FOContext;
@@ -53,16 +52,15 @@
final String value) throws PropertyException {
final PropertyValue pv = standardParse(propertyList, value, false,
false);
- if (pv instanceof DtLength) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
}
public int getValue(final FOContext context, final FObj fobj) {
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
}
return getValueNoInstance();
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthBPIPDirection.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthBPIPDirection.java 2006-10-28 20:55:03 UTC (rev 8447)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthBPIPDirection.java 2006-10-28 21:31:59 UTC (rev 8448)
@@ -28,37 +28,53 @@
package org.foray.fotree.value;
+import org.foray.fotree.PropertyException;
+
/**
* A length-conditional datatype in XSL. This datatype is described in the
* XSL-FO Standard 1.0, at Section 5.11.
*/
public class DtLengthBPIPDirection extends Datatype {
- private DtLength bpdLength;
- private DtLength ipdLength;
+ private ExprNumeric bpdLength;
+ private ExprNumeric ipdLength;
/**
* Constructor.
*/
- public DtLengthBPIPDirection(final DtLength bpdLength,
- final DtLength ipdLength) {
+ public DtLengthBPIPDirection(final ExprNumeric bpdLength,
+ final ExprNumeric ipdLength) throws PropertyException {
+ if (! bpdLength.canEvaluateLength()) {
+ throw new PropertyException("BPD must evaluate to a length.");
+ }
+ if (! ipdLength.canEvaluateLength()) {
+ throw new PropertyException("IPD must evaluate to a length.");
+ }
this.bpdLength = bpdLength;
this.ipdLength = ipdLength;
}
- public void setBPDLength(final DtLength length) {
+ public void setBPDLength(final ExprNumeric length)
+ throws PropertyException {
+ if (! bpdLength.canEvaluateLength()) {
+ throw new PropertyException("BPD must evaluate to a length.");
+ }
this.bpdLength = length;
}
- public DtLength getBPDLength() {
+ public ExprNumeric getBPDLength() {
return this.bpdLength;
}
- public void setIPDLength(final DtLength length) {
+ public void setIPDLength(final ExprNumeric length)
+ throws PropertyException {
+ if (! ipdLength.canEvaluateLength()) {
+ throw new PropertyException("IPD must evaluate to a length.");
+ }
this.ipdLength = length;
}
- public DtLength getIPDLength() {
+ public ExprNumeric getIPDLength() {
return this.ipdLength;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-28 20:55:31
|
Revision: 8447
http://svn.sourceforge.net/foray/?rev=8447&view=rev
Author: victormote
Date: 2006-10-28 13:55:03 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
1. Add some convenience methods to PropertyValue to make parsing cleaner.
2. Some steps toward making the parsing methods more static.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Azimuth.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Background.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundImage.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BaselineShift.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Boolean.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderPrecedence.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSeparation.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSpacing.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderStyle.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Character.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Clip.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Color.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnCount.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnGap.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentDimension.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentType.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Country.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Cue.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DisplayAlign.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DominantBaseline.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Elevation.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Enumerated.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Extent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCountry.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyValue.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 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -166,7 +166,7 @@
protected PropertyValue standardParse(final PropertyList propertyList,
final String rawPropertyValue, final boolean integerOnly,
final boolean percentsAsLengths) throws PropertyException {
- PropertyValue pv = checkKeywords(rawPropertyValue);
+ PropertyValue pv = checkKeywords(getValidKeywords(), rawPropertyValue);
if (pv != null) {
return pv;
}
@@ -190,7 +190,12 @@
protected abstract short[] getValidKeywords();
protected PropertyKeyword checkKeywords(final String possibleKeyword) {
- final short[] validKeywords = getValidKeywords();
+ /* TODO: Remove this method! */
+ return checkKeywords(this.getValidKeywords(), possibleKeyword);
+ }
+
+ protected PropertyKeyword checkKeywords(final short[] validKeywords,
+ final String possibleKeyword) {
final short kwIndex = getKeywordIndex(possibleKeyword, validKeywords);
if (kwIndex < 1) {
return null;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Azimuth.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Azimuth.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Azimuth.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -124,7 +124,8 @@
throw unexpectedValue(value, propertyList);
}
}
- PropertyValue pv = checkKeywords(remainingValue);
+ PropertyValue pv = checkKeywords(this.getValidKeywords(),
+ remainingValue);
if (pv != null) {
final short keyword = ((PropertyKeyword) pv).getValue();
switch (keyword) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Background.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Background.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Background.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -64,7 +64,7 @@
final String propertyFullName, final String value)
throws PropertyException {
final PropertyCollection collection = new PropertyCollection();
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
collection.addItem(new BackgroundColor(propertyList,
Constants.FOPROP_BACKGROUND_COLOR, pv));
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundImage.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundImage.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundImage.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -70,12 +70,12 @@
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 = DtURI.makeUriDT(value);
- if (pv != null) {
+ if (pv instanceof DtURI) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -35,6 +35,7 @@
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyCollection;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -85,17 +86,19 @@
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 = DtPercentage.makePercentageDT(value);
- if (pv != null) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- pv = DtLength.makeLengthDT(value);
- if (pv != null) {
- return pv;
+ if (pv instanceof ExprNumeric) {
+ final ExprNumeric numeric = (ExprNumeric) pv;
+ if (numeric.canEvaluateLength()) {
+ return pv;
+ }
}
throw unexpectedValue(value, propertyList);
}
@@ -103,7 +106,7 @@
private PropertyValue createShorthandValue(final PropertyList propertyList,
final String value) throws PropertyException {
final PropertyCollection collection = new PropertyCollection();
- PropertyValue pv = checkKeywords(value);
+ PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
final BackgroundPosition property = new BackgroundPosition(
propertyList, getPropertyType(), pv);
@@ -187,16 +190,17 @@
public int getValue(final FOContext context, final FObj fobj,
final byte axis, final int paddingRectangleDimension,
final int backgroundImageDimension) {
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
final float percent = ((DtPercentage) value()).getValue();
return Math.round(percent / WKConstants.PERCENT_CONVERSION
* (paddingRectangleDimension
- backgroundImageDimension));
}
+ if (value() instanceof ExprNumeric) {
+ final ExprNumeric numeric = (ExprNumeric) value();
+ final int fontSize = fobj.traitFontSize(context);
+ return numeric.getLength(fontSize, 0);
+ }
if (value() instanceof PropertyKeyword) {
final short keyword = ((PropertyKeyword) value()).getValue();
switch (keyword) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BaselineShift.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BaselineShift.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BaselineShift.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -32,8 +32,8 @@
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.DtPercentage;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -62,15 +62,15 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -101,19 +101,20 @@
}
}
}
- if (value() instanceof DtLength) {
- /* The spec specifically points out percentages as being relative
- * to the parent-area's line-height, so we assume here that any
- * relative length is relative to the current object. */
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
/* TODO: This base value is almost certainly wrong. */
final int base = fobj.effectiveParent(context)
.getPropertyList().getLineHeight(context, OPTIMUM);
return Math.round(((DtPercentage) value()).getValue() * base);
}
+ if (value().validLength()) {
+ /* The spec specifically points out percentages as being relative
+ * to the parent-area's line-height, so we assume here that any
+ * relative length is relative to the current object. */
+ final ExprNumeric numeric = value().asNumeric();
+ final int fontSize = fobj.traitFontSize(context);
+ return numeric.getLength(fontSize, 0);
+ }
return traitValueNoInstance();
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Boolean.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Boolean.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Boolean.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -63,8 +63,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderPrecedence.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderPrecedence.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderPrecedence.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -83,12 +83,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 = standardParse(propertyList, value, false, false);
if (pv instanceof DtInteger) {
+ /* TODO: Generalize for expressions? */
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSeparation.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSeparation.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSeparation.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -65,7 +65,7 @@
throws PropertyException {
PropertyValue pv = null;
if (subPropertyName == null) {
- pv = checkKeywords(value);
+ pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSpacing.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSpacing.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderSpacing.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -61,7 +61,7 @@
public PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
+ PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderStyle.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderStyle.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderStyle.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -97,9 +97,10 @@
*/
private PropertyValue createSimpleValue(final String value,
final PropertyList propertyList) throws PropertyException {
- final PropertyKeyword kw = checkKeywords(value);
- if (kw != null) {
- return kw;
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
+ return pv;
}
throw unexpectedValue(value, propertyList);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Character.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Character.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Character.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -65,7 +65,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Clip.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Clip.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Clip.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -59,7 +59,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
+ PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Color.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Color.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Color.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -68,11 +68,11 @@
if (dtColor != null) {
return dtColor;
}
- PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
- pv = standardParse(propertyList, value, false, false);
if (pv instanceof ExprColor) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnCount.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnCount.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnCount.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -57,12 +57,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 = standardParse(propertyList, value, true, false);
if (pv instanceof DtInteger) {
+ /* TODO: Generalize for expressions? */
((DtInteger) pv).setMinimumValue(1);
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnGap.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnGap.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnGap.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -34,8 +34,8 @@
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
import org.foray.fotree.fo.obj.RegionBody;
-import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -64,15 +64,15 @@
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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -91,10 +91,6 @@
}
}
}
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
int base = 0;
if (fobj instanceof RegionBody) {
@@ -106,6 +102,11 @@
return Math.round(percentage * base
/ WKConstants.PERCENT_CONVERSION);
}
+ if (value().validLength()) {
+ final ExprNumeric numeric = value().asNumeric();
+ final int fontSize = fobj.traitFontSize(context);
+ return numeric.getLength(fontSize, 0);
+ }
return 0;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentDimension.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentDimension.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentDimension.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -33,8 +33,8 @@
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.DtPercentage;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -62,15 +62,15 @@
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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -126,17 +126,17 @@
}
}
}
- if (value() instanceof DtLength) {
- final DtLength dtLength = (DtLength) value();
- final float length = dtLength.getValue(fobj.traitFontSize(context),
- 0);
- return length / intrinsicContentDimension;
- }
if (value() instanceof DtPercentage) {
final DtPercentage percentageDT = (DtPercentage) value();
final float percentage = percentageDT.getValue();
return percentage / WKConstants.PERCENT_CONVERSION;
}
+ if (value().validLength()) {
+ final ExprNumeric numeric = value().asNumeric();
+ final int fontSize = fobj.traitFontSize(context);
+ final float length = numeric.getLength(fontSize, 0);
+ return length / intrinsicContentDimension;
+ }
return getValueNoInstance();
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentType.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentType.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ContentType.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -56,7 +56,7 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
+ final PropertyValue pv = checkKeywords(this.getValidKeywords(), value);
if (pv != null) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Country.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Country.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Country.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -63,8 +63,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
if (DtCountry.validCountry(value)) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Cue.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Cue.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Cue.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -71,12 +71,12 @@
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 = DtURI.makeUriDT(value);
- if (pv != null) {
+ if (pv instanceof DtURI) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DisplayAlign.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DisplayAlign.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DisplayAlign.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -61,8 +61,9 @@
public PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DominantBaseline.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DominantBaseline.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/DominantBaseline.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -69,8 +69,9 @@
public PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Elevation.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Elevation.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Elevation.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -67,12 +67,12 @@
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 = DtAngle.makeAngleDT(value);
- if (pv != null) {
+ if (pv instanceof DtAngle) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Enumerated.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Enumerated.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Enumerated.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -59,8 +59,9 @@
private PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Extent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Extent.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Extent.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -37,7 +37,6 @@
import org.foray.fotree.fo.obj.RegionBefore;
import org.foray.fotree.fo.obj.RegionEnd;
import org.foray.fotree.fo.obj.RegionStart;
-import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
import org.foray.fotree.value.DtWritingMode;
import org.foray.fotree.value.PropertyKeyword;
@@ -64,15 +63,15 @@
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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
+ if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof DtPercentage) {
+ if (pv.validLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -94,10 +93,6 @@
}
}
}
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(context),
- 0);
- }
if (value() instanceof DtPercentage) {
final int base = computeBase(context, fobj);
final DtPercentage percentageDT = (DtPercentage) value();
@@ -105,6 +100,9 @@
return Math.round(percentage * base
/ WKConstants.PERCENT_CONVERSION);
}
+ if (value().validLength()) {
+ return value().asLength(fobj, context);
+ }
return 0;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCountry.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCountry.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCountry.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -35,6 +35,8 @@
* @see org.foray.common.ISO3166
*/
public class DtCountry extends Datatype {
+ /* TODO: Make this class immutable, make the constructor private, and create
+ * only one instance for each country. */
/** The ISO 3166 code. */
private String value = null;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyValue.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyValue.java 2006-10-28 19:57:55 UTC (rev 8446)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyValue.java 2006-10-28 20:55:03 UTC (rev 8447)
@@ -28,6 +28,10 @@
package org.foray.fotree.value;
+import org.foray.fotree.FObj;
+
+import org.axsl.foR.FOContext;
+
/**
* Class representing an XSL-FO property value. For now, we consider a value to
* be either a) a valid datatype, or b) an expression (which contains valid
@@ -35,5 +39,46 @@
*/
public abstract class PropertyValue {
+ /**
+ * Convenience method indicating whether this property value is a valid
+ * length.
+ * To be a valid length the property must be numeric and have a unit power
+ * of 1.
+ * @return True iff this property is a valid length.
+ */
+ public boolean validLength() {
+ if (! (this instanceof ExprNumeric)) {
+ return false;
+ }
+ final ExprNumeric numeric = (ExprNumeric) this;
+ return numeric.canEvaluateLength();
+ }
+ /**
+ * Convenience method returning this cast as an ExprNumeric, if possible.
+ * @return This instance, cast as an ExprNumeric, or null if this is not
+ * an ExprNumeric.
+ */
+ public ExprNumeric asNumeric() {
+ if (this instanceof ExprNumeric) {
+ return (ExprNumeric) this;
+ }
+ return null;
+ }
+
+ /**
+ * Convenience method returning a length value from the property value.
+ * This should generally be used only if the property value has already
+ * been tested to be a valid length.
+ * @return The length, in millipoints.
+ */
+ public int asLength(final FObj fobj, final FOContext context) {
+ final ExprNumeric numeric = this.asNumeric();
+ if (numeric == null) {
+ return Integer.MIN_VALUE;
+ }
+ final int fontSize = fobj.traitFontSize(context);
+ return numeric.getLength(fontSize, 0);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-28 19:58:07
|
Revision: 8446
http://svn.sourceforge.net/foray/?rev=8446&view=rev
Author: victormote
Date: 2006-10-28 12:57:55 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Only construct one instance of PropertyKeyword per keyword.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextDecoration.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtRectangle.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyKeyword.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 19:34:36 UTC (rev 8445)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java 2006-10-28 19:57:55 UTC (rev 8446)
@@ -195,7 +195,7 @@
if (kwIndex < 1) {
return null;
}
- return new PropertyKeyword(kwIndex);
+ return PropertyKeyword.getPropertyKeyword(kwIndex);
}
public static short getKeywordIndex(final String possibleKeyword,
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java 2006-10-28 19:34:36 UTC (rev 8445)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BackgroundPosition.java 2006-10-28 19:57:55 UTC (rev 8446)
@@ -124,14 +124,14 @@
final short keyword = getKeywordIndex(token,
VALID_KEYWORDS_HORIZONTAL);
if (keyword > 0 && keyword != Constants.FOVAL_INHERIT) {
- pv = new PropertyKeyword(keyword);
+ pv = PropertyKeyword.getPropertyKeyword(keyword);
}
}
if (pv == null) {
final short keyword = getKeywordIndex(token,
VALID_KEYWORDS_VERTICAL);
if (keyword > 0 && keyword != Constants.FOVAL_INHERIT) {
- pv = new PropertyKeyword(keyword);
+ pv = PropertyKeyword.getPropertyKeyword(keyword);
}
}
if (pv != null) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java 2006-10-28 19:34:36 UTC (rev 8445)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Border.java 2006-10-28 19:57:55 UTC (rev 8446)
@@ -104,13 +104,13 @@
BorderStyle.VALID_KEYWORDS);
if (keyword > 0) {
return new BorderStyle(Constants.FOPROP_BORDER_STYLE,
- new PropertyKeyword(keyword));
+ PropertyKeyword.getPropertyKeyword(keyword));
}
// Now check the width keywords
keyword = Property.getKeywordIndex(token, BorderWidth.VALID_KEYWORDS);
if (keyword > 0) {
return new BorderWidth(Constants.FOPROP_BORDER_WIDTH,
- new PropertyKeyword(keyword));
+ PropertyKeyword.getPropertyKeyword(keyword));
}
// Now check for color keywords
final DtColor dtColor = DtColor.mapNameToColorRGB(token);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextDecoration.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextDecoration.java 2006-10-28 19:34:36 UTC (rev 8445)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextDecoration.java 2006-10-28 19:57:55 UTC (rev 8446)
@@ -62,7 +62,7 @@
return new DtTextDeco(false, false, false, false);
}
if (value.equals("inherit")) {
- return new PropertyKeyword(Constants.FOVAL_INHERIT);
+ return PropertyKeyword.getPropertyKeyword(Constants.FOVAL_INHERIT);
}
/*
* text-decoration can have multiple words in it, so we loop through
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtRectangle.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtRectangle.java 2006-10-28 19:34:36 UTC (rev 8445)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtRectangle.java 2006-10-28 19:57:55 UTC (rev 8446)
@@ -140,7 +140,7 @@
while (st.hasMoreTokens()) {
final String token = st.nextToken();
if (token.equals("inherit")) {
- pvArray[pvIndex] = new PropertyKeyword(
+ pvArray[pvIndex] = PropertyKeyword.getPropertyKeyword(
Constants.FOVAL_INHERIT);
}
final DtLength length = DtLength.makeLengthDT(token);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyKeyword.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyKeyword.java 2006-10-28 19:34:36 UTC (rev 8445)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyKeyword.java 2006-10-28 19:57:55 UTC (rev 8446)
@@ -28,20 +28,58 @@
package org.foray.fotree.value;
+import org.axsl.common.Constants;
+
/**
* Class encapsulating those property values that are expressed as keywords
- * (e.g. "inherit", "auto", "true", etc.)
+ * (e.g. "inherit", "auto", "true", etc.).
+ * Instances of this class are immutable and are therefore treated as a group
+ * of singletons, one for each possible keyword value.
*/
-public class PropertyKeyword extends ExprPrimary {
+public final class PropertyKeyword extends ExprPrimary {
+ private static PropertyKeyword[] keywords = new PropertyKeyword[
+ Constants.PROPERTY_KEYWORD_VALUES.length];
+
+ /** The encapsulated keyword enumeration. */
private short value;
- public PropertyKeyword(final short value) {
+ /**
+ * Private constructor. Use {@link #getPropertyKeyword(short)} to obtain an
+ * instance of this class.
+ * @param value The keyword enumeration value to encapsulate in this object.
+ */
+ private PropertyKeyword(final short value) {
this.value = value;
}
+ /**
+ * Return the keyword enumeration.
+ * @return The keyword enumeration.
+ * @see Constants#FOVAL_NUM_NEGATIVE_180 and following for the property
+ * keyword enumerations.
+ */
public short getValue() {
return value;
}
+ /**
+ * Gets or creates the singleton instance for the specific keyword value.
+ * There is no need for multiple instances of this class for the same
+ * keyword.
+ * @param value The value for which the singleton instance is needed.
+ * @return The singleton keyword instance, or null if the value is an
+ * invalid keyword index.
+ */
+ public static PropertyKeyword getPropertyKeyword(final short value) {
+ if (value < 1
+ || value >= Constants.PROPERTY_KEYWORD_VALUES.length) {
+ return null;
+ }
+ if (keywords[value] == null) {
+ keywords[value] = new PropertyKeyword(value);
+ }
+ return keywords[value];
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-28 19:34:43
|
Revision: 8445
http://svn.sourceforge.net/foray/?rev=8445&view=rev
Author: victormote
Date: 2006-10-28 12:34:36 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Use standardParse where possible.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteDimension.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteOffset.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentAdjust.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentBaseline.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderWidth.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteDimension.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteDimension.java 2006-10-28 19:04:07 UTC (rev 8444)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteDimension.java 2006-10-28 19:34:36 UTC (rev 8445)
@@ -32,8 +32,8 @@
import org.foray.fotree.FObj;
import org.foray.fotree.PropertyException;
import org.foray.fotree.PropertyList;
-import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -70,26 +70,25 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
- return pv;
- }
if (pv instanceof DtPercentage) {
return pv;
}
+ if (pv instanceof ExprNumeric) {
+ final ExprNumeric numeric = (ExprNumeric) pv;
+ if (numeric.canEvaluateLength()) {
+ return pv;
+ }
+ }
throw unexpectedValue(value, propertyList);
}
public int getValue(final FOContext context, final byte relativeAxis,
final FObj fobj, final int dimAncestorGenByBlockLevelFO) {
- if (value() instanceof DtLength) {
- return ((DtLength) value()).getValue(fobj.traitFontSize(
- context), 0);
- }
if (value() instanceof DtPercentage) {
final int base = dimAncestorGenByBlockLevelFO;
final DtPercentage percentageDT = (DtPercentage) value();
@@ -97,6 +96,11 @@
return Math.round(percentage * base
/ WKConstants.PERCENT_CONVERSION);
}
+ if (value() instanceof ExprNumeric) {
+ final ExprNumeric numeric = (ExprNumeric) value();
+ final int fontSize = fobj.traitFontSize(context);
+ return numeric.getLength(fontSize, 0);
+ }
if (value() instanceof PropertyKeyword) {
final PropertyKeyword kw = (PropertyKeyword) value();
final short keyword = kw.getValue();
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteOffset.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteOffset.java 2006-10-28 19:04:07 UTC (rev 8444)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AbsoluteOffset.java 2006-10-28 19:34:36 UTC (rev 8445)
@@ -33,8 +33,8 @@
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.DtPercentage;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -63,18 +63,20 @@
public PropertyValue createPropertyValue(final PropertyList propertyList,
final short enumeration, 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 = DtLength.makeLengthDT(value);
- if (pv != null) {
- return pv;
- }
- pv = standardParse(propertyList, value, false, false);
if (pv instanceof DtPercentage) {
return pv;
}
+ if (pv instanceof ExprNumeric) {
+ final ExprNumeric numeric = (ExprNumeric) pv;
+ if (numeric.canEvaluateLength()) {
+ return pv;
+ }
+ }
throw unexpectedValue(value, propertyList);
}
@@ -95,23 +97,23 @@
}
}
}
- if (value() instanceof DtLength) {
- final DtLength length = (DtLength) value();
+ if (value() instanceof DtPercentage) {
+ final DtPercentage percent = (DtPercentage) value();
+ return Math.round(dimensionContainingBlock * percent.getValue()
+ / WKConstants.PERCENT_CONVERSION);
+ }
+ if (value() instanceof ExprNumeric) {
+ final ExprNumeric numeric = (ExprNumeric) value();
+ final int fontSize = fobj.traitFontSize(context);
/*
* The XSL-FO Standard 1.0 does not specify whether negative values
* are allowed or not, but the CSS2 standard says that they are
* allowed.
*/
- final int lengthValue = length.getValue(fobj.traitFontSize(context),
- 0);
+ final int lengthValue = numeric.getLength(fontSize, 0);
return lengthValue;
}
- if (value() instanceof DtPercentage) {
- final DtPercentage percent = (DtPercentage) value();
- return Math.round(dimensionContainingBlock * percent.getValue()
- / WKConstants.PERCENT_CONVERSION);
- }
- // This is an error that should already be caught.
+ /* This is an error that should already be caught. */
return getValueNoInstance();
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentAdjust.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentAdjust.java 2006-10-28 19:04:07 UTC (rev 8444)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentAdjust.java 2006-10-28 19:34:36 UTC (rev 8445)
@@ -37,6 +37,7 @@
import org.foray.fotree.fo.obj.InstreamForeignObject;
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -74,17 +75,20 @@
public 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 = standardParse(propertyList, value, false, false);
- if (pv instanceof DtLength) {
- return pv;
- }
if (pv instanceof DtPercentage) {
return pv;
}
+ if (pv instanceof ExprNumeric) {
+ final ExprNumeric numeric = (ExprNumeric) pv;
+ if (numeric.canEvaluateLength()) {
+ return pv;
+ }
+ }
throw unexpectedValue(value, propertyList);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentBaseline.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentBaseline.java 2006-10-28 19:04:07 UTC (rev 8444)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/AlignmentBaseline.java 2006-10-28 19:34:36 UTC (rev 8445)
@@ -69,8 +69,9 @@
public PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyValue pv = checkKeywords(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof PropertyKeyword) {
return pv;
}
throw unexpectedValue(value, propertyList);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderWidth.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderWidth.java 2006-10-28 19:04:07 UTC (rev 8444)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/BorderWidth.java 2006-10-28 19:34:36 UTC (rev 8445)
@@ -90,12 +90,11 @@
private PropertyValue createSimpleValue(final PropertyList propertyList,
final String value) throws PropertyException {
- final PropertyKeyword kw = checkKeywords(value);
- if (kw != null) {
- return kw;
- }
final PropertyValue pv = standardParse(propertyList, value, false,
false);
+ if (pv instanceof PropertyKeyword) {
+ return pv;
+ }
if (pv instanceof DtLength) {
return pv;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
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.
|
|
From: <vic...@us...> - 2006-10-28 14:49:00
|
Revision: 8443
http://svn.sourceforge.net/foray/?rev=8443&view=rev
Author: victormote
Date: 2006-10-28 07:48:53 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Add to-do items regardning whether body-start and label-end functions should implement ExprNumeric.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnBodyStart.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnLabelEnd.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnBodyStart.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnBodyStart.java 2006-10-28 14:39:41 UTC (rev 8442)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnBodyStart.java 2006-10-28 14:48:53 UTC (rev 8443)
@@ -40,6 +40,7 @@
* The "body-start" function in XSL-FO.
*/
public class FnBodyStart extends Function {
+ /* TODO: Should this class implement ExprNumeric? */
public FnBodyStart(final PropertyList propertyList, final Expr[] arguments)
throws PropertyException {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnLabelEnd.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnLabelEnd.java 2006-10-28 14:39:41 UTC (rev 8442)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnLabelEnd.java 2006-10-28 14:48:53 UTC (rev 8443)
@@ -41,6 +41,7 @@
* The "label-end" function in XSL-FO.
*/
public class FnLabelEnd extends Function {
+ /* TODO: Should this class implement ExprNumeric? */
public FnLabelEnd(final PropertyList propertyList, final Expr[] arguments)
throws PropertyException {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-28 14:39:56
|
Revision: 8442
http://svn.sourceforge.net/foray/?rev=8442&view=rev
Author: victormote
Date: 2006-10-28 07:39:41 -0700 (Sat, 28 Oct 2006)
Log Message:
-----------
Make the FnProportionalColWidth class implement ExprNumeric.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnWidth.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnProportionalColWidth.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnWidth.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnWidth.java 2006-10-27 21:42:33 UTC (rev 8441)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/ColumnWidth.java 2006-10-28 14:39:41 UTC (rev 8442)
@@ -90,7 +90,7 @@
if (value() instanceof FnProportionalColWidth) {
final FnProportionalColWidth function =
(FnProportionalColWidth) value();
- return function.eval().getNumericValue();
+ return function.getNumericValue();
}
return 0;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnProportionalColWidth.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnProportionalColWidth.java 2006-10-27 21:42:33 UTC (rev 8441)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnProportionalColWidth.java 2006-10-28 14:39:41 UTC (rev 8442)
@@ -32,12 +32,13 @@
import org.foray.fotree.PropertyList;
import org.foray.fotree.fo.obj.TableColumn;
+import org.axsl.common.Constants;
import org.axsl.foR.fo.Table;
/**
* The "proportional-column-width" function in XSL-FO.
*/
-public class FnProportionalColWidth extends Function {
+public class FnProportionalColWidth extends Function implements ExprNumeric {
public FnProportionalColWidth(final PropertyList propertyList,
final Expr[] arguments) throws PropertyException {
@@ -48,6 +49,17 @@
return "proportional-column-width";
}
+ private Table getTable(final PropertyList propertyList) {
+ Table table = null;
+ if (propertyList.getFObj() instanceof Table) {
+ table = (Table) propertyList.getFObj();
+ } else {
+ /* TODO: Provide the right context. */
+ table = propertyList.getFObj().getNearestTable(null);
+ }
+ return table;
+ }
+
public boolean argumentsValid(final PropertyList propertyList)
throws PropertyException {
/*
@@ -63,29 +75,60 @@
* function to be used within a table unless the table-layout is
* "fixed".
*/
- Table table = null;
- if (propertyList.getFObj() instanceof Table) {
- table = (Table) propertyList.getFObj();
- } else {
- /* TODO: Provide the right context. */
- table = propertyList.getFObj().getNearestTable(null);
- }
+ final Table table = getTable(propertyList);
if (table == null) {
throw new PropertyException("Ancestor 'table' object not found "
- + "for function 'proportional-column-width'.");
+ + "for function \"" + getFunctionName() + "\".");
}
+ if (table.traitTableLayout() != Constants.FOVAL_FIXED) {
+ throw new PropertyException("Table layout must be \"fixed\" for "
+ + "function \"" + getFunctionName() + "\".");
+ }
+ /* There must be exactly one argument. */
if (getArgs().length != 1) {
return false;
}
+ /* The one argument must be Numeric. */
if (! (getArgs()[0] instanceof ExprNumeric)) {
return false;
}
return true;
}
- public ExprNumeric eval() {
- // Existence and type already validated at parse-time.
- return (ExprNumeric) getArgs()[0];
+ private ExprNumeric argumentAsNumeric() {
+ /* Just return the raw numeric value here, not the computed length. */
+ return (ExprNumeric) this.getArgs()[0];
}
+ /**
+ * {@inheritDoc}
+ */
+ public double getNumericValue() {
+ return argumentAsNumeric().getNumericValue();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte getUnitPower() {
+ return argumentAsNumeric().getUnitPower();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canEvaluateLength() {
+ return argumentAsNumeric().canEvaluateLength();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getLength(final int pointSize, final int percentBase) {
+ /* TODO: Consider making this return the length instead of just the
+ * raw numeric value. This would seem to be more in line with the
+ * XSL-FO grammar. */
+ return argumentAsNumeric().getLength(pointSize, percentBase);
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-27 21:42:40
|
Revision: 8441
http://svn.sourceforge.net/foray/?rev=8441&view=rev
Author: victormote
Date: 2006-10-27 14:42:33 -0700 (Fri, 27 Oct 2006)
Log Message:
-----------
Make all of the numeric Functions implement the ExprNumeric interface.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnAbs.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMax.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMin.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnAbs.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnAbs.java 2006-10-27 18:17:38 UTC (rev 8440)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnAbs.java 2006-10-27 21:42:33 UTC (rev 8441)
@@ -34,7 +34,7 @@
/**
* The "abs" function in XSL-FO.
*/
-public class FnAbs extends Function {
+public class FnAbs extends Function implements ExprNumeric {
public FnAbs(final PropertyList propertyList, final Expr[] arguments)
throws PropertyException {
@@ -46,22 +46,47 @@
}
public boolean argumentsValid(final PropertyList propertyList) {
+ /* There must be exactly one argument. */
if (getArgs().length != 1) {
return false;
}
+ /* The argument must be numeric. */
if (! (getArgs()[0] instanceof ExprNumeric)) {
return false;
}
return true;
}
- public ExprNumeric eval(final PropertyList propertyList)
- throws PropertyException {
- double value = ((ExprNumeric) getArgs()[0]).getNumericValue();
- if (value < 0) {
- value *= -1;
- }
- return new DtNumber(value);
+ private ExprNumeric argumentAsNumeric() {
+ return (ExprNumeric) this.getArgs()[0];
}
+ /**
+ * {@inheritDoc}
+ */
+ public double getNumericValue() {
+ return Math.abs(argumentAsNumeric().getNumericValue());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte getUnitPower() {
+ return argumentAsNumeric().getUnitPower();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canEvaluateLength() {
+ return argumentAsNumeric().canEvaluateLength();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getLength(final int pointSize, final int percentBase) {
+ return Math.abs(argumentAsNumeric().getLength(pointSize, percentBase));
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java 2006-10-27 18:17:38 UTC (rev 8440)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java 2006-10-27 21:42:33 UTC (rev 8441)
@@ -34,7 +34,7 @@
/**
* The "ceiling" function in XSL-FO.
*/
-class FnCeiling extends Function {
+class FnCeiling extends Function implements ExprNumeric {
public FnCeiling(final PropertyList propertyList, final Expr[] arguments)
throws PropertyException {
@@ -46,20 +46,57 @@
}
public boolean argumentsValid(final PropertyList propertyList) {
+ /* There must be exactly one argument. */
if (getArgs().length != 1) {
return false;
}
+ /* The argument must be numeric. */
if (! (getArgs()[0] instanceof ExprNumeric)) {
return false;
}
+ /* The numeric must have a unit power of zero. */
+ if (argumentAsNumeric().getUnitPower() != 0) {
+ return false;
+ }
return true;
}
- public ExprNumeric eval()
- throws PropertyException {
- final ExprNumeric numeric = (ExprNumeric) getArgs()[0];
- final double value = Math.ceil(numeric.getNumericValue());
- return new DtNumber(value);
+ private ExprNumeric argumentAsNumeric() {
+ return (ExprNumeric) this.getArgs()[0];
}
+ /**
+ * {@inheritDoc}
+ */
+ public double getNumericValue() {
+ return Math.ceil(argumentAsNumeric().getNumericValue());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte getUnitPower() {
+ /* Unit power of zero is a requirement, and is tested in the argument
+ * validation. */
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canEvaluateLength() {
+ /* Unit power of zero is a requirement, and is tested in the argument
+ * validation. */
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getLength(final int pointSize, final int percentBase) {
+ /* Unit power of zero is a requirement, and is tested in the argument
+ * validation. */
+ return Integer.MIN_VALUE;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java 2006-10-27 18:17:38 UTC (rev 8440)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java 2006-10-27 21:42:33 UTC (rev 8441)
@@ -34,7 +34,7 @@
/**
* The "floor" function in XSL-FO.
*/
-class FnFloor extends Function {
+class FnFloor extends Function implements ExprNumeric {
public FnFloor(final PropertyList propertyList, final Expr[] arguments)
throws PropertyException {
@@ -46,19 +46,57 @@
}
public boolean argumentsValid(final PropertyList propertyList) {
+ /* There must be exactly one argument. */
if (getArgs().length != 1) {
return false;
}
+ /* The argument must be numeric. */
if (! (getArgs()[0] instanceof ExprNumeric)) {
return false;
}
+ /* The numeric must have a unit power of zero. */
+ if (argumentAsNumeric().getUnitPower() != 0) {
+ return false;
+ }
return true;
}
- public ExprNumeric eval() throws PropertyException {
- final ExprNumeric numeric = (ExprNumeric) getArgs()[0];
- final double value = Math.floor(numeric.getNumericValue());
- return new DtNumber(value);
+ private ExprNumeric argumentAsNumeric() {
+ return (ExprNumeric) this.getArgs()[0];
}
+ /**
+ * {@inheritDoc}
+ */
+ public double getNumericValue() {
+ return Math.floor(argumentAsNumeric().getNumericValue());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte getUnitPower() {
+ /* Unit power of zero is a requirement, and is tested in the argument
+ * validation. */
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canEvaluateLength() {
+ /* Unit power of zero is a requirement, and is tested in the argument
+ * validation. */
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getLength(final int pointSize, final int percentBase) {
+ /* Unit power of zero is a requirement, and is tested in the argument
+ * validation. */
+ return Integer.MIN_VALUE;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMax.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMax.java 2006-10-27 18:17:38 UTC (rev 8440)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMax.java 2006-10-27 21:42:33 UTC (rev 8441)
@@ -34,7 +34,7 @@
/**
* The "max" function in XSL-FO.
*/
-public class FnMax extends Function {
+public class FnMax extends Function implements ExprNumeric {
public FnMax(final PropertyList propertyList, final Expr[] arguments)
throws PropertyException {
@@ -49,21 +49,70 @@
if (getArgs().length != 2) {
return false;
}
+ /* The arguments must be numeric. */
if (! (getArgs()[0] instanceof ExprNumeric)) {
return false;
}
if (! (getArgs()[1] instanceof ExprNumeric)) {
return false;
}
+ /* The arguments must have the same unit power. */
+ if (argument1AsNumeric().getUnitPower()
+ != argument2AsNumeric().getUnitPower()) {
+ return false;
+ }
return true;
}
- public ExprNumeric eval() throws PropertyException {
- final ExprNumeric numeric1 = (ExprNumeric) getArgs()[0];
- final ExprNumeric numeric2 = (ExprNumeric) getArgs()[1];
- final double value = Math.max(numeric1.getNumericValue(),
- numeric2.getNumericValue());
- return new DtNumber(value);
+ /**
+ * Returns the first argument (index 0) as a Numeric.
+ * @return The first argument as a Numeric.
+ */
+ private ExprNumeric argument1AsNumeric() {
+ return (ExprNumeric) this.getArgs()[0];
}
+ /**
+ * Returns the second argument (index 1) as a Numeric.
+ * @return The second argument as a Numeric.
+ */
+ private ExprNumeric argument2AsNumeric() {
+ return (ExprNumeric) this.getArgs()[1];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public double getNumericValue() {
+ return Math.max(argument1AsNumeric().getNumericValue(),
+ argument2AsNumeric().getNumericValue());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte getUnitPower() {
+ /* The equality of the unit powers of the two arguments is a
+ * requirement, and is tested in the argument validation. */
+ return argument1AsNumeric().getUnitPower();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canEvaluateLength() {
+ /* The equality of the unit powers of the two arguments is a
+ * requirement, and is tested in the argument validation. */
+ return argument1AsNumeric().canEvaluateLength();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getLength(final int pointSize, final int percentBase) {
+ return Math.max(argument1AsNumeric().getLength(pointSize, percentBase),
+ argument2AsNumeric().getLength(pointSize, percentBase));
+ }
+
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMin.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMin.java 2006-10-27 18:17:38 UTC (rev 8440)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMin.java 2006-10-27 21:42:33 UTC (rev 8441)
@@ -34,7 +34,7 @@
/**
* The "min" function in XSL-FO.
*/
-public class FnMin extends Function {
+public class FnMin extends Function implements ExprNumeric {
public FnMin(final PropertyList propertyList, final Expr[] arguments)
throws PropertyException {
@@ -46,26 +46,73 @@
}
public boolean argumentsValid(final PropertyList propertyList) {
+ /* There must be exactly two arguments. */
if (getArgs().length != 2) {
return false;
}
+ /* The arguments must be numeric. */
if (! (getArgs()[0] instanceof ExprNumeric)) {
return false;
}
if (! (getArgs()[1] instanceof ExprNumeric)) {
return false;
}
+ /* The arguments must have the same unit power. */
+ if (argument1AsNumeric().getUnitPower()
+ != argument2AsNumeric().getUnitPower()) {
+ return false;
+ }
return true;
}
- public ExprNumeric eval(final PropertyList propertyList)
- throws PropertyException {
- //Already validated as existing and as Numeric at parse-time.
- final ExprNumeric numeric1 = (ExprNumeric) getArgs()[0];
- final ExprNumeric numeric2 = (ExprNumeric) getArgs()[1];
- final double value = Math.min(numeric1.getNumericValue(),
- numeric2.getNumericValue());
- return new DtNumber(value);
+ /**
+ * Returns the first argument (index 0) as a Numeric.
+ * @return The first argument as a Numeric.
+ */
+ private ExprNumeric argument1AsNumeric() {
+ return (ExprNumeric) this.getArgs()[0];
}
+ /**
+ * Returns the second argument (index 1) as a Numeric.
+ * @return The second argument as a Numeric.
+ */
+ private ExprNumeric argument2AsNumeric() {
+ return (ExprNumeric) this.getArgs()[1];
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public double getNumericValue() {
+ return Math.min(argument1AsNumeric().getNumericValue(),
+ argument2AsNumeric().getNumericValue());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte getUnitPower() {
+ /* The equality of the unit powers of the two arguments is a
+ * requirement, and is tested in the argument validation. */
+ return argument1AsNumeric().getUnitPower();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canEvaluateLength() {
+ /* The equality of the unit powers of the two arguments is a
+ * requirement, and is tested in the argument validation. */
+ return argument1AsNumeric().canEvaluateLength();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getLength(final int pointSize, final int percentBase) {
+ return Math.min(argument1AsNumeric().getLength(pointSize, percentBase),
+ argument2AsNumeric().getLength(pointSize, percentBase));
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java 2006-10-27 18:17:38 UTC (rev 8440)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java 2006-10-27 21:42:33 UTC (rev 8441)
@@ -34,7 +34,7 @@
/**
* The "round" function in XSL-FO.
*/
-class FnRound extends Function {
+class FnRound extends Function implements ExprNumeric {
public FnRound(final PropertyList propertyList, final Expr[] arguments)
throws PropertyException {
@@ -46,23 +46,57 @@
}
public boolean argumentsValid(final PropertyList propertyList) {
+ /* There must be exactly one argument. */
if (getArgs().length != 1) {
return false;
}
+ /* The argument must be numeric. */
if (! (getArgs()[0] instanceof ExprNumeric)) {
return false;
}
+ /* The numeric must have a unit power of zero. */
+ if (argumentAsNumeric().getUnitPower() != 0) {
+ return false;
+ }
return true;
}
- public ExprNumeric eval() throws PropertyException {
- final PropertyValue pv = getArgs()[0];
- if (pv instanceof DtInteger) {
- return (DtInteger) pv;
- }
- final ExprNumeric numeric = (ExprNumeric) pv;
- final long value = Math.round(numeric.getNumericValue());
- return new DtInteger((int) value);
+ private ExprNumeric argumentAsNumeric() {
+ return (ExprNumeric) this.getArgs()[0];
}
+ /**
+ * {@inheritDoc}
+ */
+ public double getNumericValue() {
+ return Math.round(argumentAsNumeric().getNumericValue());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public byte getUnitPower() {
+ /* Unit power of zero is a requirement, and is tested in the argument
+ * validation. */
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canEvaluateLength() {
+ /* Unit power of zero is a requirement, and is tested in the argument
+ * validation. */
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getLength(final int pointSize, final int percentBase) {
+ /* Unit power of zero is a requirement, and is tested in the argument
+ * validation. */
+ return Integer.MIN_VALUE;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-27 18:17:51
|
Revision: 8440
http://svn.sourceforge.net/foray/?rev=8440&view=rev
Author: victormote
Date: 2006-10-27 11:17:38 -0700 (Fri, 27 Oct 2006)
Log Message:
-----------
Add new class to distinguish enclosed numeric expressions from enclosed expressions that are not numeric.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java
Added Paths:
-----------
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprInnerNumeric.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java 2006-10-27 17:55:09 UTC (rev 8439)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java 2006-10-27 18:17:38 UTC (rev 8440)
@@ -42,6 +42,7 @@
import org.foray.fotree.value.ExprAdditive;
import org.foray.fotree.value.ExprAdditiveOper;
import org.foray.fotree.value.ExprInner;
+import org.foray.fotree.value.ExprInnerNumeric;
import org.foray.fotree.value.ExprMultiplicative;
import org.foray.fotree.value.ExprMultiplicativeOper;
import org.foray.fotree.value.ExprNumeric;
@@ -273,6 +274,9 @@
private ExprInner parseInnerExpression() throws PropertyException {
final ExprAdditive expr = parseAdditiveExpr();
+ if (expr instanceof ExprNumeric) {
+ return new ExprInnerNumeric(expr);
+ }
return new ExprInner(expr);
}
Added: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprInnerNumeric.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprInnerNumeric.java (rev 0)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprInnerNumeric.java 2006-10-27 18:17:38 UTC (rev 8440)
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy: victormote $
+ */
+
+package org.foray.fotree.value;
+
+import org.foray.fotree.PropertyException;
+
+/**
+ * Class representing nested expressions. Specifically, in XSL-FO Standard,
+ * Section 5.9.3, it is the first item listed under grammar item [2]
+ * "PrimaryExpr".
+ */
+public class ExprInnerNumeric extends ExprInner implements ExprNumeric {
+
+ /**
+ * Constructor.
+ * @param expression The expression enclosed in parentheses.
+ * @throws PropertyException If expression is not an instanceof
+ * {@link ExprNumeric}.
+ * @see ExprInner For a similar class that takes non-numeric expressions.
+ */
+ public ExprInnerNumeric(final ExprAdditive expression)
+ throws PropertyException {
+ super(expression);
+ if (! (expression instanceof ExprNumeric)) {
+ throw new PropertyException("ExprInnerNumeric: Non-numeric "
+ + "operand: " + expression.toString());
+ }
+ }
+
+ public ExprNumeric asNumeric() {
+ return (ExprNumeric) this.getEnclosedExpression();
+ }
+
+ public double getNumericValue() {
+ return asNumeric().getNumericValue();
+ }
+
+ /**
+ * Each numeric has a "unit power".
+ * This number refers to the number of spatial dimensions in which the
+ * number operates.
+ * So, a number that has no relationship to space or refers to a point, has
+ * a length power of 0.
+ * A number that refers to length has a length power of 1 (1 dimension).
+ * Although there are none yet in XSL-FO, a number that referred to area
+ * (e.g. square inches) would, we suppose, have a length power of 2, and one
+ * referring to volume (e.g. cubic feet) would, we suppose have a length
+ * power of 3.
+ * @return The number of spatial dimensions in which this numeric item
+ * operates. For XSL-FO items, this should be either
+ * {@link #UNIT_POWER_NUMERIC} or {@link #UNIT_POWER_LENGTH}.
+ */
+ public byte getUnitPower() {
+ return asNumeric().getUnitPower();
+ }
+
+ /**
+ * Indicates whether this expression can be evaluated to a unit power = 1
+ * (length) or not.
+ * @return True if the expression can be evaluated to a unit power of 1
+ * (length).
+ */
+ public boolean canEvaluateLength() {
+ return asNumeric().canEvaluateLength();
+ }
+
+ /**
+ * Evaluates the expression to a unit power of 1 (length).
+ * @return The unit power 1 value (length) of this expression if the
+ * expression can be so evaluated, or {@link Integer#MIN_VALUE} otherwise.
+ * The value is expressed in millipoints.
+ */
+ public int getLength(final int pointSize, final int percentBase) {
+ return asNumeric().getLength(pointSize, percentBase);
+ }
+
+}
Property changes on: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprInnerNumeric.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-27 17:55:20
|
Revision: 8439
http://svn.sourceforge.net/foray/?rev=8439&view=rev
Author: victormote
Date: 2006-10-27 10:55:09 -0700 (Fri, 27 Oct 2006)
Log Message:
-----------
Add "inside" and "outside" to float property keyword values.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Enumerated.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Enumerated.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Enumerated.java 2006-10-27 17:49:28 UTC (rev 8438)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Enumerated.java 2006-10-27 17:55:09 UTC (rev 8439)
@@ -1040,6 +1040,8 @@
Constants.FOVAL_END,
Constants.FOVAL_LEFT,
Constants.FOVAL_RIGHT,
+ Constants.FOVAL_INSIDE,
+ Constants.FOVAL_OUTSIDE,
Constants.FOVAL_NONE,
Constants.FOVAL_INHERIT,
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-27 17:49:34
|
Revision: 8438
http://svn.sourceforge.net/foray/?rev=8438&view=rev
Author: victormote
Date: 2006-10-27 10:49:28 -0700 (Fri, 27 Oct 2006)
Log Message:
-----------
Accept numeric expressions for line-height property.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LineHeight.java
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-27 17:13:39 UTC (rev 8437)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LineHeight.java 2006-10-27 17:49:28 UTC (rev 8438)
@@ -37,6 +37,7 @@
import org.foray.fotree.value.DtNumber;
import org.foray.fotree.value.DtPercentage;
import org.foray.fotree.value.DtSpace;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -81,29 +82,29 @@
public PropertyValue createPropertyValue(final PropertyList propertyList,
final String value) throws PropertyException {
- PropertyValue pv = checkKeywords(value);
- if (pv != null) {
- return pv;
- }
- pv = DtNumber.makeNumberDT(value);
- if (pv != null) {
+ final PropertyValue pv = standardParse(propertyList, value, false,
+ false);
+ if (pv instanceof DtNumber) {
if (((DtNumber) pv).getValue() < 0) {
throw unexpectedValue(value, propertyList);
}
return pv;
}
- pv = DtPercentage.makePercentageDT(value);
- if (pv != null) {
+ if (pv instanceof DtPercentage) {
if (((DtPercentage) pv).getValue() < 0) {
throw unexpectedValue(value, propertyList);
}
return pv;
}
- pv = DtLength.makeLengthDT(value);
- if (pv != null) {
- if (((DtLength) pv).getNumericValue() < 0) {
- throw unexpectedValue(value, propertyList);
+ if (pv instanceof ExprNumeric) {
+ final ExprNumeric exprNumeric = (ExprNumeric) pv;
+ /* This test includes both expressions that can and cannot evaluate
+ * to a length, because <number> is one of the input values. */
+ if (exprNumeric.getNumericValue() >= 0) {
+ return pv;
}
+ }
+ if (pv instanceof DtSpace) {
return pv;
}
throw unexpectedValue(value, propertyList);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-27 17:13:51
|
Revision: 8437
http://svn.sourceforge.net/foray/?rev=8437&view=rev
Author: victormote
Date: 2006-10-27 10:13:39 -0700 (Fri, 27 Oct 2006)
Log Message:
-----------
Add PS package tests to the test suite.
Modified Paths:
--------------
trunk/foray/foray-app/.classpath
trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java
Modified: trunk/foray/foray-app/.classpath
===================================================================
--- trunk/foray/foray-app/.classpath 2006-10-27 17:12:49 UTC (rev 8436)
+++ trunk/foray/foray-app/.classpath 2006-10-27 17:13:39 UTC (rev 8437)
@@ -39,5 +39,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/FOrayHyphen-R"/>
<classpathentry kind="var" path="FORAY_LIB_ROOT/foray-hyphen-r-0.3-rsrc.jar"/>
<classpathentry kind="lib" path="/FOrayLibsBuild/junit/junit.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/FOrayPS"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java 2006-10-27 17:12:49 UTC (rev 8436)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/TestFOrayAll.java 2006-10-27 17:13:39 UTC (rev 8437)
@@ -29,6 +29,7 @@
package org.foray.app;
import org.foray.fotree.TestFOrayFOTree;
+import org.foray.ps.TestFOrayPS;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -45,6 +46,7 @@
public static Test suite() {
final TestSuite testSuite = new TestSuite();
testSuite.addTest(TestFOrayFOTree.suite());
+ testSuite.addTest(TestFOrayPS.suite());
return testSuite;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-27 17:13:08
|
Revision: 8436
http://svn.sourceforge.net/foray/?rev=8436&view=rev
Author: victormote
Date: 2006-10-27 10:12:49 -0700 (Fri, 27 Oct 2006)
Log Message:
-----------
1. Make method more visible and static to facilitate testing.
2. Add a test of the ASCII85Filter.
Modified Paths:
--------------
trunk/foray/foray-ps/.classpath
trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java
Added Paths:
-----------
trunk/foray/foray-ps/src/javatest/
trunk/foray/foray-ps/src/javatest/org/
trunk/foray/foray-ps/src/javatest/org/foray/
trunk/foray/foray-ps/src/javatest/org/foray/ps/
trunk/foray/foray-ps/src/javatest/org/foray/ps/TestFOrayPS.java
trunk/foray/foray-ps/src/javatest/org/foray/ps/filter/
trunk/foray/foray-ps/src/javatest/org/foray/ps/filter/TestASCII85Filter.java
Modified: trunk/foray/foray-ps/.classpath
===================================================================
--- trunk/foray/foray-ps/.classpath 2006-10-27 16:10:37 UTC (rev 8435)
+++ trunk/foray/foray-ps/.classpath 2006-10-27 17:12:49 UTC (rev 8436)
@@ -2,10 +2,12 @@
<classpath>
<classpathentry excluding=".#*" kind="src" path="src/java"/>
<classpathentry kind="src" path="scripts"/>
+ <classpathentry kind="src" path="src/javatest"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/FOrayCommon"/>
<classpathentry kind="src" path="/axslPS-R"/>
<classpathentry kind="src" path="/axslCommon"/>
<classpathentry kind="var" path="FORAY_LIB_ROOT/commons-logging.jar"/>
+ <classpathentry kind="lib" path="/FOrayLibsBuild/junit/junit.jar"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java 2006-10-27 16:10:37 UTC (rev 8435)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java 2006-10-27 17:12:49 UTC (rev 8436)
@@ -159,7 +159,7 @@
* @param bytes The bytes to be converted.
* @return The long containing the 4 byte values.
*/
- private long encodeAsLong(final byte[] bytes) {
+ protected static long encodeAsLong(final byte[] bytes) {
if (bytes == null
|| bytes.length != UNENCODED_BLOCK_SIZE) {
return -1;
@@ -187,7 +187,8 @@
* values of 0)
* @throws PSFilterException If an illegal character is found in the input.
*/
- private byte[] convertWord(final long word) throws PSFilterException {
+ protected static byte[] convertWord(final long word)
+ throws PSFilterException {
long wordMasked = word & 0xffffffff;
if (wordMasked < 0) {
wordMasked = -wordMasked;
Added: trunk/foray/foray-ps/src/javatest/org/foray/ps/TestFOrayPS.java
===================================================================
--- trunk/foray/foray-ps/src/javatest/org/foray/ps/TestFOrayPS.java (rev 0)
+++ trunk/foray/foray-ps/src/javatest/org/foray/ps/TestFOrayPS.java 2006-10-27 17:12:49 UTC (rev 8436)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.ps;
+
+import org.foray.ps.filter.TestASCII85Filter;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Handles testing for the FOrayPS module.
+ */
+public class TestFOrayPS extends TestCase {
+
+ /**
+ * Builds a test suite for all classes in this module.
+ * @return The built test suite.
+ */
+ public static Test suite() {
+ final TestSuite testSuite = new TestSuite();
+ testSuite.addTestSuite(TestASCII85Filter.class);
+ return testSuite;
+ }
+
+}
Property changes on: trunk/foray/foray-ps/src/javatest/org/foray/ps/TestFOrayPS.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
Added: trunk/foray/foray-ps/src/javatest/org/foray/ps/filter/TestASCII85Filter.java
===================================================================
--- trunk/foray/foray-ps/src/javatest/org/foray/ps/filter/TestASCII85Filter.java (rev 0)
+++ trunk/foray/foray-ps/src/javatest/org/foray/ps/filter/TestASCII85Filter.java 2006-10-27 17:12:49 UTC (rev 8436)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2006 The FOray Project.
+ * http://www.foray.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * This work is in part derived from the following work(s), used with the
+ * permission of the licensor:
+ * Apache FOP, licensed by the Apache Software Foundation
+ *
+ */
+
+/*
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ * $LastChangedBy$
+ */
+
+package org.foray.ps.filter;
+
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+/**
+ * JUnit test class for the class {@link ASCII85Filter}.
+ */
+public class TestASCII85Filter extends TestCase {
+
+/**
+ * Unit test for encoding 4 bytes.
+ * @throws PSFilterException for input errors.
+ */
+public void testEncode() throws PSFilterException {
+ final byte[] testInput = new byte[] {120, -100, -84, 120};
+ final byte[] expectedOutput = new byte[] {71, 97, 116, 106, 91};
+ final long value = ASCII85Filter.encodeAsLong(testInput);
+ assertEquals(2023533688, value);
+ final byte[] testOutput = ASCII85Filter.convertWord(value);
+ assertTrue(Arrays.equals(expectedOutput, testOutput));
+}
+
+}
Property changes on: trunk/foray/foray-ps/src/javatest/org/foray/ps/filter/TestASCII85Filter.java
___________________________________________________________________
Name: svn:keywords
+ "Author Id Rev Date URL"
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-27 16:10:44
|
Revision: 8435
http://svn.sourceforge.net/foray/?rev=8435&view=rev
Author: victormote
Date: 2006-10-27 09:10:37 -0700 (Fri, 27 Oct 2006)
Log Message:
-----------
Fix multiple bugs introduced in the removal of magic numbers.
Modified Paths:
--------------
trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java
Modified: trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java
===================================================================
--- trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java 2006-10-27 01:24:18 UTC (rev 8434)
+++ trunk/foray/foray-ps/src/java/org/foray/ps/filter/ASCII85Filter.java 2006-10-27 16:10:37 UTC (rev 8435)
@@ -40,15 +40,18 @@
public class ASCII85Filter extends PSFilter {
/** Mask needed during encoding. */
- private static final long MASK_BYTE_1 = WKConstants.MAX_8_BIT_UNSIGNED_INT
+ private static final long MASK_BYTE_1 =
+ ((long) WKConstants.MAX_8_BIT_UNSIGNED_INT)
<< WKConstants.SHIFT_3_BYTES;
/** Mask needed during encoding. */
- private static final long MASK_BYTE_2 = WKConstants.MAX_8_BIT_UNSIGNED_INT
+ private static final long MASK_BYTE_2 =
+ ((long) WKConstants.MAX_8_BIT_UNSIGNED_INT)
<< WKConstants.SHIFT_2_BYTES;
/** Mask needed during encoding. */
- private static final long MASK_BYTE_3 = WKConstants.MAX_8_BIT_UNSIGNED_INT
+ private static final long MASK_BYTE_3 =
+ ((long) WKConstants.MAX_8_BIT_UNSIGNED_INT)
<< WKConstants.SHIFT_1_BYTE;
/** Mask needed during encoding. */
@@ -102,12 +105,17 @@
public byte[] encode(final byte[] data) throws PSFilterException {
final ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int i;
+ byte[] unencodedBytes;
// first encode the majority of the data
// each 4 byte group becomes a 5 byte group
for (i = 0; i + UNENCODED_BLOCK_SIZE <= data.length;
i += UNENCODED_BLOCK_SIZE) {
- final long val = encodeAsLong(data);
+ unencodedBytes = new byte[UNENCODED_BLOCK_SIZE];
+ for (int j = 0; j < unencodedBytes.length; j++) {
+ unencodedBytes[j] = data[i + j];
+ }
+ final long val = encodeAsLong(unencodedBytes);
final byte[] conv = convertWord(val);
buffer.write(conv, 0, conv.length);
}
@@ -118,16 +126,16 @@
// and write out the first n+1 bytes from the result
if (i < data.length) {
final int n = data.length - i;
- final byte[] lastdata = new byte[UNENCODED_BLOCK_SIZE];
- for (int j = 0; j < lastdata.length; j++) {
+ unencodedBytes = new byte[UNENCODED_BLOCK_SIZE];
+ for (int j = 0; j < unencodedBytes.length; j++) {
if (j < n) {
- lastdata[j] = data[i++];
+ unencodedBytes[j] = data[i++];
} else {
- lastdata[j] = 0;
+ unencodedBytes[j] = 0;
}
}
- final long val = encodeAsLong(lastdata);
+ final long val = encodeAsLong(unencodedBytes);
byte[] conv = convertWord(val);
// special rule for handling zeros at the end
@@ -157,13 +165,13 @@
return -1;
}
int index = 0;
- final long byte1 = (bytes[index] << WKConstants.SHIFT_3_BYTES)
+ final long byte1 = (((long) bytes[index]) << WKConstants.SHIFT_3_BYTES)
& MASK_BYTE_1;
index ++;
- final long byte2 = (bytes[index] << WKConstants.SHIFT_2_BYTES)
+ final long byte2 = (((long) bytes[index]) << WKConstants.SHIFT_2_BYTES)
& MASK_BYTE_2;
index ++;
- final long byte3 = (bytes[index] << WKConstants.SHIFT_1_BYTE)
+ final long byte3 = (((long) bytes[index]) << WKConstants.SHIFT_1_BYTE)
& MASK_BYTE_3;
index ++;
final long byte4 = bytes[index] & MASK_BYTE_4;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-27 01:24:33
|
Revision: 8434
http://svn.sourceforge.net/foray/?rev=8434&view=rev
Author: victormote
Date: 2006-10-26 18:24:18 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Rename methods for clarity.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLength.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtNumber.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtSpace.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -105,7 +105,7 @@
return pv;
}
if (pv instanceof ExprNumeric) {
- if (((ExprNumeric) pv).canEvalUnitPower1()) {
+ if (((ExprNumeric) pv).canEvaluateLength()) {
return pv;
}
}
@@ -161,7 +161,7 @@
fobj) / WKConstants.PERCENT_CONVERSION);
}
if (value() instanceof ExprNumeric) {
- return ((ExprNumeric) value()).evalUnitPower1(getBaseFontSize(
+ return ((ExprNumeric) value()).getLength(getBaseFontSize(
context, fobj), 0);
}
return getBaseFontSize(context, fobj);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -82,7 +82,7 @@
}
if (pv instanceof ExprNumeric) {
final ExprNumeric expression = (ExprNumeric) pv;
- if (expression.canEvalUnitPower1()) {
+ if (expression.canEvaluateLength()) {
return pv;
}
}
@@ -122,7 +122,7 @@
}
if (value() instanceof ExprNumeric) {
final ExprNumeric expression = (ExprNumeric) value();
- return expression.evalUnitPower1(fobj.traitFontSize(context),
+ return expression.getLength(fobj.traitFontSize(context),
ipdContainingRA);
}
return getValueNoInstance(context, fobj, direction, ipdContainingRA);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -72,7 +72,7 @@
return pv;
}
if (pv instanceof ExprNumeric) {
- if (((ExprNumeric) pv).canEvalUnitPower1()) {
+ if (((ExprNumeric) pv).canEvaluateLength()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -94,7 +94,7 @@
}
if (value() instanceof ExprNumeric) {
final int fontSize = fobj.traitFontSize(context);
- return ((ExprNumeric) value()).evalUnitPower1(fontSize, 0);
+ return ((ExprNumeric) value()).getLength(fontSize, 0);
}
return getValueNoInstance(context, fobj, ipdAncestorBANotLA);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -83,7 +83,7 @@
pv = standardParse(propertyList, value, false, false);
if (pv instanceof ExprNumeric) {
final ExprNumeric expression = (ExprNumeric) pv;
- if (expression.canEvalUnitPower1()) {
+ if (expression.canEvaluateLength()) {
return pv;
}
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -77,7 +77,7 @@
pv = standardParse(propertyList, value, false, false);
if (pv instanceof ExprNumeric) {
final ExprNumeric expr = (ExprNumeric) pv;
- if (expr.canEvalUnitPower1()) {
+ if (expr.canEvaluateLength()) {
return new DtSpace(expr, expr, expr, Constants.FOVAL_DISCARD,
0);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -73,7 +73,7 @@
}
if (pv instanceof ExprNumeric) {
final ExprNumeric expression = (ExprNumeric) pv;
- if (expression.canEvalUnitPower1()) {
+ if (expression.canEvaluateLength()) {
return pv;
}
}
@@ -102,7 +102,7 @@
}
if (value() instanceof ExprNumeric) {
final ExprNumeric expression = (ExprNumeric) value();
- return expression.evalUnitPower1(fobj.traitFontSize(context),
+ return expression.getLength(fobj.traitFontSize(context),
widthContainingBlock);
}
return 0;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -80,7 +80,7 @@
}
/** @see ExprNumeric#getLengthPower */
- public byte getLengthPower() {
+ public byte getUnitPower() {
return 0;
}
@@ -114,14 +114,14 @@
/**
* {@inheritDoc}
*/
- public boolean canEvalUnitPower1() {
+ public boolean canEvaluateLength() {
return false;
}
/**
* {@inheritDoc}
*/
- public int evalUnitPower1(final int pointSize, final int percentBase) {
+ public int getLength(final int pointSize, final int percentBase) {
return Integer.MIN_VALUE;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLength.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLength.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLength.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -152,7 +152,7 @@
}
/** @see ExprNumeric#getLengthPower */
- public byte getLengthPower() {
+ public byte getUnitPower() {
return 1;
}
@@ -199,11 +199,11 @@
/**
* {@inheritDoc}
*/
- public boolean canEvalUnitPower1() {
+ public boolean canEvaluateLength() {
return true;
}
- public int evalUnitPower1(final int pointSize, final int percentBase) {
+ public int getLength(final int pointSize, final int percentBase) {
return getValue(pointSize, percentBase);
}
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-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtNumber.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -62,7 +62,7 @@
}
/** @see ExprNumeric#getLengthPower */
- public byte getLengthPower() {
+ public byte getUnitPower() {
return 0;
}
@@ -87,14 +87,14 @@
/**
* {@inheritDoc}
*/
- public boolean canEvalUnitPower1() {
+ public boolean canEvaluateLength() {
return false;
}
/**
* {@inheritDoc}
*/
- public int evalUnitPower1(final int pointSize, final int percentBase) {
+ public int getLength(final int pointSize, final int percentBase) {
return Integer.MIN_VALUE;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -57,7 +57,7 @@
return value;
}
- public byte getLengthPower() {
+ public byte getUnitPower() {
return 0;
}
@@ -88,14 +88,14 @@
/**
* {@inheritDoc}
*/
- public boolean canEvalUnitPower1() {
+ public boolean canEvaluateLength() {
return false;
}
/**
* {@inheritDoc}
*/
- public int evalUnitPower1(final int pointSize, final int percentBase) {
+ public int getLength(final int pointSize, final int percentBase) {
return Integer.MIN_VALUE;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtSpace.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtSpace.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtSpace.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -63,9 +63,9 @@
final ExprNumeric lengthOptimum, final ExprNumeric lengthMaximum,
final short conditionality, final int precedence)
throws PropertyException {
- if (lengthMinimum.getLengthPower() != 1
- || lengthOptimum.getLengthPower() != 1
- || lengthMaximum.getLengthPower() != 1) {
+ if (lengthMinimum.getUnitPower() != 1
+ || lengthOptimum.getUnitPower() != 1
+ || lengthMaximum.getUnitPower() != 1) {
throw new PropertyException("Invalid length");
}
this.lengthMinimum = lengthMinimum;
@@ -96,15 +96,15 @@
}
public int getLengthMinimum(final int pointSize, final int percentBase) {
- return this.lengthMinimum.evalUnitPower1(pointSize, percentBase);
+ return this.lengthMinimum.getLength(pointSize, percentBase);
}
public int getLengthOptimum(final int pointSize, final int percentBase) {
- return this.lengthOptimum.evalUnitPower1(pointSize, percentBase);
+ return this.lengthOptimum.getLength(pointSize, percentBase);
}
public int getLengthMaximum(final int pointSize, final int percentBase) {
- return this.lengthMaximum.evalUnitPower1(pointSize, percentBase);
+ return this.lengthMaximum.getLength(pointSize, percentBase);
}
public short getConditionality() {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -56,8 +56,8 @@
* For Additive Expressions, the unitPower of the two operands must
* be equal. See XSL-FO Specification 1.0, Section 5.9.6.
*/
- if (((ExprNumeric) operand1).getLengthPower()
- != ((ExprNumeric) operand2).getLengthPower()) {
+ if (((ExprNumeric) operand1).getUnitPower()
+ != ((ExprNumeric) operand2).getUnitPower()) {
throw new PropertyException("AdditiveExpr: Unit powers differ: "
+ operand1.toString() + ", " + operand2.toString());
}
@@ -69,14 +69,14 @@
this.operation = operation;
}
- public boolean canEvalUnitPower1() {
+ public boolean canEvaluateLength() {
/* In the constructor, we have already tested the equality of the
* operands unit power. Therefore, we can just evaluate one here. */
- return ((ExprNumeric) operand1).canEvalUnitPower1();
+ return ((ExprNumeric) operand1).canEvaluateLength();
}
- public int evalUnitPower1(final int pointSize, final int percentBase) {
- if (! canEvalUnitPower1()) {
+ public int getLength(final int pointSize, final int percentBase) {
+ if (! canEvaluateLength()) {
return 0;
}
switch (operation) {
@@ -95,10 +95,10 @@
/**
* {@inheritDoc}
*/
- public byte getLengthPower() {
+ public byte getUnitPower() {
/* We already tested that the unit powers were equal at construction,
* so all we need to do here is return one of them. */
- return ((ExprNumeric) operand1).getLengthPower();
+ return ((ExprNumeric) operand1).getUnitPower();
}
public double getOperand1Value() {
@@ -110,11 +110,11 @@
}
public int getOperand1Length(final int pointSize, final int percentBase) {
- return ((ExprNumeric) operand1).evalUnitPower1(pointSize, percentBase);
+ return ((ExprNumeric) operand1).getLength(pointSize, percentBase);
}
public int getOperand2Length(final int pointSize, final int percentBase) {
- return ((ExprNumeric) operand2).evalUnitPower1(pointSize, percentBase);
+ return ((ExprNumeric) operand2).getLength(pointSize, percentBase);
}
/**
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -58,8 +58,8 @@
* be equal. See XSL-FO Specification 1.0, Section 5.9.6.
*/
if (operation == ExprNumeric.OPERATION_MOD
- && ((ExprNumeric) operand1).getLengthPower()
- != ((ExprNumeric) operand2).getLengthPower()) {
+ && ((ExprNumeric) operand1).getUnitPower()
+ != ((ExprNumeric) operand2).getUnitPower()) {
throw new PropertyException("Modulo Operator: Unit powers differ: "
+ operand1.toString() + ", " + operand2.toString());
}
@@ -72,16 +72,16 @@
this.operation = operation;
}
- public boolean canEvalUnitPower1() {
- if (((ExprNumeric) operand1).canEvalUnitPower1()
- || ((ExprNumeric) operand2).canEvalUnitPower1()) {
+ public boolean canEvaluateLength() {
+ if (((ExprNumeric) operand1).canEvaluateLength()
+ || ((ExprNumeric) operand2).canEvaluateLength()) {
return true;
}
return false;
}
- public int evalUnitPower1(final int pointSize, final int percentBase) {
- if (! canEvalUnitPower1()) {
+ public int getLength(final int pointSize, final int percentBase) {
+ if (! canEvaluateLength()) {
return 0;
}
@@ -129,25 +129,25 @@
}
public byte getOperand1UnitPower() {
- return ((ExprNumeric) operand1).getLengthPower();
+ return ((ExprNumeric) operand1).getUnitPower();
}
public byte getOperand2UnitPower() {
- return ((ExprNumeric) operand2).getLengthPower();
+ return ((ExprNumeric) operand2).getUnitPower();
}
public int getOperand1Length(final int pointSize, final int percentBase) {
- return ((ExprNumeric) operand1).evalUnitPower1(pointSize, percentBase);
+ return ((ExprNumeric) operand1).getLength(pointSize, percentBase);
}
public int getOperand2Length(final int pointSize, final int percentBase) {
- return ((ExprNumeric) operand2).evalUnitPower1(pointSize, percentBase);
+ return ((ExprNumeric) operand2).getLength(pointSize, percentBase);
}
/**
* {@inheritDoc}
*/
- public byte getLengthPower() {
+ public byte getUnitPower() {
/* For multiplication, the unit power of the product is the sum
* of the unit powers of the operands.
* For example, 3 meters * 5 = 15 meters.
@@ -155,8 +155,8 @@
* of 0.
* 1 + 0 = 1, which is intuitively correct, because our product is in
* meters, which has a unit power of 1.*/
- return (byte) (((ExprNumeric) operand1).getLengthPower()
- + ((ExprNumeric) operand2).getLengthPower());
+ return (byte) (((ExprNumeric) operand1).getUnitPower()
+ + ((ExprNumeric) operand2).getUnitPower());
}
/**
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -55,19 +55,21 @@
double getNumericValue();
/**
- * Each numeric has a "length power" or a "unit power" (which we think are
- * synonymous). This number refers to the number of spatial dimensions that
- * in which the number operates. So, a number that has no relationship to
- * space or refers to a point, has a length power of 0. A number that
- * refers to length has a length power of 1 (1 dimension). Although there
- * are none yet in XSL-FO, a number that referred to area (e.g. square
- * inches) would, we suppose, have a length power of 2, and one referring to
- * volume (e.g. cubic feet) would, we suppose have a length power of 3.
+ * Each numeric has a "unit power".
+ * This number refers to the number of spatial dimensions in which the
+ * number operates.
+ * So, a number that has no relationship to space or refers to a point, has
+ * a length power of 0.
+ * A number that refers to length has a length power of 1 (1 dimension).
+ * Although there are none yet in XSL-FO, a number that referred to area
+ * (e.g. square inches) would, we suppose, have a length power of 2, and one
+ * referring to volume (e.g. cubic feet) would, we suppose have a length
+ * power of 3.
* @return The number of spatial dimensions in which this numeric item
* operates. For XSL-FO items, this should be either
* {@link #UNIT_POWER_NUMERIC} or {@link #UNIT_POWER_LENGTH}.
*/
- byte getLengthPower();
+ byte getUnitPower();
/**
* Indicates whether this expression can be evaluated to a unit power = 1
@@ -75,13 +77,14 @@
* @return True if the expression can be evaluated to a unit power of 1
* (length).
*/
- boolean canEvalUnitPower1();
+ boolean canEvaluateLength();
/**
* Evaluates the expression to a unit power of 1 (length).
* @return The unit power 1 value (length) of this expression if the
* expression can be so evaluated, or {@link Integer#MIN_VALUE} otherwise.
+ * The value is expressed in millipoints.
*/
- int evalUnitPower1(final int pointSize, final int percentBase);
+ int getLength(final int pointSize, final int percentBase);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java 2006-10-27 01:16:09 UTC (rev 8433)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java 2006-10-27 01:24:18 UTC (rev 8434)
@@ -52,20 +52,20 @@
this.operation = operation;
}
- public boolean canEvalUnitPower1() {
- if (((ExprNumeric) operand1).canEvalUnitPower1()) {
+ public boolean canEvaluateLength() {
+ if (((ExprNumeric) operand1).canEvaluateLength()) {
return true;
}
return false;
}
- public int evalUnitPower1(final int pointSize, final int percentBase) {
- if (! canEvalUnitPower1()) {
+ public int getLength(final int pointSize, final int percentBase) {
+ if (! canEvaluateLength()) {
return 0;
}
switch (operation) {
case ExprNumeric.OPERATION_NEGATION: {
- return ((ExprNumeric) operand1).evalUnitPower1(pointSize,
+ return ((ExprNumeric) operand1).getLength(pointSize,
percentBase) * -1;
}
}
@@ -75,8 +75,8 @@
/**
* {@inheritDoc}
*/
- public byte getLengthPower() {
- return ((ExprNumeric) this.operand1).getLengthPower();
+ public byte getUnitPower() {
+ return ((ExprNumeric) this.operand1).getUnitPower();
}
public double getNumericValue() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-27 01:16:18
|
Revision: 8433
http://svn.sourceforge.net/foray/?rev=8433&view=rev
Author: victormote
Date: 2006-10-26 18:16:09 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Move numeric-related constants to ExprNumeric.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java 2006-10-27 01:10:40 UTC (rev 8432)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/parse/PropertyParser.java 2006-10-27 01:16:09 UTC (rev 8433)
@@ -44,6 +44,7 @@
import org.foray.fotree.value.ExprInner;
import org.foray.fotree.value.ExprMultiplicative;
import org.foray.fotree.value.ExprMultiplicativeOper;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.ExprPrimary;
import org.foray.fotree.value.ExprUnary;
import org.foray.fotree.value.ExprUnaryOper;
@@ -324,7 +325,7 @@
if (op1 == null || op2 == null) {
throw new PropertyException("Missing parameter: addition.");
}
- return new ExprAdditiveOper(op1, op2, ExprAdditive.OPERATION_ADD);
+ return new ExprAdditiveOper(op1, op2, ExprNumeric.OPERATION_ADD);
}
/**
@@ -341,7 +342,7 @@
if (op1 == null || op2 == null) {
throw new PropertyException("Missing parameter: subtraction.");
}
- return new ExprAdditiveOper(op1, op2, ExprAdditive.OPERATION_SUBTRACT);
+ return new ExprAdditiveOper(op1, op2, ExprNumeric.OPERATION_SUBTRACT);
}
/**
@@ -357,7 +358,7 @@
if (op == null) {
throw new PropertyException("Negation: missing parameter.");
}
- return new ExprUnaryOper(op, ExprAdditive.OPERATION_NEGATION);
+ return new ExprUnaryOper(op, ExprNumeric.OPERATION_NEGATION);
}
/**
@@ -375,7 +376,7 @@
throw new PropertyException("Missing parameter: multiplication.");
}
return new ExprMultiplicativeOper(op1, op2,
- ExprAdditive.OPERATION_MULTIPLY);
+ ExprNumeric.OPERATION_MULTIPLY);
}
@@ -394,7 +395,7 @@
throw new PropertyException("Missing parameter: division.");
}
return new ExprMultiplicativeOper(op1, op2,
- ExprAdditive.OPERATION_DIVIDE);
+ ExprNumeric.OPERATION_DIVIDE);
}
/**
@@ -412,7 +413,7 @@
throw new PropertyException("Missing parameter: modulo.");
}
return new ExprMultiplicativeOper(op1, op2,
- ExprAdditive.OPERATION_MOD);
+ ExprNumeric.OPERATION_MOD);
}
public void pushFunction(final Function func) {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java 2006-10-27 01:10:40 UTC (rev 8432)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java 2006-10-27 01:16:09 UTC (rev 8433)
@@ -33,11 +33,4 @@
*/
public abstract class Expr extends PropertyValue {
- public static final byte OPERATION_ADD = '+';
- public static final byte OPERATION_SUBTRACT = '-';
- public static final byte OPERATION_MULTIPLY = '*';
- public static final byte OPERATION_DIVIDE = '/';
- public static final byte OPERATION_MOD = '%';
- public static final byte OPERATION_NEGATION = '-';
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java 2006-10-27 01:10:40 UTC (rev 8432)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java 2006-10-27 01:16:09 UTC (rev 8433)
@@ -61,8 +61,8 @@
throw new PropertyException("AdditiveExpr: Unit powers differ: "
+ operand1.toString() + ", " + operand2.toString());
}
- if (operation != Expr.OPERATION_ADD
- && operation != Expr.OPERATION_SUBTRACT) {
+ if (operation != ExprNumeric.OPERATION_ADD
+ && operation != ExprNumeric.OPERATION_SUBTRACT) {
throw new PropertyException("AdditiveExpr: Illegal Operator: "
+ operation);
}
@@ -80,11 +80,11 @@
return 0;
}
switch (operation) {
- case Expr.OPERATION_ADD: {
+ case ExprNumeric.OPERATION_ADD: {
return getOperand1Length(pointSize, percentBase)
+ getOperand2Length(pointSize, percentBase);
}
- case Expr.OPERATION_SUBTRACT: {
+ case ExprNumeric.OPERATION_SUBTRACT: {
return getOperand1Length(pointSize, percentBase)
- getOperand2Length(pointSize, percentBase);
}
@@ -122,10 +122,10 @@
*/
public double getNumericValue() {
switch (operation) {
- case Expr.OPERATION_ADD: {
+ case ExprNumeric.OPERATION_ADD: {
return getOperand1Value() + getOperand2Value();
}
- case Expr.OPERATION_SUBTRACT: {
+ case ExprNumeric.OPERATION_SUBTRACT: {
return getOperand1Value() - getOperand2Value();
}
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java 2006-10-27 01:10:40 UTC (rev 8432)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java 2006-10-27 01:16:09 UTC (rev 8433)
@@ -57,15 +57,15 @@
* For Modulo Expressions, the unitPower of the two operands must
* be equal. See XSL-FO Specification 1.0, Section 5.9.6.
*/
- if (operation == Expr.OPERATION_MOD
+ if (operation == ExprNumeric.OPERATION_MOD
&& ((ExprNumeric) operand1).getLengthPower()
!= ((ExprNumeric) operand2).getLengthPower()) {
throw new PropertyException("Modulo Operator: Unit powers differ: "
+ operand1.toString() + ", " + operand2.toString());
}
- if (operation != Expr.OPERATION_MULTIPLY
- && operation != Expr.OPERATION_DIVIDE
- && operation != Expr.OPERATION_MOD) {
+ if (operation != ExprNumeric.OPERATION_MULTIPLY
+ && operation != ExprNumeric.OPERATION_DIVIDE
+ && operation != ExprNumeric.OPERATION_MOD) {
throw new PropertyException("MultiplicativeExpr: Illegal Operator: "
+ operation);
}
@@ -164,13 +164,13 @@
*/
public double getNumericValue() {
switch (operation) {
- case Expr.OPERATION_MULTIPLY: {
+ case ExprNumeric.OPERATION_MULTIPLY: {
return getOperand1Value() * getOperand2Value();
}
- case Expr.OPERATION_DIVIDE: {
+ case ExprNumeric.OPERATION_DIVIDE: {
return getOperand1Value() / getOperand2Value();
}
- case Expr.OPERATION_MOD: {
+ case ExprNumeric.OPERATION_MOD: {
return getOperand1Value() % getOperand2Value();
}
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java 2006-10-27 01:10:40 UTC (rev 8432)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java 2006-10-27 01:16:09 UTC (rev 8433)
@@ -40,6 +40,13 @@
byte UNIT_POWER_LENGTH = 1;
byte UNIT_POWER_AREA = 2;
+ byte OPERATION_ADD = '+';
+ byte OPERATION_SUBTRACT = '-';
+ byte OPERATION_MULTIPLY = '*';
+ byte OPERATION_DIVIDE = '/';
+ byte OPERATION_MOD = '%';
+ byte OPERATION_NEGATION = '-';
+
/**
* Return the numeric value of "this".
* @return A double representation of the value of "this". Type "double" is
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java 2006-10-27 01:10:40 UTC (rev 8432)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java 2006-10-27 01:16:09 UTC (rev 8433)
@@ -45,7 +45,7 @@
+ operand1.toString());
}
this.operand1 = operand1;
- if (operation != Expr.OPERATION_NEGATION) {
+ if (operation != ExprNumeric.OPERATION_NEGATION) {
throw new PropertyException("UnaryExpr: Illegal Operator: "
+ operation);
}
@@ -64,7 +64,7 @@
return 0;
}
switch (operation) {
- case ExprAdditive.OPERATION_NEGATION: {
+ case ExprNumeric.OPERATION_NEGATION: {
return ((ExprNumeric) operand1).evalUnitPower1(pointSize,
percentBase) * -1;
}
@@ -80,7 +80,7 @@
}
public double getNumericValue() {
- if (operation == Expr.OPERATION_NEGATION) {
+ if (operation == ExprNumeric.OPERATION_NEGATION) {
return ((ExprNumeric) this.operand1).getNumericValue() * -1;
}
return 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-27 01:11:23
|
Revision: 8432
http://svn.sourceforge.net/foray/?rev=8432&view=rev
Author: victormote
Date: 2006-10-26 18:10:40 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Move the numeric-related methods from Expr to ExprNumeric.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtAngle.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCharacter.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCountry.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtFrequency.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtKeep.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLanguage.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthBPIPDirection.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthConditional.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthRange.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtName.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtNumber.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtRectangle.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtScript.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtShadowEffect.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtSpace.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtString.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtTextDeco.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtTime.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtURI.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtWritingMode.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprInner.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnAbs.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnBodyStart.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFromParent.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFromTableColumn.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnInheritedProp.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnLabelEnd.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMax.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMin.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnNearestSpecProp.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnProportionalColWidth.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRGB.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyKeyword.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -35,7 +35,7 @@
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
-import org.foray.fotree.value.Expr;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -104,8 +104,8 @@
|| pv instanceof PropertyKeyword) {
return pv;
}
- if (pv instanceof Expr) {
- if (((Expr) pv).canEvalUnitPower1()) {
+ if (pv instanceof ExprNumeric) {
+ if (((ExprNumeric) pv).canEvalUnitPower1()) {
return pv;
}
}
@@ -160,9 +160,9 @@
return Math.round(percentage * getBaseFontSize(context,
fobj) / WKConstants.PERCENT_CONVERSION);
}
- if (value() instanceof Expr) {
- return ((Expr) value()).evalUnitPower1(getBaseFontSize(context,
- fobj), 0);
+ if (value() instanceof ExprNumeric) {
+ return ((ExprNumeric) value()).evalUnitPower1(getBaseFontSize(
+ context, fobj), 0);
}
return getBaseFontSize(context, fobj);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Indent.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -35,7 +35,7 @@
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
-import org.foray.fotree.value.Expr;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.FnBodyStart;
import org.foray.fotree.value.FnLabelEnd;
import org.foray.fotree.value.PropertyKeyword;
@@ -80,8 +80,8 @@
if (pv instanceof FnBodyStart) {
return pv;
}
- if (pv instanceof Expr) {
- final Expr expression = (Expr) pv;
+ if (pv instanceof ExprNumeric) {
+ final ExprNumeric expression = (ExprNumeric) pv;
if (expression.canEvalUnitPower1()) {
return pv;
}
@@ -120,8 +120,8 @@
final DtLength lengthDT = function.eval(fobj, ipdContainingRA);
return lengthDT.getValue(fobj.traitFontSize(context), 0);
}
- if (value() instanceof Expr) {
- final Expr expression = (Expr) value();
+ if (value() instanceof ExprNumeric) {
+ final ExprNumeric expression = (ExprNumeric) value();
return expression.evalUnitPower1(fobj.traitFontSize(context),
ipdContainingRA);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LastLineEndIndent.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -35,7 +35,7 @@
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
-import org.foray.fotree.value.Expr;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyValue;
import org.axsl.common.Constants;
@@ -71,8 +71,8 @@
if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof Expr) {
- if (((Expr) pv).canEvalUnitPower1()) {
+ if (pv instanceof ExprNumeric) {
+ if (((ExprNumeric) pv).canEvalUnitPower1()) {
return pv;
}
throw unexpectedValue(value, propertyList);
@@ -92,9 +92,9 @@
return Math.round(percentage * ipdAncestorBANotLA /
WKConstants.PERCENT_CONVERSION);
}
- if (value() instanceof Expr) {
+ if (value() instanceof ExprNumeric) {
final int fontSize = fobj.traitFontSize(context);
- return ((Expr) value()).evalUnitPower1(fontSize, 0);
+ return ((ExprNumeric) value()).evalUnitPower1(fontSize, 0);
}
return getValueNoInstance(context, fobj, ipdAncestorBANotLA);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/Margin.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -36,7 +36,7 @@
import org.foray.fotree.fo.obj.SimplePageMaster;
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
-import org.foray.fotree.value.Expr;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyCollection;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -81,8 +81,8 @@
return pv;
}
pv = standardParse(propertyList, value, false, false);
- if (pv instanceof Expr) {
- final Expr expression = (Expr) pv;
+ if (pv instanceof ExprNumeric) {
+ final ExprNumeric expression = (ExprNumeric) pv;
if (expression.canEvalUnitPower1()) {
return pv;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/RelativeSpace.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -36,7 +36,7 @@
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
import org.foray.fotree.value.DtSpace;
-import org.foray.fotree.value.Expr;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -75,9 +75,9 @@
return pv;
}
pv = standardParse(propertyList, value, false, false);
- if (pv instanceof Expr) {
- final Expr expr = (Expr) pv;
- if (expr.unitPower() == 1) {
+ if (pv instanceof ExprNumeric) {
+ final ExprNumeric expr = (ExprNumeric) pv;
+ if (expr.canEvalUnitPower1()) {
return new DtSpace(expr, expr, expr, Constants.FOVAL_DISCARD,
0);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextIndent.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -35,7 +35,7 @@
import org.foray.fotree.PropertyList;
import org.foray.fotree.value.DtLength;
import org.foray.fotree.value.DtPercentage;
-import org.foray.fotree.value.Expr;
+import org.foray.fotree.value.ExprNumeric;
import org.foray.fotree.value.PropertyKeyword;
import org.foray.fotree.value.PropertyValue;
@@ -71,8 +71,8 @@
if (pv instanceof DtPercentage) {
return pv;
}
- if (pv instanceof Expr) {
- final Expr expression = (Expr) pv;
+ if (pv instanceof ExprNumeric) {
+ final ExprNumeric expression = (ExprNumeric) pv;
if (expression.canEvalUnitPower1()) {
return pv;
}
@@ -100,8 +100,8 @@
return Math.round(percentage * widthContainingBlock
/ WKConstants.PERCENT_CONVERSION);
}
- if (value() instanceof Expr) {
- final Expr expression = (Expr) value();
+ if (value() instanceof ExprNumeric) {
+ final ExprNumeric expression = (ExprNumeric) value();
return expression.evalUnitPower1(fobj.traitFontSize(context),
widthContainingBlock);
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtAngle.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtAngle.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtAngle.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -156,11 +156,4 @@
return true;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCharacter.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCharacter.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCharacter.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -51,11 +51,4 @@
return value;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtColor.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -570,11 +570,4 @@
return integralColor / divisor;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCountry.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCountry.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtCountry.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -77,11 +77,4 @@
return new DtCountry(countryCode);
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtFrequency.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtFrequency.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtFrequency.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -110,11 +110,4 @@
}
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -111,4 +111,18 @@
return this.value;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canEvalUnitPower1() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int evalUnitPower1(final int pointSize, final int percentBase) {
+ return Integer.MIN_VALUE;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtKeep.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtKeep.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtKeep.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -83,11 +83,4 @@
return new DtKeep(Keep.AUTO, Keep.AUTO, Keep.AUTO);
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLanguage.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLanguage.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLanguage.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -69,11 +69,4 @@
return new DtLanguage(languageCode);
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthBPIPDirection.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthBPIPDirection.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthBPIPDirection.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -62,11 +62,4 @@
return this.ipdLength;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthConditional.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthConditional.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthConditional.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -62,11 +62,4 @@
return this.conditionality;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthRange.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthRange.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLengthRange.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -94,11 +94,4 @@
return false;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtName.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtName.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtName.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -67,11 +67,4 @@
return new DtName(input);
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
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-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtNumber.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -84,4 +84,18 @@
return this.value;
}
+ /**
+ * {@inheritDoc}
+ */
+ public boolean canEvalUnitPower1() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int evalUnitPower1(final int pointSize, final int percentBase) {
+ return Integer.MIN_VALUE;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -88,8 +88,15 @@
/**
* {@inheritDoc}
*/
- public byte unitPower() {
- return -1;
+ public boolean canEvalUnitPower1() {
+ return false;
}
+ /**
+ * {@inheritDoc}
+ */
+ public int evalUnitPower1(final int pointSize, final int percentBase) {
+ return Integer.MIN_VALUE;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtRectangle.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtRectangle.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtRectangle.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -162,11 +162,4 @@
}
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtScript.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtScript.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtScript.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -187,11 +187,4 @@
return false;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtShadowEffect.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtShadowEffect.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtShadowEffect.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -141,11 +141,4 @@
blurRadius, color);
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtSpace.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtSpace.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtSpace.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -50,21 +50,22 @@
Constants.FOVAL_FORCE,
};
- private Expr lengthMinimum;
- private Expr lengthOptimum;
- private Expr lengthMaximum;
+ private ExprNumeric lengthMinimum;
+ private ExprNumeric lengthOptimum;
+ private ExprNumeric lengthMaximum;
private short conditionality;
private int precedence;
/**
* Constructor.
*/
- public DtSpace(final Expr lengthMinimum, final Expr lengthOptimum,
- final Expr lengthMaximum, final short conditionality,
- final int precedence) throws PropertyException {
- if (lengthMinimum.unitPower() != 1
- || lengthOptimum.unitPower() != 1
- || lengthMaximum.unitPower() != 1) {
+ public DtSpace(final ExprNumeric lengthMinimum,
+ final ExprNumeric lengthOptimum, final ExprNumeric lengthMaximum,
+ final short conditionality, final int precedence)
+ throws PropertyException {
+ if (lengthMinimum.getLengthPower() != 1
+ || lengthOptimum.getLengthPower() != 1
+ || lengthMaximum.getLengthPower() != 1) {
throw new PropertyException("Invalid length");
}
this.lengthMinimum = lengthMinimum;
@@ -169,11 +170,4 @@
return false;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return UNIT_POWER_LENGTH;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtString.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtString.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtString.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -51,11 +51,4 @@
return value;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtTextDeco.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtTextDeco.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtTextDeco.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -107,11 +107,4 @@
this.isUnderlined = isUnderlined;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtTime.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtTime.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtTime.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -111,11 +111,4 @@
}
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtURI.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtURI.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtURI.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -88,11 +88,4 @@
return tokenizedList;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtWritingMode.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtWritingMode.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtWritingMode.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -684,11 +684,4 @@
return -1;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -40,40 +40,4 @@
public static final byte OPERATION_MOD = '%';
public static final byte OPERATION_NEGATION = '-';
- public static final byte UNIT_POWER_NON_NUMERIC = -1;
- public static final byte UNIT_POWER_NUMERIC = 0;
- public static final byte UNIT_POWER_LENGTH = 1;
- public static final byte UNIT_POWER_AREA = 2;
-
- /**
- * Returns the unit power for this expression.
- * Unit power is the number of dimensions to which a numeric item applies.
- * Lengths have a unit power of 1, areas have a unit power of 2.
- * Valid values are {@link #UNIT_POWER_NON_NUMERIC},
- * {@link #UNIT_POWER_NUMERIC}, {@link #UNIT_POWER_LENGTH},
- * {@link #UNIT_POWER_AREA}.
- * @return The unit power to which this expression evaluates.
- */
- public abstract byte unitPower();
-
- /**
- * Indicates whether this expression can be evaluated to a unit power = 1
- * (length) or not.
- * @return True if the expression can be evaluated to a unit power of 1
- * (length).
- */
- public boolean canEvalUnitPower1() {
- return false;
- }
-
- /**
- * Evaluates the expression to a unit power of 1 (length).
- * This superclass method always returns 0, so subclasses that can return a
- * length must override this method.
- * @return The unit power 1 value (length) of this expression.
- */
- public int evalUnitPower1(final int pointSize, final int percentBase) {
- return 0;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprAdditiveOper.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -33,7 +33,7 @@
/**
* Class for handling AdditiveExpr.
*/
-public class ExprAdditiveOper extends ExprAdditive {
+public class ExprAdditiveOper extends ExprAdditive implements ExprNumeric {
private ExprAdditive operand1;
private ExprMultiplicative operand2;
@@ -42,12 +42,12 @@
public ExprAdditiveOper(final ExprAdditive operand1,
final ExprMultiplicative operand2,
final byte operation) throws PropertyException {
- if (operand1.unitPower() < 0) {
+ if (! (operand1 instanceof ExprNumeric)) {
throw new PropertyException("AdditiveExpr: Non-numeric operand: "
+ operand1.toString());
}
this.operand1 = operand1;
- if (operand2.unitPower() < 0) {
+ if (! (operand2 instanceof ExprNumeric)) {
throw new PropertyException("AdditiveExpr: Non-numeric operand: "
+ operand2.toString());
}
@@ -56,7 +56,8 @@
* For Additive Expressions, the unitPower of the two operands must
* be equal. See XSL-FO Specification 1.0, Section 5.9.6.
*/
- if (operand1.unitPower() != operand2.unitPower()) {
+ if (((ExprNumeric) operand1).getLengthPower()
+ != ((ExprNumeric) operand2).getLengthPower()) {
throw new PropertyException("AdditiveExpr: Unit powers differ: "
+ operand1.toString() + ", " + operand2.toString());
}
@@ -69,10 +70,9 @@
}
public boolean canEvalUnitPower1() {
- if (operand1.canEvalUnitPower1() && operand2.canEvalUnitPower1()) {
- return true;
- }
- return false;
+ /* In the constructor, we have already tested the equality of the
+ * operands unit power. Therefore, we can just evaluate one here. */
+ return ((ExprNumeric) operand1).canEvalUnitPower1();
}
public int evalUnitPower1(final int pointSize, final int percentBase) {
@@ -81,12 +81,12 @@
}
switch (operation) {
case Expr.OPERATION_ADD: {
- return operand1.evalUnitPower1(pointSize, percentBase)
- + operand2.evalUnitPower1(pointSize, percentBase);
+ return getOperand1Length(pointSize, percentBase)
+ + getOperand2Length(pointSize, percentBase);
}
case Expr.OPERATION_SUBTRACT: {
- return operand1.evalUnitPower1(pointSize, percentBase)
- - operand2.evalUnitPower1(pointSize, percentBase);
+ return getOperand1Length(pointSize, percentBase)
+ - getOperand2Length(pointSize, percentBase);
}
}
return 0;
@@ -95,10 +95,41 @@
/**
* {@inheritDoc}
*/
- public byte unitPower() {
+ public byte getLengthPower() {
/* We already tested that the unit powers were equal at construction,
* so all we need to do here is return one of them. */
- return operand1.unitPower();
+ return ((ExprNumeric) operand1).getLengthPower();
}
+ public double getOperand1Value() {
+ return ((ExprNumeric) operand1).getNumericValue();
+ }
+
+ public double getOperand2Value() {
+ return ((ExprNumeric) operand2).getNumericValue();
+ }
+
+ public int getOperand1Length(final int pointSize, final int percentBase) {
+ return ((ExprNumeric) operand1).evalUnitPower1(pointSize, percentBase);
+ }
+
+ public int getOperand2Length(final int pointSize, final int percentBase) {
+ return ((ExprNumeric) operand2).evalUnitPower1(pointSize, percentBase);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public double getNumericValue() {
+ switch (operation) {
+ case Expr.OPERATION_ADD: {
+ return getOperand1Value() + getOperand2Value();
+ }
+ case Expr.OPERATION_SUBTRACT: {
+ return getOperand1Value() - getOperand2Value();
+ }
+ }
+ return 0;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprInner.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprInner.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprInner.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -41,15 +41,8 @@
this.enclosedExpression = expression;
}
- public boolean canEvalUnitPower1() {
- if (enclosedExpression.canEvalUnitPower1()) {
- return true;
- }
- return false;
+ public ExprAdditive getEnclosedExpression() {
+ return this.enclosedExpression;
}
- public byte unitPower() {
- return this.enclosedExpression.unitPower();
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -33,7 +33,8 @@
/**
*
*/
-public class ExprMultiplicativeOper extends ExprMultiplicative {
+public class ExprMultiplicativeOper extends ExprMultiplicative
+ implements ExprNumeric {
private ExprMultiplicative operand1;
private ExprUnary operand2;
@@ -57,7 +58,8 @@
* be equal. See XSL-FO Specification 1.0, Section 5.9.6.
*/
if (operation == Expr.OPERATION_MOD
- && operand1.unitPower() != operand2.unitPower()) {
+ && ((ExprNumeric) operand1).getLengthPower()
+ != ((ExprNumeric) operand2).getLengthPower()) {
throw new PropertyException("Modulo Operator: Unit powers differ: "
+ operand1.toString() + ", " + operand2.toString());
}
@@ -71,7 +73,8 @@
}
public boolean canEvalUnitPower1() {
- if (operand1.canEvalUnitPower1() || operand2.canEvalUnitPower1()) {
+ if (((ExprNumeric) operand1).canEvalUnitPower1()
+ || ((ExprNumeric) operand2).canEvalUnitPower1()) {
return true;
}
return false;
@@ -84,8 +87,8 @@
// Compute raw value for operand1
double rawOperand1 = 0;
- if (operand1.unitPower() == 1) {
- rawOperand1 = operand1.evalUnitPower1(pointSize, percentBase);
+ if (getOperand1UnitPower() == 1) {
+ rawOperand1 = getOperand1Length(pointSize, percentBase);
} else {
/* Cast verified during construction. */
rawOperand1 = ((ExprNumeric) operand1).getNumericValue();
@@ -93,8 +96,8 @@
// Compute raw value for operand2
double rawOperand2 = 0;
- if (operand2.unitPower() == 1) {
- rawOperand2 = operand2.evalUnitPower1(pointSize, percentBase);
+ if (getOperand2UnitPower() == 1) {
+ rawOperand2 = getOperand2Length(pointSize, percentBase);
} else {
rawOperand2 = ((ExprNumeric) operand2).getNumericValue();
}
@@ -117,10 +120,34 @@
return (int) Math.round(rawValue);
}
+ public double getOperand1Value() {
+ return ((ExprNumeric) operand1).getNumericValue();
+ }
+
+ public double getOperand2Value() {
+ return ((ExprNumeric) operand2).getNumericValue();
+ }
+
+ public byte getOperand1UnitPower() {
+ return ((ExprNumeric) operand1).getLengthPower();
+ }
+
+ public byte getOperand2UnitPower() {
+ return ((ExprNumeric) operand2).getLengthPower();
+ }
+
+ public int getOperand1Length(final int pointSize, final int percentBase) {
+ return ((ExprNumeric) operand1).evalUnitPower1(pointSize, percentBase);
+ }
+
+ public int getOperand2Length(final int pointSize, final int percentBase) {
+ return ((ExprNumeric) operand2).evalUnitPower1(pointSize, percentBase);
+ }
+
/**
* {@inheritDoc}
*/
- public byte unitPower() {
+ public byte getLengthPower() {
/* For multiplication, the unit power of the product is the sum
* of the unit powers of the operands.
* For example, 3 meters * 5 = 15 meters.
@@ -128,7 +155,26 @@
* of 0.
* 1 + 0 = 1, which is intuitively correct, because our product is in
* meters, which has a unit power of 1.*/
- return (byte) (operand1.unitPower() + operand2.unitPower());
+ return (byte) (((ExprNumeric) operand1).getLengthPower()
+ + ((ExprNumeric) operand2).getLengthPower());
}
+ /**
+ * {@inheritDoc}
+ */
+ public double getNumericValue() {
+ switch (operation) {
+ case Expr.OPERATION_MULTIPLY: {
+ return getOperand1Value() * getOperand2Value();
+ }
+ case Expr.OPERATION_DIVIDE: {
+ return getOperand1Value() / getOperand2Value();
+ }
+ case Expr.OPERATION_MOD: {
+ return getOperand1Value() % getOperand2Value();
+ }
+ }
+ return 0;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -35,6 +35,11 @@
*/
public interface ExprNumeric {
+ byte UNIT_POWER_NON_NUMERIC = -1;
+ byte UNIT_POWER_NUMERIC = 0;
+ byte UNIT_POWER_LENGTH = 1;
+ byte UNIT_POWER_AREA = 2;
+
/**
* Return the numeric value of "this".
* @return A double representation of the value of "this". Type "double" is
@@ -52,8 +57,24 @@
* inches) would, we suppose, have a length power of 2, and one referring to
* volume (e.g. cubic feet) would, we suppose have a length power of 3.
* @return The number of spatial dimensions in which this numeric item
- * operates. For XSL-FO items, this should be either 0 or 1.
+ * operates. For XSL-FO items, this should be either
+ * {@link #UNIT_POWER_NUMERIC} or {@link #UNIT_POWER_LENGTH}.
*/
byte getLengthPower();
+ /**
+ * Indicates whether this expression can be evaluated to a unit power = 1
+ * (length) or not.
+ * @return True if the expression can be evaluated to a unit power of 1
+ * (length).
+ */
+ boolean canEvalUnitPower1();
+
+ /**
+ * Evaluates the expression to a unit power of 1 (length).
+ * @return The unit power 1 value (length) of this expression if the
+ * expression can be so evaluated, or {@link Integer#MIN_VALUE} otherwise.
+ */
+ int evalUnitPower1(final int pointSize, final int percentBase);
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprUnaryOper.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -33,14 +33,14 @@
/**
*
*/
-public class ExprUnaryOper extends ExprUnary {
+public class ExprUnaryOper extends ExprUnary implements ExprNumeric {
private ExprUnary operand1;
private byte operation;
public ExprUnaryOper(final ExprUnary operand1, final byte operation)
throws PropertyException {
- if (operand1.unitPower() < 0) {
+ if (! (operand1 instanceof ExprNumeric)) {
throw new PropertyException("UnaryExpr: Non-numeric operand: "
+ operand1.toString());
}
@@ -53,7 +53,7 @@
}
public boolean canEvalUnitPower1() {
- if (operand1.canEvalUnitPower1()) {
+ if (((ExprNumeric) operand1).canEvalUnitPower1()) {
return true;
}
return false;
@@ -65,8 +65,8 @@
}
switch (operation) {
case ExprAdditive.OPERATION_NEGATION: {
- return operand1.evalUnitPower1(pointSize, percentBase)
- * -1;
+ return ((ExprNumeric) operand1).evalUnitPower1(pointSize,
+ percentBase) * -1;
}
}
return 0;
@@ -75,8 +75,15 @@
/**
* {@inheritDoc}
*/
- public byte unitPower() {
- return this.operand1.unitPower();
+ public byte getLengthPower() {
+ return ((ExprNumeric) this.operand1).getLengthPower();
}
+ public double getNumericValue() {
+ if (operation == Expr.OPERATION_NEGATION) {
+ return ((ExprNumeric) this.operand1).getNumericValue() * -1;
+ }
+ return 0;
+ }
+
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnAbs.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnAbs.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnAbs.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -64,11 +64,4 @@
return new DtNumber(value);
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnBodyStart.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnBodyStart.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnBodyStart.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -106,11 +106,4 @@
return lengthDT;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnCeiling.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -62,11 +62,4 @@
return new DtNumber(value);
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFloor.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -61,11 +61,4 @@
return new DtNumber(value);
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFromParent.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFromParent.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFromParent.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -105,11 +105,4 @@
return ps.value();
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFromTableColumn.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFromTableColumn.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnFromTableColumn.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -78,11 +78,4 @@
+ "'from-table-column'");
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnInheritedProp.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnInheritedProp.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnInheritedProp.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -96,11 +96,4 @@
return ps.value();
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnLabelEnd.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnLabelEnd.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnLabelEnd.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -113,11 +113,4 @@
return lengthDT;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMax.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMax.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMax.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -66,11 +66,4 @@
return new DtNumber(value);
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMin.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMin.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnMin.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -68,11 +68,4 @@
return new DtNumber(value);
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnNearestSpecProp.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnNearestSpecProp.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnNearestSpecProp.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -96,11 +96,4 @@
return ps.value();
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnProportionalColWidth.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnProportionalColWidth.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnProportionalColWidth.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -88,11 +88,4 @@
return (ExprNumeric) getArgs()[0];
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRGB.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRGB.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRGB.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -103,11 +103,4 @@
return eval();
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/FnRound.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -65,11 +65,4 @@
return new DtInteger((int) value);
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyKeyword.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyKeyword.java 2006-10-27 00:10:48 UTC (rev 8431)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/PropertyKeyword.java 2006-10-27 01:10:40 UTC (rev 8432)
@@ -44,11 +44,4 @@
return value;
}
- /**
- * {@inheritDoc}
- */
- public byte unitPower() {
- return -1;
- }
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-27 00:10:53
|
Revision: 8431
http://svn.sourceforge.net/foray/?rev=8431&view=rev
Author: victormote
Date: 2006-10-26 17:10:48 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Remove no-longer-needed method, replacing it with pre-existing method in ExprNumeric.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java 2006-10-26 22:27:40 UTC (rev 8430)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/Expr.java 2006-10-27 00:10:48 UTC (rev 8431)
@@ -76,8 +76,4 @@
return 0;
}
- public double evalNumeric() {
- return 0;
- }
-
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java 2006-10-26 22:27:40 UTC (rev 8430)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprMultiplicativeOper.java 2006-10-27 00:10:48 UTC (rev 8431)
@@ -42,12 +42,12 @@
public ExprMultiplicativeOper(final ExprMultiplicative operand1,
final ExprUnary operand2, final byte operation)
throws PropertyException {
- if (operand1.unitPower() < 0) {
+ if (! (operand1 instanceof ExprNumeric)) {
throw new PropertyException(this.getClass().getName()
+ ": Non-numeric operand: " + operand1.toString());
}
this.operand1 = operand1;
- if (operand2.unitPower() < 0) {
+ if (! (operand2 instanceof ExprNumeric)) {
throw new PropertyException(this.getClass().getName()
+ "Non-numeric operand: " + operand2.toString());
}
@@ -87,7 +87,8 @@
if (operand1.unitPower() == 1) {
rawOperand1 = operand1.evalUnitPower1(pointSize, percentBase);
} else {
- rawOperand1 = operand1.evalNumeric();
+ /* Cast verified during construction. */
+ rawOperand1 = ((ExprNumeric) operand1).getNumericValue();
}
// Compute raw value for operand2
@@ -95,7 +96,7 @@
if (operand2.unitPower() == 1) {
rawOperand2 = operand2.evalUnitPower1(pointSize, percentBase);
} else {
- rawOperand2 = operand2.evalNumeric();
+ rawOperand2 = ((ExprNumeric) operand2).getNumericValue();
}
double rawValue = 0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-26 22:27:49
|
Revision: 8430
http://svn.sourceforge.net/foray/?rev=8430&view=rev
Author: victormote
Date: 2006-10-26 15:27:40 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Remove unneeded setter method.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLength.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtNumber.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java 2006-10-26 20:04:29 UTC (rev 8429)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtInteger.java 2006-10-26 22:27:40 UTC (rev 8430)
@@ -63,10 +63,6 @@
return value;
}
- public void setNumericValue(final double value) {
- this.value = (int) Math.round(value);
- }
-
public DtInteger round() {
return this;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLength.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLength.java 2006-10-26 20:04:29 UTC (rev 8429)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtLength.java 2006-10-26 22:27:40 UTC (rev 8430)
@@ -151,13 +151,6 @@
return this.value;
}
- /**
- * Note that this sets the raw numeric value, without regard to units.
- */
- public void setNumericValue(final double value) {
- this.value = (int) Math.round(value);
- }
-
/** @see ExprNumeric#getLengthPower */
public byte getLengthPower() {
return 1;
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-26 20:04:29 UTC (rev 8429)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtNumber.java 2006-10-26 22:27:40 UTC (rev 8430)
@@ -56,10 +56,6 @@
return value;
}
- public void setNumericValue(final double value) {
- this.value = value;
- }
-
public DtInteger round() {
final int integer = (int) Math.round(this.value);
return new DtInteger(integer);
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java 2006-10-26 20:04:29 UTC (rev 8429)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/DtPercentage.java 2006-10-26 22:27:40 UTC (rev 8430)
@@ -57,10 +57,6 @@
return value;
}
- public void setNumericValue(final double value) {
- this.value = (float) value;
- }
-
public byte getLengthPower() {
return 0;
}
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java 2006-10-26 20:04:29 UTC (rev 8429)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/value/ExprNumeric.java 2006-10-26 22:27:40 UTC (rev 8430)
@@ -43,14 +43,6 @@
double getNumericValue();
/**
- * Set the numeric value of "this" to <code>value</code>.
- * @param value The value to which the numeric portion of "this" should be
- * set. The implementation must round and/or narrow the value to the
- * appropriate form.
- */
- void setNumericValue(double value);
-
- /**
* Each numeric has a "length power" or a "unit power" (which we think are
* synonymous). This number refers to the number of spatial dimensions that
* in which the number operates. So, a number that has no relationship to
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-26 20:04:36
|
Revision: 8429
http://svn.sourceforge.net/foray/?rev=8429&view=rev
Author: victormote
Date: 2006-10-26 13:04:29 -0700 (Thu, 26 Oct 2006)
Log Message:
-----------
Make checking of keywords the first part of the standard parsing routine.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.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-24 01:44:10 UTC (rev 8428)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/Property.java 2006-10-26 20:04:29 UTC (rev 8429)
@@ -166,8 +166,11 @@
protected PropertyValue standardParse(final PropertyList propertyList,
final String rawPropertyValue, final boolean integerOnly,
final boolean percentsAsLengths) throws PropertyException {
- final PropertyValue pv = PropertyParser.parse(propertyList,
- rawPropertyValue);
+ PropertyValue pv = checkKeywords(rawPropertyValue);
+ if (pv != null) {
+ return pv;
+ }
+ pv = PropertyParser.parse(propertyList, rawPropertyValue);
if (integerOnly) {
if (pv instanceof DtNumber) {
// Only integers wanted, so convert to one here.
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java 2006-10-24 01:44:10 UTC (rev 8428)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/FontSize.java 2006-10-26 20:04:29 UTC (rev 8429)
@@ -98,14 +98,12 @@
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 DtPercentage
+ || pv instanceof PropertyKeyword) {
return pv;
}
- pv = standardParse(propertyList, value, false, false);
- if (pv instanceof DtPercentage) {
- return pv;
- }
if (pv instanceof Expr) {
if (((Expr) pv).canEvalUnitPower1()) {
return pv;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-24 01:44:14
|
Revision: 8428
http://svn.sourceforge.net/foray/?rev=8428&view=rev
Author: victormote
Date: 2006-10-23 18:44:10 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Add missing Eclipse project file.
Added Paths:
-----------
trunk/foray/lib/.project
Added: trunk/foray/lib/.project
===================================================================
--- trunk/foray/lib/.project (rev 0)
+++ trunk/foray/lib/.project 2006-10-24 01:44:10 UTC (rev 8428)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>FOrayLibs</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <vic...@us...> - 2006-10-24 01:37:35
|
Revision: 8427
http://svn.sourceforge.net/foray/?rev=8427&view=rev
Author: victormote
Date: 2006-10-23 18:37:22 -0700 (Mon, 23 Oct 2006)
Log Message:
-----------
Clean up some style complaints.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/SpanRA.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderLength.java
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/SpanRA.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/SpanRA.java 2006-10-23 14:16:47 UTC (rev 8426)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/SpanRA.java 2006-10-24 01:37:22 UTC (rev 8427)
@@ -134,7 +134,7 @@
* Just return the main-reference-area. The span can't be created
* until we return back down to the first block-level area.
*/
- return (MainRA) getParentArea().getOverflowArea(this);
+ return getParentArea().getOverflowArea(this);
}
public int traitColumnCount() {
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderLength.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderLength.java 2006-10-23 14:16:47 UTC (rev 8426)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/LeaderLength.java 2006-10-24 01:37:22 UTC (rev 8427)
@@ -85,7 +85,7 @@
return new DtLengthRange(length, length, length);
}
if (pv instanceof DtPercentage) {
- return (DtPercentage) pv;
+ return pv;
}
throw unexpectedValue(value, propertyList);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|