Package org.apache.fop.fo.expr
Class RelativeNumericProperty
- java.lang.Object
-
- org.apache.fop.fo.properties.Property
-
- org.apache.fop.fo.expr.RelativeNumericProperty
-
public class RelativeNumericProperty extends Property implements Length
This class represent a node in a property expression tree. It is created when an operation involve relative expression and is used to delay evaluation of the operation until the time where getNumericValue() or getValue() is called.
-
-
Field Summary
Fields Modifier and Type Field Description static int
ABS
ABSstatic int
ADDITION
ADDITIONprivate int
dimension
The dimension of the result.static int
DIVIDE
DIVIDEstatic int
MAX
MAXstatic int
MIN
MINstatic int
MODULO
MODULOstatic int
MULTIPLY
MULTIPLYstatic int
NEGATE
NEGATEprivate Numeric
op1
The first (or only) operand.private Numeric
op2
The second operand.private int
operation
The operation identifier.private static java.lang.String
operations
static int
SUBTRACTION
SUBTRACTION
-
Constructor Summary
Constructors Constructor Description RelativeNumericProperty(int operation, Numeric op)
Constructor for a one argument operation.RelativeNumericProperty(int operation, Numeric op1, Numeric op2)
Constructor for a two argument operation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
int
getDimension()
Return the dimension of the expressionLength
getLength()
Cast this numeric as a Length.Numeric
getNumeric()
This method expects to be overridden by subclassesdouble
getNumericValue()
Return the resolved (calculated) value of the expression.double
getNumericValue(PercentBaseContext context)
Return the value of this Numericprivate Numeric
getResolved(PercentBaseContext context)
Return a resolved (calculated) Numeric with the value of the expression.double
getTableUnits()
Return the number of table units which are included in this length specification.int
getValue()
Returns the length in 1/1000ths of a point (millipoints)int
getValue(PercentBaseContext context)
Returns the length in 1/1000ths of a point (millipoints)int
hashCode()
boolean
isAbsolute()
Return false since an expression is only created when there is relative numerics involved.java.lang.String
toString()
Return a string represention of the expression.-
Methods inherited from class org.apache.fop.fo.properties.Property
getCharacter, getColor, getCondLength, getEnum, getKeep, getLengthPair, getLengthRange, getList, getNCname, getNumber, getObject, getSpace, getSpecifiedValue, getString, isAuto, setSpecifiedValue
-
-
-
-
Field Detail
-
ADDITION
public static final int ADDITION
ADDITION- See Also:
- Constant Field Values
-
SUBTRACTION
public static final int SUBTRACTION
SUBTRACTION- See Also:
- Constant Field Values
-
MULTIPLY
public static final int MULTIPLY
MULTIPLY- See Also:
- Constant Field Values
-
DIVIDE
public static final int DIVIDE
DIVIDE- See Also:
- Constant Field Values
-
MODULO
public static final int MODULO
MODULO- See Also:
- Constant Field Values
-
NEGATE
public static final int NEGATE
NEGATE- See Also:
- Constant Field Values
-
ABS
public static final int ABS
ABS- See Also:
- Constant Field Values
-
MAX
public static final int MAX
MAX- See Also:
- Constant Field Values
-
MIN
public static final int MIN
MIN- See Also:
- Constant Field Values
-
operations
private static java.lang.String operations
-
operation
private int operation
The operation identifier.
-
op1
private Numeric op1
The first (or only) operand.
-
op2
private Numeric op2
The second operand.
-
dimension
private int dimension
The dimension of the result.
-
-
Constructor Detail
-
RelativeNumericProperty
public RelativeNumericProperty(int operation, Numeric op1, Numeric op2)
Constructor for a two argument operation.- Parameters:
operation
- the operation opcode: ADDITION, SUBTRACTION, ...op1
- the first operand.op2
- the second operand
-
RelativeNumericProperty
public RelativeNumericProperty(int operation, Numeric op)
Constructor for a one argument operation.- Parameters:
operation
- the operation opcode: NEGATE, ABSop
- the operand.
-
-
Method Detail
-
getResolved
private Numeric getResolved(PercentBaseContext context) throws PropertyException
Return a resolved (calculated) Numeric with the value of the expression.- Parameters:
context
- Evaluation context- Returns:
- the resolved
Numeric
corresponding to the value of the expression - Throws:
PropertyException
- when an exception occur during evaluation.
-
getNumericValue
public double getNumericValue()
Return the resolved (calculated) value of the expression. Return the value of this Numeric- Specified by:
getNumericValue
in interfaceNumeric
- Returns:
- the computed value.
-
getNumericValue
public double getNumericValue(PercentBaseContext context)
Return the value of this Numeric- Specified by:
getNumericValue
in interfaceNumeric
- Parameters:
context
- The context for the length calculation (for percentage based lengths)- Returns:
- the computed value.
-
getDimension
public int getDimension()
Return the dimension of the expression- Specified by:
getDimension
in interfaceNumeric
- Returns:
- numeric value as dimension
-
isAbsolute
public boolean isAbsolute()
Return false since an expression is only created when there is relative numerics involved.- Specified by:
isAbsolute
in interfaceNumeric
- Returns:
- true if expression is absolute
-
getLength
public Length getLength()
Cast this numeric as a Length.
-
getNumeric
public Numeric getNumeric()
Description copied from class:Property
This method expects to be overridden by subclasses- Overrides:
getNumeric
in classProperty
- Returns:
- numeric value
-
getValue
public int getValue()
Returns the length in 1/1000ths of a point (millipoints)
-
getValue
public int getValue(PercentBaseContext context)
Returns the length in 1/1000ths of a point (millipoints)
-
getTableUnits
public double getTableUnits()
Return the number of table units which are included in this length specification. This will always be 0 unless the property specification used the proportional-column-width() function (only on table column FOs).If this value is not 0, the actual value of the Length cannot be known without looking at all of the columns in the table to determine the value of a "table-unit".
- Returns:
- The number of table units which are included in this length specification.
-
toString
public java.lang.String toString()
Return a string represention of the expression. Only used for debugging.
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-