org.foray.fotree.value
Class DtSpace

java.lang.Object
  extended by org.foray.fotree.value.Expr
      extended by org.foray.fotree.value.ExprAdditive
          extended by org.foray.fotree.value.ExprMultiplicative
              extended by org.foray.fotree.value.ExprUnary
                  extended by org.foray.fotree.value.ExprPrimary
                      extended by org.foray.fotree.value.Datatype
                          extended by org.foray.fotree.value.DtSpace
All Implemented Interfaces:
PropertyValue

public class DtSpace
extends Datatype

A space quantity in XSL (space-before, space-after). This datatype is described in the XSL-FO Standard 1.0, at Section 4.3 and Section 5.11.


Field Summary
static FoValue[] CONDITIONALITY_KEYWORDS
          Array of the keywords that describe conditionality.
static int PRECEDENCE_FORCE
          Constant indicating the numeric weight assigned to precedence of "force".
static FoValue[] PRECEDENCE_KEYWORDS
          Array of the keywords that describe precedence.
 
Fields inherited from class org.foray.fotree.value.Expr
OPERATION_ADD, OPERATION_DIVIDE, OPERATION_MOD, OPERATION_MULTIPLY, OPERATION_NEGATION, OPERATION_SUBTRACT, UNIT_POWER_AREA, UNIT_POWER_LENGTH, UNIT_POWER_NON_NUMERIC, UNIT_POWER_NUMERIC
 
Constructor Summary
DtSpace(PropertyValue lengthMinimum, PropertyValue lengthOptimum, PropertyValue lengthMaximum, FoValue conditionality, Expr precedence)
          Constructor.
 
Method Summary
 boolean addComponent(String subPropertyName, PropertyValue value)
          Adds a component to the "space" datatype.
 boolean addComponent(String subPropertyName, String value)
          Adds a component to the "space" datatype.
 boolean canEvalColor()
          Indicates whether this property value has the ability to express itself as a Color.
 boolean canEvalInteger()
          Indicates whether this property value has the ability to express itself as an integer Numeric item.
 boolean canEvalKeyword()
          Indicates whether this property value can evaluate to a keyword.
 boolean canEvalLength()
          Indicates whether this expression can be evaluated to a unit power = 1 (length) or not.
 boolean canEvalNumeric()
          Indicates whether this property value has the ability to express itself as a Numeric item.
 boolean canEvalPercentage()
          Indicates whether this property value can evaluate to a percentage.
 Color evalColor()
          Return the color value of "this".
 int evalInteger()
          Return this value as an int.
 PvKeyword evalKeyword()
          Returns the keyword value of this property value.
 int evalLength(int pointSize)
          Evaluates the expression to a unit power of 1 (length).
 double evalNumeric()
          Return the raw numeric value of "this", without regard to unit power.
 float evalPercentage()
          Returns the percentage value of this property value.
 org.axsl.common.value.Conditionality getConditionality()
          Returns the conditionality in this space.
 int getLengthMaximum(int pointSize)
          Returns the maximum length in this space.
 int getLengthMinimum(int pointSize)
          Returns the minimum length in this space.
 int getLengthOptimum(int pointSize)
          Returns the optimum length in this space.
 int getPrecedence()
          Returns the precedence in this space.
 byte getUnitPower()
          Each numeric has a "unit power".
 boolean lengthRequiresFontSize()
          Indicates whether the computation of the length will require an accurate font-size parameter.
 void setConditionality(org.axsl.common.value.Conditionality conditionality)
          Sets the conditionality component in this space.
 void setConditionality(FoValue conditionality)
          Sets the conditionality component in this space.
 void setLengthMaximum(PropertyValue lengthMaximum)
          Sets the maximum length component in this space.
 void setLengthMinimum(PropertyValue lengthMinimum)
          Sets the minimum length component in this space.
 void setLengthOptimum(PropertyValue lengthOptimum)
          Sets the optimum length component in this space.
 void setPrecedence(PropertyValue precedence)
          Sets the precedence component in this space.
 
Methods inherited from class org.foray.fotree.value.Datatype
convertValueToFoValue
 
Methods inherited from class org.foray.fotree.value.Expr
evalColorException, evalIntegerException, evalKeywordException, evalLengthException, evalNumericException, evalPercentageException
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PRECEDENCE_FORCE

public static final int PRECEDENCE_FORCE
Constant indicating the numeric weight assigned to precedence of "force".

See Also:
Constant Field Values

CONDITIONALITY_KEYWORDS

public static final FoValue[] CONDITIONALITY_KEYWORDS
Array of the keywords that describe conditionality.


PRECEDENCE_KEYWORDS

public static final FoValue[] PRECEDENCE_KEYWORDS
Array of the keywords that describe precedence.

Constructor Detail

DtSpace

public DtSpace(PropertyValue lengthMinimum,
               PropertyValue lengthOptimum,
               PropertyValue lengthMaximum,
               FoValue conditionality,
               Expr precedence)
        throws PropertyException
Constructor.

Parameters:
lengthMinimum - The minimum length component in this space.
lengthOptimum - The optimum length component in this space.
lengthMaximum - The maximum length component in this space.
conditionality - The conditionality component in this space.
precedence - The precedence component in this space.
Throws:
PropertyException - If any of the length components do not evaluate to a length power.
Method Detail

setLengthMinimum

public void setLengthMinimum(PropertyValue lengthMinimum)
                      throws PropertyException
Sets the minimum length component in this space.

Parameters:
lengthMinimum - The new minimum length.
Throws:
PropertyException - If the input value is not a valid length.

setLengthOptimum

public void setLengthOptimum(PropertyValue lengthOptimum)
                      throws PropertyException
Sets the optimum length component in this space.

Parameters:
lengthOptimum - The new optimum length.
Throws:
PropertyException - If the input value is not a valid length.

setLengthMaximum

public void setLengthMaximum(PropertyValue lengthMaximum)
                      throws PropertyException
Sets the maximum length component in this space.

Parameters:
lengthMaximum - The new maximum length.
Throws:
PropertyException - If the input value is not a valid length.

setConditionality

public void setConditionality(org.axsl.common.value.Conditionality conditionality)
Sets the conditionality component in this space.

Parameters:
conditionality - The new conditionality.

setConditionality

public void setConditionality(FoValue conditionality)
                       throws PropertyException
Sets the conditionality component in this space.

Parameters:
conditionality - The new conditionality, which must be one of FoValue.DISCARD or FoValue.RETAIN.
Throws:
PropertyException - If the conditionality value is not a valid conditionality.

setPrecedence

public void setPrecedence(PropertyValue precedence)
                   throws PropertyException
Sets the precedence component in this space.

Parameters:
precedence - The new precedence.
Throws:
PropertyException - If the new precedence value is not Numeric.

getLengthMinimum

public int getLengthMinimum(int pointSize)
Returns the minimum length in this space.

Parameters:
pointSize - The point size of the font.
Returns:
The minimum length in this space.

getLengthOptimum

public int getLengthOptimum(int pointSize)
Returns the optimum length in this space.

Parameters:
pointSize - The point size of the font.
Returns:
The optimum length in this space.

getLengthMaximum

public int getLengthMaximum(int pointSize)
Returns the maximum length in this space.

Parameters:
pointSize - The point size of the font.
Returns:
The maximum length in this space.

getConditionality

public org.axsl.common.value.Conditionality getConditionality()
Returns the conditionality in this space.

Returns:
The conditionality in this space.

getPrecedence

public int getPrecedence()
Returns the precedence in this space.

Returns:
The precedence in this space.

addComponent

public boolean addComponent(String subPropertyName,
                            String value)
                     throws PropertyException
Adds a component to the "space" datatype.

Parameters:
subPropertyName - String containing one of "conditionality", "precedence", "minimum", "optimum", or "maximum".
value - String containing the value of the subProperty to be set.
Returns:
True if the component was set, false if value was not valid for the subPropertyName given.
Throws:
PropertyException - If the subPropertyName is not valid.

addComponent

public boolean addComponent(String subPropertyName,
                            PropertyValue value)
                     throws PropertyException
Adds a component to the "space" datatype.

Parameters:
subPropertyName - String containing one of "conditionality", "precedence", "minimum", "optimum", or "maximum".
value - The value of the sub-property to be set.
Returns:
True if the component was set, false if value was not valid for the subPropertyName given.
Throws:
PropertyException - If the subPropertyName is not valid.

canEvalNumeric

public boolean canEvalNumeric()
Description copied from interface: PropertyValue
Indicates whether this property value has the ability to express itself as a Numeric item.

Returns:
True iff this property value is a numeric.

evalNumeric

public double evalNumeric()
Description copied from interface: PropertyValue
Return the raw numeric value of "this", without regard to unit power.

Returns:
A double representation of the value of "this". Type "double" is assumed to be the lowest-common-denominator of all numeric values.

canEvalLength

public boolean canEvalLength()
Description copied from interface: PropertyValue
Indicates whether this expression can be evaluated to a unit power = 1 (length) or not.

Returns:
True if the expression can be evaluated to a unit power of 1 (length).

getUnitPower

public byte getUnitPower()
Description copied from interface: PropertyValue
Each numeric has a "unit power". This number refers to the number of spatial dimensions in which the number operates. So, a number that has no relationship to space or refers to a point, has a length power of 0. A number that refers to length has a length power of 1 (1 dimension). Although there are none yet in XSL-FO, a number that referred to area (e.g. square inches) would, we suppose, have a length power of 2, and one referring to volume (e.g. cubic feet) would, we suppose have a length power of 3.

Returns:
The number of spatial dimensions in which this numeric item operates. For XSL-FO items, this should be either Expr.UNIT_POWER_NUMERIC or Expr.UNIT_POWER_LENGTH.

evalLength

public int evalLength(int pointSize)
Description copied from interface: PropertyValue
Evaluates the expression to a unit power of 1 (length).

Parameters:
pointSize - The point size, in millipoints, of the font. This is used in calculations that are relative to the point size. In cases where the computation of the font-size is expensive, check PropertyValue.lengthRequiresFontSize() first. If that method returns false, zero or some other constant can safely be passed, as it will be ignored anyway.
Returns:
The unit power 1 value (length) of this expression if the expression can be so evaluated, or Integer.MIN_VALUE otherwise. The value is expressed in millipoints.

canEvalColor

public boolean canEvalColor()
Description copied from interface: PropertyValue
Indicates whether this property value has the ability to express itself as a Color.

Returns:
True iff this property value is a color.

evalColor

public Color evalColor()
Description copied from interface: PropertyValue
Return the color value of "this".

Returns:
The color representation of the value of "this".

lengthRequiresFontSize

public boolean lengthRequiresFontSize()
Description copied from interface: PropertyValue
Indicates whether the computation of the length will require an accurate font-size parameter.

Returns:
True iff the computation of the length will require an accurate font-size parameter.

canEvalInteger

public boolean canEvalInteger()
Description copied from interface: PropertyValue
Indicates whether this property value has the ability to express itself as an integer Numeric item.

Returns:
True iff this property value is an integer.

evalInteger

public int evalInteger()
Description copied from interface: PropertyValue
Return this value as an int. This method should only be executed on instances where PropertyValue.canEvalInteger() returns true. Doing so on other instances may result in an IllegalStateException.

Returns:
This value as an int.

canEvalKeyword

public boolean canEvalKeyword()
Description copied from interface: PropertyValue
Indicates whether this property value can evaluate to a keyword.

Returns:
True iff this property value can evaluate to a keyword.

evalKeyword

public PvKeyword evalKeyword()
Description copied from interface: PropertyValue
Returns the keyword value of this property value. This method should only be executed on instances where PropertyValue.canEvalKeyword() returns true. Doing so on other instances may result in an IllegalStateException.

Returns:
The keyword value of this property value.

canEvalPercentage

public boolean canEvalPercentage()
Description copied from interface: PropertyValue
Indicates whether this property value can evaluate to a percentage.

Returns:
True iff this property value can evaluate to a percentage.

evalPercentage

public float evalPercentage()
Description copied from interface: PropertyValue
Returns the percentage value of this property value. This method should only be executed on instances where PropertyValue.canEvalPercentage() returns true. Doing so on other instances may result in an IllegalStateException.

Returns:
The percentage value of this property value.


Copyright © 2017. All rights reserved.