public class Turtle
extends javafx.scene.layout.Pane
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, heightProperty, insetsProperty, maxHeightProperty, maxWidthProperty, minHeightProperty, minWidthProperty, opaqueInsetsProperty, paddingProperty, prefHeightProperty, prefWidthProperty, scaleShapeProperty, shapeProperty, snapToPixelProperty, widthProperty
impl_traversalEngineProperty, needsLayoutProperty
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, cacheHintProperty, cacheProperty, clipProperty, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, focusedProperty, focusTraversableProperty, hoverProperty, idProperty, impl_showMnemonicsProperty, inputMethodRequestsProperty, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParentTransformProperty, localToSceneTransformProperty, managedProperty, mouseTransparentProperty, nodeOrientationProperty, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, pickOnBoundsProperty, pressedProperty, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, styleProperty, translateXProperty, translateYProperty, translateZProperty, visibleProperty
Constructor and Description |
---|
Turtle()
Creates a Turtle with a canvas.
|
Modifier and Type | Method and Description |
---|---|
void |
canvasMouseClicked(javafx.scene.input.MouseEvent evt)
Set the position of the Turtle by clicking on the canvas
|
void |
clear()
Clear the Turtle's canvas with the fill color.
|
void |
draw(double length)
The Turtle draws a line of the length specified in the current direction.
|
void |
drawto(double x,
double y)
The Turtle draws a line form the current position (turtleX, turtleY) to the
position (x, y) relativ to the cartesian coordinate system.
|
boolean |
getAnimated()
gets animation mode
Example: myTurtle.getAnimated();
|
double |
getAnimationspeed()
Gets the animationspeed, default is 100px/s and 100°/s
Example: myTurtle.getAnimationspeed();
|
javafx.scene.paint.Color |
getFill()
Gets the backgorund color of the Turtle.
|
double |
getOriginX()
gets OriginX of the cartesian coordinate system within the turtle's canvas.
|
double |
getOriginY()
gets OriginY of the cartesian coordinate system within the turtle's canvas.
|
javafx.scene.paint.Color |
getStroke()
Gets the drawing color of the Turtle.
|
double |
getTurtleW()
Gets turtleW, the current angle of the turtle in degrees.
|
double |
getTurtleX()
Gets turtleX of the cartesian coordinate system within the turtle's canvas.
|
double |
getTurtleY()
Gets turtleY of the cartesian coordinate system within the turtle's canvas.
|
void |
move(double length)
The Turtle moves without drawing the length specified in the current
direction.
|
void |
moveto(double x,
double y)
The Turtle moves without drawing to position (x, y) relativ to the
cartesian coordinate system.
|
void |
setAnimated(boolean a)
Sets animation on/off.
|
void |
setAnimationspeed(double speed)
Sets the animationspeed, default is 100px/s and 100°/s
Example: myTurtle.setAnimationspeed(100);
|
void |
setFill(javafx.scene.paint.Color c)
Sets the canvas color of the Turtle to color c.
|
void |
setHeight(int height)
Sets the height of the Turtle.
|
void |
setLineCap(javafx.scene.shape.StrokeLineCap cap)
Sets the stroke line cap of the Turtle to cap.
|
void |
setLineDashOffset(double dash)
Sets the line dash offset of the Turtle to dash.
|
void |
setLineJoin(javafx.scene.shape.StrokeLineJoin join)
Sets the stroke line join of the Turtle to join.
|
void |
setLineWidth(int width)
Sets the line width of the Turtle to width w.
|
void |
setMiterLimit(double limit)
Sets the miter limit of the Turtle to ml.
|
void |
setOriginX(double x)
Sets OriginX of the cartesian coordinate system within the turtle's canvas.
|
void |
setOriginY(double y)
Sets OriginY of the cartesian coordinate system within the turtle's canvas.
|
void |
setSmooth(boolean smooth)
Sets the smooth-property of the Turtle to s.
|
void |
setStroke(javafx.scene.paint.Color c)
Sets the drawing color of the Turtle to color c.
|
void |
setTurtleW(double w)
Sets turtleW, the current angle of the turtle in the range form 0 to 360 degrees.
|
void |
setTurtleX(double x)
Sets turtleX of the cartesian coordinate system within the turtle's canvas.
|
void |
setTurtleY(double y)
Sets turtleY of the cartesian coordinate system within the turtle's canvas.
|
void |
setWidth(int width)
Sets the width of the Turtle.
|
void |
stop()
Stops the animation
Example: myTurtle.stop();
|
void |
turn(double angle)
Turns the angle of the turtle relativ by the parameter angle.
|
void |
turnto(double angle)
Sets the angle of the turtle absolute by the parameter angle.
|
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, impl_computeGeomBounds, impl_createPeer, impl_updatePeer, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapToPixelProperty, widthProperty
getBaselineOffset, getChildrenUnmodifiable, getImpl_traversalEngine, getStylesheets, impl_getAllParentStylesheets, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, setImpl_traversalEngine
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, hasProperties, hoverProperty, idProperty, impl_findStyles, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_isShowMnemonics, impl_isTreeVisible, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setEffect, setEventDispatcher, setFocusTraversable, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
public Turtle()
The turtle position can easily be changed by clicking into the canvas.
The size of the canvas can easily be changed with the mouse.
originX and orginY define the origin of a cartesian coordinate system related to upper left corner of the canvas.
turtleX and turtleY are the coordinates related to this cartesian coordinate system. Example:
Turtle myTurtle = new Turtle();
public void canvasMouseClicked(javafx.scene.input.MouseEvent evt)
public void draw(double length)
Example:
myTurtle.draw(100);
public void drawto(double x, double y)
Example:
myTurtle.drawto(200, 300);
public void clear()
Example:
myTurtle.clear();
public void stop()
Example:
myTurtle.stop();
public void move(double length)
Example:
myTurtle.move(100);
public void moveto(double x, double y)
Example:
myTurtle.moveto(100, 200);
public void turn(double angle)
Example:
myTurtle.turn(-90);
public void turnto(double angle)
Example:
myTurtle.turnto(270);
public void setTurtleX(double x)
Example:
myTurtle.setTurtleX(100);
public double getTurtleX()
Example:
int xpos = myTurtle.getTurtleX();
public void setTurtleY(double y)
Example:
myTurtle.setTurtleY(100);
public double getTurtleY()
Example:
int ypos = myTurtle.getTurtleY();
public void setTurtleW(double w)
Example:
myTurtle.setTurtleW(90);
public double getTurtleW()
Example:
double alpha = myTurtle.getTurtleW();
public double getOriginX()
Example:
int originX = myTurtle.getOriginX();
public void setOriginX(double x)
Example:
myTurtle.setOriginX(100);
public double getOriginY()
Example:
int originY = myTurtle.getOriginY();
public void setOriginY(double y)
Example:
myTurtle.setOriginY(100);
public void setWidth(int width)
Example:
myTurtle.setWidth(400);
public void setHeight(int height)
Example:
myTurtle.setHeight(400);
public void setAnimated(boolean a)
Example:
myTurtle.setAnimated(true);
public boolean getAnimated()
Example:
myTurtle.getAnimated();
public void setAnimationspeed(double speed)
Example:
myTurtle.setAnimationspeed(100);
public double getAnimationspeed()
Example:
myTurtle.getAnimationspeed();
public javafx.scene.paint.Color getStroke()
Example:
Color c = myTurtle.getStroke();
public void setStroke(javafx.scene.paint.Color c)
Example:
myTurtle.setStroke(Color.red);
public javafx.scene.paint.Color getFill()
Example:
Color c = myTurtle.getFill();
public void setFill(javafx.scene.paint.Color c)
Example:
myTurtle.setFill(Color.blue);
public void setLineCap(javafx.scene.shape.StrokeLineCap cap)
Example:
myTurtle.setLineCap(StrokeLineCap.BUTT);
public void setLineJoin(javafx.scene.shape.StrokeLineJoin join)
Example:
myTurtle.setLineJoin(StrokeLineJoin.ROUND);
public void setLineWidth(int width)
Example:
myTurtle.setLineWidth(3);
public void setLineDashOffset(double dash)
Example:
myTurtle.setLineDashOffset(double dash);
public void setMiterLimit(double limit)
Example:
myTurtle.setMiterLimit(15);
public void setSmooth(boolean smooth)
Example:
myTurtle.setSmooth(true);