exe
Class GAIGStext

java.lang.Object
  extended by exe.GAIGStext
All Implemented Interfaces:
GAIGSdatastr

public class GAIGStext
extends java.lang.Object
implements GAIGSdatastr

This is the new GAIGS support class for drawing text to the visualization pane. Unlike GAIGSlabel, which previously provided support for drawing text to the screen, a GAIGStext object can be used to precisely position the text that is to be drawn. The appearance of this text is controlled by the following fields:

  x        - The x-coordinate (usually within the bounds [0,1]) at which the
             text is to be drawn. How the text is displayed relative to this
             x-coordinate is controlled by the halign field.

  y        - The y-coordinate (usually within the bounds [0,1]) at which the
             text is to be drawn. How the text is displayed relative to this
             y-coordinate is controlled by the valign field.

  halign   - Controls how the text is drawn relative to the x-coordinate
             stored in x. This field can have one of three possible values:
               HCENTER - Centers the text horizontally about x.
               HLEFT   - Left-justifies the text with x as the left margin.
               HRIGHT  - Right-justifies the text with x as the right margin.

  valign   - Controls how the text is drawn relative to the y-coordinate
             stored in y. This field can have one of three possible values:
               VCENTER - Centers the text vertically about y.
               VBOTTOM - Draws the lowest line of text at y.
               VTOP    - Draws the highest line of text at y.

  fontsize - The size of the text that is to be drawn. This corresponds to
             the fontsize field used in the other GAIGS structures.

  color    - The default color of the text that is to be drawn. This is
             similar to the coloring used in other GAIGS structures; the
             value is a hexadecimal RGB string of the form #000000. Note that
             color escapes (e.g., \#000000) can be used to change the color
             of text within a line. However, each new line in the text String
             will revert back to the default color stored in color so a color
             escape is required to begin a line in a different color than the
             color stored in the color field.

  text     - The actual text String that is to be drawn to the screen. This
             String can have multiple lines, and the newlines will be 
             preserved when it is displayed. Note that the vertical 
             positioning set using valign uses all the lines of text to
             compute where the text is displayed. For example, a five-line
             String that has been vertically centered will appear with its
             third line positioned vertically on y.
 

Version:
1.0 (28 June 2006)
Author:
Andrew Jungwirth

Field Summary
static int HCENTER
          Value that can be assigned to halign to center the text horizontally about the x-coordinate in x.
static int HLEFT
          Value that can be assigned to halign to left-justify the text horizontally at the x-coordinate in x.
static int HRIGHT
          Value that can be assigned to halign to right-justify the text horizontally at the x-coordinate in x.
static int VBOTTOM
          Value that can be assigned to valign to position the lowest line of text at the y-coordinate in y.
static int VCENTER
          Value that can be assigned to valign to center the text vertically about the y-coordinate in y.
static int VTOP
          Value that can be assigned to valign to position the highest line of text at the y-coordinate in y.
 
Fields inherited from interface exe.GAIGSdatastr
DEFAULT_COLOR, DEFAULT_FONT_SIZE, DEFAULT_NAME, DEFAULT_X1, DEFAULT_X2, DEFAULT_Y1, DEFAULT_Y2
 
Constructor Summary
GAIGStext()
          Default constructor that assigns default values to all fields.
GAIGStext(double x, double y)
          Constuctor that only sets the location of the text.
GAIGStext(double x, double y, int halign, int valign, double fontsize, java.lang.String color, java.lang.String text)
          Constructor that sets all fields for this GAIGStext object.
GAIGStext(double x, double y, java.lang.String text)
          Constructor that sets the text and its location.
 
Method Summary
 java.lang.String getColor()
          Gives the value stored to color.
 double getFontsize()
          Gives the value stored to fontsize.
 int getHalign()
          Gives the value stored to halign.
 java.lang.String getName()
          Method required to implement the GAIGSdatastr interface.
 java.lang.String getText()
          Gives the value stored to text.
 int getValign()
          Gives the value stored to valign.
 double getX()
          Gives the value stored to x.
 double getY()
          Gives the value stored to y.
 void setColor(java.lang.String color)
          Sets the value of color.
 void setFontsize(double fontsize)
          Sets the value of fontsize.
 boolean setHalign(int halign)
          Sets the value of halign.
 void setName(java.lang.String text)
          Method required to implement the GAIGSdatastr interface.
 void setText(java.lang.String text)
          Sets the value of text.
 boolean setValign(int valign)
          Sets the value of valign.
 void setX(double x)
          Sets the value of x.
 void setY(double y)
          Sets the value of y.
 java.lang.String toXML()
          Returns the GAIGS XML representation of this GAIGStext object as a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HCENTER

public static final int HCENTER
Value that can be assigned to halign to center the text horizontally about the x-coordinate in x.

See Also:
Constant Field Values

HLEFT

public static final int HLEFT
Value that can be assigned to halign to left-justify the text horizontally at the x-coordinate in x.

See Also:
Constant Field Values

HRIGHT

public static final int HRIGHT
Value that can be assigned to halign to right-justify the text horizontally at the x-coordinate in x.

See Also:
Constant Field Values

VCENTER

public static final int VCENTER
Value that can be assigned to valign to center the text vertically about the y-coordinate in y.

See Also:
Constant Field Values

VBOTTOM

public static final int VBOTTOM
Value that can be assigned to valign to position the lowest line of text at the y-coordinate in y.

See Also:
Constant Field Values

VTOP

public static final int VTOP
Value that can be assigned to valign to position the highest line of text at the y-coordinate in y.

See Also:
Constant Field Values
Constructor Detail

GAIGStext

public GAIGStext()
Default constructor that assigns default values to all fields. The fields are set as follows:
  x = 0.5
  y = 0.5
  halign = HCENTER
  valign = VCENTER
  fontsize = 0.04
  color = "#000000"
  text = ""
 


GAIGStext

public GAIGStext(double x,
                 double y)
Constuctor that only sets the location of the text. The remaining fields are set as follows:
  halign = HCENTER
  valign = VCENTER
  fontsize = 0.04
  color = "#000000"
  text = ""
 

Parameters:
x - The x-coordinate for the text (usually within [0,1]).
y - The y-coordinate for the text (usually within [0,1]).

GAIGStext

public GAIGStext(double x,
                 double y,
                 java.lang.String text)
Constructor that sets the text and its location. The remaining fields are set as follows:
  halign = HCENTER
  valign = VCENTER
  fontsize = 0.04
  color = "#000000"
 

Parameters:
x - The x-coordinate for the text (usually within [0,1]).
y - The y-coordinate for the text (usually within [0,1]).
text - The text that is to be displayed on the screen.

GAIGStext

public GAIGStext(double x,
                 double y,
                 int halign,
                 int valign,
                 double fontsize,
                 java.lang.String color,
                 java.lang.String text)
Constructor that sets all fields for this GAIGStext object.

Parameters:
x - The x-coordinate for the text (usually within [0,1]).
y - The y-coordinate for the text (usually within [0,1]).
halign - One of the three possible constant values used to define the horizontal alignment of the text relative to x. An invalid input defaults to HCENTER.
valign - One of the three possible constant values used to define the vertical alignment of the text relative to y. An invalid input defaults to VCENTER.
fontsize - The size of the text that is to be displayed. Functions similarly to other GAIGS structures.
color - The default color in which the text is to be drawn.
text - The text that is to be displayed on the screen.
Method Detail

getX

public double getX()
Gives the value stored to x.

Returns:
The x-coordinate for this GAIGStext object.

getY

public double getY()
Gives the value stored to y.

Returns:
The y-coordinate for this GAIGStext object.

getHalign

public int getHalign()
Gives the value stored to halign.

Returns:
The horizontal alignment constant for this GAIGStext object.

getValign

public int getValign()
Gives the value stored to valign.

Returns:
The vertical alignment constant for this GAIGStext object.

getFontsize

public double getFontsize()
Gives the value stored to fontsize.

Returns:
The fontsize for this GAIGStext object.

getColor

public java.lang.String getColor()
Gives the value stored to color.

Returns:
The color String for this GAIGStext object.

getText

public java.lang.String getText()
Gives the value stored to text.

Returns:
The text String for this GAIGStext object.

getName

public java.lang.String getName()
Method required to implement the GAIGSdatastr interface. Returns the value stored in text. This method is identical to getText.

Specified by:
getName in interface GAIGSdatastr
Returns:
The text String for this GAIGStext object.

setX

public void setX(double x)
Sets the value of x. This should usually be in the range [0,1].

Parameters:
x - The new x-coordinate for this GAIGStext object.

setY

public void setY(double y)
Sets the value of y. This should usually be in the range [0,1].

Parameters:
y - The new y-coordinate for this GAIGStext object.

setHalign

public boolean setHalign(int halign)
Sets the value of halign. The value of halign remains unchanged if an invalid input is given.

Parameters:
halign - The new horizontal alignment for this GAIGStext object.
Returns:
True if halign was successfully changed; false otherwise.

setValign

public boolean setValign(int valign)
Sets the value of valign. The value of valign remains unchanged if an invalid input is given.

Parameters:
valign - The new vertical alignment for this GAIGStext object.
Returns:
True if valign was successfully changed; false otherwise.

setFontsize

public void setFontsize(double fontsize)
Sets the value of fontsize.

Parameters:
fontsize - The new fontsize for this GAIGStext object.

setColor

public void setColor(java.lang.String color)
Sets the value of color.

Parameters:
color - The new default color for this GAIGStext object.

setText

public void setText(java.lang.String text)
Sets the value of text.

Parameters:
text - The new text String for this GAIGStext object.

setName

public void setName(java.lang.String text)
Method required to implement the GAIGSdatastr interface. Sets the value of text. This method is identical to setText.

Specified by:
setName in interface GAIGSdatastr
Parameters:
text - The new text String for this GAIGStext object.

toXML

public java.lang.String toXML()
Returns the GAIGS XML representation of this GAIGStext object as a String.

Specified by:
toXML in interface GAIGSdatastr
Returns:
A String containing the GAIGS XML representation of this GAIGStext object.