diff options
author | Peter Bernard West <pbwest@apache.org> | 2002-10-19 02:04:19 +0000 |
---|---|---|
committer | Peter Bernard West <pbwest@apache.org> | 2002-10-19 02:04:19 +0000 |
commit | dfe78601810c44b533e30c95546838ee2e0a9a70 (patch) | |
tree | 738617463e02384cb818d580167436add28cf325 | |
parent | e1d93c4a1e90d816934a4cf00e07eae7f2cc32d1 (diff) | |
download | xmlgraphics-fop-dfe78601810c44b533e30c95546838ee2e0a9a70.tar.gz xmlgraphics-fop-dfe78601810c44b533e30c95546838ee2e0a9a70.zip |
Added subtract/add(double) and isInteger().
Removed setPower().
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP_0-20-0_Alt-Design@195333 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/org/apache/fop/datatypes/Numeric.java | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/org/apache/fop/datatypes/Numeric.java b/src/org/apache/fop/datatypes/Numeric.java index 0f18cf42b..9c5732fa6 100644 --- a/src/org/apache/fop/datatypes/Numeric.java +++ b/src/org/apache/fop/datatypes/Numeric.java @@ -14,6 +14,7 @@ import java.lang.Number; import org.apache.fop.datatypes.AbstractPropertyValue; import org.apache.fop.fo.expr.PropertyException; +import org.apache.fop.fo.PropNames; import org.apache.fop.fo.PropertyConsts; import org.apache.fop.fo.Properties; import org.apache.fop.datatypes.PropertyValue; @@ -287,14 +288,6 @@ public class Numeric extends AbstractPropertyValue implements Cloneable { } /** - * Set the power. A complement to the <i>setValue</i> method. - * @param power - the <tt>int</tt> power. - */ - protected void setPower(int power) { - this.power = power; - } - - /** * @return <tt>int</tt> current baseunit of this <i>Numeric</i>. */ public int getBaseunit() { @@ -374,6 +367,14 @@ public class Numeric extends AbstractPropertyValue implements Cloneable { } /** + * This object is an integer if it is a number and the + * rounded value is equal to the value. + */ + public boolean isInteger() { + return (isNumber() && (double)(Math.round(value)) == value); + } + + /** * This object is an EMS factor if the baseunit is EMS. Power is * guaranteed to be zero for EMS baseunit. */ @@ -499,6 +500,21 @@ public class Numeric extends AbstractPropertyValue implements Cloneable { } /** + * Subtract a <tt>double</tt> from the current value. + * @param op - the value to subtract. + * @return <i>Numeric</i>; this object. + * @throws PropertyException if this is not a number. + */ + public Numeric subtract(double op) throws PropertyException { + // Check of same dimension + if (power != 0 || baseunit != NUMBER) + throw new PropertyException + ("Can't subtract number from length."); + value -= op; + return this; + } + + /** * Add the operand to the current value. * @param op The value to add. * @return <i>Numeric</i>; this object. @@ -527,6 +543,21 @@ public class Numeric extends AbstractPropertyValue implements Cloneable { } /** + * Add a <tt>double</tt> to the current value. + * @param op - the value to add. + * @return <i>Numeric</i>; this object. + * @throws PropertyException if this is not a number. + */ + public Numeric add(double op) throws PropertyException { + // Check of same dimension + if (power != 0 || baseunit != NUMBER) + throw new PropertyException + ("Can't add number to length."); + value += op; + return this; + } + + /** * Derive the remainder from a truncating division (mod). As with * additive operators, the values must be absolute <tt>Numeric</tt>s * of the same unit value. (5.9.6) |