Class Sprite

java.lang.Object
  extended by java.awt.Component
      extended by Sprite
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class Sprite
extends java.awt.Component

Sprite provides support for a turtle's graphics state. This consists of stuff like current heading, current location in TurtleSpace, the set of of pixels that represent it, etc... Associated with this state are the methods to access and manipulate it, e.g., support for FORWARD, RIGHT, POS, HEADING, etc... Commands and Operators.

Sprite must extend Component so that it can use createImage() to supply TGCanvas with its Image.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int ARROW
          jLogo comes with a few basic shapes (images) that the turtle may take on.
static int BALL
          jLogo comes with a few basic shapes (images) that the turtle may take on.
static int BOX
          jLogo comes with a few basic shapes (images) that the turtle may take on.
static java.lang.String CLASS_NAME
          Class' name as String.
static int COURIER
          Symbolic constant for setlabelfont() to select a fixed-width Courier font.
static int COURIER_BOLD
          Symbolic constant for setlabelfont() to select an emboldened fixed-width Courier font.
static int COURIER_BOLD_ITALIC
          Symbolic constant for setlabelfont() to select an emboldened and italicized fixed-width Courier font.
static int COURIER_ITALIC
          Symbolic constant for setlabelfont() to select an italicized fixed-width Courier font.
static int CROSS
          jLogo comes with a few basic shapes (images) that the turtle may take on.
static int DIAMOND
          jLogo comes with a few basic shapes (images) that the turtle may take on.
static int LINECAP_BUTT
          Symbolic constant for setLinecap() which selects a basic line with no endcap.
static int LINECAP_ROUND
          Symbolic constant for setLinecap() to which selects a rounded endcap.
static int LINECAP_SQUARE
          Symbolic constant for setLinecap() to which selects a squared-off endcap.
static int MAX_BUILTIN_SHAPENUM
          Maximum shape number that Sprite knows how to construct.
static int MAX_LABEL_ASCENT
          Largest supported CAPITAL letter ascent
static int MAX_THROTTLE_AMT
          To aid debugging and/or optimizing a grapical program it can be helpful to artificially slow down the drawing.
static int NUM_FONTS
          Number of fonts supported.
static int SANS_SERIF
          Symbolic constant for setlabelfont() to select the Sans Serif font.
static int SANS_SERIF_BOLD
          Symbolic constant for setlabelfont() to select an emboldened Sans Serif font.
static int SANS_SERIF_BOLD_ITALIC
          Symbolic constant for setlabelfont() to select an emboldened and italicized Sans Serif font.
static int SANS_SERIF_ITALIC
          Symbolic constant for setlabelfont() to select an italicized Sans Serif font.
static int SERIF
          Symbolic constant for setlabelfont() to select the Serif font.
static int SERIF_BOLD
          Symbolic constant for setlabelfont() to select an emboldened Serif font.
static int SERIF_BOLD_ITALIC
          Symbolic constant for setlabelfont() to select an emboldened and italicized Serif font.
static int SERIF_ITALIC
          Symbolic constant for setlabelfont() to select an italicized Serif font.
static int TRIANGLE
          jLogo comes with a few basic shapes (images) that the turtle may take on.
static int TURTLE
          jLogo comes with a few basic shapes (images) that the turtle may take on.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Sprite(TGCanvas canvas)
          Instantiate the graphics sprite associated with a turtle.
 
Method Summary
 void arc(double angle, double radius)
          Draws an arc of a circle, with the Sprite at the center, with the specified radius, starting at the Sprite's heading and extending clockwise through the specified angle.
 void arc(int angle, int radius)
          Draws an arc of a circle, with the Sprite at the center, with the specified radius, starting at the Sprite's heading and extending clockwise through the specified angle.
 void back(double steps)
          Move this Sprite backwards along its current heading.
 void back(float steps)
           
 void back(int steps)
           
 void bk(double steps)
           
 void bk(float steps)
          Move this Sprite backwards along its current heading.
 void bk(int steps)
           
 void close()
          Clean up before going away.
 int[] colorsunder()
          Return an array of the unique colors this Sprite's image is positioned over.
 int colorunder()
          Return the color this Sprite is sitting on, -1 if there is not a current graphics canvas to draw on.
 void fd(double steps)
           
 void fd(float steps)
          Move this Sprite forward along its current heading.
 void fd(int steps)
           
 void fill()
          Fill a bounded area in the graphics image.
 void forward(double steps)
          Move this Sprite forward along its current heading.
 void forward(float steps)
           
 void forward(int steps)
           
 java.awt.Image getImage()
          Return this Sprite's Image so it can be drawn on a Canvas by a Graphics object.
 int getImageSideSize()
          Return the size of a side of this Sprite's Image.
 int getLabelWidth(java.lang.String label)
          Return the width of the provided String in turtle steps (pixels).
 SpritePixels getSpritePixels()
          Return this Sprite's SpritePixels object.
 int getThrottleSleepAmt()
          Get the amount of time (milliseconds) that drawing is suspended each time a method which visibly changes the Sprite's state is performed.
 double heading()
          Return this Sprite's heading in degrees.
 void hideturtle()
          Hide this Sprite; make it invisible.
 void home()
          Move this Sprite to the center of the display.
 void ht()
          Hide this Sprite; make it invisible.
 boolean ispendown()
          Return the current status of the pen.
 void label(java.lang.String text)
          Draws a String of characters onto the graphics canvas.
 void left(double degrees)
          Rotate this Sprite counterclockwise by the specified angle, measured in degrees.
 void left(float degrees)
           
 void left(int degrees)
           
 void left(long degrees)
           
 void lt(double degrees)
           
 void lt(float degrees)
          Rotate this Sprite counterclockwise by the specified angle, measured in degrees.
 void lt(int degrees)
           
 void lt(long degrees)
           
 void pd()
          Put this Sprite's pen in the down position.
 int pencolor()
          Return the color the pen is currently drawing in.
 void pendown()
          Put this Sprite's pen in the down position.
 int pensize()
          Return the width of the pen this Sprite is currently drawing with.
 void penup()
          Put this Sprite's pen in the up position.
 TGPoint pos()
          Return the current position of theis Sprite.
 void pu()
          Put this Sprite's pen in the up position.
 void right(double degrees)
          Rotate this Sprite clockwise by the specified angle, measured in degrees.
 void right(float degrees)
           
 void right(int degrees)
           
 void right(long degrees)
           
 void rt(double degrees)
           
 void rt(float degrees)
          Rotate this Sprite clockwise by the specified angle, measured in degrees.
 void rt(int degrees)
           
 void rt(long degrees)
           
 void setCanvas(TGCanvas canvas)
          Set/clear the reference to this Sprite's graphics canvas.
 void seth(double turtleSpaceDegrees)
           
 void seth(float turtleSpaceDegrees)
          Turns this Sprite to the specified absolute heading.
 void seth(int turtleSpaceDegrees)
           
 void seth(long turtleSpaceDegrees)
           
 void setheading(double turtleSpaceDegrees)
          Turns this Sprite to the specified absolute heading.
 void setheading(float turtleSpaceDegrees)
           
 void setheading(int turtleSpaceDegrees)
           
 void setheading(long turtleSpaceDegrees)
           
 void setlabelfont(int fontNumber)
          Set the font for LABELs.
 void setlabelheight(int size)
          Set the size of the text displayed in the graphics area.
 void setLinecap(int type)
          Set the type of linecaps applied to the ends of lines drawn.
 void setpc(int logoColorNum)
          Sets the color of this Sprite's pen to the supplied number.
 void setpencolor(int colorNum)
          Sets the color of this Sprite's pen to the supplied number.
 void setpenpattern(int[] pattern)
          Set the pattern used to draw lines.
 void setpensize(int width)
          Sets the width of this Sprite's pen to the supplied number.
 boolean setshape(int shapeNum, int[] params)
          Sets the shape of this Sprite - its pixel image.
 void setshape(SpritePixels newSpritePixels)
          Sets the shape of this Sprite - its pixel image.
 void setThrottleSleepAmt(int newThrottleSleepAmt)
          Set the amount of time (milliseconds) that drawing is suspended each time a method which visibly changes the Sprite's state is performed.
 void setx(double newX)
           
 void setx(float newX)
          Move this Sprite to an absolute display position.
 void setx(int newX)
           
 void setx(long newX)
           
 void setxy(double newX, double newY)
          Move this Sprite to an absolute display position.
 void setxy(float newX, float newY)
           
 void setxy(int newX, int newY)
           
 void setxy(long newX, long newY)
           
 void setxy(TGPoint newPt)
          Move this Sprite to an absolute display position.
 void sety(double newY)
           
 void sety(float newY)
          Move this Sprite to an absolute display position.
 void sety(int newY)
           
 void sety(long newY)
           
 boolean shownp()
          Return true if this Sprite's image is being displayed on the graphics canvas, else return false.
 void showturtle()
          Show this Sprite; make it visible.
 void st()
          Show this Sprite; make it visible.
 void stamp()
          Draw the current Sprite Image onto the graphics canvas.
 java.lang.String toString()
          Return String representation of this Sprite consisting of lots of its state; to be used when debugging.
 double xcor()
          Return this Sprite's X-coordinate
 double ycor()
          Return this Sprite's Y-coordinate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_NAME

public static final java.lang.String CLASS_NAME
Class' name as String.

See Also:
Constant Field Values

TURTLE

public static final int TURTLE
jLogo comes with a few basic shapes (images) that the turtle may take on. Each is assigned a fixed shape number. The initial shape roughly looks like a turtle (come-on... think artististic license). This default turtle image is shape number 0.

See Also:
Constant Field Values

ARROW

public static final int ARROW
jLogo comes with a few basic shapes (images) that the turtle may take on. Each is assigned a fixed shape number. An image which resembles an arrow is shape number 1.

See Also:
Constant Field Values

BALL

public static final int BALL
jLogo comes with a few basic shapes (images) that the turtle may take on. Each is assigned a fixed shape number. An image which is a filled circle, a ball, is shape number 2.

See Also:
Constant Field Values

BOX

public static final int BOX
jLogo comes with a few basic shapes (images) that the turtle may take on. Each is assigned a fixed shape number. An image which is a filled rectangle, a box, is shape number 3.

See Also:
Constant Field Values

CROSS

public static final int CROSS
jLogo comes with a few basic shapes (images) that the turtle may take on. Each is assigned a fixed shape number. An image which resembles a filled plus-sign, a cross, is shape number 4.

See Also:
Constant Field Values

TRIANGLE

public static final int TRIANGLE
jLogo comes with a few basic shapes (images) that the turtle may take on. Each is assigned a fixed shape number. An image which is a filled triangle is shape number 5.

See Also:
Constant Field Values

DIAMOND

public static final int DIAMOND
jLogo comes with a few basic shapes (images) that the turtle may take on. Each is assigned a fixed shape number. An image which is a filled diamond is shape number 6.

See Also:
Constant Field Values

MAX_BUILTIN_SHAPENUM

public static final int MAX_BUILTIN_SHAPENUM
Maximum shape number that Sprite knows how to construct.

See Also:
Constant Field Values

LINECAP_BUTT

public static final int LINECAP_BUTT
Symbolic constant for setLinecap() which selects a basic line with no endcap.

See Also:
Constant Field Values

LINECAP_ROUND

public static final int LINECAP_ROUND
Symbolic constant for setLinecap() to which selects a rounded endcap. This is the default.

See Also:
Constant Field Values

LINECAP_SQUARE

public static final int LINECAP_SQUARE
Symbolic constant for setLinecap() to which selects a squared-off endcap.

See Also:
Constant Field Values

COURIER

public static final int COURIER
Symbolic constant for setlabelfont() to select a fixed-width Courier font.

See Also:
Constant Field Values

COURIER_BOLD

public static final int COURIER_BOLD
Symbolic constant for setlabelfont() to select an emboldened fixed-width Courier font.

See Also:
Constant Field Values

COURIER_ITALIC

public static final int COURIER_ITALIC
Symbolic constant for setlabelfont() to select an italicized fixed-width Courier font.

See Also:
Constant Field Values

COURIER_BOLD_ITALIC

public static final int COURIER_BOLD_ITALIC
Symbolic constant for setlabelfont() to select an emboldened and italicized fixed-width Courier font.

See Also:
Constant Field Values

SANS_SERIF

public static final int SANS_SERIF
Symbolic constant for setlabelfont() to select the Sans Serif font.

See Also:
Constant Field Values

SANS_SERIF_BOLD

public static final int SANS_SERIF_BOLD
Symbolic constant for setlabelfont() to select an emboldened Sans Serif font.

See Also:
Constant Field Values

SANS_SERIF_ITALIC

public static final int SANS_SERIF_ITALIC
Symbolic constant for setlabelfont() to select an italicized Sans Serif font.

See Also:
Constant Field Values

SANS_SERIF_BOLD_ITALIC

public static final int SANS_SERIF_BOLD_ITALIC
Symbolic constant for setlabelfont() to select an emboldened and italicized Sans Serif font.

See Also:
Constant Field Values

SERIF

public static final int SERIF
Symbolic constant for setlabelfont() to select the Serif font.

See Also:
Constant Field Values

SERIF_BOLD

public static final int SERIF_BOLD
Symbolic constant for setlabelfont() to select an emboldened Serif font.

See Also:
Constant Field Values

SERIF_ITALIC

public static final int SERIF_ITALIC
Symbolic constant for setlabelfont() to select an italicized Serif font.

See Also:
Constant Field Values

SERIF_BOLD_ITALIC

public static final int SERIF_BOLD_ITALIC
Symbolic constant for setlabelfont() to select an emboldened and italicized Serif font.

See Also:
Constant Field Values

MAX_LABEL_ASCENT

public static final int MAX_LABEL_ASCENT
Largest supported CAPITAL letter ascent

See Also:
Constant Field Values

MAX_THROTTLE_AMT

public static final int MAX_THROTTLE_AMT
To aid debugging and/or optimizing a grapical program it can be helpful to artificially slow down the drawing. A Sprite can be throttled by invoking setThrottleSleepAmt() with some positive value, an amount of time (milliseconds). Each time a method which visibly changes this Sprite's state finishes its action, the Sprite takes a nap. But, bounds must be set to catch unreasonble requests. Currently the maximum throttle value is five seconds.

See Also:
Constant Field Values

NUM_FONTS

public static final int NUM_FONTS
Number of fonts supported. The font number argument to setlabelfont() must be in the range 0..NUM_FONTS-1.

Constructor Detail

Sprite

public Sprite(TGCanvas canvas)
Instantiate the graphics sprite associated with a turtle. The sprite is setup with a default location (home), heading, image, font and pen.

Method Detail

arc

public void arc(double angle,
                double radius)
Draws an arc of a circle, with the Sprite at the center, with the specified radius, starting at the Sprite's heading and extending clockwise through the specified angle. The Sprite is not moved.

Parameters:
angle - clockwise rotation from current heading (in degrees)
radius - distance from center of Sprite to the drawn arc, to the center of the arc line if the pen width is greater than 1.

arc

public void arc(int angle,
                int radius)
Draws an arc of a circle, with the Sprite at the center, with the specified radius, starting at the Sprite's heading and extending clockwise through the specified angle. The Sprite is not moved.

Parameters:
angle - clockwise rotation from current heading (in degrees)
radius - distance from center of Sprite to the drawn arc, to the center of the arc line if the pen width is greater than 1.

back

public void back(double steps)
          throws AbortException
Move this Sprite backwards along its current heading. If the pen is currently in the DOWN position, a line is drawn.

Long name for bk(). Both spellings need to provided for compatibility.

Parameters:
steps - Number of pixels (in this implementation) to take.
Throws:
AbortException
See Also:
bk(float)

back

public void back(float steps)
          throws AbortException
Throws:
AbortException

back

public void back(int steps)
          throws AbortException
Throws:
AbortException

bk

public void bk(float steps)
        throws AbortException
Move this Sprite backwards along its current heading. If the pen is currently in the DOWN position, a line is drawn.

Abbreviation for back(). Both spellings need to provided for compatibility.

Parameters:
steps - Number of pixels (in this implementation) to take.
Throws:
AbortException
See Also:
back(double)

bk

public void bk(int steps)
        throws AbortException
Throws:
AbortException

bk

public void bk(double steps)
        throws AbortException
Throws:
AbortException

close

public void close()
Clean up before going away.


colorsunder

public int[] colorsunder()
Return an array of the unique colors this Sprite's image is positioned over.

See Also:
pencolor(), setpc(int), setpencolor(int)

colorunder

public int colorunder()
Return the color this Sprite is sitting on, -1 if there is not a current graphics canvas to draw on.

See Also:
pencolor(), setpc(int), setpencolor(int)

fill

public void fill()
Fill a bounded area in the graphics image.

Perform a flood-fill operation starting at the Sprite's current position. The current pixel, and any of its neighbors that are the same color as it (and any of their neighbors that are the same color as it, etc...) are changed to the current color.

For more * information on flood-fill, see the wikipedia entry or google for it.


fd

public void fd(float steps)
        throws AbortException
Move this Sprite forward along its current heading. If the pen is currently in the DOWN position, a line is drawn.

Abbreviation for forward(). Both spellings need to provided for compatibility.

Parameters:
steps - Distance in TurtleSpace to move.
Throws:
AbortException
See Also:
forward(double)

fd

public void fd(int steps)
        throws AbortException
Throws:
AbortException

fd

public void fd(double steps)
        throws AbortException
Throws:
AbortException

forward

public void forward(double steps)
             throws AbortException
Move this Sprite forward along its current heading. If the pen is currently in the DOWN position, a line is drawn.

Long name for fd(). Both spellings need to provided for compatibility.

Parameters:
steps - Number of pixels (in this implementation) to take.
Throws:
AbortException
See Also:
fd(float)

forward

public void forward(float steps)
             throws AbortException
Throws:
AbortException

forward

public void forward(int steps)
             throws AbortException
Throws:
AbortException

getImage

public java.awt.Image getImage()
Return this Sprite's Image so it can be drawn on a Canvas by a Graphics object.


getImageSideSize

public int getImageSideSize()
Return the size of a side of this Sprite's Image.

See Also:
getImage()

getLabelWidth

public int getLabelWidth(java.lang.String label)
Return the width of the provided String in turtle steps (pixels).

See Also:
label(java.lang.String)

getSpritePixels

public SpritePixels getSpritePixels()
Return this Sprite's SpritePixels object.


getThrottleSleepAmt

public int getThrottleSleepAmt()
Get the amount of time (milliseconds) that drawing is suspended each time a method which visibly changes the Sprite's state is performed. To aid debugging and/or optimizing a grapical program it can be helpful to artificially slow down the drawing. When throttleSleepAmt is greater than zero, concerned methods suspend the current Thread for it's amount.


heading

public double heading()
Return this Sprite's heading in degrees.

Logo's TurtleSpace does not match the mathematical convention of measuring angles counter-clockwise from the positive X axis. Logo defines NORTH (+Y axis) as 0 degrees and degrees increase in the clockwise direction, so East is 90 degrees, South is 180 degrees and West is 270 degrees.

See Also:
seth(float), setheading(double)

hideturtle

public void hideturtle()
Hide this Sprite; make it invisible.

Long name for ht(). Both spellings need to provided for compatibility.

See Also:
ht(), showturtle(), st()

home

public void home()
          throws AbortException
Move this Sprite to the center of the display. If the pen is currently in the DOWN position, a line is drawn.

Home is equivilent to setxy( 0, 0 )

Throws:
AbortException
See Also:
setxy(double, double)

ht

public void ht()
Hide this Sprite; make it invisible.

Abbreviation for hideturtle(). Both spellings need to provided for compatibility.

See Also:
hideturtle(), showturtle(), st()

ispendown

public boolean ispendown()
Return the current status of the pen. Return true if this Sprite's pen is down or false if it in the up position.

See Also:
pendown(), penup(), pd(), pu()

label

public void label(java.lang.String text)
Draws a String of characters onto the graphics canvas. The text is drawn in the current pen's color, starting at the current position of the Sprite.

The text is always drawn in the standard horizontal manner, i.e., the heading of this Sprite is ignored.

Parameters:
text - characters to be drawn on the display.

left

public void left(double degrees)
          throws AbortException
Rotate this Sprite counterclockwise by the specified angle, measured in degrees.

Parameters:
degrees - Angle to change this Sprite's heading by.
Throws:
AbortException
See Also:
lt(float)

left

public void left(float degrees)
          throws AbortException
Throws:
AbortException

left

public void left(int degrees)
          throws AbortException
Throws:
AbortException

left

public void left(long degrees)
          throws AbortException
Throws:
AbortException

lt

public void lt(float degrees)
        throws AbortException
Rotate this Sprite counterclockwise by the specified angle, measured in degrees.

Abbreviation for left(). Both spellings need to provided for compatibility.

Parameters:
degrees - Angle to change this Sprite's heading by.
Throws:
AbortException
See Also:
left(double)

lt

public void lt(int degrees)
        throws AbortException
Throws:
AbortException

lt

public void lt(long degrees)
        throws AbortException
Throws:
AbortException

lt

public void lt(double degrees)
        throws AbortException
Throws:
AbortException

pd

public void pd()
Put this Sprite's pen in the down position.

When this Sprite moves, it will leave a trace from its current position to its destination (its new position).

See Also:
ispendown(), pendown(), pu(), penup()

pencolor

public int pencolor()
Return the color the pen is currently drawing in.

See Also:
setpc(int), setpencolor(int)

pendown

public void pendown()
Put this Sprite's pen in the down position.

When this Sprite moves, it will leave a trace from its current position to its destination (its new position).

See Also:
ispendown(), pd(), pu(), penup()

pensize

public int pensize()
Return the width of the pen this Sprite is currently drawing with.

See Also:
setpensize(int)

pos

public TGPoint pos()
Return the current position of theis Sprite.

Returns:
TGPoint a virtual point, a point in TurtleSpace. In TurtleSpace, 0.0,0.0 is at the center of the graphics canvas.

pu

public void pu()
Put this Sprite's pen in the up position.

When this Sprite moves, it will leave no trace.

See Also:
ispendown(), pd(), pendown(), penup()

penup

public void penup()
Put this Sprite's pen in the up position.

When this Sprite moves, it will leave no trace.

See Also:
ispendown(), pd(), pendown(), pu()

right

public void right(double degrees)
           throws AbortException
Rotate this Sprite clockwise by the specified angle, measured in degrees.

Parameters:
degrees - Angle to change this Sprite's heading by.
Throws:
AbortException
See Also:
rt(float)

right

public void right(float degrees)
           throws AbortException
Throws:
AbortException

right

public void right(int degrees)
           throws AbortException
Throws:
AbortException

right

public void right(long degrees)
           throws AbortException
Throws:
AbortException

rt

public void rt(float degrees)
        throws AbortException
Rotate this Sprite clockwise by the specified angle, measured in degrees.

Abbreviation for right(). Both spellings need to provided for compatibility.

Parameters:
degrees - Angle to change this Sprite's heading by.
Throws:
AbortException
See Also:
right(double)

rt

public void rt(int degrees)
        throws AbortException
Throws:
AbortException

rt

public void rt(long degrees)
        throws AbortException
Throws:
AbortException

rt

public void rt(double degrees)
        throws AbortException
Throws:
AbortException

setCanvas

public void setCanvas(TGCanvas canvas)
Set/clear the reference to this Sprite's graphics canvas.


seth

public void seth(float turtleSpaceDegrees)
          throws AbortException
Turns this Sprite to the specified absolute heading. The heading is specified in degrees (units of 1/360th of a circle) with 0 being North (+Y axis), increasing clockwise. So, East is 90 degrees, South is 180 degrees, and West is 270 degrees.

Abbreviation for setheading(). Both spellings need to provided for compatibility.

Parameters:
turtleSpaceDegrees - number of 1/360ths increments clockwise from the positive Y axis.
Throws:
AbortException
See Also:
setheading(double)

seth

public void seth(int turtleSpaceDegrees)
          throws AbortException
Throws:
AbortException

seth

public void seth(long turtleSpaceDegrees)
          throws AbortException
Throws:
AbortException

seth

public void seth(double turtleSpaceDegrees)
          throws AbortException
Throws:
AbortException

setheading

public void setheading(double turtleSpaceDegrees)
                throws AbortException
Turns this Sprite to the specified absolute heading. The heading is specified in degrees (units of 1/360th of a circle) with 0 being North (+Y axis), increasing clockwise. So, East is 90 degrees, South is 180 degrees, and West is 270 degrees.

Parameters:
turtleSpaceDegrees - number of 1/360ths increments clockwise from the positive Y axis.
Throws:
AbortException
See Also:
seth(float)

setheading

public void setheading(float turtleSpaceDegrees)
                throws AbortException
Throws:
AbortException

setheading

public void setheading(int turtleSpaceDegrees)
                throws AbortException
Throws:
AbortException

setheading

public void setheading(long turtleSpaceDegrees)
                throws AbortException
Throws:
AbortException

setlabelfont

public void setlabelfont(int fontNumber)
Set the font for LABELs.

Parameters:
fontNumber - an integer representing a font face and font style.

 Number   Font         Style
 ------   ----------   -----------
    0     Courier      Plain
    1     Courier      Bold
    2     Courier      Italic
    3     Courier      Bold Italic
    4     Sans Serif   Plain
    5     Sans Serif   Bold
    6     Sans Serif   Italic
    7     Sans Serif   Bold Italic
    8     Serif        Plain
    9     Serif        Bold
   10     Serif        Italic
   11     Serif        Bold Italic
 
See Also:
label(java.lang.String), setlabelheight(int), COURIER, COURIER_BOLD, COURIER_ITALIC, COURIER_BOLD_ITALIC, SANS_SERIF, SANS_SERIF_BOLD, SANS_SERIF_ITALIC, SANS_SERIF_BOLD_ITALIC, SERIF, SERIF_BOLD, SERIF_ITALIC, SERIF_BOLD_ITALIC

setlabelheight

public void setlabelheight(int size)
Set the size of the text displayed in the graphics area.

See Also:
label(java.lang.String)

setLinecap

public void setLinecap(int type)
Set the type of linecaps applied to the ends of lines drawn. If the input is not a valid type, the default LINECAP_BUTT is used.

Parameters:
type - an integer representing a linecap
 Number   Linecap
 ------   -------
    0     BUTT
    1     ROUND
    2     SQUARE
 
See Also:
arc(double, double), forward(double), LINECAP_BUTT, LINECAP_ROUND, LINECAP_SQUARE

setpc

public void setpc(int logoColorNum)
Sets the color of this Sprite's pen to the supplied number.

Parameters:
logoColorNum - numbers 0-31 are:

 Number Color        Number Color        Number Color
 ------ ----------   ------ ----------   ------ ---------
    0   black          11   aqua           22   gold
    1   blue           12   salmon         23   lightgray
    2   green          13   purple         24   peru
    3   cyan           14   orange         25   wheat
    4   red            15   grey           26   palegreen
    5   magenta        16   navy           27   lightblue
    6   yellow         17   skyblue        28   khaki
    7   white          18   lime           29   pink
    8   brown          19   steelblue      30   lawngreen
    9   light brown    20   chocolate      31   olive
   10   forest         21   purple
 

Color numbers greater than 31 will be assumed to be RGB values with the red component in bits 8-15, the green component in bits 16-23, and the blue component in bits 24-31. The actual color used in rendering will depend on finding the best match given the color space available for a given display.

See Also:
pencolor(), setpencolor(int)

setpencolor

public void setpencolor(int colorNum)
Sets the color of this Sprite's pen to the supplied number.

Parameters:
colorNum - numbers 0-31 are:

 Number Color        Number Color        Number Color
 ------ ----------   ------ ----------   ------ ---------
    0   black          11   aqua           22   gold
    1   blue           12   salmon         23   lightgray
    2   green          13   purple         24   peru
    3   cyan           14   orange         25   wheat
    4   red            15   grey           26   palegreen
    5   magenta        16   navy           27   lightblue
    6   yellow         17   skyblue        28   khaki
    7   white          18   lime           29   pink
    8   brown          19   steelblue      30   lawngreen
    9   light brown    20   chocolate      31   olive
   10   forest         21   purple
 
Color numbers greater than 15 will be assumed to be RGB values with the red component in bits 8-15, the green component in bits 16-23, and the blue component in bits 24-31. The actual color used in rendering will depend on finding the best match given the color space available for a given display.
See Also:
setpc(int)

setpenpattern

public void setpenpattern(int[] pattern)
Set the pattern used to draw lines. A pattern consists of lengths of down and up pen states when drawing lines. If the pattern is null or empty, solid lines are drawn. Otherwise, the array's even elements are distances to draw and the odd elements are distances to skip over.

Parameters:
pattern - array of draw/skip amounts. If pattern has an odd number of elements, the last draw amount is duplicated for the skip amount, producing an array one element larger.
See Also:
pendown(), penup(), pd(), pu()

setpensize

public void setpensize(int width)
Sets the width of this Sprite's pen to the supplied number.

Parameters:
width - small positive number; 1 (or less) results in a single pixel line.

setshape

public boolean setshape(int shapeNum,
                        int[] params)
Sets the shape of this Sprite - its pixel image. Returns true if shape successfully set, else false failure.

Parameters:
shapeNum - small positive number; 0 for default Sprite; see constants (e.g., BALL, BOX, etc...) for other Sprite image shapes...
params - an optional int array containing sizing information hints, e.g. radius of a ball, width and height of a box, etc...

 Number  Shape      Optional Size Parameters
 ------  --------   ------------------------
    0    Turtle
    1    Arrow      width, height
    2    Ball       diameter
    3    Box        width, height
    4    Cross      width, height
    5    Triangle   width, height
    6    Diamond    width, height
 
See Also:
TURTLE, ARROW, BALL, BOX, CROSS, TRIANGLE, DIAMOND

setshape

public void setshape(SpritePixels newSpritePixels)
Sets the shape of this Sprite - its pixel image.

Parameters:
newSpritePixels - - instance of an object extending SpritePixels which provides an image for a Sprite.

setThrottleSleepAmt

public void setThrottleSleepAmt(int newThrottleSleepAmt)
Set the amount of time (milliseconds) that drawing is suspended each time a method which visibly changes the Sprite's state is performed. To aid debugging and/or optimizing a grapical program it can be helpful to artificially slow down the drawing. When throttleSleepAmt is greater than zero, concerned methods suspend the current Thread for it's amount.


setx

public void setx(float newX)
          throws AbortException
Move this Sprite to an absolute display position.

Move this Sprite horizontally to a new location specified as an X coordinate argument.

Parameters:
newX - the X-coordinate of destination.
Throws:
AbortException
See Also:
home(), setxy(double, double), sety(float)

setx

public void setx(int newX)
          throws AbortException
Throws:
AbortException

setx

public void setx(long newX)
          throws AbortException
Throws:
AbortException

setx

public void setx(double newX)
          throws AbortException
Throws:
AbortException

setxy

public void setxy(double newX,
                  double newY)
           throws AbortException
Move this Sprite to an absolute display position.

Move this Sprite to the x and y coordinates provided as arguments.

Parameters:
newX - the X-coordinate of destination.
newY - the Y-coordinate of destination.
Throws:
AbortException
See Also:
home(), setx(float), sety(float)

setxy

public void setxy(float newX,
                  float newY)
           throws AbortException
Throws:
AbortException

setxy

public void setxy(int newX,
                  int newY)
           throws AbortException
Throws:
AbortException

setxy

public void setxy(long newX,
                  long newY)
           throws AbortException
Throws:
AbortException

setxy

public void setxy(TGPoint newPt)
           throws AbortException
Move this Sprite to an absolute display position.

Move this Sprite to the x and y coordinates provided in the TGPoint parameter.

Parameters:
newPt - a TGPoint objext containing the X-coordinate and Y-coordinate of destination.
Throws:
AbortException
See Also:
home(), setx(float), sety(float)

sety

public void sety(float newY)
          throws AbortException
Move this Sprite to an absolute display position.

Move this Sprite vertically to a new location specified as an Y coordinate argument.

Parameters:
newY - the Y-coordinate of destination.
Throws:
AbortException
See Also:
home(), setx(float), setxy(double, double)

sety

public void sety(int newY)
          throws AbortException
Throws:
AbortException

sety

public void sety(long newY)
          throws AbortException
Throws:
AbortException

sety

public void sety(double newY)
          throws AbortException
Throws:
AbortException

shownp

public boolean shownp()
Return true if this Sprite's image is being displayed on the graphics canvas, else return false.

See Also:
hideturtle(), ht(), showturtle(), st()

showturtle

public void showturtle()
Show this Sprite; make it visible.

Long name for st(). Both spellings need to provided for compatibility.

See Also:
hideturtle(), ht(), st()

st

public void st()
Show this Sprite; make it visible.

Abbreviation for showturtle(). Both spellings need to provided for compatibility.

See Also:
hideturtle(), ht(), showturtle()

stamp

public void stamp()
Draw the current Sprite Image onto the graphics canvas.


toString

public java.lang.String toString()
Return String representation of this Sprite consisting of lots of its state; to be used when debugging.

Overrides:
toString in class java.awt.Component

xcor

public double xcor()
Return this Sprite's X-coordinate

See Also:
setxy(double, double), setx(float), sety(float), ycor()

ycor

public double ycor()
Return this Sprite's Y-coordinate

See Also:
setxy(double, double), setx(float), sety(float), xcor()