ikg.eleven.turtle
Class Turtle

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Window
              extended by java.awt.Frame
                  extended by javax.swing.JFrame
                      extended by ikg.eleven.turtle.Turtle
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

public class Turtle
extends javax.swing.JFrame
implements java.awt.event.ActionListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JFrame
javax.swing.JFrame.AccessibleJFrame
 
Nested classes/interfaces inherited from class java.awt.Frame
java.awt.Frame.AccessibleAWTFrame
 
Nested classes/interfaces inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int black
           
static int blau
           
static int blue
           
static java.awt.Color[] colors
           
static int gelb
           
static int grau
           
static int gray
           
static int green
           
static int gruen
           
static int hellgrau
           
static int lightGray
           
static int orange
           
static int red
           
static int[] rgbColor
           
static int rot
           
static int schwarz
           
static int weiss
           
static int white
           
static int yellow
           
 
Fields inherited from class javax.swing.JFrame
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
 
Fields inherited from class java.awt.Frame
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Turtle()
           
Turtle(int b, int h)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
           
 void clearScreen()
          clears the Screen, not the informations about the turtles
 void copyPixel(int x, int y, int xTarget, int yTarget)
          Copy of a pixel.
 void drawCircle(double radius)
          Draw a circle.
 void drehe(double degree)
           
 void fillCircle(double radius)
          Fills a circle with the current color.
 void fuelleKreis(double r)
           
 void geheImBogen(double arc, double r)
           
 void geheNach(double newX, double newY)
           
 int getColor()
          get the pencolor
 double getDirection()
           
 double getMaxX()
           
 double getMaxY()
           
 int getPixelColor()
           
 double getXPos()
           
 double getYPos()
           
 void hebeStift()
           
protected  void hideFrame()
           
 void hideTurtle()
          hide the turtle
 int liesFarbe()
           
 double liesMaxX()
           
 double liesMaxY()
           
 int liesPixelFarbe()
           
 double liesRichtung()
           
 double liesX()
           
 double liesY()
           
 void mouseClicked(java.awt.event.MouseEvent me)
           
 void mouseDragged(java.awt.event.MouseEvent me)
           
 void mouseEntered(java.awt.event.MouseEvent me)
           
 void mouseExited(java.awt.event.MouseEvent me)
           
 void mouseMoved(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent me)
           
 void mouseReleased(java.awt.event.MouseEvent me)
           
 void move(double steps)
          the turtle moves forward in the current direction
 void moveArc(double arcAngle, double radius)
          Move along the outline of a circular arc
 void moveTo(double nextX, double nextY)
          move to a new position (shortest way)
 void paint(java.awt.Graphics gr)
           
 void penDown()
          puts the pen down.
 void penUp()
          no drawing while moving, because the pen is up
 void plotPixel()
          Plots a pixel at the current position in the current color
static void register(EventStation er)
           
 void restoreWindow()
          restores the window
 void ruhe(int time)
           
 void schaueNach(double x, double y)
           
 void schreibe(java.lang.String s)
           
 void senkeStift()
           
 void setColor(int c)
          color of the pen (and of the turtle)
 void setDirection(double angle)
          changes the direction of movement.
 void setDirection(double deltaX, double deltaY)
          sets the direction as gradient with deltaX and deltaY
 void setSpeed(int s)
           
 void setzeFarbe(int c)
           
 void setzeRichtung(double degree)
           
 void setzeRichtung(double deltaX, double deltaY)
           
 void setzeTempo(int s)
           
 void showTurtle()
          show the turtle, the turtle is visible as a triangle
 void sleep(int time)
           
 void toStartingPoint(double sx, double sy)
          fixing a starting point
 void turn(double angle)
          Rotation
 void turnTo(double x, double y)
          facing to the point (x,y)
 void verstecke()
           
 void vor(double l)
           
 void write(java.lang.String s)
          Write a string, beginning at the current Position (horizontal).
 void zeichneKreis(double r)
           
 void zeige()
           
 void zumStart(double sx, double sy)
           
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setResizable, setState, setTitle, setUndecorated
 
Methods inherited from class java.awt.Window
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isShowing, pack, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, setAlwaysOnTop, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationByPlatform, setLocationRelativeTo, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Field Detail

colors

public static java.awt.Color[] colors

black

public static final int black
See Also:
Constant Field Values

green

public static final int green
See Also:
Constant Field Values

blue

public static final int blue
See Also:
Constant Field Values

yellow

public static final int yellow
See Also:
Constant Field Values

red

public static final int red
See Also:
Constant Field Values

gray

public static final int gray
See Also:
Constant Field Values

lightGray

public static final int lightGray
See Also:
Constant Field Values

orange

public static final int orange
See Also:
Constant Field Values

white

public static final int white
See Also:
Constant Field Values

rgbColor

public static int[] rgbColor

schwarz

public static final int schwarz
See Also:
Constant Field Values

gruen

public static final int gruen
See Also:
Constant Field Values

blau

public static final int blau
See Also:
Constant Field Values

gelb

public static final int gelb
See Also:
Constant Field Values

rot

public static final int rot
See Also:
Constant Field Values

grau

public static final int grau
See Also:
Constant Field Values

hellgrau

public static final int hellgrau
See Also:
Constant Field Values

weiss

public static final int weiss
See Also:
Constant Field Values
Constructor Detail

Turtle

public Turtle()

Turtle

public Turtle(int b,
              int h)
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

clearScreen

public void clearScreen()
clears the Screen, not the informations about the turtles


hideFrame

protected void hideFrame()

restoreWindow

public void restoreWindow()
restores the window


paint

public void paint(java.awt.Graphics gr)
Overrides:
paint in class java.awt.Container

move

public void move(double steps)
the turtle moves forward in the current direction

Parameters:
steps - number of pixelunits

penUp

public void penUp()
no drawing while moving, because the pen is up


penDown

public void penDown()
puts the pen down. The turtle draws a line, if it is moving.


setDirection

public void setDirection(double angle)
changes the direction of movement.

Parameters:
angle - -360 <= angle <= 360, 0 = right, 180 = left

getDirection

public double getDirection()
Returns:
the way our turtle faces; -360 <= direction <= 360

getXPos

public double getXPos()
Returns:
the x-position of the turtle

getYPos

public double getYPos()
Returns:
the width of the window

getMaxX

public double getMaxX()
Returns:
the x-position of the turtle

getMaxY

public double getMaxY()
Returns:
the height of the window

turn

public void turn(double angle)
Rotation

Parameters:
angle - -350 <= angle <= 360

setColor

public void setColor(int c)
color of the pen (and of the turtle)

Parameters:
c - colors: black=0, green=1, blue=2, yellow=3, red=4, gray=5, lightGrau=6, white=8

getColor

public int getColor()
get the pencolor

Returns:
black=0, green=1, blue=2, yellow=3, red=4, gray=5, lightGrau=6, white=8

turnTo

public void turnTo(double x,
                   double y)
facing to the point (x,y)

Parameters:
x - x-value
y - y-value

write

public void write(java.lang.String s)
Write a string, beginning at the current Position (horizontal). The turtle move back to the begin of the sting

Parameters:
s - a string

setSpeed

public void setSpeed(int s)
Parameters:
s - 0 <= s <= 10

hideTurtle

public void hideTurtle()
hide the turtle


showTurtle

public void showTurtle()
show the turtle, the turtle is visible as a triangle


toStartingPoint

public void toStartingPoint(double sx,
                            double sy)
fixing a starting point

Parameters:
sx - x-coordinate
sy - y-coordinate

moveTo

public void moveTo(double nextX,
                   double nextY)
move to a new position (shortest way)

Parameters:
nextX - x-coordinate of the new position
nextY - y-coordinate of the new position

moveArc

public void moveArc(double arcAngle,
                    double radius)
Move along the outline of a circular arc

Parameters:
arcAngle - -360 <= angle <= 360
radius - radius of the circle

setDirection

public void setDirection(double deltaX,
                         double deltaY)
sets the direction as gradient with deltaX and deltaY


drawCircle

public void drawCircle(double radius)
Draw a circle. The position if the turtle does not change.

Parameters:
radius - radius of the circle

fillCircle

public void fillCircle(double radius)
Fills a circle with the current color. No changing of the position.

Parameters:
radius - radius of the circle.

plotPixel

public void plotPixel()
Plots a pixel at the current position in the current color


sleep

public void sleep(int time)
Parameters:
time - in milliseconds

copyPixel

public void copyPixel(int x,
                      int y,
                      int xTarget,
                      int yTarget)
Copy of a pixel. The new position of the turtle is P(xTarget, yTarget) Die position of the turtle will be later xTarget, xTarget

Parameters:
x - x-coordinate of the source
y - y-coordinate of the source
xTarget - x-coordinate of the target
yTarget - y-coordinate of the target

getPixelColor

public int getPixelColor()
Returns:
color of the current position as int (0 <= color <= 8)

register

public static void register(EventStation er)

mousePressed

public void mousePressed(java.awt.event.MouseEvent me)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent me)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent me)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent me)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent me)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

vor

public void vor(double l)

hebeStift

public void hebeStift()

senkeStift

public void senkeStift()

setzeRichtung

public void setzeRichtung(double degree)

setzeRichtung

public void setzeRichtung(double deltaX,
                          double deltaY)

liesRichtung

public double liesRichtung()

liesX

public double liesX()

liesY

public double liesY()

liesMaxX

public double liesMaxX()

liesMaxY

public double liesMaxY()

drehe

public void drehe(double degree)

setzeFarbe

public void setzeFarbe(int c)

liesFarbe

public int liesFarbe()

schaueNach

public void schaueNach(double x,
                       double y)

schreibe

public void schreibe(java.lang.String s)

setzeTempo

public void setzeTempo(int s)

verstecke

public void verstecke()

zeige

public void zeige()

zumStart

public void zumStart(double sx,
                     double sy)

geheNach

public void geheNach(double newX,
                     double newY)

geheImBogen

public void geheImBogen(double arc,
                        double r)

zeichneKreis

public void zeichneKreis(double r)

fuelleKreis

public void fuelleKreis(double r)

ruhe

public void ruhe(int time)

liesPixelFarbe

public int liesPixelFarbe()