ch.aplu.turtle
Class Turtle

java.lang.Object
  |
  +--ch.aplu.turtle.Turtle
All Implemented Interfaces:
java.lang.Cloneable

public class Turtle
extends java.lang.Object
implements java.lang.Cloneable

The core class for turtles. For a simple example on how to use Turtle, cf. the Java Turtle Package description.


Constructor Summary
Turtle()
          Create a new Turtle in its own new window.
Turtle(boolean show)
          Create a new Turtle with specified visibility in its own new window.
Turtle(java.awt.Color color)
          Create a new Turtle with specified color in its own new window.
Turtle(javax.swing.JMenuBar menuBar)
          Create a new Turtle in its own new window and the given menu.
Turtle(javax.swing.JMenuBar menuBar, boolean show)
          Create a new Turtle with specified visibility in its own new window and the given menu.
Turtle(javax.swing.JMenuBar menuBar, java.awt.Color color)
          Create a new Turtle with specified color in its own new window and the given menu.
Turtle(Turtle otherTurtle)
          Create a new Turtle in the same TurtleContainer (window) as otherTurtle.
Turtle(Turtle otherTurtle, boolean show)
          Create a new Turtle in the same TurtleContainer (window) as otherTurtle with specified visibility.
Turtle(Turtle otherTurtle, java.awt.Color color)
          Create a new Turtle with the specified color in the same TurtleContainer (window) as otherTurtle.
Turtle(TurtleContainer turtleContainer)
          Create a new Turtle in the given TurtleContainer.
Turtle(TurtleContainer turtleContainer, boolean show)
          Create a new Turtle with specified visiblity in the given TurtleContainer.
Turtle(TurtleContainer turtleContainer, java.awt.Color color)
          Create a new Turtle with specified color in the given TurtleContainer.
 
Method Summary
 double _getX()
          Query the Turtle's x-position.
 double _getY()
          Query the Turtle's y-position without wrapping.
 void addComponentListener(java.awt.event.ComponentListener l)
          Add the specified component listener to receive component events.
 void addFocusListener(java.awt.event.FocusListener l)
          Add the specified focus listener to receive focus events.
 void addKeyListener(java.awt.event.KeyListener l)
          Add the specified key listener to receive key events.
 void addMouseListener(java.awt.event.MouseListener l)
          Add the specified mouse listener to receive mouse events.
 void addMouseMotionListener(java.awt.event.MouseMotionListener l)
          Add the specified mouse motion listener to receive mouse motion events.
 void addWindowFocusListener(java.awt.event.WindowFocusListener l)
          Add the specified window focus listener to receive window focus events.
 void addWindowListener(java.awt.event.WindowListener l)
          Add the specified window listener to receive window events.
 Turtle antiAliasing(boolean on)
          Set antialiasing on or off for the turtle trace buffer This may result in an better image quality, especially for filling operations (platform dependant).
 Turtle back(double distance)
          Same as bk(double distance).
 void beep()
          Emit a beep.
 Turtle bk(double distance)
          Move the Turtle backwards.
 Turtle clean()
          Erase all traces and text painted by the turtles.
 Turtle clip()
          Set the Turtle to clip-mode.
 java.lang.Object clone()
          Creates a clone of the Turtle in it's Playground.
 double distance(double x, double y)
          Query the distance from the current location to the given one.
 double distance(java.awt.geom.Point2D.Double p)
          Query the distance from the current location to the given one.
 Turtle fd(double distance)
          Move the Turtle forwards.
 Turtle fill()
          Fill the region the Turtle is in.
 Turtle fill(double x, double y)
          Fill the region with coordinates x and y.
 Turtle forward(double distance)
          Same as fd(double distance)
static java.lang.String[] getAvailableFontFamilies()
          Provide information about all font families (e.g. roman) currently available on your system.
 java.awt.Color getColor()
          Query the Turtle's current color.
 java.awt.Font getFont()
          Return the current font.
 TurtleFrame getFrame()
          Get the TurtleFrame (derivated from JFrame)
 Pen getPen()
          Get the Turtle's Pen.
 Playground getPlayground()
          Get the Playground.
 java.awt.geom.Point2D.Double getPos()
          Query the Turtle's position
 double getSpeed()
          Get the current speed.
 TurtleFactory getTurtleFactory()
          Return the TurtleFactory of this turtle.
 double getX()
          Query the Turtle's x-position.
 double getY()
          Query the Turtle's x-position.
 double heading()
          Query the Turtle's heading.
 double heading(double degrees)
          Set the Turtle's heading to the new value.
 Turtle hideTurtle()
          Hide the Turtle.
 Turtle home()
          Move the Turtle back "home", i.e. set its position to the origin, facing NORTH.
 Turtle ht()
          Hide the Turtle.
 boolean isClip()
          Tell whether the Turtle is in clip mode.
 boolean isHidden()
          Tell whether the Turtle is hidden or not.
 boolean isPenUp()
          Query the Pen's state (up or down).
 boolean isWrap()
          Tell wheter the Turtle is in wrap mode.
 Turtle label(java.lang.String text)
          Paint the specified text at the current turtle position.
 Turtle left(double degrees)
          Same as lt(double degrees)
 Turtle leftCircle(double radius)
          Draw a circle to the left from the current position with turtle's heading tangent direction and given radius.
 Turtle lt(double degrees)
          Turn the Turtle the given angle (in degrees) to the left
 Turtle pd()
          Lowers the Turtle's pen down so it will draw a line when moving.
 Turtle pe()
          The Turtle's Pen is changed to an eraser (which is in fact a pen with background color).
 Turtle penDown()
          Lower the Turtle's Pen down so it will draw a line when moving.
 Turtle penErase()
          The Turtle's Pen is changed to an eraser (which is in fact a pen with background color).
 Turtle penUp()
          Lift the Turtle's pen up so it won't draw a line anymore.
 int penWidth()
          Query the pen width.
 Turtle penWidth(int newWidth)
          Set the pen width.
 boolean print(TPrintable tp)
          Same as print(gp, scale) with scale = 1.
 boolean print(TPrintable tp, double scale)
          Print the graphics context to an attached printer with the given magnification scale factor.
 boolean printScreen()
          Same as printScreen(scale) with scale = 1.
 boolean printScreen(double scale)
          Print the Turtle's current playground with given scale.
 Turtle pu()
          Lift the Turtle's pen up so it won't draw a line anymore.
 Turtle right(double degrees)
          Same as rt(double degrees).
 Turtle rightCircle(double radius)
          Draw a circle to the right from the current position with turtle's heading tangent direction and given radius.
 Turtle rt(double degrees)
          Turn the Turtle the given angle (in degrees) to the right.
 Turtle setAngleResolution(int newResolution)
          Set the angle resolution for the Turtle's pictures.
 Turtle setColor(java.awt.Color color)
          Set the Turtle's color to the specified one.
 Turtle setFillColor(java.awt.Color color)
          Set the color to the specified one.
 Turtle setFont(java.awt.Font font)
          Set the current font as specified.
 Turtle setFont(java.lang.String fontName, int style, int size)
          Change the current font to the specified one.
 Turtle setFontSize(int size)
          Set the font size.
 Turtle setFontStyle(int style)
          Set the font style.
 Turtle setH(double degrees)
          Set the Turtle's heading. 0 means facing NORTH.
 Turtle setHeading(double degrees)
          This is the same as setH(double degrees).
 Turtle setLineWidth(double lineWidth)
          Set the line thickness.
 Turtle setLineWidth(float lineWidth)
          Set the line thickness.
 Turtle setPenColor(java.awt.Color color)
          Set the Turtle's pen color.
 Turtle setPos(double x, double y)
          Put the Turtle to a new position with specified x- and y-coordinates.
 Turtle setPos(java.awt.geom.Point2D.Double p)
          Put the Turtle to a new position.
 Turtle setScreenPos(java.awt.Point p)
          Put the Turtle to a new screen position.
 Turtle setScreenX(int x)
          Put the Turtle to a new position with the given screen x-coordinates.
 Turtle setScreenY(int y)
          Put the Turtle to a new position with the given screen y-coordinates.
 void setTitle(java.lang.String text)
          Set the title of Turtle's playground
 Turtle setX(double x)
          Put the Turtle to a new position with the given x-coordinates.
 Turtle setY(double y)
          Put the Turtle to a new position with the given y-coordinates.
 Turtle showTurtle()
          The same as st().
static void sleep(int time)
          Delay execution for the given amount of time ( in ms ).
 Turtle speed(double speed)
          Set the Turtle's speed.
 Turtle st()
          Set the Turtle to show mode.
 Turtle stampTurtle()
          Put a Turtle image at the current position.
 Turtle toBottom()
          Put this turtle to the bottom.
 Turtle toTop()
          Put this turtle to the top.
 java.awt.geom.Point2D.Double toTurtlePos(int x, int y)
          Convert from screen coordinates to turtle coordinates
 java.awt.geom.Point2D.Double toTurtlePos(java.awt.Point p)
          Convert from screen coordinates to turtle coordinates
 double toTurtleX(int x)
          Convert from screen coordinates to turtle coordinates
 double toTurtleY(int y)
          Convert from screen coordinates to turtle coordinates
 double towards(double x, double y)
          Calculate the direction to a given point.
 double towards(java.awt.geom.Point2D.Double p)
          Calculate the direction to a given point.
 java.lang.String version()
          Return version information
 Turtle wrap()
          Causes the Turtle to wrap around the edges.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Turtle

public Turtle()
Create a new Turtle in its own new window.


Turtle

public Turtle(boolean show)
Create a new Turtle with specified visibility in its own new window.


Turtle

public Turtle(java.awt.Color color)
Create a new Turtle with specified color in its own new window.


Turtle

public Turtle(javax.swing.JMenuBar menuBar)
Create a new Turtle in its own new window and the given menu.


Turtle

public Turtle(javax.swing.JMenuBar menuBar,
              boolean show)
Create a new Turtle with specified visibility in its own new window and the given menu.


Turtle

public Turtle(javax.swing.JMenuBar menuBar,
              java.awt.Color color)
Create a new Turtle with specified color in its own new window and the given menu.


Turtle

public Turtle(Turtle otherTurtle)
Create a new Turtle in the same TurtleContainer (window) as otherTurtle.


Turtle

public Turtle(Turtle otherTurtle,
              boolean show)
Create a new Turtle in the same TurtleContainer (window) as otherTurtle with specified visibility.


Turtle

public Turtle(Turtle otherTurtle,
              java.awt.Color color)
Create a new Turtle with the specified color in the same TurtleContainer (window) as otherTurtle.


Turtle

public Turtle(TurtleContainer turtleContainer)
Create a new Turtle in the given TurtleContainer.


Turtle

public Turtle(TurtleContainer turtleContainer,
              boolean show)
Create a new Turtle with specified visiblity in the given TurtleContainer.


Turtle

public Turtle(TurtleContainer turtleContainer,
              java.awt.Color color)
Create a new Turtle with specified color in the given TurtleContainer.

Method Detail

_getX

public double _getX()
Query the Turtle's x-position. Coordinate are not bound to playground even when wrapping is on.


_getY

public double _getY()
Query the Turtle's y-position without wrapping. Coordinate are not bound to playground even when wrapping is on.


addComponentListener

public void addComponentListener(java.awt.event.ComponentListener l)
Add the specified component listener to receive component events.


addFocusListener

public void addFocusListener(java.awt.event.FocusListener l)
Add the specified focus listener to receive focus events.


addKeyListener

public void addKeyListener(java.awt.event.KeyListener l)
Add the specified key listener to receive key events.


addMouseListener

public void addMouseListener(java.awt.event.MouseListener l)
Add the specified mouse listener to receive mouse events.


addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener l)
Add the specified mouse motion listener to receive mouse motion events.


addWindowFocusListener

public void addWindowFocusListener(java.awt.event.WindowFocusListener l)
Add the specified window focus listener to receive window focus events.


addWindowListener

public void addWindowListener(java.awt.event.WindowListener l)
Add the specified window listener to receive window events.


antiAliasing

public Turtle antiAliasing(boolean on)
Set antialiasing on or off for the turtle trace buffer This may result in an better image quality, especially for filling operations (platform dependant).

Returns:
a reference to the Turtle to allow chaining.

back

public Turtle back(double distance)
Same as bk(double distance).

Returns:
a reference to the Turtle to allow chaining.
See Also:
bk(double)

beep

public void beep()
Emit a beep.


bk

public Turtle bk(double distance)
Move the Turtle backwards. Negative values for distance are allowed. In that case, the Turtle will move forwards.

Returns:
a reference to the Turtle to allow chaining.
See Also:
fd(double)

clean

public Turtle clean()
Erase all traces and text painted by the turtles.

Returns:
a reference to the Turtle to allow chaining.

clip

public Turtle clip()
Set the Turtle to clip-mode. It could be that the Turtle moves beyond the edge of the window. You won't see it anymore unless it finds its way back :-)
The default edge behaviour is clipping.

Returns:
a reference to the Turtle to allow chaining.
See Also:
wrap(), #clips()

clone

public java.lang.Object clone()
Creates a clone of the Turtle in it's Playground. Color, position and heading are the same. (It's visible and pen is down.) Return the cloned object reference as a Object type, because it overrides Object.clone(). (You may cast it to a Turtle.)

Overrides:
clone in class java.lang.Object

distance

public double distance(double x,
                       double y)
Query the distance from the current location to the given one.

Returns:
a reference to the Turtle to allow chaining.

distance

public double distance(java.awt.geom.Point2D.Double p)
Query the distance from the current location to the given one. Actually a polygon with 36 sides is drawn.

Returns:
a reference to the Turtle to allow chaining.

fd

public Turtle fd(double distance)
Move the Turtle forwards. Negative values for distance are allowed. In that case, the Turtle will move backwards.

Returns:
a reference to the Turtle to allow chaining.
See Also:
bk(double)

fill

public Turtle fill()
Fill the region the Turtle is in. A region is bounded by lines of any other color than the background color and by the border of the window.
(The pen of the Turtle must be down.)

Returns:
a reference to the Turtle to allow chaining.

fill

public Turtle fill(double x,
                   double y)
Fill the region with coordinates x and y. A region is bounded by lines of any other color than the background color and by the border of the window.
(The pen of the Turtle must be down.)

Returns:
a reference to the Turtle to allow chaining.

forward

public Turtle forward(double distance)
Same as fd(double distance)

Returns:
a reference to the Turtle to allow chaining.
See Also:
fd(double)

getAvailableFontFamilies

public static java.lang.String[] getAvailableFontFamilies()
Provide information about all font families (e.g. roman) currently available on your system. Each font name is a string packed into a array of strings. (This might be useful when you want to change the font.)

See Also:
setFont(java.awt.Font), setFont(java.lang.String, int, int)

getColor

public java.awt.Color getColor()
Query the Turtle's current color.


getFont

public java.awt.Font getFont()
Return the current font.

See Also:
changing the font size, changing the font style, changing the whole font.

getFrame

public TurtleFrame getFrame()
Get the TurtleFrame (derivated from JFrame)


getPen

public Pen getPen()
Get the Turtle's Pen. You need it if you want to change end caps etc.

See Also:
Pen

getPlayground

public Playground getPlayground()
Get the Playground.


getPos

public java.awt.geom.Point2D.Double getPos()
Query the Turtle's position


getSpeed

public double getSpeed()
Get the current speed.


getTurtleFactory

public TurtleFactory getTurtleFactory()
Return the TurtleFactory of this turtle.

See Also:
TurtleFactory

getX

public double getX()
Query the Turtle's x-position. If turtle is outside playground and wrapping is on return the coordinate in range -200..200.


getY

public double getY()
Query the Turtle's x-position. If turtle is outside playground and wrapping is on return the coordinate in range -200..200.


heading

public double heading()
Query the Turtle's heading.

See Also:
setH(double)

heading

public double heading(double degrees)
Set the Turtle's heading to the new value.

Returns:
the old (previous) value.
See Also:
setH(double)

hideTurtle

public Turtle hideTurtle()
Hide the Turtle. This is the same as ht().

Returns:
a reference to the Turtle to allow chaining.
See Also:
st()

home

public Turtle home()
Move the Turtle back "home", i.e. set its position to the origin, facing NORTH. Color, PenColor etc. remain the same.

Returns:
a reference to the Turtle to allow chaining.
See Also:
#reinit()

ht

public Turtle ht()
Hide the Turtle.

Returns:
a reference to the Turtle to allow chaining.
See Also:
If there is only one turte, the speed is set to -1 so there is no animation at all.

isClip

public boolean isClip()
Tell whether the Turtle is in clip mode.

Returns:
true if in clip mode, false otherwise.
See Also:
clip(), #wraps()

isHidden

public boolean isHidden()
Tell whether the Turtle is hidden or not.

Returns:
true if the Turtle is hidden, false otherwise.

isPenUp

public boolean isPenUp()
Query the Pen's state (up or down).

Returns:
true if the Pen is up, false otherwise.
See Also:
pu(), pd()

isWrap

public boolean isWrap()
Tell wheter the Turtle is in wrap mode.

Returns:
true if in wrap mode, false otherwise.
See Also:
wrap(), #clips()

label

public Turtle label(java.lang.String text)
Paint the specified text at the current turtle position.

Returns:
a reference to the Turtle to allow chaining.

left

public Turtle left(double degrees)
Same as lt(double degrees)

Returns:
a reference to the Turtle to allow chaining.
See Also:
lt(double)

leftCircle

public Turtle leftCircle(double radius)
Draw a circle to the left from the current position with turtle's heading tangent direction and given radius. Actually a polygon with 36 sides is drawn.

Returns:
a reference to the Turtle to allow chaining.

lt

public Turtle lt(double degrees)
Turn the Turtle the given angle (in degrees) to the left

Returns:
a reference to the Turtle to allow chaining.
See Also:
rt(double)

pd

public Turtle pd()
Lowers the Turtle's pen down so it will draw a line when moving. This is the same as penDown().

Returns:
a reference to the Turtle to allow chaining.
See Also:
penDown(), penUp(), pu()

pe

public Turtle pe()
The Turtle's Pen is changed to an eraser (which is in fact a pen with background color). This is the same as penErase()

Returns:
a reference to the Turtle to allow chaining.
See Also:
penErase()

penDown

public Turtle penDown()
Lower the Turtle's Pen down so it will draw a line when moving. This is the same as pd().

Returns:
a reference to the Turtle to allow chaining.
See Also:
pd(), penUp(), pu()

penErase

public Turtle penErase()
The Turtle's Pen is changed to an eraser (which is in fact a pen with background color). This is the same as pe()

Returns:
a reference to the Turtle to allow chaining.
See Also:
pe()

penUp

public Turtle penUp()
Lift the Turtle's pen up so it won't draw a line anymore. This is the same as pu().

Returns:
a reference to the Turtle to allow chaining.
See Also:
pu(), penDown(), pd()

penWidth

public int penWidth()
Query the pen width.


penWidth

public Turtle penWidth(int newWidth)
Set the pen width.

Returns:
a reference to the Turtle to allow chaining.

print

public boolean print(TPrintable tp)
Same as print(gp, scale) with scale = 1.


print

public boolean print(TPrintable tp,
                     double scale)
Print the graphics context to an attached printer with the given magnification scale factor. scale = 1 will print on standard A4 format paper.
The given gp must implement the GPrintable interface, e.g. the single method void draw(), where all the drawing into the GPanel must occur. Be aware the turtle(s) state (position, direction, etc.) must be reinitialized, because draw() is called several times by the printing system. A standard printer dialog is shown before printing is started. Only turte traces are printed.
Example:
import ch.aplu.turtle.*;

public class PrintTest implements TPrintable
{
private Turtle t = new Turtle();

public PrintTest()
{
draw(); // Draw on screen
t.print(this); // Draw on printer
}

public void draw()
{
t.home(); // Needed for initialization
for (int i = 0; i < 5; i++)
t.fd(20).rt(90).fd(20).lt(90);
}

public static void main(String[] args)
{
new PrintTest();
}
}


printScreen

public boolean printScreen()
Same as printScreen(scale) with scale = 1.


printScreen

public boolean printScreen(double scale)
Print the Turtle's current playground with given scale.


pu

public Turtle pu()
Lift the Turtle's pen up so it won't draw a line anymore. This is the same as penUp().

Returns:
a reference to the Turtle to allow chaining.
See Also:
penUp(), penDown(), pd()

right

public Turtle right(double degrees)
Same as rt(double degrees).

Returns:
a reference to the Turtle to allow chaining.
See Also:
rt(double)

rightCircle

public Turtle rightCircle(double radius)
Draw a circle to the right from the current position with turtle's heading tangent direction and given radius. Actually a polygon with 36 sides is drawn.

Returns:
a reference to the Turtle to allow chaining.

rt

public Turtle rt(double degrees)
Turn the Turtle the given angle (in degrees) to the right.

Returns:
a reference to the Turtle to allow chaining.
See Also:
rt(double)

setAngleResolution

public Turtle setAngleResolution(int newResolution)
Set the angle resolution for the Turtle's pictures. It specifies how many pictures are used. e.g. an angle resolution of 90 means that you get one picture for every 4 degrees (= 360/90 degrees).

See Also:
#DEFAULT_ANGLE_RESOLUTION

setColor

public Turtle setColor(java.awt.Color color)
Set the Turtle's color to the specified one.

Returns:
a reference to the Turtle to allow chaining.

setFillColor

public Turtle setFillColor(java.awt.Color color)
Set the color to the specified one.

Returns:
a reference to the Turtle to allow chaining.
See Also:
fill()

setFont

public Turtle setFont(java.awt.Font font)
Set the current font as specified.

Returns:
a reference to the Turtle to allow chaining.
See Also:
Font

setFont

public Turtle setFont(java.lang.String fontName,
                      int style,
                      int size)
Change the current font to the specified one. If you want to know what fonts are available on your system, call #getAvailableFontFamilies() .

See Also:
getAvailableFontFamilies(), more information about fontName, style and size.

setFontSize

public Turtle setFontSize(int size)
Set the font size.

Returns:
a reference to the Turtle to allow chaining.
See Also:
changing the font style, changing the whole font.

setFontStyle

public Turtle setFontStyle(int style)
Set the font style. This is either java.awt.Font.PLAIN, java.awt.Font.BOLD, java.awt.Font.ITALIC or java.awt.Font.BOLD+java.awt.Font.ITALIC

Returns:
a reference to the Turtle to allow chaining.
See Also:
changing the font size, changing the whole font.

setH

public Turtle setH(double degrees)
Set the Turtle's heading. 0 means facing NORTH.
the angles are measured clockwise.

Returns:
a reference to the Turtle to allow chaining.
See Also:
setHeading(double)

setHeading

public Turtle setHeading(double degrees)
This is the same as setH(double degrees).

Returns:
a reference to the Turtle to allow chaining.
See Also:
setH(double)

setLineWidth

public Turtle setLineWidth(double lineWidth)
Set the line thickness. This works only neatly in clip mode (yet).

See Also:
clip(), wrap()

setLineWidth

public Turtle setLineWidth(float lineWidth)
Set the line thickness. This works only neatly in clip mode (yet).

See Also:
clip(), wrap()

setPenColor

public Turtle setPenColor(java.awt.Color color)
Set the Turtle's pen color.

Returns:
a reference to the Turtle to allow chaining.

setPos

public Turtle setPos(double x,
                     double y)
Put the Turtle to a new position with specified x- and y-coordinates.

Returns:
a reference to the Turtle to allow chaining.

setPos

public Turtle setPos(java.awt.geom.Point2D.Double p)
Put the Turtle to a new position.

Returns:
the a reference to Turtle to allow chaining.

setScreenPos

public Turtle setScreenPos(java.awt.Point p)
Put the Turtle to a new screen position.

Returns:
a reference to the Turtle to allow chaining.

setScreenX

public Turtle setScreenX(int x)
Put the Turtle to a new position with the given screen x-coordinates.

Returns:
a reference to theTurtle to allow chaining.

setScreenY

public Turtle setScreenY(int y)
Put the Turtle to a new position with the given screen y-coordinates.

Returns:
a reference to the Turtle to allow chaining.

setTitle

public void setTitle(java.lang.String text)
Set the title of Turtle's playground


setX

public Turtle setX(double x)
Put the Turtle to a new position with the given x-coordinates.

Returns:
a reference to the Turtle to allow chaining.

setY

public Turtle setY(double y)
Put the Turtle to a new position with the given y-coordinates.

Returns:
a reference to the Turtle to allow chaining.

showTurtle

public Turtle showTurtle()
The same as st().

Returns:
a reference to the Turtle to allow chaining.
See Also:
st()

sleep

public static void sleep(int time)
Delay execution for the given amount of time ( in ms ).


speed

public Turtle speed(double speed)
Set the Turtle's speed. If you try to set the speed to 0, it will be set to 1 (very slow). A negative speed means that moving the Turtle (fd, bk) will not be animated.
The unit is pixels per second (up to certain bounds depending on the CPU etc.).
Remark: Dashed lines will only be painted as you expect it with speed set to -1.

Returns:
a reference to the Turtle reference to allow chaining.
See Also:
fd(double), bk(double)

st

public Turtle st()
Set the Turtle to show mode. That means that the Turtle will be drawn.

Returns:
a reference to the Turtle to allow chaining.
See Also:
ht()

stampTurtle

public Turtle stampTurtle()
Put a Turtle image at the current position.

Returns:
a reference to the Turtle to allow chaining.

toBottom

public Turtle toBottom()
Put this turtle to the bottom. So any other turtle in the same Playground will be drawn over it.

Returns:
a reference to the Turtle to allow chaining.

toTop

public Turtle toTop()
Put this turtle to the top. So it will be drawn over any other turtle in the same Playground.

Returns:
a reference to the Turtle to allow chaining.

toTurtlePos

public java.awt.geom.Point2D.Double toTurtlePos(int x,
                                                int y)
Convert from screen coordinates to turtle coordinates


toTurtlePos

public java.awt.geom.Point2D.Double toTurtlePos(java.awt.Point p)
Convert from screen coordinates to turtle coordinates


toTurtleX

public double toTurtleX(int x)
Convert from screen coordinates to turtle coordinates


toTurtleY

public double toTurtleY(int y)
Convert from screen coordinates to turtle coordinates


towards

public double towards(double x,
                      double y)
Calculate the direction to a given point.

Returns:
the direction from the current turtle position towards the given point, measured in degrees and clockwise from the vertical upwards position.

towards

public double towards(java.awt.geom.Point2D.Double p)
Calculate the direction to a given point.

Returns:
the direction from the current turtle position towards the given point, measured in degrees and clockwise from the vertical upwards position.

version

public java.lang.String version()
Return version information


wrap

public Turtle wrap()
Causes the Turtle to wrap around the edges. This means: as soon as the Turtle leaves the Window on one side, it re- appears on the opposite side.

Returns:
a reference to the Turtle to allow chaining.
See Also:
clip()