uwcse.graphics
Class TextShape

java.lang.Object
  |
  +--uwcse.graphics.ShapeImpl
        |
        +--uwcse.graphics.TextShape
All Implemented Interfaces:
Shape

public class TextShape
extends ShapeImpl
implements Shape

TextShape is used for displaying text onto the GWindow. The main operations are to read the x and y coordinates of the upper-left corner and the center of the bounding rectangle of the text (getX(), getY(), getCenterX(), and getCenterY()), to change the position of the text (moveBy(...) and moveTo(...)), to rotate the position of the text (but not the text itself) around some point (rotateAround(...)), to read and change the color of the text (getColor() and setColor(...)), to set the text and the font of the text (setText(...) and setFont(...)), to read the width and height of the text (getWidth(), getHeight()), and add to and remove from a GWindow (addTo(...) and removeFromWindow()). Other operations are mainly for internal use, and should not be called by regular client programs.


Constructor Summary
TextShape(java.lang.String txt, int x, int y)
          Create a new text shape, in black using the default font
TextShape(java.lang.String txt, int x, int y, java.awt.Color c)
          Create a new text shape, using the default font
TextShape(java.lang.String txt, int x, int y, java.awt.Color c, java.awt.Font font)
          Create a new text shape
TextShape(java.lang.String txt, int x, int y, java.awt.Font font)
          Create a new text shape, in black
 
Method Summary
 void paint(java.awt.Graphics g)
          Paint this shape onto the given graphics context.
 void setFont(java.awt.Font newFont)
          Change the font.
 void setText(java.lang.String newText)
          Change the text.
 java.lang.String toString()
          Answer the printed representation of this shape.
 
Methods inherited from class uwcse.graphics.ShapeImpl
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, getHeight, getWidth, getX, getY, intersects, moveBy, moveTo, recordWindow, removeFromWindow, rotateAround, setColor
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface uwcse.graphics.Shape
addTo, currentWindow, getBoundingBox, getCenterX, getCenterY, getColor, getHeight, getWidth, getX, getY, intersects, moveBy, moveTo, recordWindow, removeFromWindow, rotateAround, setColor
 

Constructor Detail

TextShape

public TextShape(java.lang.String txt,
                 int x,
                 int y)
Create a new text shape, in black using the default font
Parameters:
txt - the text to display
x - the X coordinate of the upper-left corner of the text shape
y - the Y coordinate of the upper-left corner of the text shape

TextShape

public TextShape(java.lang.String txt,
                 int x,
                 int y,
                 java.awt.Color c)
Create a new text shape, using the default font
Parameters:
txt - the text to display
x - the X coordinate of the upper-left corner of the text shape
y - the Y coordinate of the upper-left corner of the text shape
c - the color of the text

TextShape

public TextShape(java.lang.String txt,
                 int x,
                 int y,
                 java.awt.Color c,
                 java.awt.Font font)
Create a new text shape
Parameters:
txt - the text to display
x - the X coordinate of the upper-left corner of the text shape
y - the Y coordinate of the upper-left corner of the text shape
c - the color of the text
font - the font of the text shape

TextShape

public TextShape(java.lang.String txt,
                 int x,
                 int y,
                 java.awt.Font font)
Create a new text shape, in black
Parameters:
txt - the text to display
x - the X coordinate of the upper-left corner of the text shape
y - the Y coordinate of the upper-left corner of the text shape
font - the font of the text shape
Method Detail

paint

public void paint(java.awt.Graphics g)
Description copied from interface: Shape
Paint this shape onto the given graphics context. For internal use only.
Specified by:
paint in interface Shape

setFont

public void setFont(java.awt.Font newFont)
Change the font.
Parameters:
newFont - the new font of the text shape

setText

public void setText(java.lang.String newText)
Change the text.
Parameters:
newText - the new text of the text shape

toString

public java.lang.String toString()
Description copied from class: ShapeImpl
Answer the printed representation of this shape.
Overrides:
toString in class ShapeImpl