jsky.graphics
Interface CanvasGraphics

All Known Implementing Classes:
DivaImageGraphics

public interface CanvasGraphics

This defines an interface for drawing figures on a canvas of some type.

Version:
$Revision: 1.1 $
Author:
Allan Brighton

Field Summary
static int MOVE
          Constant indicating that a figure may be moved
static int RESIZE
          Constant indicating that a figure may be resized
static int ROTATE
          Constant indicating that a figure may be rotated
static int SELECT
          Constant indicating that a figure may be selected
 
Method Summary
 void add(CanvasFigure fig)
          Add the given figure to the canvas.
 void deselect(CanvasFigure fig)
          Deselect the given figure.
 int getFigureCount()
          Return the number of figures.
 CanvasFigure makeFigure(java.awt.Shape shape, java.awt.Paint fill, java.awt.Paint outline, float lineWidth)
          Make and return a figure with the given shape, fill, outline and line width.
 CanvasFigureGroup makeFigureGroup()
          Make and return a new CanvasFigureGroup object that can be used as a figure container to hold other figures.
 CanvasFigure makeLabel(java.awt.geom.Point2D.Double pos, java.lang.String text, java.awt.Paint color, java.awt.Font font)
          Make and return a canvas label.
 CanvasFigure makeLabeledFigure(java.awt.Shape shape, java.awt.Paint fill, java.awt.Paint outline, float lineWidth, java.lang.String label, int anchor, java.awt.Paint labelColor, java.awt.Font font)
          Make and return a labeled figure with the given shape, fill, outline and line width.
 void remove(CanvasFigure fig)
          Remove the given figure from the display.
 void repaint()
          Schedule a repaint of the window containing the graphics.
 void scheduleRemoval(CanvasFigure fig)
          Schedule the removal of the given figure from the display at a later time.
 void select(CanvasFigure fig)
          Select the given figure.
 void selectArea(SelectedAreaListener l)
          Wait for the user to drag out an area on the canvas and then notify the listener with the coordinates of the box.
 void setInteractionMode(CanvasFigure fig, int mode)
          Set the interaction mode for the given figure to an OR'ed combination of the following constants: SELECT, MOVE, RESIZE, ROTATE.
 void transform(java.awt.geom.AffineTransform trans)
          Transform all graphics according to the given AffineTransform object.
 

Field Detail

SELECT

static final int SELECT
Constant indicating that a figure may be selected

See Also:
Constant Field Values

MOVE

static final int MOVE
Constant indicating that a figure may be moved

See Also:
Constant Field Values

RESIZE

static final int RESIZE
Constant indicating that a figure may be resized

See Also:
Constant Field Values

ROTATE

static final int ROTATE
Constant indicating that a figure may be rotated

See Also:
Constant Field Values
Method Detail

makeFigure

CanvasFigure makeFigure(java.awt.Shape shape,
                        java.awt.Paint fill,
                        java.awt.Paint outline,
                        float lineWidth)
Make and return a figure with the given shape, fill, outline and line width. The shape is expected to be in screen coordinates.

The CoordinateConverter object of the image display class may be used while constructing the shape to convert to screen coordinates as needed.

Parameters:
shape - the shape to draw
fill - the paint to use to fill the shape
outline - the paint to use for the outline
lineWidth - the width of the shape lines in pixels
Returns:
an object representing the figure
See Also:
CoordinateConverter, GraphicsImageDisplay

makeLabeledFigure

CanvasFigure makeLabeledFigure(java.awt.Shape shape,
                               java.awt.Paint fill,
                               java.awt.Paint outline,
                               float lineWidth,
                               java.lang.String label,
                               int anchor,
                               java.awt.Paint labelColor,
                               java.awt.Font font)
Make and return a labeled figure with the given shape, fill, outline and line width. The shape is expected to be in screen coordinates.

Parameters:
shape - the shape to draw
fill - the paint to use to fill the shape
outline - the paint to use for the outline
lineWidth - the width of the shape lines in pixels
label - the label text to be displayed with the figure
anchor - SwingConstants value for the label position (CENTER, EAST, ...)
labelColor - color of the label
font - the label's font
Returns:
an object representing the figure

makeLabel

CanvasFigure makeLabel(java.awt.geom.Point2D.Double pos,
                       java.lang.String text,
                       java.awt.Paint color,
                       java.awt.Font font)
Make and return a canvas label.

Parameters:
pos - the label position
text - the text of the label to draw
color - the paint to use to draw the text
font - the font to use for the label

makeFigureGroup

CanvasFigureGroup makeFigureGroup()
Make and return a new CanvasFigureGroup object that can be used as a figure container to hold other figures.


add

void add(CanvasFigure fig)
Add the given figure to the canvas. The figure will remain until removed again by a call to remove().


remove

void remove(CanvasFigure fig)
Remove the given figure from the display.


select

void select(CanvasFigure fig)
Select the given figure.


deselect

void deselect(CanvasFigure fig)
Deselect the given figure.


scheduleRemoval

void scheduleRemoval(CanvasFigure fig)
Schedule the removal of the given figure from the display at a later time. This version may be used to avoid problems with iterators working on a a list of figures that should not be modified inside the loop.


getFigureCount

int getFigureCount()
Return the number of figures.


transform

void transform(java.awt.geom.AffineTransform trans)
Transform all graphics according to the given AffineTransform object.


setInteractionMode

void setInteractionMode(CanvasFigure fig,
                        int mode)
Set the interaction mode for the given figure to an OR'ed combination of the following constants: SELECT, MOVE, RESIZE, ROTATE. For example, if mode is (SELECT | MOVE | RESIZE), the figure can be selected, moved, and resized. (Note that MOVE, RESIZE and ROTATE automatically assume SELECT).


selectArea

void selectArea(SelectedAreaListener l)
Wait for the user to drag out an area on the canvas and then notify the listener with the coordinates of the box.


repaint

void repaint()
Schedule a repaint of the window containing the graphics.