Class BaseFontStyle
java.lang.Object
org.web3d.vrml.renderer.common.nodes.AbstractNode
org.web3d.vrml.renderer.common.nodes.text.BaseFontStyle
- All Implemented Interfaces:
VRMLNode
,FrameStateListener
,VRMLFontStyleNodeType
,VRMLNodeType
- Direct Known Subclasses:
DefaultFontStyle
,NRFontStyle
,OGLFontStyle
Scene graph representation of a font style information.
The fontstyle is a fixed, read-only node. Once created, you cannot change the fields. Thus, all field setting code will throw an exception. Because this class is fixed, once the Text node has fetched the font setup information, this class could be thrown away.
PropertiesThe following properties are used by this class
org.web3d.vrml.nodes.fontstyle.font.size
The font size in points. The default value is 36 point font.
- Version:
- $Revision: 1.21 $
- Author:
- Justin Couch
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final int
Index of the Family fieldprotected static final int
Index of the Horizontal fieldprotected static final int
Index of the justify fieldprotected static final int
Index of the language fieldprotected static final int
Index of the leftToRight fieldprotected static final int
Index of the size fieldprotected static final int
Index of the spacing fieldprotected static final int
Index of the style fieldprotected static final int
Index of the topToBottom fieldprotected static VRMLFieldDeclaration[]
Array of VRMLFieldDeclarationsHashmap between a field name and its indexMapping of the family field string to the internal Font name typeMapping of the justify field string to the internal int typeprotected static final int
The last field index used by this classprotected static final int
Number of fields constantMapping of the style field string to the internal int typeFields inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
errorReporter, FIELD_METADATA, fieldLocalData, hasChanged, inSetup, isDEF, isStatic, LAST_NODE_INDEX, layerIds, nodeName, pMetadata, refCounts, removedLayerIds, stateManager, STATIC_SCENE_GRAPH, vfMetadata, vrmlMajorVersion, vrmlMinorVersion
Fields inherited from interface org.web3d.vrml.nodes.VRMLFontStyleNodeType
BEGIN_JUSTIFY, BOLD_STYLE, BOLDITALIC_STYLE, END_JUSTIFY, FIRST_JUSTIFY, ITALIC_STYLE, MIDDLE_JUSTIFY, PLAIN_STYLE
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a default instance of the scriptBaseFontStyle
(VRMLNodeType node) Construct a new instance of this node based on the details from the given node. -
Method Summary
Modifier and TypeMethodDescriptiongetFieldDeclaration
(int index) Get the declaration of the field at the given index.int
getFieldIndex
(String fieldName) Get the index of the given field name.getFieldValue
(int index) Get the value of a field.getFont()
Fetch the AWT font description that matches the internal field settings.int
Get the horizontal justification flag.int[]
Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode).int
Get the number of fields.int
Get the primary type of this node.float
getSize()
Get the size information for a single line of text.float
Get the spacing definition for the lines of text.int
Get the vertical justification flag.boolean
Get the value of the horizontal flag.boolean
Get the value of the leftToRight flag.boolean
Get the value of the topToBottom flag.void
Notification that the construction phase of this node has finished.void
setValue
(int index, boolean value) Set the value of the field at the given index as an boolean.void
setValue
(int index, float value) Set the value of the field at the given index as a float.void
Set the value of the field at the given index as a string.void
Set the value of the field at the given index as an array of strings.Methods inherited from class org.web3d.vrml.renderer.common.nodes.AbstractNode
addNodeListener, allEventsComplete, checkNodeType, checkSecondaryType, checkSecondaryType, clearRemovedLayerIds, fireFieldChanged, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, getSecondaryType, getUserData, getVRMLNodeName, hasFieldChanged, isDEF, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, sendRoute, setDEF, setErrorReporter, setFrameStateManager, setMetadataObject, setUserData, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setVersion, throwInitOnlyWriteException, throwInputOnlyWriteException, throwInvalidNodeException, throwInvalidProtoException, throwOutputOnlyWriteException, updateRefCount, updateRefs
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.web3d.vrml.nodes.FrameStateListener
allEventsComplete
Methods inherited from interface org.web3d.vrml.lang.VRMLNode
getSecondaryType, getUserData, getVRMLNodeName, isDEF, setErrorReporter, setUserData, setVersion
Methods inherited from interface org.web3d.vrml.nodes.VRMLNodeType
addNodeListener, clearRemovedLayerIds, getLayerIds, getMetadataObject, getRefCount, getRemovedLayerIds, hasFieldChanged, isSetupFinished, notifyExternProtoLoaded, removeNodeListener, sendRoute, setDEF, setFrameStateManager, setMetadataObject, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, updateRefCount
-
Field Details
-
FIELD_FAMILY
protected static final int FIELD_FAMILYIndex of the Family field- See Also:
-
FIELD_HORIZONTAL
protected static final int FIELD_HORIZONTALIndex of the Horizontal field- See Also:
-
FIELD_JUSTIFY
protected static final int FIELD_JUSTIFYIndex of the justify field- See Also:
-
FIELD_LANGUAGE
protected static final int FIELD_LANGUAGEIndex of the language field- See Also:
-
FIELD_LEFTTORIGHT
protected static final int FIELD_LEFTTORIGHTIndex of the leftToRight field- See Also:
-
FIELD_SIZE
protected static final int FIELD_SIZEIndex of the size field- See Also:
-
FIELD_SPACING
protected static final int FIELD_SPACINGIndex of the spacing field- See Also:
-
FIELD_STYLE
protected static final int FIELD_STYLEIndex of the style field- See Also:
-
FIELD_TOPTOBOTTOM
protected static final int FIELD_TOPTOBOTTOMIndex of the topToBottom field- See Also:
-
LAST_FONTSTYLE_INDEX
protected static final int LAST_FONTSTYLE_INDEXThe last field index used by this class- See Also:
-
NUM_FIELDS
protected static final int NUM_FIELDSNumber of fields constant- See Also:
-
fieldDecl
Array of VRMLFieldDeclarations -
fieldMap
-
justifyMap
-
styleMap
-
fontMap
-
-
Constructor Details
-
BaseFontStyle
public BaseFontStyle()Construct a default instance of the script -
BaseFontStyle
Construct a new instance of this node based on the details from the given node. If the node is not a group node, an exception will be thrown. It does not copy the children nodes, just this node.- Parameters:
node
- The node to copy- Throws:
IllegalArgumentException
- The node is not a Group node
-
-
Method Details
-
getFont
Fetch the AWT font description that matches the internal field settings.- Specified by:
getFont
in interfaceVRMLFontStyleNodeType
- Returns:
- The font that is based on the fields
-
getHorizontalJustification
public int getHorizontalJustification()Get the horizontal justification flag. Uses the constants defined in this interface. This is the real justification after it has been modified according to the effects of the horizontal field- Specified by:
getHorizontalJustification
in interfaceVRMLFontStyleNodeType
- Returns:
- The justification value
-
getVerticalJustification
public int getVerticalJustification()Get the vertical justification flag. Uses the constants defined in this interface. This is the real justification after it has been modified according to the effects of the horizontal field- Specified by:
getVerticalJustification
in interfaceVRMLFontStyleNodeType
- Returns:
- The justification value
-
getSpacing
public float getSpacing()Get the spacing definition for the lines of text.- Specified by:
getSpacing
in interfaceVRMLFontStyleNodeType
- Returns:
- The font spacing information
-
getSize
public float getSize()Get the size information for a single line of text. Font size is already incorporated into the AWT Font information, but may also be needed for the inter-line spacing.- Specified by:
getSize
in interfaceVRMLFontStyleNodeType
- Returns:
- The font size information
-
isTopToBottom
public boolean isTopToBottom()Get the value of the topToBottom flag. Returns true if the text strings should be rendered from the top first, false for bottom first.- Specified by:
isTopToBottom
in interfaceVRMLFontStyleNodeType
- Returns:
- true if rendering top to bottom
-
isLeftToRight
public boolean isLeftToRight()Get the value of the leftToRight flag. Returns true if the text strings should be rendered from the left side to the right or in reverse - regardless of the original character encoding.- Specified by:
isLeftToRight
in interfaceVRMLFontStyleNodeType
- Returns:
- true if rendering left to right
-
isHorizontal
public boolean isHorizontal()Get the value of the horizontal flag. Returns true if the text strings should be rendered from vertically rather than horizontally for each string.- Specified by:
isHorizontal
in interfaceVRMLFontStyleNodeType
- Returns:
- true if rendering with a horizontal orientation
-
setupFinished
public void setupFinished()Notification that the construction phase of this node has finished. If the node would like to do any internal processing, such as setting up geometry, then go for it now.- Specified by:
setupFinished
in interfaceVRMLNodeType
- Overrides:
setupFinished
in classAbstractNode
-
getFieldIndex
Get the index of the given field name. If the name does not exist for this node then return a value of -1.- Specified by:
getFieldIndex
in interfaceVRMLNode
- Parameters:
fieldName
- The name of the field we want the index from- Returns:
- The index of the field name or -1
-
getNodeFieldIndices
public int[] getNodeFieldIndices()Get the list of indices that correspond to fields that contain nodes ie MFNode and SFNode). Used for blind scene graph traversal without needing to spend time querying for all fields etc. If a node does not have any fields that contain nodes, this shall return null. The field list covers all field types, regardless of whether they are readable or not at the VRML-level.- Specified by:
getNodeFieldIndices
in interfaceVRMLNode
- Returns:
- The list of field indices that correspond to SF/MFnode fields or null if none
-
getFieldDeclaration
Get the declaration of the field at the given index. This allows for reverse lookup if needed. If the field does not exist, this will give a value of null.- Specified by:
getFieldDeclaration
in interfaceVRMLNode
- Parameters:
index
- The index of the field to get information- Returns:
- A representation of this field's information
-
getNumFields
public int getNumFields()Get the number of fields.- Specified by:
getNumFields
in interfaceVRMLNode
- Returns:
- The number of fields.
-
getFieldValue
Get the value of a field. If the field is a primitive type, it will return a class representing the value. For arrays or nodes it will return the instance directly. An eventOut does not have field data available. This is neither an exceptional condition, nor something that should return valid data. Therefore the method returns null if you ask for the value of an eventOut.- Specified by:
getFieldValue
in interfaceVRMLNodeType
- Overrides:
getFieldValue
in classAbstractNode
- Parameters:
index
- The index of the field to change.- Returns:
- The class representing the field value or null for eventOuts
- Throws:
InvalidFieldException
- The field index is not known
-
getPrimaryType
public int getPrimaryType()Get the primary type of this node. Replaces the instanceof mechanism for use in switch statements.- Specified by:
getPrimaryType
in interfaceVRMLNode
- Returns:
- The primary type
-
setValue
public void setValue(int index, String value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a string. This would be used to set SFString field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, String[] value, int numValid) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as an array of strings. This would be used to set MFString field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the nodenumValid
- The number of valid values to copy from the array- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, float value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as a float. This would be used to set SFFloat field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.
-
setValue
public void setValue(int index, boolean value) throws InvalidFieldException, InvalidFieldValueException Set the value of the field at the given index as an boolean. This would be used to set SFBool field types.- Specified by:
setValue
in interfaceVRMLNodeType
- Overrides:
setValue
in classAbstractNode
- Parameters:
index
- The index of destination field to setvalue
- The new value to use for the node- Throws:
InvalidFieldException
- The field index is not knownInvalidFieldValueException
- The value provided is out of range for the field type.
-