ch.aplu.turtle
Class Turtle

java.lang.Object
  extended by 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.


Field Summary
static int APPLETFRAME
          Mode attribute for turtle applets in standalone window
static int STANDARDFRAME
          Mode attribute for normal turtle application (default)
 
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, 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.
Turtle(TurtlePane turtlePane)
          Create a new Turtle in the given TurtlePane.
 
Method Summary
 java.awt.geom.Point2D.Double _getPos()
          Query the Turtle's position without wrapping.
 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 addStatusBar(int height)
          Add a status window attached at the bottom of the game grid window.
 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).
 Turtle beep()
          Emit a beep.
 Turtle bk(double distance)
          Move the Turtle backwards.
 Turtle bong()
          Emit a 'bong' via the sound card.
 Turtle clean()
          Erase all traces and text painted by the turtles, but let all turtles where they are.
 void clear()
          Clear the Turtle's playground.
 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.
 void enableRepaint(boolean b)
          Enable/disable automatic repainting.
 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 as if the Turtle where at 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.
 java.awt.Color getPixelColor()
          Return the color of the pixel at the current turtle position.
 Playground getPlayground()
          Get the Playground.
 java.awt.geom.Point2D.Double getPos()
          Query the Turtle's position
 double getSpeed()
          Get the current speed.
 ch.aplu.turtle.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(tp, 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.
 void repaint()
          Perform manual repainting when automatic repainting is disabled.
 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 setStatusText(java.lang.String text)
          Replace the text in the status bar by the given text using the current JOptionPane font and color.
 void setStatusText(java.lang.String text, java.awt.Font font, java.awt.Color color)
          Replace the text in the status bar by the given text using the given font and text color.
 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.
 void showStatusBar(boolean show)
          Show or hide the status bar.
 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()
          Cause the Turtle to wrap around the playground borders.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

APPLETFRAME

public static int APPLETFRAME
Mode attribute for turtle applets in standalone window


STANDARDFRAME

public static int STANDARDFRAME
Mode attribute for normal turtle application (default)

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,
              java.awt.Color color)
Create a new Turtle with specified color in its own new window and the given menu.


Turtle

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


Turtle

public Turtle(TurtlePane turtlePane)
Create a new Turtle in the given TurtlePane.


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.


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.

Method Detail

toTurtlePos

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


toTurtlePos

public java.awt.geom.Point2D.Double toTurtlePos(int x,
                                                int y)
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


getFrame

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


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.


addKeyListener

public void addKeyListener(java.awt.event.KeyListener l)
Add the specified key listener to receive key events. (Not allowed for embedded applets.)


addWindowListener

public void addWindowListener(java.awt.event.WindowListener l)
Add the specified window listener to receive window events. (Not allowed for embedded applets.)


addWindowFocusListener

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


addComponentListener

public void addComponentListener(java.awt.event.ComponentListener l)
Add the specified component listener to receive component events. (Not allowed for embedded applets.)


addFocusListener

public void addFocusListener(java.awt.event.FocusListener l)
Add the specified focus listener to receive focus events. (Not allowed for embedded applets.)


beep

public Turtle beep()
Emit a beep. Fails if no standard speaker available. Try to use bong() instead.

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

bong

public Turtle bong()
Emit a 'bong' via the sound card. Useful on computers without standard speaker.

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

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).


getTurtleFactory

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

See Also:
TurtleFactory

getPlayground

public Playground getPlayground()
Get the Playground.


getSpeed

public double getSpeed()
Get the current speed.


_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.


getX

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


getY

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


_getPos

public java.awt.geom.Point2D.Double _getPos()
Query the Turtle's position without wrapping. Coordinate are not bound to playground even when wrapping is on.


getPos

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


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.

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.

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.

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.

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 Turtle animation at all. Hiding the Turtle speeds up the graphics enormously.

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()

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()

showTurtle

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

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

isHidden

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

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

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)

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)

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)

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)

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)

left

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

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

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)

right

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

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

forward

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

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

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)

back

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

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

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)

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.

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.

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.

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()

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()

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()

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()

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()

getPen

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

See Also:
Pen

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()

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()

getColor

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


setPenColor

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

Returns:
a reference to the Turtle to allow chaining.

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.

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()

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()

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.

stampTurtle

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

Returns:
a reference to the Turtle to allow chaining.

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.

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.

penWidth

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

Returns:
a reference to the Turtle to allow chaining.

penWidth

public int penWidth()
Query the pen width.


clip

public Turtle clip()
Set the Turtle to clip-mode.

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

wrap

public Turtle wrap()
Cause the Turtle to wrap around the playground borders. e.g when as the Turtle leaves the Window on one side, it reappears on the opposite side.

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

isClip

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

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

isWrap

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

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

fill

public Turtle fill()
Fill the region the Turtle is in.
A region is bounded by lines of any color different to the pixel color at the current turtle position 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 as if the Turtle where at coordinates x and y.
A region is bounded by lines of any color different to the pixel color at the given position and by the border of the window.
(The pen of the Turtle must be down.)

Returns:
a reference to the Turtle to allow chaining.

clean

public Turtle clean()
Erase all traces and text painted by the turtles, but let all turtles where they are.

Returns:
a reference to the Turtle to allow chaining.

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.

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.

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)

getFont

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

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

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

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.

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 tp 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();
}
}


print

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


printScreen

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


printScreen

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


clear

public void clear()
Clear the Turtle's playground. All turtle images and traces are erased, but the turtles remain (invisible) at their positions.


sleep

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


setTitle

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


version

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


enableRepaint

public void enableRepaint(boolean b)
Enable/disable automatic repainting. If disabled, call repaint() to perform repainting. Disabling automatic repainting and hiding the Turtle speeds up the graphics enormously.


repaint

public void repaint()
Perform manual repainting when automatic repainting is disabled.


getPixelColor

public java.awt.Color getPixelColor()
Return the color of the pixel at the current turtle position.


addStatusBar

public void addStatusBar(int height)
Add a status window attached at the bottom of the game grid window. The dialog has no decoration, the same width as the turtle frame and the given height in pixels.


setStatusText

public void setStatusText(java.lang.String text)
Replace the text in the status bar by the given text using the current JOptionPane font and color. The text is left-justified, vertical-centered and may be multi-line. If there is no status bar, nothing happens.


setStatusText

public void setStatusText(java.lang.String text,
                          java.awt.Font font,
                          java.awt.Color color)
Replace the text in the status bar by the given text using the given font and text color. The text is left-justified, vertical-centered and may be multi-line. If there is no status bar, nothing happens.


showStatusBar

public void showStatusBar(boolean show)
Show or hide the status bar. If there is no status bar, nothing happens.