TurtleGraphics
Interface Pen

All Known Implementing Classes:
AbstractPen, BackwardPen, RainbowPen, StandardPen, WigglePen, WiggleRainbowPen

public interface Pen

Copyright 2006 by Ken Lambert and Martin Osborne.

The behavior of all pens.


Method Summary
 void down()
          Action: The pen lowers itself to the drawing surface.
 void drawString(java.lang.String text)
          Action: Draws the string at the pen's position.
 void home()
          The pen jumps to the center of the graphics window without drawing and points north.
 void move(double distance)
          Action: The pen moves the specified distance in the current direction.
 void move(double x, double y)
          Action: Moves the pen to the position (x, y).
 void setColor(java.awt.Color color)
          Action: Sets the pen's color to the specified color.
 void setDirection(double direction)
          Action: The pen points in the indicated direction.
 void setWidth(int width)
          Action: Sets the pen's width to the specified width (the default width is 2 pixels).
 java.lang.String toString()
          Action: Returns information about the pen's state.
 void turn(double degrees)
          Action: The pen adds the indicated degrees to its current direction.
 void up()
          Action: The pen raises itself from the drawing surface.
 

Method Detail

down

void down()
Action: The pen lowers itself to the drawing surface.


drawString

void drawString(java.lang.String text)
Action: Draws the string at the pen's position.


home

void home()
The pen jumps to the center of the graphics window without drawing and points north.


move

void move(double distance)
Action: The pen moves the specified distance in the current direction. The distance can be an integer or floating-point number and is measured in pixels (picture elements). The size of a pixel depends on the monitorŐs resolution. For instance, when we say that a monitor's resolution is 800 by 600, we mean that the monitor is 800 pixels wide and 600 pixels high.


move

void move(double x,
          double y)
Action: Moves the pen to the position (x, y).


setColor

void setColor(java.awt.Color color)
Action: Sets the pen's color to the specified color.


setDirection

void setDirection(double direction)
Action: The pen points in the indicated direction. Due east corresponds to 0 degrees, north to 90 degrees, west to 180 degrees, and south to 270 degrees. Because there are 360 degrees in a circle, setting the direction to 400 would be equivalent to 400 - 360 or 40 and setting it to -30 would be equivalent to 360 - 30 or 330. Example: pen.setDirection(90); Make the pen point due north.


setWidth

void setWidth(int width)
Action: Sets the pen's width to the specified width (the default width is 2 pixels).


toString

java.lang.String toString()
Action: Returns information about the pen's state.

Overrides:
toString in class java.lang.Object

turn

void turn(double degrees)
Action: The pen adds the indicated degrees to its current direction. Positive degrees correspond to turning counterclockwise. The degrees can be an integer or floating-point number. Example: pen.turn(-45); Rotate the pen 45 degrees clockwise.


up

void up()
Action: The pen raises itself from the drawing surface.