public class Turtle
extends java.lang.Object
implements java.lang.Cloneable
================ UML diagram ===========================================
----------- -------------------------- ------------
|JPanel | |interface | |JFrame |
|-----------| |TurtleContainer | |----------- |
| | |--------------------------| | |
| | |Playground getPlayground()| | |
----------- -------------------------- ------------
^ ^ ^
| is-a | |
| | |
----------- | |
|class | | | is-a
|Playground | |implements |
|-----------| | |
| | | |
| | | -------------
----------- | |
^ o --------------------------------
| | |class |
| | has-a |TurtleFrame |
| | (creates) |------------------------------- |
| ----------------- |TurtleFrame(...new Playground())|
| is-a |Playground playground |
| --------------------------------
---------- o
|class | | has-a (creates)
|TurtlePane| |
|----------| |
| | --------------------------------
| | |class |
---------- |Turtle |
|------------------------------- |
|TurtleFrame turtleFrame |
| |
--------------------------------
========================================================================
Modifier and Type | Field and Description |
---|---|
static int |
APPLETFRAME
Mode attribute for turtle applets in a standalone window
(value: 1).
|
static int |
ASK_ON_CLOSE
Mode attribute for a turtle frame that opens a confirm dialog when
the close button is hit (value: 3).
|
static java.awt.Color |
BLACK |
static java.awt.Color |
BLUE
Short for Color.BLUE.
|
static int |
CLEAR_ON_CLOSE
Mode attribute for a turtle frame that calls Turtle.clear() when
the close button is hit (value: 2).
|
static java.awt.Color |
CYAN
Short for Color.CYAN.
|
static int |
DISPOSE_ON_CLOSE
Mode attribute for a turtle frame that closes the turtle frame
and releases grapics resources (value: 4), but does not call
System.exit().
|
static java.awt.Color |
DKGRAY
Short for Color.GRAY.
|
static java.awt.Color |
GRAY
Short for Color.GRAY.
|
static java.awt.Color |
GREEN
Short for Color.GREEN.
|
static java.awt.Color |
LTGRAY
Short for Color.LIGHT_GRAY.
|
static java.awt.Color |
MAGENTA
Short for Color.MAGENTA.
|
static int |
NOTHING_ON_CLOSE
Mode attribute for a turtle frame that does nothing when
the close button is hit (value: -1).
|
static java.awt.Color |
RED
Short for Color.RED.
|
static int |
RELEASE_ON_CLOSE
Mode attribute for a turtle frame that closes the turtle frame
by disposing all resources (value: 5), but does not call
System.exit().
|
static int |
STANDARDFRAME
Mode attribute for normal turtle applications (default, value: 0).
|
static java.awt.Color |
WHITE
Short for Color.WHITE.
|
static java.awt.Color |
YELLOW
Short for Color.YELLOW.
|
Constructor and Description |
---|
Turtle()
Creates a new turtle in its own new window.
|
Turtle(boolean show)
Creates a new turtle with specified visibility
in its own new window.
|
Turtle(java.awt.Color color)
Creates a new turtle with specified color in its own new window.
|
Turtle(javax.swing.JMenuBar menuBar,
java.awt.Color color)
Creates a new turtle with specified color in its own new window
with the given menu.
|
Turtle(java.lang.String colorStr)
Creates a new turtle with specified color as string in its own new window.
|
Turtle(Turtle otherTurtle)
Creates a new turtle in the same TurtleContainer (window) as
the given turtle.
|
Turtle(Turtle otherTurtle,
boolean show)
Creates a new turtle in the same
TurtleContainer (window) as
the given turtle and specifies its visibility.
|
Turtle(Turtle otherTurtle,
java.awt.Color color)
Creates a new turtle with the specified color in the same
TurtleContainer (window) as the given turtle.
|
Turtle(TurtleContainer turtleContainer)
Creates a new turtle in the given TurtleContainer.
|
Turtle(TurtleContainer turtleContainer,
boolean show)
Creates a new turtle with specified visibility
in the given TurtleContainer.
|
Turtle(TurtleContainer turtleContainer,
java.awt.Color color)
Creates a new turtle with specified color
in the given TurtleContainer.
|
Turtle(TurtleContainer turtleContainer,
java.lang.String colorStr)
Creates a new turtle with specified color as a string
in the given TurtleContainer.
|
Turtle(TurtlePane turtlePane)
Creates a new turtle in the given TurtlePane.
|
Turtle(Turtle otherTurtle,
java.lang.String colorStr)
Creates a new turtle with specified color as string
in the same TurtleContainer (window) as the given turtle.
|
Modifier and Type | Method and Description |
---|---|
java.awt.geom.Point2D.Double |
_getPos()
Returns the current unbounded turtle position.
|
double |
_getX()
Returns the current unbounded turtle's x-coordinate.
|
double |
_getY()
Returns the current unbounded turtle's y-coordinate.
|
void |
_sleep(int time)
Non-static version of sleep().
|
void |
addComponentListener(java.awt.event.ComponentListener listener)
Adds the specified ComponentListener to receive component events.
|
void |
addExitListener(ExitListener listener)
Adds the specifiec ExitListener to get a notification when the close button is clicked.
|
void |
addFocusListener(java.awt.event.FocusListener listener)
Adds the specified FocusListener to receive focus events.
|
void |
addKeyListener(java.awt.event.KeyListener listener)
Adds the specified KeyListener to receive key events.
|
void |
addMouseDoubleClickListener(MouseDoubleClickListener listener)
Adds the specified MouseDoubleClickListener to receive mouse events.
|
void |
addMouseHitListener(MouseHitListener listener)
Adds the specified mouse-hit listener to receive mouse events.
|
void |
addMouseHitXListener(MouseHitXListener listener)
Adds the specified MouseHitXListener to receive mouse events.
|
void |
addMouseListener(java.awt.event.MouseListener listener)
Adds the specified MouseListener to receive mouse events.
|
void |
addMouseMotionListener(java.awt.event.MouseMotionListener listener)
Adds the specified MouseMotionListener to receive mouse motion events.
|
void |
addStatusBar(int height)
Adds a status window attached at the bottom of the game grid window.
|
void |
addTurtleHitListener(TurtleHitListener listener)
Adds the specified turtle-hit listener to receive mouse events when
the mouse cursor is inside the turtle image.
|
void |
addWindowFocusListener(java.awt.event.WindowFocusListener listener)
Adds the specified WindowFocusListener to receive window focus events.
|
void |
addWindowListener(java.awt.event.WindowListener listener)
Adds the specified WindowListener to receive window events.
|
Turtle |
antiAliasing(boolean on)
Sets anti-aliasing (for the turtle trace buffer) on or off.
|
Turtle |
back(double distance)
Same as bk().
|
Turtle |
beep()
Emits a 'beep'.
|
Turtle |
bk(double distance)
Moves the turtle backwards.
|
Turtle |
clean()
Clears the turtle's playground.
|
Turtle |
clean(java.awt.Color color)
Clears the turtle's playground but painting it with the given color.
|
Turtle |
clean(java.lang.String colorStr)
Clears the turtle's playground but painting it with the given color.
|
Turtle |
clear()
Clears the turtle's playground.
|
Turtle |
clear(java.awt.Color color)
Clears the turtle's playground but painting it with the given color.
|
Turtle |
clear(java.lang.String colorStr)
Clears the turtle's playground but painting it with the given color.
|
Turtle |
clearStates()
Empties the state buffer.
|
Turtle |
clip()
Sets the turtle to clip mode.
|
java.lang.Object |
clone()
Creates a partial clone of the turtle.
|
double |
direction(double x,
double y)
Returns the relative direction to a given position.
|
double |
direction(java.awt.geom.Point2D.Double pt)
Returns the direction to a given position.
|
double |
direction(Turtle otherTurtle)
Returns the relative direction to a given other turtle.
|
void |
dispose()
Disposes the TurtleFrame.
|
double |
distance(double x,
double y)
Returns the distance between the current turtle position and the
given position,
The turtle position is bounded to the playground.
|
double |
distance(java.awt.geom.Point2D.Double pt)
Returns the distance between the current turtle position and the
given position,
The turtle position is bounded to the playground.
|
double |
distance(Turtle otherTurtle)
Returns the distance between the current turtle position and an other turtle.
|
Turtle |
dot(double diameter)
Draws a dot (filled circle) at the current turtle position using the
current pen color.
|
Turtle |
drawBkImage(java.lang.String imagePath)
Draws the given image into the background (trace buffer).
|
Turtle |
drawImage(java.awt.image.BufferedImage bi)
Draws the given image into background with the image center at
the current turtle position and rotated to the current turtle
viewing direction.
|
Turtle |
drawImage(java.lang.String imagePath)
Retrieves the image either from the jar resource, from local drive or
from a internet server.
|
void |
enableRepaint(boolean b)
Enables/disables automatic repainting (default: enabled).
|
Turtle |
fd(double distance)
Moves the turtle forwards.
|
Turtle |
fill()
Fills a closed region (flood fill) with the current fill color
(default: Color.blue).
|
Turtle |
fill(double x,
double y)
Fills a closed region (flood fill) with the current fill color
(default: Color.blue) as if the turtle where at the given coordinates.
|
Turtle |
fill(java.awt.geom.Point2D.Double pt)
Fills a closed region (flood fill) with the current fill color
(default: Color.blue) as if the turtle where at the given coordinates.
|
Turtle |
fillOff()
Stops the filling started by calling fillToPoint(),
fillToHorizontal() or fillToVertical().
|
Turtle |
fillPath()
Closes the path (line from current position to where
the turtle path starts) and fills the polygon with
the current fill color.
|
Turtle |
fillToHorizontal(double y)
Draws a imaginary horizonatal line at given y-coordinate.
|
Turtle |
fillToPoint()
Same as fillToPoint(x, y) using the current turtle coordinates.
|
Turtle |
fillToPoint(double x,
double y)
Attachs a imaginary rubber band between the turtle and the given
anchor point.
|
Turtle |
fillToVertical(double x)
Draws a imaginary vertical line at given x-coordinate.
|
Turtle |
forward(double distance)
Same as fd().
|
static java.lang.String[] |
getAvailableFontFamilies()
Provides information about all font families
currently available on your system.
|
java.awt.Color |
getColor()
Returns the turtle's current color.
|
java.lang.String |
getColorStr()
Returns the X11 color string of the turtle's current color.
|
static java.lang.String |
getEnvironment()
Returns environment information (JRE and OS).
|
java.awt.Color |
getFillColor()
Returns the turtle's current fill color.
|
java.lang.String |
getFillColorStr()
Returns the X11 color string of the turtle's current fill color.
|
java.awt.Font |
getFont()
Returns the current font.
|
TurtleFrame |
getFrame()
Returns the turtle's TurtleFrame (derivated from JFrame).
|
static GBitmap |
getImage(java.lang.String imagePath)
Retrieves the image either from the jar resource, from local drive or
from a internet server.
|
Pen |
getPen()
Return the turtle's Pen reference.
|
java.awt.Color |
getPenColor()
Returns the turtle's pen color.
|
java.lang.String |
getPenColorStr()
Returns the X11 color string of the turtle's current pen color.
|
int |
getPenWidth()
Returns the current pen width.
|
java.awt.Color |
getPixelColor()
Returns the color of the pixel at the current turtle position.
|
java.lang.String |
getPixelColorStr()
Returns the color of the pixel at the current turtle position as X11 string.
|
Playground |
getPlayground()
Returns the turtle's Playground.
|
java.awt.geom.Point2D.Double |
getPos()
Returns the current playground bounded turtle position.
|
static java.lang.String |
getPropLocation()
Returns properties file location.
|
double |
getSpeed()
Returns the current turtle animation speed.
|
int |
getTextAscent()
Returns ascender height of text with current font (in pixels).
|
int |
getTextDescent()
Returns descender height of text with current font (in pixels).
|
int |
getTextHeight()
Returns height of text with current font (in pixels).
|
int |
getTextWidth(java.lang.String text)
Returns width of text with current font (in pixels).
|
TurtleFactory |
getTurtleFactory()
Returns the turtle's TurtleFactory.
|
java.awt.image.BufferedImage |
getTurtleImage()
Returns the turtle's image (not rotated).
|
double |
getX()
Returns the current playground bounded turtle's x-coordinate.
|
double |
getY()
Returns the current playground bounded turtle's y-coordinate.
|
double |
heading()
Returns the turtle's heading.
|
double |
heading(double degrees)
Sets the turtle's heading (zero to north, clockwise positive).
|
Turtle |
hideTurtle()
Hide the Turtle.
|
Turtle |
home()
Moves the turtle back "home", i.e. to coordinates (0, 0),
heading north.
|
Turtle |
ht()
Hides the Turtle.
|
boolean |
isClip()
Reports if the turtle is in clip mode.
|
static boolean |
isDisposed()
Checks if the turtle frame was disposed or released.
|
boolean |
isHidden()
Reports if the turtle is hidden or shown.
|
boolean |
isInPlayground()
Checks if the turtle stays within the playground.
|
boolean |
isPenUp()
Reports if the pen is up.
|
boolean |
isWrap()
Requests if the turtle is in wrap mode.
|
Turtle |
label(java.lang.String text)
Draw the specified text at the current turtle position using
the current text font (default SansSerif, Font.PLAIN, 24).
|
Turtle |
label(java.lang.String text,
char align)
Draw the specified text at the current turtle position using
the current text font (default SansSerif, Font.PLAIN, 24).
|
Turtle |
left(double degrees)
Same as lt()
|
Turtle |
leftArc(double radius,
double angle)
Moves the turtle on a left-oriented arc from the
current position with turtle's heading tangent direction,
given radius and given sector angle.
|
Turtle |
leftCircle(double radius)
Moves the turtle on a left-oriented circle from the
current position with turtle's heading tangent direction
and given radius.
|
Turtle |
lt(double degrees)
Turns the turtle to the left.
|
Turtle |
moveTo(double x,
double y)
Moves the turtle to the given position.
|
Turtle |
moveTo(java.awt.geom.Point2D.Double pt)
Moves the turtle to the given position.
|
Turtle |
openDot(double diameter)
Draws an open dot (unfilled circle) with line width 1 at the current turtle position using the
current pen color.
|
Turtle |
pd()
Lowers the turtle's pen, so the trace is drawn.
|
Turtle |
pe()
Sets the pen color to the background color, so existing traces
are erased.
|
Turtle |
penDown()
Same as pd().
|
Turtle |
penErase()
Same as pe().
|
Turtle |
penUp()
Same as pu().
|
int |
penWidth()
Returns the current pen width.
|
Turtle |
penWidth(int width)
Sets the line width of the traces.
|
Turtle |
popState()
Retrieves the last state from the turtle state buffer and
sets the turtle properties accordingly.
|
boolean |
print(TPrintable tp)
Same as print(tp, scale) with scale = 1.
|
boolean |
print(TPrintable tp,
double scale)
Prints 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()
Lifts the turtle's pen up, so no trace is drawn.
|
Turtle |
pushState()
Saves the current turtle state in a turtle state buffer.
|
void |
repaint()
Performs manual repainting when automatic repainting is
disabled.
|
Turtle |
right(double degrees)
Same as rt().
|
Turtle |
rightArc(double radius,
double angle)
Moves the turtle on a right-oriented arc from the
current position with turtle's heading tangent direction,
given radius and given sector angle.
|
Turtle |
rightCircle(double radius)
Moves the turtle on a right-oriented circle from the
current position with turtle's heading tangent direction
and given radius.
|
Turtle |
rt(double degrees)
Turns the turtle to the right.
|
boolean |
savePlayground(java.lang.String fileName,
java.lang.String formatName)
Saves the playground (turtles and traces) in an image file.
|
Turtle |
setAngleResolution(int resolution)
Sets the angle resolution when animating the turtle rotation.
|
Turtle |
setColor(java.awt.Color color)
Sets the turtle's color.
|
Turtle |
setColor(java.lang.String colorStr)
Sets the turtle's color as string.
|
Turtle |
setCursor(int cursorType)
Sets the mouse cursor image.
|
java.awt.Dimension |
setCustomCursor(java.lang.String cursorImage)
Same as setCustomCursor(cursorImage, hotSpot) with
hotSpot in center of image.
|
java.awt.Dimension |
setCustomCursor(java.lang.String cursorImage,
java.awt.Point hotSpot)
Sets the mouse cursor image to a custom icon.
|
Turtle |
setFillColor(java.awt.Color color)
Sets the fill color for fill().
|
Turtle |
setFillColor(java.lang.String colorStr)
Sets the fill color for fill() using the color as string.
|
Turtle |
setFont(java.awt.Font font)
Sets the current text font (default:
Font("SansSerif", Font.PLAIN, 24).
|
Turtle |
setFont(java.lang.String fontName,
int style,
int size)
Sets the current text font (default:
Font("SansSerif", Font.PLAIN, 24).
|
Turtle |
setFontSize(int size)
Sets the font size.
|
Turtle |
setFontStyle(int style)
Sets the font style.
|
Turtle |
setH(double degrees)
Sets the turtle's heading (zero to north, clockwise positive).
|
Turtle |
setHeading(double degrees)
Same as setH().
|
Turtle |
setLineWidth(double lineWidth)
Sets the line width of the traces.
|
Turtle |
setPenColor(java.awt.Color color)
Sets the turtle's pen color.
|
Turtle |
setPenColor(java.lang.String colorStr)
Sets the turtle's pen color as string.
|
Turtle |
setPenWidth(int width)
Sets the line width of the traces.
|
Turtle |
setPos(double x,
double y)
Puts the turtle to a new position without drawing a trace.
|
Turtle |
setPos(java.awt.geom.Point2D.Double pt)
Puts the turtle to a new position without drawing a trace.
|
Turtle |
setRandomHeading()
Sets the turtle's heading to a random value between 0 and 360 degrees.
|
Turtle |
setRandomPos(double width,
double height)
Puts the turtle to a new random position in a rectangle area with
given width and height (center in the middle of the playground)
without drawing a trace.
|
Turtle |
setScreenPos(java.awt.Point pt)
Puts the Turtle to a new screen position without drawing a trace.
|
Turtle |
setScreenX(int x)
Puts the turtle to a new position with the given
screen x-coordinates without drawing a trace.
|
Turtle |
setScreenY(int y)
Puts the turtle to a new position with the given
screen y-coordinates without drawing a trace.
|
void |
setStatusText(java.lang.String text)
Replaces 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)
Replaces the text in the status bar by the given text
using the given font and text color.
|
void |
setTitle(java.lang.String text)
Sets the title of turtle's playground
|
Turtle |
setX(double x)
Puts the turtle to a new position with the given x-coordinates
without drawing a trace.
|
Turtle |
setY(double y)
Puts the turtle to a new position with the given y-coordinates
without drawing a trace.
|
void |
showStatusBar(boolean show)
Shows/hides the status bar.
|
Turtle |
showTurtle()
Same as st().
|
static void |
sleep(int time)
Delays execution for the given amount of time (in ms).
|
void |
sound(double frequency,
double duration)
Plays a sine tone with given frequency and duration and maximum volume.
|
void |
sound(double volume,
double frequency,
double duration,
boolean blocking)
Plays a sine tone with given frequency and duration.
|
Turtle |
speed(double speed)
Sets the turtle's speed.
|
Turtle |
spray(int density,
double spread)
Same as spray(density, extend, size) with size = 1.
|
Turtle |
spray(int density,
double spread,
int size)
Draws a random scatter plot at turtle position with current pen color.
|
Turtle |
st()
Makes a hidden turtle visible.
|
Turtle |
stampTurtle()
Shows a turtle image (a clone) at the current position/heading.
|
Turtle |
stampTurtle(java.awt.Color color)
Shows a turtle image (a clone) with given color at the current position/heading.
|
Turtle |
stampTurtle(java.lang.String colorStr)
Shows a turtle image (a clone) with given color as string at the current position/heading.
|
Turtle |
startPath()
Starts recording the path vertexes where the turtle moves.
|
Turtle |
toBottom()
Puts the turtle to the bottom, so other turtles
will be drawn above.
|
static java.awt.Color |
toColor(java.lang.String colorStr)
Returns the Color reference for the given color as string.
|
java.lang.String |
toString()
Returns a string with turtle information in format
Turtle(Position=(x, y), Heading=h) unless the turtle frame is disposed.
|
Turtle |
toTop()
Puts the turtle to the top, so other turtles
will be drawn below.
|
java.awt.geom.Point2D.Double |
toTurtlePos(int x,
int y)
Converts from screen coordinates to turtle coordinates.
|
java.awt.geom.Point2D.Double |
toTurtlePos(java.awt.Point p)
Converts from screen coordinates to turtle coordinates.
|
double |
toTurtleX(int x)
Converts from screen coordinates to turtle coordinates.
|
double |
toTurtleY(int y)
Converts from screen coordinates to turtle coordinates.
|
double |
towards(double x,
double y)
Returns the direction (heading) to a given position.
|
double |
towards(java.awt.geom.Point2D.Double pt)
Returns the direction (heading) to a given position.
|
double |
towards(Turtle otherTurtle)
Returns the direction (heading) to a given other turtle.
|
static java.lang.String |
version()
Returns libarary version information.
|
Turtle |
viewingMoveTo(double x,
double y)
Moves the turtle to the new relative position.
|
Turtle |
viewingSetPos(double x,
double y)
Puts the turtle to a new relative position without drawing a trace.
|
Turtle |
wrap()
Sets the turtle to wrap mode.
|
public static final java.awt.Color BLACK
public static final java.awt.Color BLUE
public static final java.awt.Color CYAN
public static final java.awt.Color DKGRAY
public static final java.awt.Color GRAY
public static final java.awt.Color GREEN
public static final java.awt.Color LTGRAY
public static final java.awt.Color MAGENTA
public static final java.awt.Color RED
public static final java.awt.Color WHITE
public static final java.awt.Color YELLOW
public static int STANDARDFRAME
public static int APPLETFRAME
public static int CLEAR_ON_CLOSE
public static int ASK_ON_CLOSE
public static int DISPOSE_ON_CLOSE
public static int RELEASE_ON_CLOSE
public static int NOTHING_ON_CLOSE
public Turtle()
public Turtle(boolean show)
show
- if true, the turtle is visible when created; otherwise it remains
hidden until showTurtle() or st() is calledpublic Turtle(java.awt.Color color)
color
- the turtle color (default: cyan)public Turtle(java.lang.String colorStr)
colorStr
- the turtle color (default: cyan); if the
string is not one of the predefined values, the given string is
interpreted as filename for a custom turtle shape. If the image file
can't be loaded the default turtle color is usedpublic Turtle(javax.swing.JMenuBar menuBar, java.awt.Color color)
menuBar
- a reference to the JMenuBar instancecolor
- the turtle color (default: cyan)public Turtle(TurtleContainer turtleContainer)
turtleContainer
- a reference to the TurtleContainer where the
turtle livespublic Turtle(TurtlePane turtlePane)
turtlePane
- a reference to the TurtlePane where the turtle lives.public Turtle(TurtleContainer turtleContainer, boolean show)
turtleContainer
- a reference to the TurtleContainer where the
turtle livesshow
- if true, the turtle is visible when created; otherwise it remains
hidden until showTurtle() or st() is calledpublic Turtle(TurtleContainer turtleContainer, java.awt.Color color)
turtleContainer
- a reference to the TurtleContainer where the
turtle livescolor
- the turtle color (default: cyan)public Turtle(TurtleContainer turtleContainer, java.lang.String colorStr)
turtleContainer
- a reference to the TurtleContainer where the
turtle livescolorStr
- the turtle color (default: cyan); if the
string is not one of the predefined values, the given string is
interpreted as filename for a custom turtle shape. If the image file
can't be loaded the default turtle color is usedpublic Turtle(Turtle otherTurtle)
otherTurtle
- the turtle from where to take the windowpublic Turtle(Turtle otherTurtle, boolean show)
otherTurtle
- the turtle from where to take the windowshow
- if true, the turtle is visible when created; otherwise it remains
hidden until showTurtle() or st() is calledpublic Turtle(Turtle otherTurtle, java.awt.Color color)
otherTurtle
- the turtle from where to take the windowcolor
- the turtle color (default: cyan)public Turtle(Turtle otherTurtle, java.lang.String colorStr)
otherTurtle
- the turtle from where to take the windowcolorStr
- the turtle color (default: cyan); if the
string is not one of the predefined values, the given string is
interpreted as filename for a custom turtle shape. If the image file
can't be loaded the default turtle color is usedpublic java.awt.geom.Point2D.Double toTurtlePos(java.awt.Point p)
p
- the point in pixel coordinates (default 0..400)public java.awt.geom.Point2D.Double toTurtlePos(int x, int y)
x
- the x-coordinate in pixel (default 0..400)y
- the y-coordinate in pixel (default 0..400)public double toTurtleX(int x)
x
- the x-coordinate in pixelspublic double toTurtleY(int y)
y
- the y-coordinate in pixelspublic TurtleFrame getFrame()
public void addMouseListener(java.awt.event.MouseListener listener)
listener
- the registered MouseListenerpublic void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
listener
- the registered MouseMotionListenerpublic void addMouseDoubleClickListener(MouseDoubleClickListener listener)
listener
- the registered MouseDoubleClickListenerpublic void addMouseHitListener(MouseHitListener listener)
listener
- the registered MouseHitListenerpublic void addTurtleHitListener(TurtleHitListener listener)
listener
- the registered TurtleHitListenerpublic void addMouseHitXListener(MouseHitXListener listener)
listener
- the registered MouseHitXListenerpublic void addKeyListener(java.awt.event.KeyListener listener)
listener
- the registered KeyListenerpublic void addWindowListener(java.awt.event.WindowListener listener)
listener
- the registered WindowListenerpublic void addWindowFocusListener(java.awt.event.WindowFocusListener listener)
listener
- the registered WindowFocusListenerpublic void addComponentListener(java.awt.event.ComponentListener listener)
listener
- the registered ComponentListenerpublic void addFocusListener(java.awt.event.FocusListener listener)
listener
- the registered FocusListenerpublic void addExitListener(ExitListener listener)
public Turtle beep()
public Turtle setAngleResolution(int resolution)
resolution
- the new angle resolution (default: 72)public TurtleFactory getTurtleFactory()
public Playground getPlayground()
public double getSpeed()
public double _getX()
public double _getY()
public double getX()
public double getY()
public java.awt.geom.Point2D.Double _getPos()
public java.awt.geom.Point2D.Double getPos()
public Turtle setRandomPos(double width, double height)
width
- the width of the rectangular areaheight
- the height of the rectangularpublic Turtle setPos(double x, double y)
x
- the x-coordinate of the new positiony
- the y-coordinate of the new positionpublic Turtle setPos(java.awt.geom.Point2D.Double pt)
pt
- the turtle coordinates of the new positionpublic Turtle setScreenPos(java.awt.Point pt)
pt
- the screen coordinates of the new position
(coordinate system with origin at upper left
vertex of playground, same coordinate increments as turtle coordinates)public Turtle setScreenX(int x)
public Turtle setScreenY(int y)
public Turtle setX(double x)
public Turtle setY(double y)
public Turtle ht()
public Turtle hideTurtle()
public Turtle st()
public Turtle showTurtle()
public boolean isHidden()
public Turtle setH(double degrees)
degrees
- the compass direction (in degrees)public Turtle setHeading(double degrees)
public Turtle setRandomHeading()
public double heading()
public double heading(double degrees)
degrees
- the compass direction (in degrees)public Turtle speed(double speed)
speed
- the speed in turtle coordinates (pixels per second
up to a certain limit depending on the hardware). Zero causes
forward() to return immediatetly, -1 if for no animation.public Turtle lt(double degrees)
degrees
- the rotation angle (in degrees)public Turtle left(double degrees)
public Turtle rt(double degrees)
degrees
- the rotation angle (in degrees)public Turtle right(double degrees)
degrees
- the rotation angle (in degrees)public Turtle fd(double distance)
distance
- the moving distance in turtle coordinates. Negative
values move the turtle backwards.public Turtle forward(double distance)
distance
- the moving distance in turtle coordinates. Negative
values move the turtle backwards.public Turtle bk(double distance)
distance
- the moving distance in turtle coordinates. Negative
values move the turtle forwards.public Turtle back(double distance)
distance
- the moving distance in turtle coordinates. Negative
values move the turtle forwards.public double distance(Turtle otherTurtle)
otherTurtle
- the other turtle to sightpublic double distance(double x, double y)
x
- the x-coordinate of the target positiony
- the y-coordinate of the target positionpublic double distance(java.awt.geom.Point2D.Double pt)
pt
- the coordinate of the target positionpublic Turtle pu()
public Turtle penUp()
public Turtle pd()
public Turtle penDown()
public boolean isPenUp()
public Pen getPen()
public Turtle penWidth(int width)
width
- the line width in pixelspublic Turtle setPenWidth(int width)
width
- the line width in pixelspublic int penWidth()
public int getPenWidth()
public Turtle setLineWidth(double lineWidth)
lineWidth
- the line width in turtle coordinates (pixels)public Turtle setColor(java.awt.Color color)
color
- the new turtle color. If a custom turtle image is used,
the method does nothingpublic Turtle setColor(java.lang.String colorStr)
colorStr
- the turtle's color (default: cyan); if the
string is not one of the predefined values or a custom turtle
image is used, the color is not modified; if a custom turtle image
is used, the method does nothingpublic static java.awt.Color toColor(java.lang.String colorStr)
public Turtle setFillColor(java.awt.Color color)
color
- the new fill color (default: Color.blue).public Turtle setFillColor(java.lang.String colorStr)
colorStr
- the fill color (default: blue); if the
string is not one of the predefined values, the color is not modifiedpublic java.awt.Color getFillColor()
public java.lang.String getFillColorStr()
public java.awt.Color getColor()
public java.lang.String getColorStr()
public Turtle setPenColor(java.awt.Color color)
color
- the new pen colorpublic Turtle setPenColor(java.lang.String colorStr)
colorStr
- the pen color (default: blue); if the
string is not one of the predefined values, the color is not modifiedpublic java.awt.Color getPenColor()
public java.lang.String getPenColorStr()
public Turtle home()
public Turtle pe()
public Turtle penErase()
public Turtle stampTurtle()
public Turtle stampTurtle(java.awt.Color color)
public Turtle stampTurtle(java.lang.String colorStr)
public double towards(Turtle otherTurtle)
otherTurtle
- the other turtle to sightpublic double towards(double x, double y)
x
- the x-coordinate of the targety
- the x-coordinate of the targetpublic double towards(java.awt.geom.Point2D.Double pt)
pt
- the coordinates of the targetpublic double direction(Turtle otherTurtle)
otherTurtle
- the other turtle to sightpublic double direction(double x, double y)
x
- the x-coordinate of the targety
- the x-coordinate of the targetpublic double direction(java.awt.geom.Point2D.Double pt)
pt
- the coordinates of the targetpublic Turtle toBottom()
public Turtle toTop()
public Turtle clip()
public Turtle wrap()
public boolean isClip()
public boolean isWrap()
public Turtle fill()
public Turtle fill(double x, double y)
x
- the x-coordinate of the inner pointy
- the y-coordinate of the inner pointpublic Turtle fill(java.awt.geom.Point2D.Double pt)
pt
- coordinates of the inner pointpublic Turtle label(java.lang.String text)
public Turtle label(java.lang.String text, char align)
public Turtle setFont(java.awt.Font font)
font
- the new text font.public Turtle setFont(java.lang.String fontName, int style, int size)
fontName
- the name of the fontstyle
- the font style idsize
- the font sizepublic Turtle setFontSize(int size)
size
- the font sizepublic Turtle setFontStyle(int style)
style
- the font style idpublic static java.lang.String[] getAvailableFontFamilies()
public java.awt.Font getFont()
public int getTextWidth(java.lang.String text)
public int getTextHeight()
public int getTextAscent()
public int getTextDescent()
public java.lang.Object clone()
clone
in class java.lang.Object
public Turtle antiAliasing(boolean on)
public boolean print(TPrintable tp, double scale)
tp
- a TPrintable referencescale
- the scaling factorpublic boolean print(TPrintable tp)
tp
- a TPrintable referencepublic boolean printScreen(double scale)
scale
- the scaling factorpublic boolean printScreen()
public Turtle clear()
public Turtle clear(java.awt.Color color)
public Turtle clear(java.lang.String colorStr)
colorStr
- the background color (default: white); if the
string is not one of the predefined values, the current background color is usedpublic Turtle clean()
public Turtle clean(java.awt.Color color)
public Turtle clean(java.lang.String colorStr)
colorStr
- the background color (default: white); if the
string is not one of the predefined values, the current background color is usedpublic Turtle drawBkImage(java.lang.String imagePath)
imagePath
- the file name or urlpublic void _sleep(int time)
public static void sleep(int time)
public void setTitle(java.lang.String text)
text
- the title textpublic static java.lang.String version()
public static java.lang.String getPropLocation()
public static java.lang.String getEnvironment()
public void enableRepaint(boolean b)
b
- if true, automatic repaining is performed; otherwise repainting
must be performed by calling repaint()public void repaint()
public java.awt.Color getPixelColor()
public java.lang.String getPixelColorStr()
public void addStatusBar(int height)
height
- the height of the status bar in pixelspublic void setStatusText(java.lang.String text)
text
- the text to displaypublic void setStatusText(java.lang.String text, java.awt.Font font, java.awt.Color color)
text
- the text to displayfont
- the text fontcolor
- the text colorpublic void showStatusBar(boolean show)
show
- if true, the status bar is visible; otherwise invisiblepublic Turtle fillToPoint(double x, double y)
x
- the x-coordinate of the anchor pointy
- the y-coordinate of the anchor pointpublic Turtle fillToPoint()
public Turtle fillToHorizontal(double y)
y
- the y-coordinate of the horizontal linepublic Turtle fillToVertical(double x)
x
- the x-coordinate of the vertical linepublic Turtle fillOff()
public Turtle spray(int density, double spread)
density
- the number of pointsspread
- the mean variation in turtle coordinatespublic Turtle spray(int density, double spread, int size)
density
- the number of pointsspread
- the mean variation in turtle coordinatessize
- the size (diameter) in pixels of the pointspublic Turtle dot(double diameter)
diameter
- the diameter of the circlepublic Turtle openDot(double diameter)
diameter
- the diameter of the circlepublic Turtle moveTo(double x, double y)
x
- the new turtle's x coordinatey
- the new turtle's y coordinatepublic Turtle moveTo(java.awt.geom.Point2D.Double pt)
pt
- the turtle coordinates of the new positionpublic boolean isInPlayground()
public Turtle setCursor(int cursorType)
cursorType
- one of the constants in class java.awt.Cursorpublic java.awt.Dimension setCustomCursor(java.lang.String cursorImage, java.awt.Point hotSpot)
cursorImage
- the path to the image filehotSpot
- the image point that reports the mouse
location (origin in upper left corner). Must be inside the custom image.public java.awt.Dimension setCustomCursor(java.lang.String cursorImage)
cursorImage
- the path to the image filepublic static boolean isDisposed()
public void dispose()
public static GBitmap getImage(java.lang.String imagePath)
imagePath
- the file name or urlpublic Turtle drawImage(java.awt.image.BufferedImage bi)
public Turtle drawImage(java.lang.String imagePath)
public Turtle startPath()
public Turtle fillPath()
public Turtle pushState()
public Turtle popState()
public Turtle clearStates()
public Turtle viewingSetPos(double x, double y)
x
- the relative x coordinatey
- the relative y coordinatepublic Turtle viewingMoveTo(double x, double y)
x
- the relative x coordinatey
- the relative y coordinatepublic Turtle rightCircle(double radius)
radius
- the radius of the circle.If negative, nothing happenspublic Turtle rightArc(double radius, double angle)
radius
- the radius of the arc. If negative, nothing happens.angle
- the sector angle in degrees (if negative, performs leftArc())public Turtle leftCircle(double radius)
radius
- the radius of the circle.If negative, nothing happenspublic Turtle leftArc(double radius, double angle)
radius
- the radius of the arc. If negative, nothing happens.angle
- the sector angle in degrees (if negative, performs rightArc())public java.lang.String toString()
toString
in class java.lang.Object
public void sound(double frequency, double duration)
frequency
- the frequency of the tone (in Hertz) (double rounded to int)duration
- the duration of the tone (in Millisec) (double rounded to int)public void sound(double volume, double frequency, double duration, boolean blocking)
volume
- the sound volume (0..100) (double rounded to int)frequency
- the frequency of the tone (in Hertz) (double rounded to int)duration
- the duration of the tone (in Millisec) (double rounded to int)blocking
- if true, the methods blocks until the tone is finishedpublic java.awt.image.BufferedImage getTurtleImage()
public boolean savePlayground(java.lang.String fileName, java.lang.String formatName)
fileName
- the image file pathformatName
- the image format (supported values: "PNG", "GIF")