jdraw.graphics
Class TextObject

java.lang.Object
  |
  +--jdraw.graphics.GraphicObject
        |
        +--jdraw.graphics.TextObject
All Implemented Interfaces:
java.io.Serializable

public class TextObject
extends GraphicObject

Class RectangleObject is the GraphicObject extension which holds a rectangle shape.

See Also:
Serialized Form

Field Summary
protected  double angle
          The angle by which to rotate the text (in radians).
protected  java.awt.Font font
          The Font with which to write the text.
protected  java.awt.geom.Point2D.Double location
          The location of the upper-left hand corner of the box.
protected  java.lang.String text
          The string of the text.
 
Fields inherited from class jdraw.graphics.GraphicObject
arrowsOn, backgroundColor, color, controlPoints, graphicType, paint, shape, stroke
 
Constructor Summary
TextObject(java.awt.Color c, java.awt.Color bgc, java.util.Vector p, java.util.Vector cPoints, java.awt.BasicStroke bs, java.lang.String t, java.awt.Font font, double theta)
          Construct this with the given Shape, Color, FillStyle, and ControlPoints objects.
TextObject(java.awt.geom.Point2D.Double pt1, java.awt.Color c, java.awt.Color bgc, java.util.Vector p, java.awt.BasicStroke bs, java.lang.String t, java.awt.Font font, double theta)
          Construct this with the given Points, Colors, FillStyle, BasicStroke objects.
 
Method Summary
 void appendText(char c)
          Appends character c onto the end of text.
 java.lang.Object clone()
          returns - A copy of this.
 void deleteChar()
          Removes the last character from text.
 void draw(java.awt.Graphics2D g2D, float zoom)
          Draws this text object to the screen.
 int getMaxX()
          Returns the int X value of the right side of the Rectangle which bounds this.shape.
 int getMaxY()
          Returns the int Y value of the bottom side of the Rectangle which bounds this.shape.
 int getMinX()
          Returns the int X value of the left side of the Rectangle which bounds this.shape.
 int getMinY()
          Returns the int Y value of the top side of the Rectangle which bounds this.shape.
 java.util.Vector getSaveBundle()
          Returns a Vector with all the necessary save information.
 java.awt.Rectangle getTextSize(java.awt.Font tempFont, java.awt.geom.Point2D.Double topLeft)
          Returns the Rectangle which bounds the string this.text, when written with this.font.
 boolean isPointOnShape(java.awt.Point clickedPoint)
          Returns a boolean value representing whether the given Point resides on this.shape.
 void rotate(double theta, double anchorX, double anchorY)
          Rotates this.location around point (anchorX, anchorY) by theta radians.
 void setControlPoints()
          Sets this.controlPoints based on the current PathIterator of this.shape.
 void setFont(java.awt.Font f)
          Sets this.font given the new font type 'f'.
 void setFontSize(int size)
          Sets this.font given the new font size 'size'.
 void setFontStyle(int style)
          Sets this.font given the new font style 'style'.
 void setMaxX(int newMaxX)
          Sets the int newMaxX value as the right side of the Rectangle which bounds this.shape.
 void setMaxY(int newMaxY)
          Sets the int newMaxY value as the bottom side of the Rectangle which bounds this.shape.
 void setMinX(int newMinX)
          Sets the int newMinX value as the left side of the Rectangle which bounds this.shape.
 void setMinY(int newMinY)
          Sets the int newMinY value as the top side of the Rectangle which bounds this.shape.
 void setShape()
          Sets this.shape based on the points currently in this.controlPoints.
 void translate(float deltaX, float deltaY)
          Translates the position of this.shape by the given deltaX and deltaY values.
 void translateControlPoint(int a, int b, int c)
          translateControlPoint(int, int, int) is disabled for a TextObject.
 
Methods inherited from class jdraw.graphics.GraphicObject
addPoint, containedIn, deriveImage, flipHorizontally, flipVertically, getBackgroundColor, getColor, getControlPoints, getGraphicType, getShape, getStroke, getTouchedControlPoint, setArrows, setBackgroundColor, setColor, setHorizontalCenter, setLastPoint, setPaint, setSecondPoint, setStroke, setVerticalCenter, translateControlPoint
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

location

protected java.awt.geom.Point2D.Double location
The location of the upper-left hand corner of the box.

text

protected java.lang.String text
The string of the text.

angle

protected double angle
The angle by which to rotate the text (in radians).

font

protected java.awt.Font font
The Font with which to write the text.
Constructor Detail

TextObject

public TextObject(java.awt.Color c,
                  java.awt.Color bgc,
                  java.util.Vector p,
                  java.util.Vector cPoints,
                  java.awt.BasicStroke bs,
                  java.lang.String t,
                  java.awt.Font font,
                  double theta)
Construct this with the given Shape, Color, FillStyle, and ControlPoints objects.
Parameters:
c - - The Color object to store in this.color.
bgc - - The Color object to store in this.backgroundColor.
p - - The Vector to store in this.paint.
cPoints - - Vector object to store in this.controlPoints.
bs - - The BasicStroke object to store in this.stroke.
font - - The Font object to store in this.font.
theta - - The double value to store in this.angle.

TextObject

public TextObject(java.awt.geom.Point2D.Double pt1,
                  java.awt.Color c,
                  java.awt.Color bgc,
                  java.util.Vector p,
                  java.awt.BasicStroke bs,
                  java.lang.String t,
                  java.awt.Font font,
                  double theta)
Construct this with the given Points, Colors, FillStyle, BasicStroke objects.
Parameters:
pt1 - - The Point object at which to start the GeneralPath.
pt2 - - The Point object at the opposite corner of the shape from pt1
c - - The Color object to store in this.color.
bgc - - The Color object to store in this.backgroundColor.
p - - The Vector to store in this.paint.
bs - - The BasicStroke object to store in this.stroke.
font - - The Font object to store in this.font.
theta - - The double value to store in this.angle.
Method Detail

clone

public java.lang.Object clone()
returns - A copy of this.
Overrides:
clone in class GraphicObject

setShape

public void setShape()
Sets this.shape based on the points currently in this.controlPoints.
Overrides:
setShape in class GraphicObject

setControlPoints

public void setControlPoints()
Sets this.controlPoints based on the current PathIterator of this.shape.
Overrides:
setControlPoints in class GraphicObject

draw

public void draw(java.awt.Graphics2D g2D,
                 float zoom)
Draws this text object to the screen.
Overrides:
draw in class GraphicObject
Following copied from class: jdraw.graphics.GraphicObject
Parameters:
g2D - - The Graphics2D object on which to draw this.shape.
zoom - - The float value indicating the current zoom factor.

translate

public void translate(float deltaX,
                      float deltaY)
Translates the position of this.shape by the given deltaX and deltaY values.
Overrides:
translate in class GraphicObject
Parameters:
deltaX - - The int value by which to alter the X position of this.shape.
deltaY - - The int value by which to alter the Y position of this.shape.

appendText

public void appendText(char c)
Appends character c onto the end of text.
Parameters:
c - - The char to be appended to the string.

deleteChar

public void deleteChar()
Removes the last character from text.

getTextSize

public java.awt.Rectangle getTextSize(java.awt.Font tempFont,
                                      java.awt.geom.Point2D.Double topLeft)
Returns the Rectangle which bounds the string this.text, when written with this.font.

getSaveBundle

public java.util.Vector getSaveBundle()
Returns a Vector with all the necessary save information.
Overrides:
getSaveBundle in class GraphicObject

setFont

public void setFont(java.awt.Font f)
Sets this.font given the new font type 'f'.
Parameters:
f - - The Font object used to derive this.font.

setFontSize

public void setFontSize(int size)
Sets this.font given the new font size 'size'.
Parameters:
size - - The int value used as the size of this.font.

setFontStyle

public void setFontStyle(int style)
Sets this.font given the new font style 'style'.
Parameters:
style - - The int value representing the style of this.font.

rotate

public void rotate(double theta,
                   double anchorX,
                   double anchorY)
Rotates this.location around point (anchorX, anchorY) by theta radians.
Overrides:
rotate in class GraphicObject
Parameters:
theta - - The double value representing an angle in radians.
anchorX - - The double value of the x-coordinate of a point.
anchorY - - The double value of the y-coordinate of a point.

isPointOnShape

public boolean isPointOnShape(java.awt.Point clickedPoint)
Returns a boolean value representing whether the given Point resides on this.shape.
Overrides:
isPointOnShape in class GraphicObject
Parameters:
clickedPoint - - The Point object represent the position of a mouse click.
Returns:
- The boolean value described above.

getMinX

public int getMinX()
Returns the int X value of the left side of the Rectangle which bounds this.shape.
Overrides:
getMinX in class GraphicObject
Returns:
- The int value of the left side of the Rectangle which bounds this.shape.

getMinY

public int getMinY()
Returns the int Y value of the top side of the Rectangle which bounds this.shape.
Overrides:
getMinY in class GraphicObject
Returns:
- The int value of the top side of the Rectangle which bounds this.shape.

getMaxX

public int getMaxX()
Returns the int X value of the right side of the Rectangle which bounds this.shape.
Overrides:
getMaxX in class GraphicObject
Returns:
- The int value of the right side of the Rectangle which bounds this.shape.

getMaxY

public int getMaxY()
Returns the int Y value of the bottom side of the Rectangle which bounds this.shape.
Overrides:
getMaxY in class GraphicObject
Returns:
- The int value of the bottom side of the Rectangle which bounds this.shape.

setMinX

public void setMinX(int newMinX)
Sets the int newMinX value as the left side of the Rectangle which bounds this.shape.
Overrides:
setMinX in class GraphicObject
Parameters:
newMinX - - The int value to be set as the left side of the Rectangle which bounds this.shape.

setMinY

public void setMinY(int newMinY)
Sets the int newMinY value as the top side of the Rectangle which bounds this.shape.
Overrides:
setMinY in class GraphicObject
Parameters:
newMinY - - The int value to be set as the top side of the Rectangle which bounds this.shape.

setMaxX

public void setMaxX(int newMaxX)
Sets the int newMaxX value as the right side of the Rectangle which bounds this.shape.
Overrides:
setMaxX in class GraphicObject
Parameters:
newMaxX - - The int value to be set as the right side of the Rectangle which bounds this.shape.

setMaxY

public void setMaxY(int newMaxY)
Sets the int newMaxY value as the bottom side of the Rectangle which bounds this.shape.
Overrides:
setMaxY in class GraphicObject
Parameters:
newMaxY - - The int value to be set as the bottom side of the Rectangle which bounds this.shape.

translateControlPoint

public void translateControlPoint(int a,
                                  int b,
                                  int c)
translateControlPoint(int, int, int) is disabled for a TextObject.