edu.cmu.sun.components
Class TextComponent

java.lang.Object
  extended by Component3D
      extended by edu.cmu.sun.components.TextComponent

public class TextComponent
extends Component3D

TextComponent is a Component3D that displays a simple string at a specified size and weight (boldness). This is a wraper class for the extremely hacked Text2DView class. Unlike most components used in this application, this Class registers along the baseline of the font. It is useful to have text as a Component because it's attributes can be changed after it is created.

Author:
Braden Kowitz

Field Summary
(package private)  boolean bold
          Whether the string should be rendered in a bold font.
(package private) static int DEFAULT_QUALITY
          The default quality of the text to be rendered.
static float DEFAULT_SIZE
          The default size of the text to be rendered.
(package private)  float size
          The size of the font to be rendered.
(package private)  java.lang.String string
          The string to rendered.
(package private)  Text2DView textView
          The Shape3D object that is actuially responsible for the rendering of the text.
 
Constructor Summary
TextComponent(java.lang.String string)
          Create a text component at the default size, quality, and weight.
TextComponent(java.lang.String string, boolean bold)
           
TextComponent(java.lang.String string, float size)
          Render text at a specified size.
 
Method Summary
 float getHeight()
          The height of the resulting text component
 float getWidth()
          The width of the resulting text component
 boolean isBold()
           
 void setBold(boolean bold)
          Allows user to change this Component to render text in a bold font.
private  void update()
          Internal method for updating the state of the component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_QUALITY

static final int DEFAULT_QUALITY
The default quality of the text to be rendered.

See Also:
Text2DView, Constant Field Values

DEFAULT_SIZE

public static final float DEFAULT_SIZE
The default size of the text to be rendered. (in meters)

See Also:
Constant Field Values

string

java.lang.String string
The string to rendered.


bold

boolean bold
Whether the string should be rendered in a bold font.


size

float size
The size of the font to be rendered.


textView

Text2DView textView
The Shape3D object that is actuially responsible for the rendering of the text.

Constructor Detail

TextComponent

public TextComponent(java.lang.String string)
Create a text component at the default size, quality, and weight.

Parameters:
string -

TextComponent

public TextComponent(java.lang.String string,
                     float size)
Render text at a specified size.

Parameters:
string - Text to be rendered
size - specified size (in meters?)
See Also:
Text2DView

TextComponent

public TextComponent(java.lang.String string,
                     boolean bold)
Method Detail

update

private void update()
Internal method for updating the state of the component.


getWidth

public float getWidth()
The width of the resulting text component

Returns:
Width in meters

getHeight

public float getHeight()
The height of the resulting text component

Returns:
Height in meters

isBold

public boolean isBold()
Returns:
True if component is drawn in a bold font.

setBold

public void setBold(boolean bold)
Allows user to change this Component to render text in a bold font.

Parameters:
bold - True if font is to be drawn in a bold font, false otherwise.