pbwest 2002/10/18 19:04:19 Modified: src/org/apache/fop/datatypes Tag: FOP_0-20-0_Alt-Design Numeric.java Log: Added subtract/add(double) and isInteger(). Removed setPower(). Revision Changes Path No revision No revision 1.1.2.9 +42 -11 xml-fop/src/org/apache/fop/datatypes/Attic/Numeric.java Index: Numeric.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/datatypes/Attic/Numeric.java,v retrieving revision 1.1.2.8 retrieving revision 1.1.2.9 diff -u -r1.1.2.8 -r1.1.2.9 --- Numeric.java 9 Oct 2002 05:45:56 -0000 1.1.2.8 +++ Numeric.java 19 Oct 2002 02:04:19 -0000 1.1.2.9 @@ -14,6 +14,7 @@ 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 @@ } /** - * 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 @@ } /** + * 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 @@ } /** + * 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. @@ -523,6 +539,21 @@ // Add each type of value value += op.value; + return this; + } + + /** + * 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; }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]