Revision: 12994
http://sourceforge.net/p/foray/code/12994
Author: victormote
Date: 2023-01-01 01:30:16 +0000 (Sun, 01 Jan 2023)
Log Message:
-----------
Conform to aXSL change: Normalize angle property return values to millidegrees instead of fractional degrees.
Modified Paths:
--------------
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/AbstractGlyphOrientation.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdAzimuth.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdElevation.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Degrees.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Grads.java
trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Radians.java
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2023-01-01 00:58:40 UTC (rev 12993)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/FoObj.java 2023-01-01 01:30:16 UTC (rev 12994)
@@ -2612,12 +2612,12 @@
}
@Override
- public Number traitAzimuth(final FoContext context) {
+ public int traitAzimuth(final FoContext context) {
return getPropertyList().traitAzimuth(this, context);
}
@Override
- public Number traitElevation(final FoContext context) {
+ public int traitElevation(final FoContext context) {
return getPropertyList().traitElevation(this, context);
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java 2023-01-01 00:58:40 UTC (rev 12993)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/PropertyList.java 2023-01-01 01:30:16 UTC (rev 12994)
@@ -3811,7 +3811,7 @@
* @param context An object that knows how to resolve FO Tree context issues.
* @return The azimuth property.
*/
- public Number traitAzimuth(final FoObj fobj, final FoContext context) {
+ public int traitAzimuth(final FoObj fobj, final FoContext context) {
final PdAzimuth property = (PdAzimuth) getProperty(FoPropertyId.AZIMUTH);
if (property != null) {
return property.getValue(context, fobj);
@@ -3825,7 +3825,7 @@
* @param context An object that knows how to resolve FO Tree context issues.
* @return The elevation property.
*/
- public Number traitElevation(final FoObj fobj, final FoContext context) {
+ public int traitElevation(final FoObj fobj, final FoContext context) {
final PdElevation property = (PdElevation) getProperty(FoPropertyId.ELEVATION);
if (property != null) {
return property.getValue(context, fobj);
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/AbstractGlyphOrientation.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/AbstractGlyphOrientation.java 2023-01-01 00:58:40 UTC (rev 12993)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/AbstractGlyphOrientation.java 2023-01-01 01:30:16 UTC (rev 12994)
@@ -102,7 +102,7 @@
throw new IllegalStateException("Value must be an angle to round.");
}
final DtAngle angle = (DtAngle) value();
- final double angleValue = angle.getValue();
+ final int angleValue = angle.getValue();
if (angleValue < AbstractGlyphOrientation.ANGLE_ROUNDING_0_CUTOFF) {
return 0;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdAzimuth.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdAzimuth.java 2023-01-01 00:58:40 UTC (rev 12993)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdAzimuth.java 2023-01-01 01:30:16 UTC (rev 12994)
@@ -189,7 +189,7 @@
* @param fobj The FO for which this value is needed.
* @return The value of this property.
*/
- public Number getValue(final FoContext context, final FoObj fobj) {
+ public int getValue(final FoContext context, final FoObj fobj) {
if (value() instanceof DtAngle) {
return ((DtAngle) value()).getValue();
}
@@ -248,12 +248,12 @@
return PdAzimuth.ANGLE_RIGHT_SIDE;
}
case LEFTWARDS: {
- return (getValueNoInstance(context, fobj).doubleValue()
+ return (getValueNoInstance(context, fobj)
- PdAzimuth.ANGLE_RELATIVE_INCREMENTOR)
% NumericConstants.DEGREES_PER_CIRCLE;
}
case RIGHTWARDS: {
- return (getValueNoInstance(context, fobj).doubleValue()
+ return (getValueNoInstance(context, fobj)
+ PdAzimuth.ANGLE_RELATIVE_INCREMENTOR)
% NumericConstants.DEGREES_PER_CIRCLE;
}
@@ -271,8 +271,7 @@
* @param fobj The FO for which this value is needed.
* @return The initial value for this property.
*/
- public static Number getValueNoInstance(final FoContext context,
- final FoObj fobj) {
+ public static int getValueNoInstance(final FoContext context, final FoObj fobj) {
final FoObj parent = fobj.effectiveParent(context);
if (parent != null) {
return parent.traitAzimuth(context);
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdElevation.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdElevation.java 2023-01-01 00:58:40 UTC (rev 12993)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/fo/prop/PdElevation.java 2023-01-01 01:30:16 UTC (rev 12994)
@@ -107,7 +107,7 @@
* @param fobj The FO for which this value is needed.
* @return The value of this property.
*/
- public Number getValue(final FoContext context, final FoObj fobj) {
+ public int getValue(final FoContext context, final FoObj fobj) {
if (value() instanceof DtAngle) {
return ((DtAngle) value()).getValue();
}
@@ -127,12 +127,12 @@
return PdElevation.ANGLE_ABOVE;
}
case HIGHER: {
- return Math.min(getValueNoInstance(context, fobj).doubleValue()
+ return Math.min(getValueNoInstance(context, fobj)
+ PdElevation.ANGLE_RELATIVE_INCREMENT,
PdElevation.ANGLE_ABOVE);
}
case LOWER: {
- return Math.max(getValueNoInstance(context, fobj).doubleValue()
+ return Math.max(getValueNoInstance(context, fobj)
- PdElevation.ANGLE_RELATIVE_INCREMENT,
PdElevation.ANGLE_BELOW);
}
@@ -150,8 +150,7 @@
* @param fobj The FO for which this value is needed.
* @return The initial value for this property.
*/
- public static Number getValueNoInstance(final FoContext context,
- final FoObj fobj) {
+ public static int getValueNoInstance(final FoContext context, final FoObj fobj) {
final FoObj parent = fobj.effectiveParent(context);
if (parent != null) {
return parent.traitAzimuth(context);
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle.java 2023-01-01 00:58:40 UTC (rev 12993)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle.java 2023-01-01 01:30:16 UTC (rev 12994)
@@ -30,6 +30,7 @@
import org.axsl.constants.NumericConstants;
+import java.math.BigDecimal;
import java.util.regex.Matcher;
/**
@@ -39,16 +40,16 @@
public abstract class DtAngle extends Datatype {
/**
- * Returns the value of this angle.
+ * Returns the value of this angle, in millidegrees.
* @return The normalized value of this angle, i.e. a value between 0 and 360 degrees, in degrees.
*/
- public float getValue() {
- float returnValue = asDegrees();
- while (returnValue < 0) {
- returnValue += NumericConstants.DEGREES_PER_CIRCLE;
+ public int getValue() {
+ double degrees = asDegrees();
+ while (degrees < 0) {
+ degrees += NumericConstants.DEGREES_PER_CIRCLE;
}
- returnValue %= NumericConstants.DEGREES_PER_CIRCLE;
- return returnValue;
+ degrees %= NumericConstants.DEGREES_PER_CIRCLE;
+ return (int) Math.round(degrees * NumericConstants.MILLIDEGREES_PER_DEGREE);
}
/**
@@ -55,7 +56,7 @@
* Returns this value as degrees.
* @return This value as degrees.
*/
- public abstract float asDegrees();
+ public abstract double asDegrees();
/**
* Factory method that creates or obtains a {@link DtAngle} instance if the input is valid.
@@ -70,9 +71,9 @@
final String numericPart = matcher.group(1);
final String unitsPart = matcher.group(2);
- final float numeric;
+ final BigDecimal numeric;
try {
- numeric = Float.parseFloat(numericPart);
+ numeric = new BigDecimal(numericPart);
} catch (final NumberFormatException e) {
return null;
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Degrees.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Degrees.java 2023-01-01 00:58:40 UTC (rev 12993)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Degrees.java 2023-01-01 01:30:16 UTC (rev 12994)
@@ -28,6 +28,8 @@
package org.foray.fotree.value;
+import java.math.BigDecimal;
+
/**
* An "angle" property datatype in XSL-FO, stored as "degrees".
* Members of this class are immutable.
@@ -35,19 +37,19 @@
public final class DtAngle_Degrees extends DtAngle {
/** The signed number value. Stored locally to ensure immutability. */
- private float value = 0;
+ private BigDecimal value;
/**
* Constructor.
* @param value The signed angle value.
*/
- public DtAngle_Degrees(final float value) {
+ public DtAngle_Degrees(final BigDecimal value) {
this.value = value;
}
@Override
- public float asDegrees() {
- return this.value;
+ public double asDegrees() {
+ return this.value.doubleValue();
}
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Grads.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Grads.java 2023-01-01 00:58:40 UTC (rev 12993)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Grads.java 2023-01-01 01:30:16 UTC (rev 12994)
@@ -30,6 +30,8 @@
import org.axsl.constants.NumericConstants;
+import java.math.BigDecimal;
+
/**
* An "angle" property datatype in XSL-FO, stored as "degrees".
* Members of this class are immutable.
@@ -37,19 +39,19 @@
public final class DtAngle_Grads extends DtAngle {
/** The signed number value. Stored locally to ensure immutability. */
- private float value = 0;
+ private BigDecimal value;
/**
* Constructor.
* @param value The signed angle value.
*/
- public DtAngle_Grads(final float value) {
+ public DtAngle_Grads(final BigDecimal value) {
this.value = value;
}
@Override
- public float asDegrees() {
- return value * NumericConstants.DEGREES_PER_CIRCLE / NumericConstants.GRADS_PER_CIRCLE;
+ public double asDegrees() {
+ return value.doubleValue() * NumericConstants.DEGREES_PER_CIRCLE / NumericConstants.GRADS_PER_CIRCLE;
}
}
Modified: trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Radians.java
===================================================================
--- trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Radians.java 2023-01-01 00:58:40 UTC (rev 12993)
+++ trunk/foray/foray-fotree/src/main/java/org/foray/fotree/value/DtAngle_Radians.java 2023-01-01 01:30:16 UTC (rev 12994)
@@ -28,6 +28,8 @@
package org.foray.fotree.value;
+import java.math.BigDecimal;
+
/**
* An "angle" property datatype in XSL-FO, stored as "degrees".
* Members of this class are immutable.
@@ -35,19 +37,19 @@
public final class DtAngle_Radians extends DtAngle {
/** The signed number value. Stored locally to ensure immutability. */
- private float value = 0;
+ private BigDecimal value;
/**
* Constructor.
* @param value The signed angle value.
*/
- public DtAngle_Radians(final float value) {
+ public DtAngle_Radians(final BigDecimal value) {
this.value = value;
}
@Override
- public float asDegrees() {
- return (float) Math.toDegrees(this.value);
+ public double asDegrees() {
+ return Math.toDegrees(this.value.doubleValue());
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|