|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectobjectdraw.Drawable
objectdraw.Drawable2D
objectdraw.Text
Text is an implementation of text strings that can be drawn on a Drawingcanvas.
Constructor Summary | |
Text(boolean text,
double x,
double y,
DrawingCanvas canvas)
Creates a new Text object that displays a boolean. |
|
Text(boolean text,
Location origin,
DrawingCanvas canvas)
Creates a new Text object that displays a boolean. |
|
Text(char text,
double x,
double y,
DrawingCanvas canvas)
Creates a new Text object that displays a char. |
|
Text(char text,
Location origin,
DrawingCanvas canvas)
Creates a new Text object that displays a char. |
|
Text(double text,
double x,
double y,
DrawingCanvas canvas)
Creates a new Text object that displays a double or float. |
|
Text(double text,
Location origin,
DrawingCanvas canvas)
Creates a new Text object that displays a double or float. |
|
Text(long text,
double x,
double y,
DrawingCanvas canvas)
Creates a new Text object that displays a short, int, byte or long. |
|
Text(long text,
Location origin,
DrawingCanvas canvas)
Creates a new Text object that displays a short, int, byte or long. |
|
Text(java.lang.Object text,
double x,
double y,
DrawingCanvas canvas)
Creates a new Text object that displays an arbitrary Object. |
|
Text(java.lang.Object text,
Location origin,
DrawingCanvas canvas)
Creates a new Text object that displays an arbitrary Object. |
Method Summary | |
void |
addToCanvas(DrawingCanvas canvas)
Places an existing object on a specified DrawingCanvas. |
boolean |
contains(Location point)
Determines if a particular position on the DrawingCanvas is contained within the object. |
DrawingCanvas |
getCanvas()
Determine which (if any) DrawingCanvas this object is positioned on |
java.awt.Color |
getColor()
Retrieves the color of the object. |
java.awt.Font |
getFont()
Retrieves the text object's font. |
double |
getHeight()
Get the height of a graphical object |
Location |
getLocation()
Get a graphical object's position |
java.lang.String |
getText()
Gets the text of the object. |
double |
getWidth()
Get the width of a graphical object |
double |
getX()
Get the x coordinate of left edge of rectangle bounding the object |
double |
getY()
Get the y coordinate of top edge of rectangle bounding the object |
void |
hide()
Temporarily hides an object on a DrawingCanvas from view. |
boolean |
isHidden()
Determine whether an object is currently visible on its canvas |
void |
move(double dx,
double dy)
Moves the object within the canvas in the x and y direction by the amounts specified as parameters. |
void |
moveTo(double x,
double y)
Moves the object within the canvas to the x and y coordinates provided. |
void |
moveTo(Location point)
Moves the object within the canvas to the specified Location |
boolean |
overlaps(Drawable2DInterface item)
Determines if another Drawable's bounding rectangle overlaps with this object's bounding rectangle. |
void |
removeFromCanvas()
Permanently removes the object from the canvas it is currently on. |
void |
sendBackward()
Sends the object backward. |
void |
sendForward()
Sends the object forward. |
void |
sendToBack()
Sends the object to the back. |
void |
sendToFront()
Sends the object to the front. |
void |
setBold()
Deprecated. Use setBold(boolean) instead. |
void |
setBold(boolean bool)
Toggles whether the text object's style is bold or not. |
void |
setColor(java.awt.Color c)
Sets the color of the object. |
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. 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 display a boolean value. |
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 text representation of a double |
void |
setText(long text)
Sets the text object's value to the representation of a short, int, byte, or long value. |
void |
setText(java.lang.Object text)
Sets the text object's value to a representation of the Object text |
void |
setText(java.lang.String text)
Sets the text object's value to the String text. |
void |
show()
Shows the object if it has been hidden. |
java.lang.String |
toString()
Generates a string representation of the object. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface objectdraw.Drawable2DInterface |
getLocation, getX, getY, overlaps |
Methods inherited from interface objectdraw.DrawableInterface |
contains, getCanvas, getColor, hide, isHidden, moveTo, removeFromCanvas, sendBackward, sendForward, sendToBack, sendToFront, setColor, show |
Constructor Detail |
public Text(java.lang.Object text, Location origin, DrawingCanvas canvas)
text
- the object to be displayedorigin
- the upper left corner of the bounding region for the text that
appearscanvas
- the canvas into which the text will be drawnpublic Text(java.lang.Object text, double x, double y, DrawingCanvas canvas)
text
- the object to be displayedx
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglecanvas
- the canvas into which the text will be drawnpublic Text(boolean text, Location origin, DrawingCanvas canvas)
text
- the boolean to be displayedorigin
- the upper left corner of the bounding region for the text
displayedcanvas
- the canvas into which the text will be drawnpublic Text(boolean text, double x, double y, DrawingCanvas canvas)
text
- the boolean to be displayedx
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglecanvas
- the canvas into which the text will be drawnpublic Text(char text, Location origin, DrawingCanvas canvas)
text
- the char to be displayedorigin
- the upper left corner of the bounding region for the text
displayedcanvas
- the canvas into which the text will be drawnpublic Text(char text, double x, double y, DrawingCanvas canvas)
text
- the char to be displayedx
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglecanvas
- the canvas into which the text will be drawnpublic Text(long text, Location origin, DrawingCanvas canvas)
text
- the numeric value to be displayedorigin
- the upper left corner of the bounding region for the
information displayedcanvas
- the canvas into which the text will be drawnpublic Text(long text, double x, double y, DrawingCanvas canvas)
text
- the numeric value to be displayedx
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglecanvas
- the canvas into which the text will be drawnpublic Text(double text, Location origin, DrawingCanvas canvas)
text
- the numeric value to be displayedorigin
- the upper left corner of the bounding region for the displaycanvas
- the canvas into which the text will be drawnpublic Text(double text, double x, double y, DrawingCanvas canvas)
text
- the numeric value to be displayedx
- coordinate of the upper left corner of the bounding rectangley
- coordinate of the upper left corner of the bounding rectanglecanvas
- the canvas into which the text will be drawnMethod Detail |
public void addToCanvas(DrawingCanvas canvas)
DrawableInterface
removeFromCanvas()
followed
by addToCanvas. This method can also be invoked to place a Drawable object on a
DrawingCanvas after the object is loaded from a file or other stream.
addToCanvas
in interface DrawableInterface
public double getWidth()
Drawable2DInterface
getWidth
in interface Drawable2DInterface
public double getHeight()
Drawable2DInterface
getHeight
in interface Drawable2DInterface
public void moveTo(Location point)
DrawableInterface
moveTo
in interface DrawableInterface
public void move(double dx, double dy)
DrawableInterface
move
in interface DrawableInterface
public java.awt.Font getFont()
public void setText(java.lang.String text)
text
- the textpublic void setText(long text)
text
- the numeric value to be displayedpublic void setText(boolean text)
text
- the boolean to be displayedpublic void setText(char text)
text
- the char to be displayedpublic void setText(double text)
text
- the number to be displayedpublic void setText(java.lang.Object text)
text
- the object to be displayedpublic java.lang.String getText()
public void setFont(java.awt.Font f)
f
- the fontpublic void setFont(java.lang.String fname)
fname
- -
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()
public double getX()
Drawable2DInterface
getX
in interface Drawable2DInterface
public double getY()
Drawable2DInterface
getY
in interface Drawable2DInterface
public Location getLocation()
Drawable2DInterface
getLocation
in interface Drawable2DInterface
public boolean contains(Location point)
DrawableInterface
contains
in interface DrawableInterface
public boolean overlaps(Drawable2DInterface item)
Drawable2DInterface
overlaps
in interface Drawable2DInterface
item
- the other object
true
if item intersects this object;
false
otherwise.public void removeFromCanvas()
DrawableInterface
hide()
instead.
removeFromCanvas
in interface DrawableInterface
public DrawingCanvas getCanvas()
DrawableInterface
getCanvas
in interface DrawableInterface
public void hide()
DrawableInterface
show()
method.
If the goal is to remove an object from the display permanently, the
removeFromCanvas()
method should be used instead.
hide
in interface DrawableInterface
public void show()
DrawableInterface
show
in interface DrawableInterface
public boolean isHidden()
DrawableInterface
isHidden
in interface DrawableInterface
public void moveTo(double x, double y)
DrawableInterface
moveTo
in interface DrawableInterface
x
- horizontal coordinate of destination.y
- horizontal coordinate of destination.public void setColor(java.awt.Color c)
DrawableInterface
setColor
in interface DrawableInterface
c
- the color.public java.awt.Color getColor()
DrawableInterface
getColor
in interface DrawableInterface
public void sendForward()
DrawableInterface
sendForward
in interface DrawableInterface
public void sendBackward()
DrawableInterface
sendBackward
in interface DrawableInterface
public void sendToFront()
DrawableInterface
sendToFront
in interface DrawableInterface
public void sendToBack()
DrawableInterface
sendToBack
in interface DrawableInterface
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |