|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectgalapagos.Turtle
public class Turtle
This Turtle draws geometric shapes a DrawingCanvas. This turtle will run in a separate Thread so multiple turtles can be drawing on a single canvas,
| Field Summary | |
|---|---|
static int |
CREATE_DEFAULT_WINDOW
Constant for creating a default drawing window |
static int |
NO_DEFAULT_WINDOW
Constant for not creating any default drawing window |
| Constructor Summary | |
|---|---|
Turtle()
A default constructor that creates an instance of the Turtle class with a default drawing window. |
|
Turtle(int choice)
Constructs a standard turtle with or without default drawing window assigned. |
|
| Method Summary | |
|---|---|
void |
backup(double length)
Moves this turtle backward for a specified length. |
void |
bodyColor(java.awt.Color color)
Changes the body color of this turtle. |
void |
bodyShape(java.awt.Point[] point)
Sets the shape of this turtle to the give shape expressed in an array of Point objects. |
void |
forward(double length)
Moves this turtle forward for a given length. |
void |
heading(double degree)
Sets this turtle's heading for a specified degree. |
void |
hide()
Hides this turtle. |
void |
init()
Initializes this turtle. |
void |
jumpTo(double x,
double y)
Jumps to the given (x, y). |
void |
move(double length)
Moves this turtle's for a specified length. |
void |
moveTo(double targetX,
double targetY)
Moves this turtle to the specified target (x, y) position. |
void |
pause()
Stops this turtle from moving. |
void |
penColor(java.awt.Color color)
Sets the color of the turtle's pen. |
void |
penDown()
Sets the pen state to down. |
void |
penSize(int penSize)
Sets the size of this turtle's pen. |
void |
penUp()
Sets the pen state to up. |
void |
print(java.lang.String text)
Prints the given text at the current location |
void |
redraw(java.awt.Graphics g)
Required method to implement the DrawingController interface. |
void |
run()
Required method to implement the Runnable interface. |
void |
setCanvas(galapagos.DrawingCanvas canvas)
Required method to implement the DrawingController interface. |
void |
show()
Shows this turtle. |
void |
speed(int speed)
Changes the speed of this turtle |
void |
start()
Starts moving this turtle in its own thread. |
void |
turn(double degree)
Turns the turtle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int CREATE_DEFAULT_WINDOW
public static final int NO_DEFAULT_WINDOW
| Constructor Detail |
|---|
public Turtle()
public Turtle(int choice)
defaultWindow - zero means no default window; non-zero will create a
default window| Method Detail |
|---|
public void backup(double length)
length - the length to move backwardpublic void bodyColor(java.awt.Color color)
color - a new body colorpublic void bodyShape(java.awt.Point[] point)
Point[] - an array of Point objects representing a polygonpublic void forward(double length)
length - the length to move forwardpublic void hide()
public void move(double length)
public void moveTo(double targetX,
double targetY)
targetX - the x coordinate of the target pointtargetY - the y coordinate of the target pointpublic void heading(double degree)
degree - the new orientation of this turtlepublic void init()
public void jumpTo(double x,
double y)
x - the x coordinate of the target positiony - the y coordinate of the target positionpublic void pause()
public void penColor(java.awt.Color color)
penColor - a new pen color for subseqent drawingpublic void penDown()
public void penSize(int penSize)
penSize - the new pen sizepublic void penUp()
public void print(java.lang.String text)
text - the text to printpublic void redraw(java.awt.Graphics g)
g - the Graphics object where this turtle can drawpublic void run()
run in interface java.lang.Runnablepublic void setCanvas(galapagos.DrawingCanvas canvas)
canvas - the object that called this methodpublic void show()
public void speed(int speed)
speed - the new speed of this turtlepublic void start()
public void turn(double degree)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||