geneseo.cs.sc
Class LineDrawing

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Canvas
          extended bygeneseo.cs.sc.LineDrawing
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class LineDrawing
extends java.awt.Canvas

Represents a drawing made up of one or more sets of connected line segments. Each of these drawings is associated with a window that makes it visible to users. These windows define a coordinate system relative to which to define lines. The center of the window corresponds to coordinate (0,0), the coordinate system extends symmetrically out from the window's center. Coordinates measure in units of pixels. To place lines in a drawing, think of the drawing containing a (invisible) pen, which you can move for a specified distance in a specified direction. Messages to line drawings allow you to say where this pen should start from (if you don't say, it starts wherever it last ended, thus connecting line segments), what direction it should move in, how far it should move, et cetera.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
LineDrawing()
          Initialize a line drawing.
 
Method Summary
 void clear()
          Erase a line drawing and prepare any new segments to start at (0,0), with the pen moving straight right and drawing in black.
 double getAngle()
          Find out what direction the pen is moving.
 java.awt.Color getColor()
          Find out what color the pen is currently drawing in.
 double getPositionX()
          Find out the X coordinate of the pen's position.
 double getPositionY()
          Find out the Y coordinate of the pen's position.
 void movePen(double distance)
          Move the pen, adding a line segment to the current set of segments.
 void paint(java.awt.Graphics g)
          Draw the contents of a line drawing.
 void setAngle(double angle)
          Set the direction the pen will move next time a line drawing receives a "movePen" message.
 void setColor(java.awt.Color newColor)
          Set the color in which the pen draws future line segments.
 void setPosition(double x, double y)
          Position the pen to start a new set of line segments.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LineDrawing

public LineDrawing()
Initialize a line drawing.

Method Detail

clear

public void clear()
Erase a line drawing and prepare any new segments to start at (0,0), with the pen moving straight right and drawing in black.


setPosition

public void setPosition(double x,
                        double y)
Position the pen to start a new set of line segments.

Parameters:
x - The x coordinate at which the first segment of the set will start.
y - The y coordinate at which the first segment of the set will start.

setAngle

public void setAngle(double angle)
Set the direction the pen will move next time a line drawing receives a "movePen" message.

Parameters:
angle - The counterclockwise angle from due right that the pen should move, measured in degrees.

setColor

public void setColor(java.awt.Color newColor)
Set the color in which the pen draws future line segments.

Parameters:
newColor - The color to use for future line segments.

getPositionX

public double getPositionX()
Find out the X coordinate of the pen's position.

Returns:
The X coordinate of the pen position.

getPositionY

public double getPositionY()
Find out the Y coordinate of the pen's position.

Returns:
The Y coordinate of the pen position.

getAngle

public double getAngle()
Find out what direction the pen is moving.

Returns:
The pen's current heading, in degrees counterclockwise from straight right.

getColor

public java.awt.Color getColor()
Find out what color the pen is currently drawing in.

Returns:
The current color.

movePen

public void movePen(double distance)
Move the pen, adding a line segment to the current set of segments. The new segment starts at the pen's current position and has the pen's current color.

Parameters:
distance - The distance the pen should move.

paint

public void paint(java.awt.Graphics g)
Draw the contents of a line drawing. Normally called by the Java runtime system when the line drawing needs to be (re)displayed, not called directly by client code.

Parameters:
g - The graphics context for drawing the lines.