objectdraw
Class Text

java.lang.Object
  extended by objectdraw.ObjectDrawObject
      extended by objectdraw.ObjectDrawShape
          extended by objectdraw.Text
All Implemented Interfaces:
objectdraw.Dependent, Drawable2DInterface, DrawableInterface, LocatableInterface, objectdraw.TextWrappingLayout.TextRun

public class Text
extends objectdraw.ObjectDrawShape
implements Drawable2DInterface, objectdraw.TextWrappingLayout.TextRun

A Text object displays some text on the screen. The text can have multiple lines separated by "\n" line breaks, and can be aligned in various different ways. It is also possible to wrap text within another shape, or align it along a line. The shape that a Text is aligned with or wrapped within is called its basis.

The color, font, size, and style of text can be altered. If you want to have text containing runs of several different styles, you can create many Text objects and chain them together by passing along the previous segment as the basis when you create a new segment.

Author:
Russell Zahniser (russell@zahniser.net)

Field Summary
static int BOTTOM
          Alignment value to align the bottom of text with the basis
static int CENTER
          Alignment value to center text with respect to the basis.
static Font DEFAULT_FONT
          Font used for newly created Text objects
static int LEFT
          Alignment value to align the left edge of text with the basis.
static int RIGHT
          Alignment value to align the right edge of text with the basis.
static int TOP
          Alignment value to align the top of text with the basis.
 
Constructor Summary
Text(boolean text, double x, double y, Color color, DrawingCanvas canvas)
          Create a Text object at (x, y), displaying the given text in the given color.
Text(boolean text, double x, double y, DrawingCanvas canvas)
          Create a Text object at (x, y), displaying the given text.
Text(boolean text, DrawableInterface basis, Color color, DrawingCanvas canvas)
          Create a Text object attached to the given basis, displaying the given text in the given color.
Text(boolean text, DrawableInterface basis, DrawingCanvas canvas)
          Create a Text object attached to the given basis, displaying the given text.
Text(boolean text, Location origin, Color color, DrawingCanvas canvas)
          Create a Text object at origin, displaying the given text in the given color.
Text(boolean text, Location origin, DrawingCanvas canvas)
          Create a Text object at origin, displaying the given text.
Text(char text, double x, double y, Color color, DrawingCanvas canvas)
          Create a Text object at (x, y), displaying the given text in the given color.
Text(char text, double x, double y, DrawingCanvas canvas)
          Create a Text object at (x, y), displaying the given text.
Text(char text, DrawableInterface basis, Color color, DrawingCanvas canvas)
          Create a Text object attached to the given basis, displaying the given text in the given color.
Text(char text, DrawableInterface basis, DrawingCanvas canvas)
          Create a Text object attached to the given basis, displaying the given text.
Text(char text, Location origin, Color color, DrawingCanvas canvas)
          Create a Text object at origin, displaying the given text in the given color.
Text(char text, Location origin, DrawingCanvas canvas)
          Create a Text object at origin, displaying the given text.
Text(double text, double x, double y, Color color, DrawingCanvas canvas)
          Create a Text object at (x, y), displaying the given text in the given color.
Text(double text, double x, double y, DrawingCanvas canvas)
          Create a Text object at (x, y), displaying the given text.
Text(double text, DrawableInterface basis, Color color, DrawingCanvas canvas)
          Create a Text object attached to the given basis, displaying the given text in the given color.
Text(double text, DrawableInterface basis, DrawingCanvas canvas)
          Create a Text object attached to the given basis, displaying the given text.
Text(double text, Location origin, Color color, DrawingCanvas canvas)
          Create a Text object at origin, displaying the given text in the given color.
Text(double text, Location origin, DrawingCanvas canvas)
          Create a Text object at origin, displaying the given text.
Text(long text, double x, double y, Color color, DrawingCanvas canvas)
          Create a Text object at (x, y), displaying the given text in the given color.
Text(long text, double x, double y, DrawingCanvas canvas)
          Create a Text object at (x, y), displaying the given text.
Text(long text, DrawableInterface basis, Color color, DrawingCanvas canvas)
          Create a Text object attached to the given basis, displaying the given text in the given color.
Text(long text, DrawableInterface basis, DrawingCanvas canvas)
          Create a Text object attached to the given basis, displaying the given text.
Text(long text, Location origin, Color color, DrawingCanvas canvas)
          Create a Text object at origin, displaying the given text in the given color.
Text(long text, Location origin, DrawingCanvas canvas)
          Create a Text object at origin, displaying the given text.
Text(Object text, double x, double y, Color color, DrawingCanvas canvas)
          Create a Text object at (x, y), displaying the given text in the given color.
Text(Object text, double x, double y, DrawingCanvas canvas)
          Create a Text object at (x, y), displaying the given text.
Text(Object text, DrawableInterface basis, Color color, DrawingCanvas canvas)
          Create a Text object attached to the given basis, displaying the given text in the given color.
Text(Object text, DrawableInterface basis, DrawingCanvas canvas)
          Create a Text object attached to the given basis, displaying the given text.
Text(Object text, Location origin, Color color, DrawingCanvas canvas)
          Create a Text object at origin, displaying the given text in the given color.
Text(Object text, Location origin, DrawingCanvas canvas)
          Create a Text object at origin, displaying the given text.
 
Method Summary
 void addToCanvas(DrawingCanvas c)
          Place this object on the specified canvas.
 boolean contains(Location point)
          Return true if the given location is inside this object, false otherwise.
static String formatDecimal(double num)
          Format a decimal value as a string, using a maximum of 4 decimal points.
static String formatDecimal(double num, int places)
          Format a decimal value as a string, using a maximum of places decimal points.
 DrawableInterface getBasis()
          Get the shape that is the basis of this text, or null if this text is simply placed at a point, with no basis.
 DrawingCanvas getCanvas()
          Return the canvas that this object is on.
 Color getColor()
          Return the color of this object
 double getDoubleHeight()
          Return the height of the rectangle bounding this object, in double precision.
 double getDoubleWidth()
          Return the height of the rectangle bounding this object, in double precision.
 double getDoubleX()
          Get this object's x coordinate, in double precision.
 double getDoubleY()
          Get this object's y coordinate, in double precision.
 Font getFont()
          Return the Font object representing the font, font size, and style of this Text.
 int getHeight()
          Return the width of the rectangle bounding this object.
 double getHorizontalAlignment()
          Retrieve the horizontal alignment value
 Location getLocation()
          Get this object's location.
 Text getNext()
          Get the next Text object in a chain, or null if there is no more text after this one.
 Text getPrevious()
          Get the previous Text object in a chain, or null if there is no more text before this one.
 String getText()
          Return the text string displayed by this Text.
 double getVerticalAlignment()
          Retrieve the vertical alignment value
 int getWidth()
          Return the height of the rectangle bounding this object.
 int getX()
          Get this object's x coordinate.
 int getY()
          Get this object's y coordinate.
 void hide()
          Make this object invisible.
 boolean isHidden()
          Return true if this object has been rendered invisible with a call to its hide() method, false if it is still being drawn.
 void move(double dx, double dy)
          Shift (translate) this object left or right by an amount dx, and up or down by an amount dy.
 void moveTo(double x, double y)
          Move the reference point of this object to the given location.
 void moveTo(Location point)
          Move the reference point of this object to the given location.
 boolean overlaps(Drawable2DInterface other)
          Return true if the rectangle bounding this object overlaps with the rectangle bounding another object; false otherwise.
 void removeFromCanvas()
          Remove this object from its canvas.
 void sendBackward()
          Move this object one step backward in the draw order, causing it to be drawn underneath the objects that are in front of it.
 void sendForward()
          Move this object one step forward in the draw order, causing it to be drawn on top of the objects that are behind it.
 void sendToBack()
          Move this object to the very back of the draw order, causing it to be drawn underneath all the other objects.
 void sendToFront()
          Move this object to the very front of the draw order, causing it to be drawn on top of all the other objects.
 void setAlignment(double horizontalAlign, double verticalAlign)
          Set the horizontal and vertical alignment of this text.
 void setBold()
          Set this text to be bold
 void setBold(boolean b)
          Set this font to be bold or not, depending on the value of b.
 void setColor(Color c)
          Change the color of this object.
 void setFont(Font f)
          Set the Font of this Text.
 void setFont(String fname)
          Change the font name being used by this Text.
 void setFontSize(int size)
          Change the font size of this text.
 void setItalic()
          Set this text to be italic
 void setItalic(boolean i)
          Set this font to be italic or not, depending on the value of i.
 void setPlain()
          Set the style of this text to plain (not bold or italic)
 void setText(String t)
          Change the text string displayed by this Text.
 void show()
          Make an object visible again after it had been hidden.
 String toString()
          Return a string describing how this object might be constructed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface objectdraw.TextWrappingLayout.TextRun
getNextRun, setShape
 

Field Detail

BOTTOM

public static final int BOTTOM
Alignment value to align the bottom of text with the basis

See Also:
Constant Field Values

CENTER

public static final int CENTER
Alignment value to center text with respect to the basis.

See Also:
Constant Field Values

DEFAULT_FONT

public static final Font DEFAULT_FONT
Font used for newly created Text objects


LEFT

public static final int LEFT
Alignment value to align the left edge of text with the basis.

See Also:
Constant Field Values

RIGHT

public static final int RIGHT
Alignment value to align the right edge of text with the basis.

See Also:
Constant Field Values

TOP

public static final int TOP
Alignment value to align the top of text with the basis.

See Also:
Constant Field Values
Constructor Detail

Text

public Text(boolean text,
            double x,
            double y,
            Color color,
            DrawingCanvas canvas)
Create a Text object at (x, y), displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
x - x coordinate of the Text's position
y - y coordinate of the Text's position
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(boolean text,
            double x,
            double y,
            DrawingCanvas canvas)
Create a Text object at (x, y), displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
x - x coordinate of the Text's position
y - y coordinate of the Text's position
canvas - DrawingCanvas to place this text on

Text

public Text(boolean text,
            DrawableInterface basis,
            Color color,
            DrawingCanvas canvas)
Create a Text object attached to the given basis, displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
basis - shape that this text will be attached to
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(boolean text,
            DrawableInterface basis,
            DrawingCanvas canvas)
Create a Text object attached to the given basis, displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
basis - shape that this text will be attached to
canvas - DrawingCanvas to place this text on

Text

public Text(boolean text,
            Location origin,
            Color color,
            DrawingCanvas canvas)
Create a Text object at origin, displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
origin - Location at which this Text will be positioned
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(boolean text,
            Location origin,
            DrawingCanvas canvas)
Create a Text object at origin, displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
origin - Location at which this Text will be positioned
canvas - DrawingCanvas to place this text on

Text

public Text(char text,
            double x,
            double y,
            Color color,
            DrawingCanvas canvas)
Create a Text object at (x, y), displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
x - x coordinate of the Text's position
y - y coordinate of the Text's position
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(char text,
            double x,
            double y,
            DrawingCanvas canvas)
Create a Text object at (x, y), displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
x - x coordinate of the Text's position
y - y coordinate of the Text's position
canvas - DrawingCanvas to place this text on

Text

public Text(char text,
            DrawableInterface basis,
            Color color,
            DrawingCanvas canvas)
Create a Text object attached to the given basis, displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
basis - shape that this text will be attached to
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(char text,
            DrawableInterface basis,
            DrawingCanvas canvas)
Create a Text object attached to the given basis, displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
basis - shape that this text will be attached to
canvas - DrawingCanvas to place this text on

Text

public Text(char text,
            Location origin,
            Color color,
            DrawingCanvas canvas)
Create a Text object at origin, displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
origin - Location at which this Text will be positioned
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(char text,
            Location origin,
            DrawingCanvas canvas)
Create a Text object at origin, displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
origin - Location at which this Text will be positioned
canvas - DrawingCanvas to place this text on

Text

public Text(double text,
            double x,
            double y,
            Color color,
            DrawingCanvas canvas)
Create a Text object at (x, y), displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
x - x coordinate of the Text's position
y - y coordinate of the Text's position
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(double text,
            double x,
            double y,
            DrawingCanvas canvas)
Create a Text object at (x, y), displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
x - x coordinate of the Text's position
y - y coordinate of the Text's position
canvas - DrawingCanvas to place this text on

Text

public Text(double text,
            DrawableInterface basis,
            Color color,
            DrawingCanvas canvas)
Create a Text object attached to the given basis, displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
basis - shape that this text will be attached to
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(double text,
            DrawableInterface basis,
            DrawingCanvas canvas)
Create a Text object attached to the given basis, displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
basis - shape that this text will be attached to
canvas - DrawingCanvas to place this text on

Text

public Text(double text,
            Location origin,
            Color color,
            DrawingCanvas canvas)
Create a Text object at origin, displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
origin - Location at which this Text will be positioned
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(double text,
            Location origin,
            DrawingCanvas canvas)
Create a Text object at origin, displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
origin - Location at which this Text will be positioned
canvas - DrawingCanvas to place this text on

Text

public Text(long text,
            double x,
            double y,
            Color color,
            DrawingCanvas canvas)
Create a Text object at (x, y), displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
x - x coordinate of the Text's position
y - y coordinate of the Text's position
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(long text,
            double x,
            double y,
            DrawingCanvas canvas)
Create a Text object at (x, y), displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
x - x coordinate of the Text's position
y - y coordinate of the Text's position
canvas - DrawingCanvas to place this text on

Text

public Text(long text,
            DrawableInterface basis,
            Color color,
            DrawingCanvas canvas)
Create a Text object attached to the given basis, displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
basis - shape that this text will be attached to
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(long text,
            DrawableInterface basis,
            DrawingCanvas canvas)
Create a Text object attached to the given basis, displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
basis - shape that this text will be attached to
canvas - DrawingCanvas to place this text on

Text

public Text(long text,
            Location origin,
            Color color,
            DrawingCanvas canvas)
Create a Text object at origin, displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
origin - Location at which this Text will be positioned
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(long text,
            Location origin,
            DrawingCanvas canvas)
Create a Text object at origin, displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
origin - Location at which this Text will be positioned
canvas - DrawingCanvas to place this text on

Text

public Text(Object text,
            double x,
            double y,
            Color color,
            DrawingCanvas canvas)
Create a Text object at (x, y), displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
x - x coordinate of the Text's position
y - y coordinate of the Text's position
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(Object text,
            double x,
            double y,
            DrawingCanvas canvas)
Create a Text object at (x, y), displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
x - x coordinate of the Text's position
y - y coordinate of the Text's position
canvas - DrawingCanvas to place this text on

Text

public Text(Object text,
            DrawableInterface basis,
            Color color,
            DrawingCanvas canvas)
Create a Text object attached to the given basis, displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
basis - shape that this text will be attached to
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(Object text,
            DrawableInterface basis,
            DrawingCanvas canvas)
Create a Text object attached to the given basis, displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
basis - shape that this text will be attached to
canvas - DrawingCanvas to place this text on

Text

public Text(Object text,
            Location origin,
            Color color,
            DrawingCanvas canvas)
Create a Text object at origin, displaying the given text in the given color. It will start out using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
origin - Location at which this Text will be positioned
color - Color of the Text
canvas - DrawingCanvas to place this text on

Text

public Text(Object text,
            Location origin,
            DrawingCanvas canvas)
Create a Text object at origin, displaying the given text. It will start out drawn in black, using the default font and default alignment (bottom left).

Parameters:
text - value whose String form will be displayed.
origin - Location at which this Text will be positioned
canvas - DrawingCanvas to place this text on
Method Detail

addToCanvas

public void addToCanvas(DrawingCanvas c)
Place this object on the specified canvas. The object will be removed from its current canvas, if it is on a canvas that is not the one it is being moved to. The object will be at the front of the canvas, as if it had just been drawn. If the given canvas is null the object is simply removed from its current canvas.

Specified by:
addToCanvas in interface DrawableInterface
Overrides:
addToCanvas in class objectdraw.ObjectDrawShape
Parameters:
c - DrawingCanvas to place this object on

contains

public boolean contains(Location point)
Return true if the given location is inside this object, false otherwise. Because Lines and FramedArcs have no "inside", a point is considered to be contained in one of them as long as it is within a few pixels of the line.

Specified by:
contains in interface DrawableInterface
Parameters:
point - Location to test
Returns:
whether the given location is inside this shape

formatDecimal

public static String formatDecimal(double num)
Format a decimal value as a string, using a maximum of 4 decimal points.

Parameters:
num - number to format
Returns:
the String representation of that number

formatDecimal

public static String formatDecimal(double num,
                                   int places)
Format a decimal value as a string, using a maximum of places decimal points.

Parameters:
num - number to format
places - maximum number of decimal places
Returns:
the String representation of that number

getBasis

public DrawableInterface getBasis()
Get the shape that is the basis of this text, or null if this text is simply placed at a point, with no basis.

Returns:
the basis object for this text

getCanvas

public DrawingCanvas getCanvas()
Return the canvas that this object is on. If it has been removed from its canvas, this method will return null.

Specified by:
getCanvas in interface DrawableInterface
Overrides:
getCanvas in class objectdraw.ObjectDrawShape
Returns:
the DrawingCanvas that this object is on.

getColor

public Color getColor()
Return the color of this object

Specified by:
getColor in interface DrawableInterface
Overrides:
getColor in class objectdraw.ObjectDrawShape
Returns:
the Color of this object

getDoubleHeight

public double getDoubleHeight()
Return the height of the rectangle bounding this object, in double precision.

Specified by:
getDoubleHeight in interface Drawable2DInterface
Returns:
the height of the rectangle bounding this object, in double precision.

getDoubleWidth

public double getDoubleWidth()
Return the height of the rectangle bounding this object, in double precision.

Specified by:
getDoubleWidth in interface Drawable2DInterface
Returns:
the height of the rectangle bounding this object, in double precision.

getDoubleX

public double getDoubleX()
Get this object's x coordinate, in double precision.

Specified by:
getDoubleX in interface LocatableInterface
Returns:
this object's x coordinate, in double precision

getDoubleY

public double getDoubleY()
Get this object's y coordinate, in double precision.

Specified by:
getDoubleY in interface LocatableInterface
Returns:
this object's y coordinate, in double precision

getFont

public Font getFont()
Return the Font object representing the font, font size, and style of this Text.

Specified by:
getFont in interface objectdraw.TextWrappingLayout.TextRun
Returns:
the font of this text

getHeight

public int getHeight()
Return the width of the rectangle bounding this object.

Specified by:
getHeight in interface Drawable2DInterface
Returns:
the width of the rectangle bounding this object.

getHorizontalAlignment

public double getHorizontalAlignment()
Retrieve the horizontal alignment value

Returns:
the horizontal alignment value, ranging from -1 (align the left of the text with the basis) to 1 (align the right) of the text with the basis.

getLocation

public Location getLocation()
Get this object's location. Translating this Location object will have the same effect as moving the object. So, the following two lines of code are equivalent:

object.move(10, 20);
object.getLocation().translate(10, 20);


If you want to create a Location offset by some amount from the Location of this object, without actually moving this object, use the offset() method in Location, which creates a new Location.

Specified by:
getLocation in interface LocatableInterface
Returns:
the Location of this object.

getNext

public Text getNext()
Get the next Text object in a chain, or null if there is no more text after this one.

Returns:
the next Text in the chain

getPrevious

public Text getPrevious()
Get the previous Text object in a chain, or null if there is no more text before this one.

Returns:
the previous Text in the chain

getText

public String getText()
Return the text string displayed by this Text.

Specified by:
getText in interface objectdraw.TextWrappingLayout.TextRun
Returns:
the text string displayed by this Text

getVerticalAlignment

public double getVerticalAlignment()
Retrieve the vertical alignment value

Returns:
the vertical alignment value, ranging from -1 (align the top of the text with the basis) to 1 (align the bottom) of the text with the basis.

getWidth

public int getWidth()
Return the height of the rectangle bounding this object.

Specified by:
getWidth in interface Drawable2DInterface
Returns:
the height of the rectangle bounding this object.

getX

public int getX()
Get this object's x coordinate.

Specified by:
getX in interface LocatableInterface
Returns:
this object's x coordinate

getY

public int getY()
Get this object's y coordinate.

Specified by:
getY in interface LocatableInterface
Returns:
this object's y coordinate

hide

public void hide()
Make this object invisible. It stays in position on its canvas; it is simply not drawn. This method has no effect if the object was already hidden.

Specified by:
hide in interface DrawableInterface
Overrides:
hide in class objectdraw.ObjectDrawShape

isHidden

public boolean isHidden()
Return true if this object has been rendered invisible with a call to its hide() method, false if it is still being drawn.

Specified by:
isHidden in interface DrawableInterface
Overrides:
isHidden in class objectdraw.ObjectDrawShape
Returns:
whether this object is hidden

move

public void move(double dx,
                 double dy)
Shift (translate) this object left or right by an amount dx, and up or down by an amount dy. A negative dx indicates a shift to the left; a negative dy indicates a shift up

Specified by:
move in interface DrawableInterface
Overrides:
move in class objectdraw.ObjectDrawShape
Parameters:
dx - amount of x translation
dy - amount of y translation

moveTo

public void moveTo(double x,
                   double y)
Move the reference point of this object to the given location. For a Drawable2D object, the reference point is the top left corner; for a line, it is the start point.

Specified by:
moveTo in interface DrawableInterface
Overrides:
moveTo in class objectdraw.ObjectDrawShape
Parameters:
x - x coordinate to move to
y - y coordinate to move to

moveTo

public void moveTo(Location point)
Move the reference point of this object to the given location. For a Drawable2D object, the reference point is the top left corner; for a line, it is the start point.

Specified by:
moveTo in interface DrawableInterface
Overrides:
moveTo in class objectdraw.ObjectDrawShape
Parameters:
point - Location to move to

overlaps

public boolean overlaps(Drawable2DInterface other)
Return true if the rectangle bounding this object overlaps with the rectangle bounding another object; false otherwise.

Specified by:
overlaps in interface Drawable2DInterface
Parameters:
other - another two dimensional object to check for overlapping with
Returns:
whether the bounding rectangles of the two objects overlap

removeFromCanvas

public void removeFromCanvas()
Remove this object from its canvas.

Specified by:
removeFromCanvas in interface DrawableInterface
Overrides:
removeFromCanvas in class objectdraw.ObjectDrawShape

sendBackward

public void sendBackward()
Move this object one step backward in the draw order, causing it to be drawn underneath the objects that are in front of it.

Specified by:
sendBackward in interface DrawableInterface
Overrides:
sendBackward in class objectdraw.ObjectDrawShape

sendForward

public void sendForward()
Move this object one step forward in the draw order, causing it to be drawn on top of the objects that are behind it.

Specified by:
sendForward in interface DrawableInterface
Overrides:
sendForward in class objectdraw.ObjectDrawShape

sendToBack

public void sendToBack()
Move this object to the very back of the draw order, causing it to be drawn underneath all the other objects.

Specified by:
sendToBack in interface DrawableInterface
Overrides:
sendToBack in class objectdraw.ObjectDrawShape

sendToFront

public void sendToFront()
Move this object to the very front of the draw order, causing it to be drawn on top of all the other objects.

Specified by:
sendToFront in interface DrawableInterface
Overrides:
sendToFront in class objectdraw.ObjectDrawShape

setAlignment

public void setAlignment(double horizontalAlign,
                         double verticalAlign)
Set the horizontal and vertical alignment of this text. The possible alignment values are the constants Text.TOP, Text.BOTTOM, and so on.

Parameters:
horizontalAlign - horizontal alignment value, ranging from -1 (align the left of the text with the basis) to 1 (align the right) of the text with the basis.
verticalAlign - vertical alignment value, ranging from -1 (align the top of the text with the basis) to 1 (align the bottom) of the text with the basis.

setBold

public void setBold()
Set this text to be bold


setBold

public void setBold(boolean b)
Set this font to be bold or not, depending on the value of b.

Parameters:
b - whether to become bold (true) or not bold (false)

setColor

public void setColor(Color c)
Change the color of this object.

Specified by:
setColor in interface DrawableInterface
Overrides:
setColor in class objectdraw.ObjectDrawShape
Parameters:
c - new Color for this object

setFont

public void setFont(Font f)
Set the Font of this Text. The Font object contains information on the font used, and also the size and style of the text.

Parameters:
f - new Font to use

setFont

public void setFont(String fname)
Change the font name being used by this Text. The new font name should be a common font, like "Times" or "Courier"; not all computers have all fonts. If that font does not exist on this computer, another font will be substituted for it.

Parameters:
fname - name of new font to use

setFontSize

public void setFontSize(int size)
Change the font size of this text.

Parameters:
size - new font size

setItalic

public void setItalic()
Set this text to be italic


setItalic

public void setItalic(boolean i)
Set this font to be italic or not, depending on the value of i.

Parameters:
i - whether to become bold (true) or not bold (false)

setPlain

public void setPlain()
Set the style of this text to plain (not bold or italic)


setText

public void setText(String t)
Change the text string displayed by this Text.

Parameters:
t - new text to display

show

public void show()
Make an object visible again after it had been hidden. This method has no effect if the object was already visible.

Specified by:
show in interface DrawableInterface
Overrides:
show in class objectdraw.ObjectDrawShape

toString

public String toString()
Return a string describing how this object might be constructed.

Overrides:
toString in class objectdraw.ObjectDrawObject