Class Text

java.lang.Object
  extended by Text
All Implemented Interfaces:
Shape

public class Text
extends java.lang.Object
implements Shape


Constructor Summary
Text(double x, double y, java.lang.String message)
          Constructs a text at a given location.
 
Method Summary
 void draw()
          Shows this text on the canvas.
 int getHeight()
          Gets the height of the bounding box.
 int getWidth()
          Gets the width of the bounding box.
 int getX()
          Gets the leftmost x-position of the bounding box.
 int getY()
          Gets the topmost y-position of the bounding box.
 void grow(double dw, double dh)
          Resizes this text both horizontally and vertically.
 void paintShape(java.awt.Graphics2D g2)
          Paints the shape
 void setColor(Color newColor)
          Sets the color for drawing this text.
 java.lang.String toString()
           
 void translate(double dx, double dy)
          Moves this text by a given amount.
 
Methods inherited from class
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Text

public Text(double x,
            double y,
            java.lang.String message)
Constructs a text at a given location.

Parameters:
x - the leftmost x-position of the shape
y - the topmost y-position of the shape
message - the text string
Method Detail

draw

public void draw()
Shows this text on the canvas.


getHeight

public int getHeight()
Gets the height of the bounding box.

Specified by:
getHeight in interface Shape
Returns:
the height

getWidth

public int getWidth()
Gets the width of the bounding box.

Specified by:
getWidth in interface Shape
Returns:
the width

getX

public int getX()
Gets the leftmost x-position of the bounding box.

Specified by:
getX in interface Shape
Returns:
the leftmost x-position

getY

public int getY()
Gets the topmost y-position of the bounding box.

Specified by:
getY in interface Shape
Returns:
the topmost y-position

grow

public void grow(double dw,
                 double dh)
Resizes this text both horizontally and vertically.

Parameters:
dw - the amount by which to resize the width on each side
dw - the amount by which to resize the height on each side

paintShape

public void paintShape(java.awt.Graphics2D g2)
Description copied from interface: Shape
Paints the shape

Specified by:
paintShape in interface Shape
Parameters:
g2 - the graphics object

setColor

public void setColor(Color newColor)
Sets the color for drawing this text.

Parameters:
newColor - the new color

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

translate

public void translate(double dx,
                      double dy)
Moves this text by a given amount.

Parameters:
dx - the amount by which to move in x-direction
dy - the amount by which to move in y-direction