Background
jLogo Programming
- Commanding a Turtle
- Pseudocode
- Adding New Commands
- Iteration & Animation
- Hierarchical Structure
- Procedure Inputs
- Primitive Operators
- Defining Operators
- Words & Sentences
- User Interface Events
- What If? (Predicates)
- Recursion
- Local Variables
- Global Variables
- Word/Sentence Iteration
- Mastermind Project
- Multiple Turtles
- Arrays
Java
- A Java Program
- What's a Class?
- Extending Existing Classes
- Types
- Turtle Graphics
- Control Flow
- User Interface Events
Appendices
Lastly
Java TurtleGraphics
Introduction
In this lesson you will use a Turtle object. It has methods that correspond to procedures in Logo. This will help you see and compare programs that you started out writing in Logo with similar programs written in Java.
TurtleGraphics in a Java Program
Like the approach I took in Extending Existing
Classes, I've written a bunch of classes you can use to do TurtleGraphics
in Java. The class that you will extend is named
TurtleGraphicsWindow. When you extend it, you inherit all
of the methods it provides. It gets you all of the graphics-oriented
commands and operators you've been using in Logo.
*** NOTE *** This does not get you access to the full Logo language, only the graphics stuff. If you look at Appendix C, jLogo Primitives, you will see that there is a lot more to jLogo than its Graphics Procedures. |
To use the TurtleGraphics stuff, you will need to copy a few Java source code files to your computer and compile them. The files you need are:
ArrowTurtle.javaBallTurtle.java
BoxTurtle.java
CrossTurtle.java
TGCanvas.java
TGFillOp.java
TGGraphicsOp.java
TGKeyHandler.java
TGLabelOp.java
TGLineOp.java
TGMouseHandler.java
TGPoint.java
TriangleTurtle.java
Turtle.java
TurtleGraphicsWindow.java
TurtlePixels.java
TurtleTurtle.java
CompileTGW.bat
Cross.java
To get you started, here is the JavaDoc documentation of the methods that are available.
And... here is a very simple program to draw an X axis and Y axis. Copy it and paste it into a file named Cross.java, then compile and run it.
|
Summary
Go to the Table of Contents
On to Control Flow