|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--objectdraw.Drawable | +--objectdraw.Drawable2D | +--objectdraw.Text
Text is an implementation of a drawable text string object.
Field Summary | |
protected double |
baseHeight
The text's height above baseline. |
protected java.awt.Font |
font
The text's font. |
protected double |
height
The text's height. |
protected Location |
origin
The location of the upper-left-most point of the text |
protected java.lang.String |
text
The object's text contents. |
protected double |
width
The text's width. |
Fields inherited from class objectdraw.Drawable |
canvas, canvasContent, color, DEBUGGING, shown |
Constructor Summary | |
Text(boolean text,
double x,
double y,
DrawingCanvas c)
Creates a new Text object a boolean. |
|
Text(boolean text,
Location origin,
DrawingCanvas c)
Creates a new Text object that displays a boolean. |
|
Text(char text,
double x,
double y,
DrawingCanvas c)
Creates a new Text object that displays a char. |
|
Text(char text,
Location origin,
DrawingCanvas c)
Creates a new Text object that displays a char. |
|
Text(double text,
double x,
double y,
DrawingCanvas c)
Creates a new Text object that displays a double or float. |
|
Text(double text,
Location origin,
DrawingCanvas c)
Creates a new Text object that displays a double or float. |
|
Text(long text,
double x,
double y,
DrawingCanvas c)
Creates a new Text object that displays a long, int, short, or byte. |
|
Text(long text,
Location origin,
DrawingCanvas c)
Creates a new Text object that displays a short, int, byte or long. |
|
Text(java.lang.Object text,
double x,
double y,
DrawingCanvas c)
Creates a new Text object that displays an object. |
|
Text(java.lang.Object text,
Location origin,
DrawingCanvas c)
Creates a new Text object that displays an Object. |
Method Summary | |
protected void |
changeSize()
Updates instance variables when something changes that may impact bounding box of the text. |
void |
draw(java.awt.Graphics g)
Draws the object. |
Bounds |
getBounds()
Retrieves the bounding rectangle of the object. |
java.awt.Font |
getFont()
Retrieves the text object's font. |
double |
getHeight()
Gets the width of the object's bounding rectangle |
java.lang.String |
getText()
Gets the text of the object. |
double |
getWidth()
Gets the width of the object's bounding rectangle |
void |
move(double dx,
double dy)
Moves the Text object within the canvas by the amount specified in the x and y direction. |
void |
moveTo(Location point)
Moves the Text object within the canvas to the specified Location. |
void |
setBold()
Deprecated. Deprecated since objectdraw 4, use setBold(boolean) instead. |
void |
setBold(boolean bool)
Toggles whether the text object's style is bold or not. |
void |
setFont(java.awt.Font f)
Sets the text object's font. |
void |
setFont(java.lang.String fname)
Sets the text object's font. |
void |
setFontSize(int size)
Sets the text object's font size. |
void |
setItalic()
Deprecated. Deprecated since objectdraw 4, use setItalic(boolean) instead. |
void |
setItalic(boolean bool)
Toggles whether the text object's style is italics or not. |
void |
setPlain()
Sets the text object's font to have plain style. |
void |
setText(boolean text)
Sets the text object's value to the boolean text. |
void |
setText(char text)
Sets the text object's value to the char text |
void |
setText(double text)
Sets the text object's value to the double text |
void |
setText(long text)
Sets the text object's value to the short, int, byte, or long text. |
void |
setText(java.lang.Object text)
Sets the text object's value to the Object text |
void |
setText(java.lang.String text)
Sets the text object's value to the String text. |
java.lang.String |
toString()
Generates a string representation of the object. |
Methods inherited from class objectdraw.Drawable2D |
contains, getLocation, getX, getY, overlaps |
Methods inherited from class objectdraw.Drawable |
addToCanvas, getColor, hide, isHidden, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, setStateChanged, show |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface objectdraw.DrawableInterface |
addToCanvas, getColor, hide, isHidden, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, show |
Field Detail |
protected Location origin
protected double width
protected double height
protected double baseHeight
protected java.awt.Font font
protected java.lang.String text
Constructor Detail |
public Text(java.lang.Object text, Location origin, DrawingCanvas c)
text
- the text to be drawnorigin
- the upper left corner of the bounding
region for the objectc
- the canvas into which the text will be drawnpublic Text(boolean text, Location origin, DrawingCanvas c)
text
- the text to be drawnorigin
- the upper left corner of the bounding
region for the objectc
- the canvas into which the text will be drawnpublic Text(char text, Location origin, DrawingCanvas c)
text
- the text to be drawnorigin
- the upper left corner of the bounding
region for the objectc
- the canvas into which the text will be drawnpublic Text(long text, Location origin, DrawingCanvas c)
text
- the text to be drawnorigin
- the upper left corner of the bounding
region for the objectc
- the canvas into which the text will be drawnpublic Text(double text, Location origin, DrawingCanvas c)
text
- the text to be drawnorigin
- the upper left corner of the bounding
region for the objectc
- the canvas into which the text will be drawnpublic Text(java.lang.Object text, double x, double y, DrawingCanvas c)
text
- the text to be drawnx
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglec
- the canvas into which the text will be drawnpublic Text(boolean text, double x, double y, DrawingCanvas c)
text
- the text to be drawnx
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglec
- the canvas into which the text will be drawnpublic Text(long text, double x, double y, DrawingCanvas c)
text
- the text to be drawnx
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglec
- the canvas into which the text will be drawnpublic Text(double text, double x, double y, DrawingCanvas c)
text
- the text to be drawnx
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglec
- the canvas into which the text will be drawnpublic Text(char text, double x, double y, DrawingCanvas c)
text
- the text to be drawnx
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglec
- the canvas into which the text will be drawnMethod Detail |
public void draw(java.awt.Graphics g)
draw
in class Drawable2D
g
- the graphics context into which the object is drawnprotected void changeSize()
public double getWidth()
public double getHeight()
getHeight
in class Drawable2D
objectdraw.Drawable2D
public Bounds getBounds()
objectdraw.Drawable2DInterface
public void moveTo(Location point)
moveTo
in class Drawable
point
- the coordinates of the upper left corner of the
object's new bounding boxpublic void move(double dx, double dy)
move
in class Drawable
dx
- the amount to move in the x-directiondy
- the amount to move in the y-directionpublic java.awt.Font getFont()
public void setText(java.lang.String text)
text
- the textpublic void setText(long text)
text
- the textpublic void setText(boolean text)
text
- the textpublic void setText(char text)
text
- the textpublic void setText(double text)
text
- the textpublic void setText(java.lang.Object text)
text
- the textpublic void setFont(java.awt.Font f)
f
- the fontpublic java.lang.String getText()
public void setFont(java.lang.String fname)
f
- the fontpublic void setFontSize(int size)
size
- the font size in pointspublic void setItalic()
public void setItalic(boolean bool)
bool
- defines whether the text object is italics or notpublic void setBold()
public void setBold(boolean bool)
bool
- defines whether the text object is bold or notpublic void setPlain()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |