|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object SimpleTurtle
Class that represents a Logo-style turtle. The turtle starts off facing north. A turtle can have a name, has a starting x and y position, has a heading, has a width, has a height, has a visible flag, has a body color, can have a shell color, and has a pen. The turtle will not go beyond the model display or picture boundaries. You can display this turtle in either a picture or in a class that implements ModelDisplay. Copyright Georgia Institute of Technology 2004
Constructor Summary | |
SimpleTurtle(int x,
int y)
Constructor that takes the x and y position for the turtle |
|
SimpleTurtle(int x,
int y,
ModelDisplay display)
Constructor that takes the x and y position and the model displayer |
|
SimpleTurtle(int x,
int y,
Picture picture)
Constructor that takes the x and y position and the picture to draw on |
|
SimpleTurtle(ModelDisplay display)
Constructor that takes a model display and adds a turtle in the middle of it |
|
SimpleTurtle(Picture picture)
Constructor that takes the picture to draw on and will appear in the middle |
Method Summary | |
void |
backward()
Method to go backward by 100 pixels |
void |
backward(int pixels)
Method to go backward a given number of pixels |
void |
clearPath()
Method to clear the path (history of where the turtle has been) |
void |
drawInfoString(java.awt.Graphics g)
Method to draw the information string |
void |
drop(Picture dropPicture)
Method to draw a passed picture at the current turtle location and rotation in a picture or model display |
void |
forward()
Method to move the turtle foward 100 pixels |
void |
forward(int pixels)
Method to move the turtle forward the given number of pixels |
java.awt.Color |
getBodyColor()
Method to get the body color |
double |
getDistance(int x,
int y)
Get the distance from the passed x and y location |
double |
getHeading()
Method to get the current heading |
int |
getHeight()
Method to return the height of this object |
java.awt.Color |
getInfoColor()
Method to get the information color |
ModelDisplay |
getModelDisplay()
Method to get the model display for this simple turtle |
java.lang.String |
getName()
Method to get the name of the turtle |
Pen |
getPen()
Method to get the pen |
java.awt.Color |
getPenColor()
Method to get the pen color |
int |
getPenWidth()
Method to get the pen width |
Picture |
getPicture()
Method to get the picture for this simple turtle |
java.awt.Color |
getShellColor()
Method to get the shell color |
boolean |
getShowInfo()
Method to get value of show info |
int |
getWidth()
Method to return the width of this object |
int |
getXPos()
Method to get the current x position |
int |
getYPos()
Method to get the current y position |
void |
hide()
Method to hide the turtle (stop showing it) This doesn't affect the pen status |
boolean |
isPenDown()
Method to check if the pen is down |
boolean |
isVisible()
Method to get the value of the visible flag |
void |
moveTo(int x,
int y)
Method to move to turtle to the given x and y location |
void |
paintComponent(java.awt.Graphics g)
Method to paint the turtle |
void |
penDown()
Method to set the pen down |
void |
penUp()
Method to lift the pen up |
void |
setBodyColor(java.awt.Color color)
Method to set the body color which will also set the pen color |
void |
setColor(java.awt.Color color)
Method to set the color of the turtle. |
void |
setHeading(double heading)
Method to set the heading |
void |
setHeight(int theHeight)
Method to set the height of this object |
void |
setInfoColor(java.awt.Color color)
Method to set the information color |
void |
setModelDisplay(ModelDisplay theModelDisplay)
Method to set the model display for this simple turtle |
void |
setName(java.lang.String theName)
Method to set the name of the turtle |
void |
setPen(Pen thePen)
Method to set the pen |
void |
setPenColor(java.awt.Color color)
Method to set the pen color |
void |
setPenDown(boolean value)
Method to set the pen down boolean variable |
void |
setPenWidth(int width)
Method to set the pen width |
void |
setPicture(Picture pict)
Method to set the picture for this simple turtle |
void |
setShellColor(java.awt.Color color)
Method to set the shell color |
void |
setShowInfo(boolean value)
Method to show the turtle information string |
void |
setVisible(boolean value)
Method to set the visible flag |
void |
setWidth(int theWidth)
Method to set the width of this object |
void |
show()
Method to show the turtle (doesn't affect the pen status |
java.lang.String |
toString()
Method to return a string with informaiton about this turtle |
void |
turn(int degrees)
Method to turn the turtle the passed degrees use negative to turn left and pos to turn right |
void |
turnLeft()
Method to turn left |
void |
turnRight()
Method to turn right |
void |
turnToFace(int x,
int y)
Method to turn towards the given x and y |
void |
turnToFace(SimpleTurtle turtle)
Method to turn to face another simple turtle |
void |
updateDisplay()
Method to update the display of this turtle and also check that the turtle is in the bounds |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public SimpleTurtle(int x, int y)
x
- the x posy
- the y pospublic SimpleTurtle(int x, int y, ModelDisplay display)
x
- the x posy
- the y posdisplay
- the model displaypublic SimpleTurtle(ModelDisplay display)
display
- the model displaypublic SimpleTurtle(int x, int y, Picture picture)
x
- the x posy
- the y pospicture
- the picture to draw onpublic SimpleTurtle(Picture picture)
picture
- the picture to draw onMethod Detail |
public double getDistance(int x, int y)
x
- the x locationy
- the y locationpublic void turnToFace(SimpleTurtle turtle)
public void turnToFace(int x, int y)
x
- the x to turn towardsy
- the y to turn towardspublic Picture getPicture()
public void setPicture(Picture pict)
pict
- the picture to usepublic ModelDisplay getModelDisplay()
public void setModelDisplay(ModelDisplay theModelDisplay)
theModelDisplay
- the model display to usepublic boolean getShowInfo()
public void setShowInfo(boolean value)
value
- the value to set showInfo topublic java.awt.Color getShellColor()
public void setShellColor(java.awt.Color color)
color
- the color to usepublic java.awt.Color getBodyColor()
public void setBodyColor(java.awt.Color color)
color
- the color to usepublic void setColor(java.awt.Color color)
color
- the color to usepublic java.awt.Color getInfoColor()
public void setInfoColor(java.awt.Color color)
color
- the new color to usepublic int getWidth()
public int getHeight()
public void setWidth(int theWidth)
theWidth
- in width in pixelspublic void setHeight(int theHeight)
theHeight
- the height in pixelspublic int getXPos()
public int getYPos()
public Pen getPen()
public void setPen(Pen thePen)
thePen
- the new pen to usepublic boolean isPenDown()
public void setPenDown(boolean value)
value
- the value to set it topublic void penUp()
public void penDown()
public java.awt.Color getPenColor()
public void setPenColor(java.awt.Color color)
color
- the color for the pen inkpublic void setPenWidth(int width)
width
- the width to use in pixelspublic int getPenWidth()
public void clearPath()
public double getHeading()
public void setHeading(double heading)
heading
- the new heading to usepublic java.lang.String getName()
public void setName(java.lang.String theName)
theName
- the new name to usepublic boolean isVisible()
public void hide()
public void show()
public void setVisible(boolean value)
value
- the value to set it topublic void updateDisplay()
public void forward()
public void forward(int pixels)
pixels
- the number of pixels to walk forward in the heading directionpublic void backward()
public void backward(int pixels)
pixels
- the number of pixels to walk backwardpublic void moveTo(int x, int y)
x
- the x value to move toy
- the y value to move topublic void turnLeft()
public void turnRight()
public void turn(int degrees)
degrees
- the amount to turn in degreespublic void drop(Picture dropPicture)
dropPicture
- the picture to droppublic void paintComponent(java.awt.Graphics g)
g
- the graphics context to paint onpublic void drawInfoString(java.awt.Graphics g)
g
- the graphics contextpublic java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |