Class  Tree  Deprecated  Index  Help 
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class TurtleGraphicsWindow

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--TurtleGraphicsWindow

public class TurtleGraphicsWindow
extends java.awt.Frame
implements TGKeyHandler, TGMouseHandler, java.awt.event.WindowListener


 
Fields inherited from interface TGKeyHandler
DOWN, ENTER, LEFT, RIGHT, SPACE, UP
   
Method Summary
 void back(int steps)
          Move the turtle backwards along its current heading.
 void bk(int steps)
          Move the turtle backwards along its current heading.
 void clean()
          Clears the graphics area of the TurtleGraphics window.
 int colorunder()
          Return the color the Turtle is sitting on
 void fd(int steps)
          Move the turtle forward along its current heading.
 void fill()
          Fill a bounded area in the graphics image.
 void forward(int steps)
          Move the turtle forward along its current heading.
 int heading()
          Return the Turtle's heading
 void hideturtle()
          Hide the turtle; make it invisible.
 void home()
          Move the turtle to the center of the display.
 void ht()
          Hide the turtle; make it invisible.
 boolean ispendown()
          Return the current status of the pen.
 void keypressed(int keyNum)
           
 void label(String text)
          Paints a String of characters on the display.
 void left(int degrees)
          Rotate the turtle counterclockwise by the specified angle, measured in degrees.
 void lt(int degrees)
          Rotate the turtle counterclockwise by the specified angle, measured in degrees.
 void mouseclick()
           
 int mousex()
          Return the x-coordinate where last mouse click occured.
 int mousey()
          Return the y-coordinate where last mouse click occured.
 void pd()
          Put the turtle's pen in the down position.
 void pendown()
          Put the turtle's pen in the down position.
 void penup()
          Put the turtle's pen in the up position.
 void pu()
          Put the turtle's pen in the up position.
 void right(int degrees)
          Rotate the turtle clockwise by the specified angle, measured in degrees.
 void rt(int degrees)
          Rotate the turtle clockwise by the specified angle, measured in degrees.
 void seth(int degrees)
          Turns the turtle to the specified absolute heading.
 void setheading(int degrees)
          Turns the turtle to the specified absolute heading.
 void setlabelheight(int size)
          Set the size of the text displayed in the graphics area.
 void setpc(int color_Num)
          Sets the color of the turtle's pen to the supplied number.
 void setpencolor(int color_Num)
          Sets the color of the turtle's pen to the supplied number.
 void setpensize(int width)
          Sets the width of the turtle's pen to the supplied number.
 void setx(int new_X)
          Move the turtle to an absolute display position.
 void setxy(int new_X, int new_Y)
          Move the turtle to an absolute display position.
 void sety(int new_Y)
          Move the turtle to an absolute display position.
 void showturtle()
          Show the turtle; make it visible.
 void st()
          Show the turtle; make it visible.
 int xcor()
          Return the Turtle's X-coordinate
 int ycor()
          Return the Turtle's Y-coordinate

Method Detail

keypressed

public void keypressed(int keyNum)

mouseclick

public void mouseclick()

bk

public void bk(int steps)
Move the turtle 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.
See Also:
back(int)

back

public void back(int steps)
Move the turtle 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.
See Also:
bk(int)

clean

public void clean()
Clears the graphics area of the TurtleGraphics window.

Note: Clean does not change the current position of the turtle, its heading, the size of the pen it is drawing with and/or the color of the pen it is drawing with.


colorunder

public int colorunder()
Return the color the Turtle is sitting on

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

fill

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

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.


fd

public void fd(int steps)
Move the turtle 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 - Number of pixels (in this implementation) to take.
See Also:
forward(int)

forward

public void forward(int steps)
Move the turtle 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.
See Also:
fd(int)

heading

public int heading()
Return the Turtle's heading

See Also:
seth(int), setheading(int)

home

public void home()
Move the turtle 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 )

See Also:
setxy(int, int)

ht

public void ht()
Hide the turtle; make it invisible.

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

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

hideturtle

public void hideturtle()
Hide the turtle; make it invisible.

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

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

ispendown

public boolean ispendown()
Return the current status of the pen.

Return true if the turtle's pen is down or false if it in the up position.

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

label

public void label(String text)
Paints a String of characters on the display. The text is painted in the current pen's color, starting at the current position of the turtle.

The text is always painted in the standard horizontal manner, i.e., the heading of the turtle is ignored.

Parameters:
text - Characters to be painted on the display.

left

public void left(int degrees)
Rotate the turtle counterclockwise by the specified angle, measured in degrees.

Parameters:
degrees - Angle to change turtle's heading by.
See Also:
lt(int)

lt

public void lt(int degrees)
Rotate the turtle counterclockwise by the specified angle, measured in degrees.

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

Parameters:
degrees - Angle to change turtle's heading by.
See Also:
left(int)

mousex

public int mousex()
Return the x-coordinate where last mouse click occured.

See Also:
mousey()

mousey

public int mousey()
Return the y-coordinate where last mouse click occured.

See Also:
mousex()

pd

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

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

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

pendown

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

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

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

penup

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

When the turtle moves, it will leave no trace.

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

pu

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

When the turtle moves, it will leave no trace.

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

setlabelheight

public void setlabelheight(int size)
Set the size of the text displayed in the graphics area.
See Also:
label(String)

st

public void st()
Show the turtle; make it visible.

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

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

showturtle

public void showturtle()
Show the turtle; make it visible.

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

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

setx

public void setx(int new_X)
Move the turtle to an absolute display position.

Move the turtle horizontally to a new location specified as an X coordinate argument.

Parameters:
newX - the X-coordinate of destination.
See Also:
home(), setxy(int, int), sety(int)

setxy

public void setxy(int new_X,
                  int new_Y)
Move the turtle to an absolute display position.

Move the turtle to the x and y coordinates provided as arguments.

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

sety

public void sety(int new_Y)
Move the turtle to an absolute display position.

Move the turtle vertically to a new location specified as an Y coordinate argument.

Parameters:
newY - the Y-coordinate of destination.
See Also:
home(), setx(int), setxy(int, int)

right

public void right(int degrees)
Rotate the turtle clockwise by the specified angle, measured in degrees.

Parameters:
degrees - Angle to change turtle's heading by.
See Also:
rt(int)

rt

public void rt(int degrees)
Rotate the turtle clockwise by the specified angle, measured in degrees.

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

Parameters:
degrees - Angle to change turtle's heading by.
See Also:
right(int)

seth

public void seth(int degrees)
Turns the turtle 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:
degrees - number of 1/360ths increments clockwise from the positive Y axis.
See Also:
setheading(int)

setheading

public void setheading(int degrees)
Turns the turtle 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:
degrees - number of 1/360ths increments clockwise from the positive Y axis.
See Also:
seth(int)

setpc

public void setpc(int color_Num)
Sets the color of the turtle's pen to the supplied number.
Parameters:
color_Num - numbers 0-15 are:

 Number  Color       Number  Color
 ------  -------     ------  -------
    0    black          8    brown
    1    blue           9    tan
    2    green         10    forest
    3    cyan          11    aqua
    4    red           12    salmon
    5    magenta       13    violet
    6    yellow        14    orange
    7    white         15    grey
 

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

See Also:
setpencolor(int)

setpencolor

public void setpencolor(int color_Num)
Sets the color of the turtle's pen to the supplied number.
Parameters:
color_Num - numbers 0-15 are:

 Number  Color       Number  Color
 ------  -------     ------  -------
    0    black          8    brown
    1    blue           9    tan
    2    green         10    forest
    3    cyan          11    aqua
    4    red           12    salmon
    5    magenta       13    violet
    6    yellow        14    orange
    7    white         15    grey
 

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

See Also:
setpencolor(int)

setpensize

public void setpensize(int width)
Sets the width of the turtle's pen to the supplied number.
Parameters:
width - small positive number; 1 (or less) results in a single pixel line. increasing numbers incrementally add approximately 2 extra pixels in width

xcor

public int xcor()
Return the Turtle's X-coordinate
See Also:
setxy(int, int), setx(int), sety(int), ycor()

ycor

public int ycor()
Return the Turtle's Y-coordinate
See Also:
setxy(int, int), setx(int), sety(int), xcor()

 Class  Tree  Deprecated  Index  Help 
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD