[FOray-commit] SF.net SVN: foray: [9162] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-04-10 01:52:00
|
Revision: 9162
http://svn.sourceforge.net/foray/?rev=9162&view=rev
Author: victormote
Date: 2007-04-09 18:51:57 -0700 (Mon, 09 Apr 2007)
Log Message:
-----------
Conform to axsl change adding new typesafe enum.
Modified Paths:
--------------
trunk/foray/foray-areatree/src/java/org/foray/area/Area.java
trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.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
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/Area.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/Area.java 2007-04-10 00:28:09 UTC (rev 9161)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/Area.java 2007-04-10 01:51:57 UTC (rev 9162)
@@ -41,6 +41,7 @@
import org.axsl.common.value.Overflow;
import org.axsl.common.value.RelativeAxis;
import org.axsl.common.value.Scaling;
+import org.axsl.common.value.TextAlign;
import org.axsl.common.value.WrapOption;
import org.axsl.common.value.WritingMode;
import org.axsl.foR.Fo;
@@ -1392,7 +1393,7 @@
* @return The text-align trait for this area.
* @see Fo#traitTextAlign(FoContext)
*/
- public FoValue traitTextAlign() {
+ public TextAlign traitTextAlign() {
return traitGeneratedBy().traitTextAlign(this);
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2007-04-10 00:28:09 UTC (rev 9161)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2007-04-10 01:51:57 UTC (rev 9162)
@@ -34,12 +34,13 @@
import org.axsl.common.value.Baseline;
import org.axsl.common.value.Compass;
import org.axsl.common.value.RelativeAxis;
+import org.axsl.common.value.TextAlign;
+import org.axsl.common.value.TextAlignLast;
import org.axsl.foR.FoContext;
import org.axsl.foR.FoText;
import org.axsl.foR.FoTextContent;
import org.axsl.foR.fo.Block;
import org.axsl.foR.fo.ExternalGraphic;
-import org.axsl.foR.fo.FoValue;
import org.axsl.foR.fo.InstreamForeignObject;
import org.axsl.foR.fo.Leader;
import org.axsl.foR.fo.PageNumber;
@@ -126,7 +127,7 @@
return this.pdAvailable() / 2;
case JUSTIFY:
return 0;
- case NOT_A_KEYWORD: {
+ case STRING: {
/*
* This is a valid setting, and means that we should find the
* string to align the text on by using
@@ -169,7 +170,7 @@
}
}
// No need to optimize unless we are justifying the line.
- if (traitTextAlign() != FoValue.JUSTIFY) {
+ if (traitTextAlign() != TextAlign.JUSTIFY) {
return false;
}
/*
@@ -627,10 +628,9 @@
* that results from aligning the line.
*/
public int startAlignmentAdjustment() {
- final FoValue textAlign = traitGeneratedBy().traitTextAlign(this);
+ final TextAlign textAlign = traitGeneratedBy().traitTextAlign(this);
switch (textAlign) {
- case END:
- case RIGHT: {
+ case END: {
return totalAlignmentAdjustment();
}
case CENTER: {
@@ -804,45 +804,40 @@
* Returns the effective text alignment value for <em>this</em> line.
* This method uses either the text-align or text-align-last properties, as
* appropriate.
- * It also resolves the values of RELATIVE, LEFT, RIGHT, INSIDE, and
- * OUTSIDE, converting them, as appropriate to the one of the cardinal
- * values (START, END, CENTER, JUSTIFY).
+ * It also resolves the values of {@link TextAlign#INSIDE} and
+ * {@link TextAlign#OUTSIDE}, converting them, as appropriate, to the one of
+ * the cardinal values (START, END, CENTER, JUSTIFY).
* @return One of the following TraitEnumeration constants: START, END,
* CENTER, JUSTIFY.
*/
- public FoValue traitTextAlign() {
- FoValue textAlign = traitGeneratedBy().traitTextAlign(this);
+ public TextAlign traitTextAlign() {
+ final Block generatedBy = traitGeneratedBy();
+ TextAlign textAlign = generatedBy.traitTextAlign(this);
if (this.textAlignLastApplies()) {
- final FoValue textAlignLast = traitGeneratedBy().traitTextAlignLast(
+ final TextAlignLast textAlignLast = generatedBy.traitTextAlignLast(
this);
- if (textAlignLast == FoValue.RELATIVE) {
- if (textAlign == FoValue.JUSTIFY) {
- return FoValue.START;
+ if (textAlignLast == TextAlignLast.RELATIVE) {
+ if (textAlign == TextAlign.JUSTIFY) {
+ return TextAlign.START;
}
} else {
- textAlign = textAlignLast;
+ textAlign = textAlignLast.getRelatedTextAlign();
}
}
switch (textAlign) {
- case LEFT: {
- return FoValue.START;
- }
- case RIGHT: {
- return FoValue.END;
- }
case INSIDE: {
if (this.getPage().getBindingEdge()
== Compass.END) {
- return FoValue.END;
+ return TextAlign.END;
}
- return FoValue.START;
+ return TextAlign.START;
}
case OUTSIDE: {
if (this.getPage().getBindingEdge()
== Compass.END) {
- return FoValue.START;
+ return TextAlign.START;
}
- return FoValue.END;
+ return TextAlign.END;
}
default: {
return textAlign;
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2007-04-10 00:28:09 UTC (rev 9161)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/FObj.java 2007-04-10 01:51:57 UTC (rev 9162)
@@ -54,6 +54,8 @@
import org.axsl.common.value.ShadowEffect;
import org.axsl.common.value.Shape;
import org.axsl.common.value.Span;
+import org.axsl.common.value.TextAlign;
+import org.axsl.common.value.TextAlignLast;
import org.axsl.common.value.WrapOption;
import org.axsl.common.value.WritingMode;
import org.axsl.foR.FoContext;
@@ -1137,10 +1139,31 @@
}
/**
+ * Converts an {@link FoValue} text-align value to the more generic
+ * {@link TextAlign} value.
+ * @param foTextAlign The raw FO text-align value to be converted.
+ * @return The matching TextAlign instance.
+ */
+ private static TextAlign convertTextAlign(final FoValue foTextAlign) {
+ switch (foTextAlign) {
+ case START: return TextAlign.START;
+ case CENTER: return TextAlign.CENTER;
+ case END: return TextAlign.END;
+ case JUSTIFY: return TextAlign.JUSTIFY;
+ case INSIDE: return TextAlign.INSIDE;
+ case OUTSIDE: return TextAlign.OUTSIDE;
+ case NOT_A_KEYWORD: return TextAlign.STRING;
+ default: throw new IllegalArgumentException("Illegal text-align value: "
+ + foTextAlign.toXslFo());
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
- public FoValue traitTextAlign(final FoContext context) {
- return propertyList.getTextAlign(context);
+ public TextAlign traitTextAlign(final FoContext context) {
+ final FoValue foTextAlign = propertyList.getTextAlign(context);
+ return convertTextAlign(foTextAlign);
}
/**
@@ -1151,10 +1174,33 @@
}
/**
+ * Converts an {@link FoValue} text-align-last value to the more generic
+ * {@link TextAlignLast} value.
+ * @param foTextAlignLast The raw FO text-align-last value to be converted.
+ * @return The matching TextAlignLast instance.
+ */
+ private static TextAlignLast convertTextAlignLast(
+ final FoValue foTextAlignLast) {
+ switch (foTextAlignLast) {
+ case RELATIVE: return TextAlignLast.RELATIVE;
+ case START: return TextAlignLast.START;
+ case CENTER: return TextAlignLast.CENTER;
+ case END: return TextAlignLast.END;
+ case JUSTIFY: return TextAlignLast.JUSTIFY;
+ case INSIDE: return TextAlignLast.INSIDE;
+ case OUTSIDE: return TextAlignLast.OUTSIDE;
+ default: throw new IllegalArgumentException(
+ "Illegal text-align-last value: "
+ + foTextAlignLast.toXslFo());
+ }
+ }
+
+ /**
* {@inheritDoc}
*/
- public FoValue traitTextAlignLast(final FoContext context) {
- return propertyList.getTextAlignLast(context);
+ public TextAlignLast traitTextAlignLast(final FoContext context) {
+ final FoValue foTextAlignLast = propertyList.getTextAlignLast(context);
+ return convertTextAlignLast(foTextAlignLast);
}
/**
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 2007-04-10 00:28:09 UTC (rev 9161)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlign.java 2007-04-10 01:51:57 UTC (rev 9162)
@@ -107,7 +107,7 @@
return FoValue.START;
}
// If you can find the parent, use its value.
- return parent.traitTextAlign(context);
+ return parent.getPropertyList().getTextAlign(context);
}
protected FoValue[] getValidKeywords() {
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 2007-04-10 00:28:09 UTC (rev 9161)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/prop/TextAlignLast.java 2007-04-10 01:51:57 UTC (rev 9162)
@@ -93,7 +93,7 @@
return FoValue.RELATIVE;
}
// If you can find the parent, use its value.
- return parent.traitTextAlignLast(context);
+ return parent.getPropertyList().getTextAlignLast(context);
}
protected FoValue[] getValidKeywords() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|