cvs commit: xml-fop/src/org/apache/fop/datatypes Numeric.java

2002-11-13 Thread pbwest
pbwest  2002/11/13 07:20:40

  Modified:src/org/apache/fop/datatypes Tag: FOP_0-20-0_Alt-Design
Numeric.java
  Log:
  Added isAbsLength() and isAbsOrRelLength().
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.1.2.12  +21 -4 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.11
  retrieving revision 1.1.2.12
  diff -u -r1.1.2.11 -r1.1.2.12
  --- Numeric.java  12 Nov 2002 02:24:36 -  1.1.2.11
  +++ Numeric.java  13 Nov 2002 15:20:39 -  1.1.2.12
  @@ -391,10 +391,27 @@
   }
   
   /**
  - * This object is a length in millipoints.
  + * This object is a length in millipoints. Same as isAbsLength().
*/
   public boolean isLength() {
   return (baseunit == MILLIPOINTS  power == 1);
  +}
  +
  +/**
  + * This object is a length in millipoints.
  + */
  +public boolean isAbsLength() {
  +return (baseunit == MILLIPOINTS  power == 1);
  +}
  +
  +/**
  + * This object is an absolute or relative length.  I.e., it has a
  + * baseunit of MILLIPOINTS with a power of 1, or a baseunit of
  + * either PERCENTAGE or EMS.
  + */
  +public boolean isAbsOrRelLength() {
  +return ((baseunit == MILLIPOINTS  power == 1)
  +|| baseunit == PERCENTAGE || baseunit == EMS);
   }
   
   /**
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




cvs commit: xml-fop/src/org/apache/fop/datatypes Numeric.java

2002-11-11 Thread pbwest
pbwest  2002/11/11 18:24:36

  Modified:src/org/apache/fop/datatypes Tag: FOP_0-20-0_Alt-Design
Numeric.java
  Log:
  Cosmetics.
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.1.2.11  +4 -4  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.10
  retrieving revision 1.1.2.11
  diff -u -r1.1.2.10 -r1.1.2.11
  --- Numeric.java  19 Oct 2002 03:31:06 -  1.1.2.10
  +++ Numeric.java  12 Nov 2002 02:24:36 -  1.1.2.11
  @@ -272,7 +272,7 @@
   }
   
   /**
  - * Set the value.  This used on ttNumeric/tt clones in the iabs/i
  + * Set the value.  This used on ttNumeric/tt clones in the iabs/i
* imin/i and imax/i operations.
* @param value - the ttdouble/tt value.
*/
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




cvs commit: xml-fop/src/org/apache/fop/datatypes Numeric.java

2002-10-19 Thread pbwest
pbwest  2002/10/18 20:31:06

  Modified:src/org/apache/fop/datatypes Tag: FOP_0-20-0_Alt-Design
Numeric.java
  Log:
  PropertyConsts now instantiated.
  PropertyConsts data is accessed through a singleton object.
  getPropertyIndex() moved to PropNames.
  Properties split into properties.Property and properties.property.
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.1.2.10  +9 -9  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.9
  retrieving revision 1.1.2.10
  diff -u -r1.1.2.9 -r1.1.2.10
  --- Numeric.java  19 Oct 2002 02:04:19 -  1.1.2.9
  +++ Numeric.java  19 Oct 2002 03:31:06 -  1.1.2.10
  @@ -16,7 +16,7 @@
   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.fo.properties.*;
   import org.apache.fop.datatypes.PropertyValue;
   
   
  @@ -196,7 +196,7 @@
  int power, int unit)
   throws PropertyException
   {
  -this(PropertyConsts.getPropertyIndex(propertyName),
  +this(PropNames.getPropertyIndex(propertyName),
value, baseunit, power, unit);
   }
   
  @@ -209,7 +209,7 @@
   public Numeric(String propertyName, double value)
   throws PropertyException
   {
  - this(PropertyConsts.getPropertyIndex(propertyName), value);
  + this(PropNames.getPropertyIndex(propertyName), value);
   }
   
   /**
  @@ -321,17 +321,17 @@
   throw new PropertyException
   (Attempt to validate Numeric with unit power of 
+ power);
  -super.validate(Properties.NUMBER);
  +super.validate(Property.NUMBER);
   break;
   case PERCENTAGE:
   if (power != 0)
   throw new PropertyException
   (Attempt to validate Percentage with unit power of 
+ power);
  -super.validate(Properties.PERCENTAGE);
  +super.validate(Property.PERCENTAGE);
   break;
   case MILLIPOINTS:
  -super.validate(Properties.LENGTH);
  +super.validate(Property.LENGTH);
   if (power != 1)
   throw new PropertyException
   (Length with unit power  + power);
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




cvs commit: xml-fop/src/org/apache/fop/datatypes Numeric.java

2002-10-08 Thread pbwest

pbwest  2002/10/08 22:45:57

  Modified:src/org/apache/fop/datatypes Tag: FOP_0-20-0_Alt-Design
Numeric.java
  Log:
  Modified abs() to return Numeric.  Works with any kind of Numeric value.
  Modified max() and min() to return Numeric and to operate on any Numerics of the 
same baseunit and power.
  Added setValue() and setPower() for use with the modified methods.
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.1.2.8   +66 -29xml-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.7
  retrieving revision 1.1.2.8
  diff -u -r1.1.2.7 -r1.1.2.8
  --- Numeric.java  18 Sep 2002 15:24:12 -  1.1.2.7
  +++ Numeric.java  9 Oct 2002 05:45:56 -   1.1.2.8
  @@ -271,6 +271,15 @@
   }
   
   /**
  + * Set the value.  This used on ttNumeric/tt clones in the iabs/i
  + * imin/i and imax/i operations.
  + * @param value - the ttdouble/tt value.
  + */
  +protected void setValue(double value) {
  +this.value = value;
  +}
  +
  +/**
* @return ttint/tt unit power of this iNumeric/i.
*/
   public int getPower() {
  @@ -278,6 +287,14 @@
   }
   
   /**
  + * Set the power.  A complement to the isetValue/i method.
  + * @param power - the ttint/tt power.
  + */
  +protected void setPower(int power) {
  +this.power = power;
  +}
  +
  +/**
* @return ttint/tt current baseunit of this iNumeric/i.
*/
   public int getBaseunit() {
  @@ -673,57 +690,77 @@
   }
   
   /**
  - * Return the absolute value of this ttNumeric/tt.  This is an
  + * Return a new ttNumeric/tt with the absolute value of this.
  + * This is an
* implementation of the core function library ttabs/tt function.
  - * It is only valid on an absolute numeric of unit power zero.
* @return A ttdouble/tt containing the absolute value.
  - * @exception PropertyException if ivalue/i is not unit power zero.
  + * @exception PropertyException if cloning fails.
*/
  -public double abs() throws PropertyException {
  -if (power != 0)
  -throw new PropertyException
  -(abs requires absolute numeric of unit power zero);
  -return Math.abs(value);
  +public Numeric abs() throws PropertyException {
  +Numeric n;
  +try {
  +n = (Numeric)(this.clone());
  +} catch (CloneNotSupportedException e) {
  +throw new PropertyException(e);
  +}
  +n.setValue(Math.abs(value));
  +return n;
   }
   
   /**
  - * Return a ttdouble/tt which is the maximum of the current value and
  + * Return a ttNumeric/tt which is the maximum of the current value and
* the operand.  This is an implementation of the core function library
* ttmax/tt function.  It is only valid for comparison of two
  - * absolute ttNumeric/tt values.
  + * values of the same unit power and same type, i.e. both absolute or
  + * both percentages.
* @param op a ttNumeric/tt representing the comparison value.
* @return a ttdouble/tt representing the imax/i of
* ithis.value/i and the ivalue/i of iop/i.
  - * @throws PropertyException If the power of this
  - * object and the operand are different or not 0.
  + * @throws PropertyException If the baseunit or power of this
  + * object and the operand are different, or if cloning fails.
*/
  -public double max(Numeric op) throws PropertyException {
  -// Only compare if both have unit power 0
  -if (power == op.power  power == 0) {
  -return Math.max(value, op.value); 
  +public Numeric max(Numeric op) throws PropertyException {
  +Numeric n;
  +// Only compare if both have same unit power and same baseunit
  +if (power == op.power  baseunit == op.baseunit) {
  +try {
  +n = (Numeric)(this.clone());
  +} catch (CloneNotSupportedException e) {
  +throw new PropertyException(e);
  +}
  +n.setValue(Math.max(value, op.value));
  +return n;
   }
   throw new PropertyException
  -(max() must compare numerics of unit power 0.);
  +(max() must compare numerics of same baseunit  unit power.);
   }
   
   /**
  - * Return a ttdouble/tt which is the minimum of the current value and
  + * Return a ttNumeric/tt which is the minimum of the current value and
* the operand.  This is an implementation of the core function library
* ttmin/tt function.  It is 

cvs commit: xml-fop/src/org/apache/fop/datatypes Numeric.java

2002-08-12 Thread pbwest

pbwest  2002/08/12 08:55:12

  Modified:src/org/apache/fop/datatypes Tag: FOP_0-20-0_Alt-Design
Numeric.java
  Log:
  Denied addops on relative lengths, and restricted multops on relative
  lengths to numbers.  Restricted multops on absolute lengths to numbers
  and absolute lengths.  Added expandEms() and expandPercent() methods
  for resolution of relative lengths, after denying direct multops.
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.1.2.5   +111 -72   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.4
  retrieving revision 1.1.2.5
  diff -u -r1.1.2.4 -r1.1.2.5
  --- Numeric.java  30 Jul 2002 02:16:38 -  1.1.2.4
  +++ Numeric.java  12 Aug 2002 15:55:12 -  1.1.2.5
  @@ -33,9 +33,14 @@
* Therefore, only a number, its power and its baseunit need be provided for
* in this class.
* All numeric values are represented as a value and a unit raised to a
  - * power.  For absolute numbers, including relative lengths, the unit power is
  - * zero.
  + * power.  For absolute numbers and relative lengths the unit power is zero.
  + *
* Whenever the power associated with a number is non-zero, it is a length.
  + * N.B. this includes relative lengths.  The resolution of a relative
  + * length is NOT performed by multiplying the relative length by its
  + * reference length in a standard * operation, but by specific methods.
  + * This allows invalid multiplication operations (any multiplication
  + * of a relative length is invalid in an expression.)
* p
* It is an error for the end result of an expression to be a numeric with
* a power other than 0 or 1. (Rec. 5.9.6)
  @@ -50,16 +55,22 @@
* )
* numeric^n   addop  numeric^m   = Illegal
* numeric1addop  numeric2= Illegal
  - * numeric1^n  addop  numeric1^n  = numeric1^n   includes number + number
  + * rel-len1addop  any = Illegal  See 5.9.6 Absolute Numerics
  + * ...only the mod, addition, and subtraction operators require that the
  + * numerics on either side of the operation be absolute numerics of the
  + * same unit power.
  + *
  + * absnum1^n   addop  absnum1^n  = absnum1^n   includes number + number
*
* number  multop anyunit = anyunit  universal multiplier
*   includes number * relunit
  - * unit1   multop unit2   = Illegal
  + *
  + * unit1   multop unit2   = Illegal  includes relunit * length
  + *
* relunit multop relunit = Illegal
*
* unit1^n multop unit1^m = unit1^(n+m)  includes number * number
*   excludes relunit* relunit
  - * relunit multop length  = length
*
* In fact, all lengths are maintained internally
* in millipoints.
  @@ -140,8 +151,9 @@
* @param property ttint/tt index of the property.
* @param value the actual value.
* @param baseunit the baseunit for this ttNumeric/tt.
  - * @param power The dimension of the value. 0 for a Number, 1 for a Length
  - * (any type), 1, 0 if Lengths have been multiplied or divided.
  + * @param power The dimension of the value. 0 for a Number,
  + * 0 for EMs or Percentage, 1 for a Length (any type),
  + * 1, 0 if Lengths have been multiplied or divided.
* @param unit ttint/tt enumeration of the subtype of the
* ibaseunit/i in which this iNumeric/i is being defined
* e.g. Length.PX or Length.MM.
  @@ -328,6 +340,14 @@
   }
   
   /**
  + * This object is an ABSOLUTE NUMERIC type if it is a NUMBER or an
  + * ABSOLUTE LENGTH.
  + */
  +public boolean isAbsoluteNumeric() {
  +return (baseunit  ABS_UNIT) != 0;
  +}
  +
  +/**
* This object is a number if the baseunit is NUMBER.  Power is
* guaranteed to be zero for NUMBER baseunit.
*/
  @@ -395,6 +415,45 @@
}
   
   /**
  + * @param fontSize a ttNumeric/tt containing the reference
  + * ifont-size/i length
  + * @return ithis/i, with values changed to reflect the conversion
  + * @exception ttPropertyException/tt
  + */
  +public Numeric expandEms(Numeric fontSize) throws PropertyException {
  +if (baseunit == EMS) {
  +value = value *= fontSize.getValue();
  +power = power += fontSize.getPower();
  +baseunit = fontSize.getBaseunit();
  +if (isLength()) return this;
  +
  +throw new PropertyException
  +(Invalid result from expandEms:  + value + power
  + + getBaseunitString());
  +}
  +throw new 

cvs commit: xml-fop/src/org/apache/fop/datatypes Numeric.java

2002-06-09 Thread pbwest

pbwest  2002/06/09 03:39:11

  Modified:src/org/apache/fop/datatypes Tag: FOP_0-20-0_Alt-Design
Numeric.java
  Log:
  Added isDistance()
  
  Revision  ChangesPath
  No   revision
  
  
  No   revision
  
  
  1.1.2.2   +15 -3 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.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- Numeric.java  7 May 2002 16:06:36 -   1.1.2.1
  +++ Numeric.java  9 Jun 2002 10:39:11 -   1.1.2.2
  @@ -1,11 +1,11 @@
   /*
  - * $Id: Numeric.java,v 1.1.2.1 2002/05/07 16:06:36 pbwest Exp $
  + * $Id: Numeric.java,v 1.1.2.2 2002/06/09 10:39:11 pbwest Exp $
*
* Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
* For details on use and redistribution please refer to the
* LICENSE file included with these sources.
* @author a href=mailto:[EMAIL PROTECTED];Peter B. West/a
  - * @version $Revision: 1.1.2.1 $ $Name:  $
  + * @version $Revision: 1.1.2.2 $ $Name:  $
*/
   
   package org.apache.fop.datatypes;
  @@ -131,6 +131,11 @@
   public static final int NOT_NUMBER = UNIT | REL_LENGTH;
   
   /**
  + * Integer constants for distances.
  + */
  +public static final int DISTANCE = MILLIPOINTS | REL_LENGTH;
  +
  +/**
* The numerical contents of this instance.
*/
   protected double value;
  @@ -399,6 +404,13 @@
   }
   
   /**
  + * This object is a distance; a absolute or relative length
  + */
  +public boolean isDistance() {
  +return (baseunit  DISTANCE) != 0;
  +}
  +
  +/**
* This object is a time in milliseconds.
*/
   public boolean isTime() {
  @@ -905,7 +917,7 @@
   }
   
   /**
  - * @param unit an ttint/tt encoding a iTime/i unit.
  + * @param unit an ttint/tt encoding a unit.
* @return the ttString/tt name of the unit.
*/
   public static String getUnitName(int unit) {
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]