java.lang.ObjectText
public class Text
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 |
---|
public Text(double x, double y, java.lang.String message)
x
- the leftmost x-position of the shapey
- the topmost y-position of the shapemessage
- the text stringMethod Detail |
---|
public void draw()
public int getHeight()
getHeight
in interface Shape
public int getWidth()
getWidth
in interface Shape
public int getX()
getX
in interface Shape
public int getY()
getY
in interface Shape
public void grow(double dw, double dh)
dw
- the amount by which to resize the width on each sidedw
- the amount by which to resize the height on each sidepublic void paintShape(java.awt.Graphics2D g2)
Shape
paintShape
in interface Shape
g2
- the graphics objectpublic void setColor(Color newColor)
newColor
- the new colorpublic java.lang.String toString()
toString
in class java.lang.Object
public void translate(double dx, double dy)
dx
- the amount by which to move in x-directiondy
- the amount by which to move in y-direction