org.foray.fotree.value
Class DtWritingMode

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.DtWritingMode
All Implemented Interfaces:
org.axsl.common.value.WritingMode, PropertyValue

public final class DtWritingMode
extends Datatype
implements org.axsl.common.value.WritingMode

Writing Mode is not a datatype recognized in XSL-FO. However, its definition in the standard makes it a de facto compound data type. It is discussed in the XSL-FO Standard 1.0 at Section 7.27.7 and at Appendix A.1. Please note that most applications using members of this class will not want to deal with the different ipd and shift values for odd and even line numbers. In that case, it is recommended that they simply use the odd value for each.


Field Summary
 
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
 
Method Summary
 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.AbsoluteAxis getAbsoluteAxis(org.axsl.common.value.RelativeAxis relativeAxis)
           
 org.axsl.common.value.AbsoluteCompass getAbsoluteDirection(org.axsl.common.value.RelativeCompass relativeDir)
           
 org.axsl.common.value.AbsoluteDirection getAbsoluteDirFromRelativeAxis(org.axsl.common.value.RelativeAxis relativeAxis)
           
 org.axsl.common.value.AbsoluteCompass getAfter()
           
 org.axsl.common.value.AbsoluteCompass getBefore()
           
 org.axsl.common.value.RelativeCompass getBottom()
           
 org.axsl.common.value.AbsoluteAxis getBpAxis()
           
 org.axsl.common.value.AbsoluteDirection getBpDirection()
           
 org.axsl.common.value.Compass getCorresponding(org.axsl.common.value.Compass inputDirection)
           
 org.axsl.common.value.AbsoluteCompass getEnd()
           
 org.axsl.common.value.RelativeAxis getHorizontalAxis()
           
 org.axsl.common.value.AbsoluteAxis getIpAxis()
           
 org.axsl.common.value.AbsoluteDirection getIpDirectionEven()
           
 org.axsl.common.value.AbsoluteDirection getIpDirectionOdd()
           
 org.axsl.common.value.RelativeCompass getLeft()
           
 org.axsl.common.value.RelativeAxis getRelativeAxis(org.axsl.common.value.AbsoluteAxis absoluteAxis)
          Converts an absolute axis(horizontal or vertical) to a relative axis (inline-progression or block-progression) for this writing mode.
 org.axsl.common.value.RelativeCompass getRelativeDirection(org.axsl.common.value.AbsoluteCompass absoluteDir)
           
 org.axsl.common.value.RelativeCompass getRight()
           
 org.axsl.common.value.AbsoluteDirection getShiftEven()
           
 org.axsl.common.value.AbsoluteDirection getShiftOdd()
           
 org.axsl.common.value.AbsoluteCompass getStart()
           
 org.axsl.common.value.RelativeCompass getTop()
           
 byte getUnitPower()
          Each numeric has a "unit power".
 org.axsl.common.value.RelativeAxis getVerticalAxis()
           
 boolean isHorizontal()
          Indicates whether this writing-mode is horizontal or vertical.
 boolean isPaired()
           
 boolean lengthRequiresFontSize()
          Indicates whether the computation of the length will require an accurate font-size parameter.
static DtWritingMode obtainWritingMode(String writingModeName)
          Returns the DtWritingMode instance for a given description of that writing mode.
 
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
 

Method Detail

obtainWritingMode

public static DtWritingMode obtainWritingMode(String writingModeName)
Returns the DtWritingMode instance for a given description of that writing mode.

Parameters:
writingModeName - The name of the writing mode, for example, "lr-tb".
Returns:
The appropriate writing mode for a given description, or null if the description is not valid.

getBpDirection

public org.axsl.common.value.AbsoluteDirection getBpDirection()
Specified by:
getBpDirection in interface org.axsl.common.value.WritingMode

getIpDirectionEven

public org.axsl.common.value.AbsoluteDirection getIpDirectionEven()
Specified by:
getIpDirectionEven in interface org.axsl.common.value.WritingMode

getIpDirectionOdd

public org.axsl.common.value.AbsoluteDirection getIpDirectionOdd()
Specified by:
getIpDirectionOdd in interface org.axsl.common.value.WritingMode

isPaired

public boolean isPaired()
Specified by:
isPaired in interface org.axsl.common.value.WritingMode

getShiftEven

public org.axsl.common.value.AbsoluteDirection getShiftEven()
Specified by:
getShiftEven in interface org.axsl.common.value.WritingMode

getShiftOdd

public org.axsl.common.value.AbsoluteDirection getShiftOdd()
Specified by:
getShiftOdd in interface org.axsl.common.value.WritingMode

getHorizontalAxis

public org.axsl.common.value.RelativeAxis getHorizontalAxis()
Specified by:
getHorizontalAxis in interface org.axsl.common.value.WritingMode

getVerticalAxis

public org.axsl.common.value.RelativeAxis getVerticalAxis()
Specified by:
getVerticalAxis in interface org.axsl.common.value.WritingMode

getBpAxis

public org.axsl.common.value.AbsoluteAxis getBpAxis()
Specified by:
getBpAxis in interface org.axsl.common.value.WritingMode

getIpAxis

public org.axsl.common.value.AbsoluteAxis getIpAxis()
Specified by:
getIpAxis in interface org.axsl.common.value.WritingMode

getAbsoluteAxis

public org.axsl.common.value.AbsoluteAxis getAbsoluteAxis(org.axsl.common.value.RelativeAxis relativeAxis)
Specified by:
getAbsoluteAxis in interface org.axsl.common.value.WritingMode

getRelativeAxis

public org.axsl.common.value.RelativeAxis getRelativeAxis(org.axsl.common.value.AbsoluteAxis absoluteAxis)
Converts an absolute axis(horizontal or vertical) to a relative axis (inline-progression or block-progression) for this writing mode.

Specified by:
getRelativeAxis in interface org.axsl.common.value.WritingMode
Parameters:
absoluteAxis - Either AXIS_HORIZONTAL or AXIS_VERTICAL.
Returns:
Either AXIS_IP or AXIS_BP, or -1 if writing-mode or input is invalid.

getStart

public org.axsl.common.value.AbsoluteCompass getStart()
Specified by:
getStart in interface org.axsl.common.value.WritingMode

getEnd

public org.axsl.common.value.AbsoluteCompass getEnd()
Specified by:
getEnd in interface org.axsl.common.value.WritingMode

getBefore

public org.axsl.common.value.AbsoluteCompass getBefore()
Specified by:
getBefore in interface org.axsl.common.value.WritingMode

getAfter

public org.axsl.common.value.AbsoluteCompass getAfter()
Specified by:
getAfter in interface org.axsl.common.value.WritingMode

getLeft

public org.axsl.common.value.RelativeCompass getLeft()
Specified by:
getLeft in interface org.axsl.common.value.WritingMode

getRight

public org.axsl.common.value.RelativeCompass getRight()
Specified by:
getRight in interface org.axsl.common.value.WritingMode

getTop

public org.axsl.common.value.RelativeCompass getTop()
Specified by:
getTop in interface org.axsl.common.value.WritingMode

getBottom

public org.axsl.common.value.RelativeCompass getBottom()
Specified by:
getBottom in interface org.axsl.common.value.WritingMode

getAbsoluteDirection

public org.axsl.common.value.AbsoluteCompass getAbsoluteDirection(org.axsl.common.value.RelativeCompass relativeDir)
Specified by:
getAbsoluteDirection in interface org.axsl.common.value.WritingMode

getAbsoluteDirFromRelativeAxis

public org.axsl.common.value.AbsoluteDirection getAbsoluteDirFromRelativeAxis(org.axsl.common.value.RelativeAxis relativeAxis)
Specified by:
getAbsoluteDirFromRelativeAxis in interface org.axsl.common.value.WritingMode

getRelativeDirection

public org.axsl.common.value.RelativeCompass getRelativeDirection(org.axsl.common.value.AbsoluteCompass absoluteDir)
Specified by:
getRelativeDirection in interface org.axsl.common.value.WritingMode

getCorresponding

public org.axsl.common.value.Compass getCorresponding(org.axsl.common.value.Compass inputDirection)
Specified by:
getCorresponding in interface org.axsl.common.value.WritingMode

canEvalNumeric

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

Specified by:
canEvalNumeric in interface PropertyValue
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.

Specified by:
evalNumeric in interface PropertyValue
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.

Specified by:
canEvalLength in interface PropertyValue
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.

Specified by:
getUnitPower in interface PropertyValue
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).

Specified by:
evalLength in interface PropertyValue
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.

Specified by:
canEvalColor in interface PropertyValue
Returns:
True iff this property value is a color.

evalColor

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

Specified by:
evalColor in interface PropertyValue
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.

Specified by:
lengthRequiresFontSize in interface PropertyValue
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.

Specified by:
canEvalInteger in interface PropertyValue
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.

Specified by:
evalInteger in interface PropertyValue
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.

Specified by:
canEvalKeyword in interface PropertyValue
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.

Specified by:
evalKeyword in interface PropertyValue
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.

Specified by:
canEvalPercentage in interface PropertyValue
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.

Specified by:
evalPercentage in interface PropertyValue
Returns:
The percentage value of this property value.

isHorizontal

public boolean isHorizontal()
Indicates whether this writing-mode is horizontal or vertical.

Returns:
True if this writing-mode is horizontal, false if it is vertical.


Copyright © 2017. All rights reserved.