wheelsunh.users
Class InputBox

java.lang.Object
  extended by wheelsunh.etc.AbstractGraphic
      extended by wheelsunh.users.AbstractShape
          extended by wheelsunh.users.Shape
              extended by wheelsunh.users.RectangularShape
                  extended by wheelsunh.users.Rectangle
                      extended by wheelsunh.users.InputBox
All Implemented Interfaces:
AdvancedColorable, Colorable, CustomGraphic, Locatable, Rotatable, Sizeable
Direct Known Subclasses:
FilterInputBox, IntInputBox, TextInputBox

public abstract class InputBox
extends Rectangle

Abstract subclass of Rectangle including an editable text box. Subclasses must override parse() in order to handle the input.


Field Summary
protected  javax.swing.JTextArea _text
           
static int DEFAULT_BORDER_WIDTH
           
static int DEFAULT_WIDTH
           
 
Fields inherited from class wheelsunh.users.Shape
_c, _dp, _shape, DEFAULT_COLOR
 
Fields inherited from class wheelsunh.users.AbstractShape
_rot
 
Constructor Summary
InputBox()
          Constructs an empty InputBox in the wheelsunh.users.Frame's DrawingPanel.
InputBox(java.lang.String text)
          Constructs an InputBox displaying the specified String in the wheelsunh.users.Frame's DrawingPanel.
InputBox(java.lang.String text, DrawingPanel dp)
          Constructs an InputBox displaying the specified String in the passed-in DrawingPanel.
 
Method Summary
 void actualPaint(java.awt.Graphics2D g)
          Normal users do not need to worry about this! Does the actual work to paint the text box.
 java.awt.Rectangle getBounds()
          Returns the bounds of the text box.
 void hide()
          Graphically hides the text box.
protected abstract  void parse(java.lang.String s)
          This method is overridden in concrete implementations It controls what the input box does with strings entered into it
 void setBorderWidth(int width)
          Changes the size of the border of whitespace between the text area and its frame.
 void setColor(java.awt.Color c)
          Set the background and frame color of the TextBox.
 void setFillColor(java.awt.Color c)
          Set the background color of the TextBox.
 void setLocation(java.awt.Point p)
          Sets the location of the TextBox.
 void setRotation(int degrees)
          Overridden to do nothing.
 void setSize(java.awt.Dimension d)
          Sets the size of the TextBox.
 void setText(java.lang.String text)
          Makes the bubble display the passed-in string.
 void setWidth(int width)
          Sizes the TextBox to the given width, but maintains full view of the contents by adjusting the height if necessary.
 void show()
          Graphically shows the text box.
 
Methods inherited from class wheelsunh.users.RectangularShape
getFillColor, getFrameColor, getFrameThickness, getHeight, getLocation, getSize, getWidth, getXLocation, getYLocation, setFrameColor, setFrameThickness, setLocation, setSize
 
Methods inherited from class wheelsunh.users.Shape
contains, getColor, getRotation, paint
 
Methods inherited from class wheelsunh.users.AbstractShape
boundsIntersects, center, distance, getCenter, getCenterX, getCenterY, getIntersection, intersects, intersects, setCenter
 
Methods inherited from class wheelsunh.etc.AbstractGraphic
mouseClicked, mouseDragged, mousePressed, mouseReleased
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface wheelsunh.Colorable
getColor
 

Field Detail

_text

protected javax.swing.JTextArea _text

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
See Also:
Constant Field Values

DEFAULT_BORDER_WIDTH

public static final int DEFAULT_BORDER_WIDTH
See Also:
Constant Field Values
Constructor Detail

InputBox

public InputBox()
Constructs an empty InputBox in the wheelsunh.users.Frame's DrawingPanel.


InputBox

public InputBox(java.lang.String text)
Constructs an InputBox displaying the specified String in the wheelsunh.users.Frame's DrawingPanel.

Parameters:
text - the String to display

InputBox

public InputBox(java.lang.String text,
                DrawingPanel dp)
Constructs an InputBox displaying the specified String in the passed-in DrawingPanel.

Parameters:
text - the String to display
dp - the DrawingPanel in which the bubble will be drawn
Method Detail

setLocation

public void setLocation(java.awt.Point p)
Sets the location of the TextBox. Overridden to position the text box within the frame. (Calls to setLocation(int, int) forward to setLocation(java.awt.Point), so either one will work correctly.)

Specified by:
setLocation in interface Locatable
Overrides:
setLocation in class RectangularShape

setSize

public void setSize(java.awt.Dimension d)
Sets the size of the TextBox. NOTE: setting an explicit size for the bubble may cut off some of the text. Use setWidth(int) to specify a width for the bubble while maintaining view of all the text.

Specified by:
setSize in interface Sizeable
Overrides:
setSize in class RectangularShape

setWidth

public void setWidth(int width)
Sizes the TextBox to the given width, but maintains full view of the contents by adjusting the height if necessary.


show

public void show()
Graphically shows the text box.

Overrides:
show in class Shape

hide

public void hide()
Graphically hides the text box.

Overrides:
hide in class Shape

setBorderWidth

public void setBorderWidth(int width)
Changes the size of the border of whitespace between the text area and its frame.


setColor

public void setColor(java.awt.Color c)
Set the background and frame color of the TextBox.

Specified by:
setColor in interface Colorable
Overrides:
setColor in class RectangularShape

setFillColor

public void setFillColor(java.awt.Color c)
Set the background color of the TextBox.

Specified by:
setFillColor in interface AdvancedColorable
Overrides:
setFillColor in class RectangularShape

setText

public void setText(java.lang.String text)
Makes the bubble display the passed-in string. Adjusts height so the all of new string is properly displayed.


actualPaint

public void actualPaint(java.awt.Graphics2D g)
Normal users do not need to worry about this! Does the actual work to paint the text box.

Overrides:
actualPaint in class RectangularShape
Parameters:
g - the instance of java.awt.Graphics2D that should be used to paint the shape

getBounds

public java.awt.Rectangle getBounds()
Returns the bounds of the text box.

Overrides:
getBounds in class RectangularShape

setRotation

public void setRotation(int degrees)
Overridden to do nothing.

Specified by:
setRotation in interface Rotatable
Overrides:
setRotation in class Shape
Parameters:
degrees - the magnitude of the rotation in degrees

parse

protected abstract void parse(java.lang.String s)
This method is overridden in concrete implementations It controls what the input box does with strings entered into it