fang
Class InputFieldSprite

java.lang.Object
  extended by fang.Sprite
      extended by fang.InputFieldSprite

public class InputFieldSprite
extends Sprite

This class enables text input within the AnimationCanvas via a special Sprite which responds to keyboard input when the specified mouse is inside the box.

Author:
Jam Jenkins

Nested Class Summary
 class InputFieldSprite.InputTracker
          This is a special tracker which responds to keyboard and mouse input and also forwards the advancing of time to another tracker which may be attached.
 
Field Summary
static double MARGIN
          margin from the edge of the inner box
 
Fields inherited from class fang.Sprite
color, config, DEBUG_BOUNDING_BOX, DEBUG_INTERSECTS, debugBoundingBoxColor, image, optimizeForBitmap, shape, tracker, transform
 
Constructor Summary
InputFieldSprite(int characters)
          creates a StringField with space for a certain number of fixed width characters
InputFieldSprite(int rows, int characters)
          creates a StringField with space for a certain number of fixed width characters
InputFieldSprite(String text)
          creates a StringField with a given starting text.
 
Method Summary
 void addTracker(Tracker t)
          adds the tracker to the sprite
 void disableInput()
          disables all input
 void disableInput(Keyboard keyboard, Mouse mouse)
          diables a keyboard mouse pair
 void enableInput(Keyboard keyboard, Mouse mouse)
          selects which mouse and which keyboard will be allowed to edit the StringField
 Tracker[] getAddedTrackers()
          gets all the added trackers to this sprite
 String getStyle()
          gets the family name of the font
 String getText()
          gets the contents of the StringField
 boolean isBold()
          determines the thickness of the lettering
 boolean isItalicized()
          determines if the text is slanted
 boolean isUnderlined()
          determines if there is a line at the baseline of the text
 void removeTracker(Tracker t)
          removes a tracker from this sprite
 void setBold(boolean bold)
          sets the thickness of the lettering
 void setItalicized(boolean italics)
          sets the slant of the text
 void setStyle(String style)
          sets the family name of the font
 void setText(String text)
          sets the sequence of characters in the StringField
 void setTracker(Tracker t)
          this method is disabled for the StringField.
 void setUnderlined(boolean underline)
          sets whether there should or should not be a line at the baseline of the text
 
Methods inherited from class fang.Sprite
addTransformer, advanceTime, bounceOffOf, disableTransformer, drawDebugShapes, enableTransformer, forward, getBlurLength, getBounds2D, getColor, getDebug, getDebugBoundingBoxColor, getDefaultColor, getHeight, getLocation, getMaxX, getMaxY, getMinX, getMinY, getNormalVector, getNormalVector, getOptimizedForBitmap, getOrientation, getOrientationDegrees, getOrientationRadians, getOrientationRevolutions, getRotation, getRotationDegrees, getRotationRadians, getRotationRevolutions, getScale, getShape, getSize, getTracker, getUseBoundingBox, getWidth, getX, getY, hasTracker, hide, intersects, intersects, intersects, intersects, intersects, isDestroyed, isEnabled, isVisible, normalize, paint, paintInternal, paintShape, removeAllTrackers, removeFromCanvas, removeTransformer, rotate, rotateDegrees, rotateRadians, rotateRevolutions, scale, setAbsoluteShape, setBlurLength, setColor, setDebug, setDebugBoundingBoxColor, setDebugBrush, setDefaultColor, setEnabled, setLocation, setLocation, setLocation, setOptimizedForBitmap, setOrientation, setOrientationDegrees, setOrientationRadians, setOrientationRevolutions, setRotation, setRotationDegrees, setRotationRadians, setRotationRevolutions, setScale, setShape, setSize, setUseBoundingBox, setVisible, setX, setY, show, translate, translate, translate, translateX, translateY, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MARGIN

public static final double MARGIN
margin from the edge of the inner box

See Also:
Constant Field Values
Constructor Detail

InputFieldSprite

public InputFieldSprite(int characters)
creates a StringField with space for a certain number of fixed width characters

Parameters:
characters - the number of characters wide to make the StringField

InputFieldSprite

public InputFieldSprite(int rows,
                        int characters)
creates a StringField with space for a certain number of fixed width characters

Parameters:
characters - the number of characters wide to make the StringField

InputFieldSprite

public InputFieldSprite(String text)
creates a StringField with a given starting text. This starting text indicates the default width of the StringField.

Parameters:
text - the starting String
Method Detail

enableInput

public void enableInput(Keyboard keyboard,
                        Mouse mouse)
selects which mouse and which keyboard will be allowed to edit the StringField

Parameters:
keyboard -
mouse -

setTracker

public void setTracker(Tracker t)
this method is disabled for the StringField. Instead use the addTracker method.

Overrides:
setTracker in class Sprite
Parameters:
t - the tracker to add

addTracker

public void addTracker(Tracker t)
adds the tracker to the sprite

Parameters:
t - the tracker

getAddedTrackers

public Tracker[] getAddedTrackers()
gets all the added trackers to this sprite

Returns:
the array of trackers which have been added

removeTracker

public void removeTracker(Tracker t)
removes a tracker from this sprite

Parameters:
t - the tracker to remove

disableInput

public void disableInput()
disables all input


disableInput

public void disableInput(Keyboard keyboard,
                         Mouse mouse)
diables a keyboard mouse pair

Parameters:
keyboard - the keyboard to ignore
mouse - the corresponding mouse

setText

public void setText(String text)
sets the sequence of characters in the StringField

Parameters:
text - the new sequence of characters

getText

public String getText()
gets the contents of the StringField

Returns:
the sequence of characters in the StringField

setItalicized

public void setItalicized(boolean italics)
sets the slant of the text

Parameters:
italics - true indicates slant, false is for no slant

setBold

public void setBold(boolean bold)
sets the thickness of the lettering

Parameters:
bold - true indicates thick lettering, false indicates normal thickness

isItalicized

public boolean isItalicized()
determines if the text is slanted

Returns:
true if the text is slanted, false otherwise

isBold

public boolean isBold()
determines the thickness of the lettering

Returns:
true if the text has extra thick lettering, false if the thickness is normal

setUnderlined

public void setUnderlined(boolean underline)
sets whether there should or should not be a line at the baseline of the text

Parameters:
underline - true indicates there should be a line, false indicates no line should be there

getStyle

public String getStyle()
gets the family name of the font

Returns:
the family name of the font

setStyle

public void setStyle(String style)
sets the family name of the font

Parameters:
style - the family name of the font

isUnderlined

public boolean isUnderlined()
determines if there is a line at the baseline of the text

Returns:
true if there is a line, false if there is not