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?".
-
ARROW_LENGTH
-
-
ARROW_WIDTH
-
-
BOARDER
-
-
CIRCLE_MODE
-
-
DRAG_BOTH
-
-
DRAG_NONE
-
-
DRAG_P1
-
-
DRAG_P2
-
-
GRAB_RADIUS
-
-
LINE_MODE
-
-
MainCanvas(AwtFrame)
- Class constructor.
-
drawLine(int, int, int, int)
- Draw a line a line in the current color in MainCanvas coordinates.
-
drawPrimitive(Point, Point)
- Draw a reconing primitive (line or circle) based on the two inputs.
-
drawString(String, int, int)
- Draws the specified string at the specified MainCanvas coordinates.
-
handleEvent(Event)
- Handle the mouse events associated with drawing in the MainCanvas.
-
minimumSize()
- Returns the minimum size of MainCanvas.
-
paint(Graphics)
- Paint the canvas including the cartesian coordinates, primitives and any rendered pixels.
-
preferredSize()
- Returns the preferred size of MainCanvas.
-
redrawPixels()
- Redraw all the currently active pixels.
-
resetDrawing()
- Remove all drawn pixels from the MainCanvas.
-
setCircleMode()
- Set the primitive drawing mode to CIRCLE_MODE.
-
setCircleValues(Point, Point)
- Set circle parameters c (center) and r (radius) in CIRCLE_MODE.
-
setLineEndPoints(Point, Point)
- Set the line endpoints p1 and p2 in LINE_MODE.
-
setLineMode()
- Set the primitive drawing mode to LINE_MODE.
-
writePixel(Point, float)
- Write a pixel of the specified color at the specified location.
LINE_MODE
public static final int LINE_MODE
CIRCLE_MODE
public static final int CIRCLE_MODE
BOARDER
public static final int BOARDER
ARROW_LENGTH
public static final int ARROW_LENGTH
ARROW_WIDTH
public static final int ARROW_WIDTH
GRAB_RADIUS
public static final int GRAB_RADIUS
DRAG_NONE
public static final int DRAG_NONE
DRAG_P1
public static final int DRAG_P1
DRAG_P2
public static final int DRAG_P2
DRAG_BOTH
public static final int DRAG_BOTH
MainCanvas
public MainCanvas(AwtFrame f)
- Class constructor.
paint
public void paint(Graphics g)
- Paint the canvas including the cartesian coordinates, primitives and any rendered pixels.
- Overrides:
- paint in class Canvas
drawPrimitive
public void drawPrimitive(Point p1,
Point p2)
- Draw a reconing primitive (line or circle) based on the two inputs.
drawLine
public void drawLine(int x1,
int y1,
int x2,
int y2)
- Draw a line a line in the current color in MainCanvas coordinates.
drawString
public void drawString(String str,
int x,
int y)
- Draws the specified string at the specified MainCanvas coordinates.
handleEvent
public boolean handleEvent(Event event)
- Handle the mouse events associated with drawing in the MainCanvas.
- Overrides:
- handleEvent in class Component
setLineMode
public void setLineMode()
- Set the primitive drawing mode to LINE_MODE.
setCircleMode
public void setCircleMode()
- Set the primitive drawing mode to CIRCLE_MODE.
setLineEndPoints
public void setLineEndPoints(Point p1,
Point p2)
- Set the line endpoints p1 and p2 in LINE_MODE.
setCircleValues
public void setCircleValues(Point p1,
Point p2)
- Set circle parameters c (center) and r (radius) in CIRCLE_MODE.
writePixel
public void writePixel(Point p,
float value)
- Write a pixel of the specified color at the specified location.
resetDrawing
public void resetDrawing()
- Remove all drawn pixels from the MainCanvas.
preferredSize
public Dimension preferredSize()
- Returns the preferred size of MainCanvas.
- Overrides:
- preferredSize in class Component
minimumSize
public Dimension minimumSize()
- Returns the minimum size of MainCanvas.
- Overrides:
- minimumSize in class Component
redrawPixels
public void redrawPixels()
- Redraw all the currently active pixels.