|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--gui.frame.JTurtle
This class is a simple MoboLogo/Slogo turtle model for illustrating rudimentary MVC for turtles and simple Graphics2D concepts
| Method Summary | |
void |
addTurtleListener(TurtleListener listener)
Add a listener. |
void |
clean()
|
void |
draw(java.awt.Graphics context,
javax.swing.JPanel contextField)
Draw the turtle, pass in a Graphics2D object. |
java.awt.Color |
getBackground()
|
java.awt.Rectangle |
getBounds(java.awt.Rectangle r)
Mirrors the functionality of JComponent/Component. |
double |
getHeading()
Returns the naive view of heading, 0 degrees = north |
java.awt.Image |
getImage()
|
static JTurtle |
getInstance()
|
java.awt.geom.Point2D |
getPoint()
Returns the turtle's point (should be centroid) |
boolean |
isVisible()
|
void |
move(int steps)
Moves the turtle forward. |
void |
notifyListeners()
Ask all registered listeners to process this turtle |
void |
reset()
Reposition turtle at the origin, facing north. |
void |
setBackground(java.awt.Color c)
|
void |
setHeading(double radians)
Set heading in radians, notify listeners. |
void |
setHeading(int degrees)
Set heading in degrees, notify listeners. |
void |
setImage(java.awt.Image im)
sets the turtle image depending on what the user chooses |
void |
setPoint(java.awt.geom.Point2D p)
Sets the turtles point, notifies listeners. |
void |
setVisbility(boolean b)
|
protected double |
trueHeading()
Return the real/true heading of the turtle. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
public static JTurtle getInstance()
public java.awt.Rectangle getBounds(java.awt.Rectangle r)
Component.getBounds()public void reset()
public void clean()
public void setImage(java.awt.Image im)
im - image to which to set the turtlepublic java.awt.Image getImage()
public void draw(java.awt.Graphics context,
javax.swing.JPanel contextField)
protected double trueHeading()
public void move(int steps)
steps - is the number of steps movedpublic void setHeading(int degrees)
degrees - will be Turtle's new headingpublic void setHeading(double radians)
public double getHeading()
public java.awt.geom.Point2D getPoint()
public void notifyListeners()
public void addTurtleListener(TurtleListener listener)
listener - is the listener addedpublic void setPoint(java.awt.geom.Point2D p)
p - is the new center pointpublic boolean isVisible()
public void setVisbility(boolean b)
public void setBackground(java.awt.Color c)
public java.awt.Color getBackground()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||