Class MainCanvas

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----MainCanvas

public class MainCanvas
extends Canvas
A subclass of Canvas the implements the main drawing area of "What's In A Line?".


Variable Index

 o ARROW_LENGTH
 o ARROW_WIDTH
 o BOARDER
 o CIRCLE_MODE
 o DRAG_BOTH
 o DRAG_NONE
 o DRAG_P1
 o DRAG_P2
 o GRAB_RADIUS
 o LINE_MODE

Constructor Index

 o MainCanvas(AwtFrame)
Class constructor.

Method Index

 o drawLine(int, int, int, int)
Draw a line a line in the current color in MainCanvas coordinates.
 o drawPrimitive(Point, Point)
Draw a reconing primitive (line or circle) based on the two inputs.
 o drawString(String, int, int)
Draws the specified string at the specified MainCanvas coordinates.
 o handleEvent(Event)
Handle the mouse events associated with drawing in the MainCanvas.
 o minimumSize()
Returns the minimum size of MainCanvas.
 o paint(Graphics)
Paint the canvas including the cartesian coordinates, primitives and any rendered pixels.
 o preferredSize()
Returns the preferred size of MainCanvas.
 o redrawPixels()
Redraw all the currently active pixels.
 o resetDrawing()
Remove all drawn pixels from the MainCanvas.
 o setCircleMode()
Set the primitive drawing mode to CIRCLE_MODE.
 o setCircleValues(Point, Point)
Set circle parameters c (center) and r (radius) in CIRCLE_MODE.
 o setLineEndPoints(Point, Point)
Set the line endpoints p1 and p2 in LINE_MODE.
 o setLineMode()
Set the primitive drawing mode to LINE_MODE.
 o writePixel(Point, float)
Write a pixel of the specified color at the specified location.

Variables

 o LINE_MODE
 public static final int LINE_MODE
 o CIRCLE_MODE
 public static final int CIRCLE_MODE
 o BOARDER
 public static final int BOARDER
 o ARROW_LENGTH
 public static final int ARROW_LENGTH
 o ARROW_WIDTH
 public static final int ARROW_WIDTH
 o GRAB_RADIUS
 public static final int GRAB_RADIUS
 o DRAG_NONE
 public static final int DRAG_NONE
 o DRAG_P1
 public static final int DRAG_P1
 o DRAG_P2
 public static final int DRAG_P2
 o DRAG_BOTH
 public static final int DRAG_BOTH

Constructors

 o MainCanvas
 public MainCanvas(AwtFrame f)
Class constructor.

Methods

 o paint
 public void paint(Graphics g)
Paint the canvas including the cartesian coordinates, primitives and any rendered pixels.

Overrides:
paint in class Canvas
 o drawPrimitive
 public void drawPrimitive(Point p1,
                           Point p2)
Draw a reconing primitive (line or circle) based on the two inputs.

 o drawLine
 public void drawLine(int x1,
                      int y1,
                      int x2,
                      int y2)
Draw a line a line in the current color in MainCanvas coordinates.

 o drawString
 public void drawString(String str,
                        int x,
                        int y)
Draws the specified string at the specified MainCanvas coordinates.

 o handleEvent
 public boolean handleEvent(Event event)
Handle the mouse events associated with drawing in the MainCanvas.

Overrides:
handleEvent in class Component
 o setLineMode
 public void setLineMode()
Set the primitive drawing mode to LINE_MODE.

 o setCircleMode
 public void setCircleMode()
Set the primitive drawing mode to CIRCLE_MODE.

 o setLineEndPoints
 public void setLineEndPoints(Point p1,
                              Point p2)
Set the line endpoints p1 and p2 in LINE_MODE.

 o setCircleValues
 public void setCircleValues(Point p1,
                             Point p2)
Set circle parameters c (center) and r (radius) in CIRCLE_MODE.

 o writePixel
 public void writePixel(Point p,
                        float value)
Write a pixel of the specified color at the specified location.

 o resetDrawing
 public void resetDrawing()
Remove all drawn pixels from the MainCanvas.

 o preferredSize
 public Dimension preferredSize()
Returns the preferred size of MainCanvas.

Overrides:
preferredSize in class Component
 o minimumSize
 public Dimension minimumSize()
Returns the minimum size of MainCanvas.

Overrides:
minimumSize in class Component
 o redrawPixels
 public void redrawPixels()
Redraw all the currently active pixels.