com.hedgehog.text
Class Text

java.lang.Object
  extended by com.hedgehog.HObject
      extended by com.hedgehog.text.Text
All Implemented Interfaces:
ModelObject, java.lang.Comparable, java.util.Comparator

public class Text
extends HObject
implements ModelObject

Title: Text - represents a text object.

Description: Represents a text object. Modelled in a similar way to the X3D Text node.

Copyright: Copyright (c) Hedgehog Software.

Company: Hedgehog Software.

Since:
1.0
Version:
1.1

Field Summary
protected  FontStyle mFontStyle
          Font style node.
protected  boolean mIsSolid
          Indicates whether or not the text is solid or wireframe.
protected  FloatingPointVector mLength
          The length of each text string in the local coordinate system.
protected  double mMaxExtent
          Limits and compresses all of the text strings if the length of the maximum string is longer than the maximum extent.
protected  Point3D mPosition
          Text string position.
protected  java.util.Vector<java.lang.String> mString
          Vector of strings that form text.
 
Fields inherited from class com.hedgehog.HObject
mID, mName
 
Constructor Summary
Text()
          Default constructor.
Text(Point3D position, FontStyle fontStyle, FloatingPointVector length, double maxExtent, java.util.Vector<java.lang.String> string, boolean isSolid)
          Constructor.
Text(Text object)
          Copy constructor.
 
Method Summary
 java.util.Vector<ModelObject> childModelObjects()
          Returns a vector of this object's child ModelObject objects.
 java.lang.String concatenatedStringLengths()
          Returns a space-concatenated string of the string lengths as sub-strings.
 java.lang.String concatenatedStrings()
          Returns a space-concatenated string of the strings as sub-strings.
 java.sql.PreparedStatement databaseInsertStatement(java.sql.Connection connection, int modelID)
          Returns a prepared statement for inserting (INSERT command) a ModelObject object into a database.
 java.sql.PreparedStatement databaseUpdateStatement(java.sql.Connection connection, int modelID)
          Returns a prepared statement for updating (UPDATE command) a ModelObject object into a database.
 ModelObject fromDatabase(java.sql.Connection connection, Model model, int modelID, int objectID)
          Returns a model object from the specified database table.
 ModelObject fromXMLNode(org.w3c.dom.Document document, org.w3c.dom.Node documentRootNode, org.w3c.dom.Node node, Model model)
          Returns a model object from the specified xml node.
 FontStyle getFontStyleNode()
          Returns the font style node.
 boolean getIsSolid()
          Returns the is-solid value.
 FloatingPointVector getLength()
          Returns the length vector.
 double getMaxExtent()
          Returns the maximum extent.
 Point3D getPosition()
          Returns the text string position.
 java.util.Vector<java.lang.String> getString()
          Returns the string vector.
 void setFontStyleNode(FontStyle fontStyle)
          Sets the font style.
 void setIsSolid(boolean isSolid)
          Sets the is-solid value.
 void setLength(FloatingPointVector length)
          Sets the length vector.
 void setMaxExtent(double maxExtent)
          Sets the maximum extent.
 void setPosition(Point3D position)
          Sets the text string position.
 void setString(java.util.Vector<java.lang.String> string)
          Sets the string vector.
 java.lang.String toString()
          Returns a String representation of a Text3D object.
 X3DNode toX3DNode(X3DObject x3dObject)
          X3D support.
 org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document, org.w3c.dom.Element documentRootNode)
          Returns the xml node of this object.
 
Methods inherited from class com.hedgehog.HObject
clone, compare, compareTo, copy, equals, getID, getName, hashCode, hasID, hasName, setID, setName
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

mPosition

protected Point3D mPosition
Text string position.


mFontStyle

protected FontStyle mFontStyle
Font style node.


mLength

protected FloatingPointVector mLength
The length of each text string in the local coordinate system.


mMaxExtent

protected double mMaxExtent
Limits and compresses all of the text strings if the length of the maximum string is longer than the maximum extent.


mString

protected java.util.Vector<java.lang.String> mString
Vector of strings that form text.


mIsSolid

protected boolean mIsSolid
Indicates whether or not the text is solid or wireframe.

Constructor Detail

Text

public Text()
Default constructor. Sets the text string position to (0,0,0), the font style to the default FontStyle object, the length vector to a non-null empty vector, the maximum extent to 0, the string vetor to a non-null empty vector and the is-solid Boolean to false.


Text

public Text(Point3D position,
            FontStyle fontStyle,
            FloatingPointVector length,
            double maxExtent,
            java.util.Vector<java.lang.String> string,
            boolean isSolid)
Constructor.

Parameters:
position - Text string posiiton.
fontStyle - Font style.
length - Length vector.
maxExtent - Maximum extent.
string - String vector.
isSolid - Is-solid value.

Text

public Text(Text object)
Copy constructor.

Parameters:
object - Object to copy.
Method Detail

getPosition

public Point3D getPosition()
Returns the text string position.

Returns:
The text stirng position.

getFontStyleNode

public FontStyle getFontStyleNode()
Returns the font style node.

Returns:
The font style.

getLength

public FloatingPointVector getLength()
Returns the length vector.

Returns:
The length vector.

getMaxExtent

public double getMaxExtent()
Returns the maximum extent.

Returns:
The maximum extent.

getString

public java.util.Vector<java.lang.String> getString()
Returns the string vector.

Returns:
The string vector.

getIsSolid

public boolean getIsSolid()
Returns the is-solid value.

Returns:
The is-solid value.

setPosition

public void setPosition(Point3D position)
Sets the text string position.

Parameters:
position - New text string position.

setFontStyleNode

public void setFontStyleNode(FontStyle fontStyle)
Sets the font style.

Parameters:
fontStyle - New font style.

setLength

public void setLength(FloatingPointVector length)
Sets the length vector.

Parameters:
length - New length vector.

setMaxExtent

public void setMaxExtent(double maxExtent)
Sets the maximum extent.

Parameters:
maxExtent - New maximum extent.

setString

public void setString(java.util.Vector<java.lang.String> string)
Sets the string vector.

Parameters:
string - New string vector.

setIsSolid

public void setIsSolid(boolean isSolid)
Sets the is-solid value.

Parameters:
isSolid - New is-solid value.

toString

public java.lang.String toString()
Returns a String representation of a Text3D object.

Overrides:
toString in class java.lang.Object
Returns:
A String representation of a Text3D object.

childModelObjects

public java.util.Vector<ModelObject> childModelObjects()
Returns a vector of this object's child ModelObject objects.

Specified by:
childModelObjects in interface ModelObject
Returns:
An empty vector. All text data are stored within the Texts table.

databaseInsertStatement

public java.sql.PreparedStatement databaseInsertStatement(java.sql.Connection connection,
                                                          int modelID)
                                                   throws java.sql.SQLException
Returns a prepared statement for inserting (INSERT command) a ModelObject object into a database.

Specified by:
databaseInsertStatement in interface ModelObject
Parameters:
connection - Database connection.
modelID - Model ID.
Returns:
A prepared statement for inserting a ModelObject object into a database.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

databaseUpdateStatement

public java.sql.PreparedStatement databaseUpdateStatement(java.sql.Connection connection,
                                                          int modelID)
                                                   throws java.sql.SQLException
Returns a prepared statement for updating (UPDATE command) a ModelObject object into a database.

Specified by:
databaseUpdateStatement in interface ModelObject
Parameters:
connection - Database connection.
modelID - Model ID.
Returns:
A prepared statement for inserting a ModelObject object into a database.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

fromDatabase

public ModelObject fromDatabase(java.sql.Connection connection,
                                Model model,
                                int modelID,
                                int objectID)
                         throws java.sql.SQLException
Returns a model object from the specified database table.

Specified by:
fromDatabase in interface ModelObject
Parameters:
connection - Database connection.
model - Model built from database.
modelID - Model ID.
objectID - Object ID in associated ModelObjects table.
Returns:
ModelObject corresponding to the specified db connection, model ID and obect ID. A null value is returned if no match found.
Throws:
java.sql.SQLException - Thrown if an SQL exception occurs.

concatenatedStringLengths

public java.lang.String concatenatedStringLengths()
Returns a space-concatenated string of the string lengths as sub-strings.

Returns:
A space-concatenated string of the string lengths as sub-strings.

concatenatedStrings

public java.lang.String concatenatedStrings()
Returns a space-concatenated string of the strings as sub-strings.

Returns:
A space-concatenated string of the strings as sub-strings.

toXMLNode

public org.w3c.dom.Element toXMLNode(org.w3c.dom.Document document,
                                     org.w3c.dom.Element documentRootNode)
                              throws InvalidObjectException
Returns the xml node of this object.

Specified by:
toXMLNode in interface ModelObject
Parameters:
document - XML document.
documentRootNode - Document root node; ie Model node.
Returns:
The xml node of this object.
Throws:
InvalidObjectException - Thrown if this object's ID is equal to the default ID of -1.

fromXMLNode

public ModelObject fromXMLNode(org.w3c.dom.Document document,
                               org.w3c.dom.Node documentRootNode,
                               org.w3c.dom.Node node,
                               Model model)
                        throws InvalidObjectException
Returns a model object from the specified xml node.

Specified by:
fromXMLNode in interface ModelObject
Parameters:
document - XML document.
documentRootNode - Document root node; ie Model node.
node - XML node.
model - Model to which node object is added.
Returns:
ModelObject corresponding to the specified node. A null value is returned if an error occurred building the object.
Throws:
InvalidObjectException - Thrown if an error occurred building the object.

toX3DNode

public X3DNode toX3DNode(X3DObject x3dObject)
                  throws InvalidObjectException
X3D support. Attributes are handled in the order MaterialNode and AppearanceNode. If a MaterialNode is associated with this object's ID then it is added to the shape node's Appearance node. If no MaterialNode is found then AppearanceNode is tested for association and if so then added.

Specified by:
toX3DNode in interface ModelObject
Parameters:
x3dObject - X3D object.
Returns:
X3D object or null if object has no visualisation.
Throws:
InvalidObjectException - Thrown if this object is invalid.