public interface CanvasGraphics
Modifier and Type | Field and Description |
---|---|
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
|
Modifier and Type | Method and Description |
---|---|
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(Shape shape,
Paint fill,
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(Point2D.Double pos,
String text,
Paint color,
Font font)
Make and return a canvas label.
|
CanvasFigure |
makeLabeledFigure(Shape shape,
Paint fill,
Paint outline,
float lineWidth,
String label,
int anchor,
Paint labelColor,
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(AffineTransform trans)
Transform all graphics according to the given AffineTransform object.
|
static final int SELECT
static final int MOVE
static final int RESIZE
static final int ROTATE
CanvasFigure makeFigure(Shape shape, Paint fill, Paint outline, float lineWidth)
The CoordinateConverter object of the image display class may be used while constructing the shape to convert to screen coordinates as needed.
shape
- the shape to drawfill
- the paint to use to fill the shapeoutline
- the paint to use for the outlinelineWidth
- the width of the shape lines in pixelsCoordinateConverter
,
GraphicsImageDisplay
CanvasFigure makeLabeledFigure(Shape shape, Paint fill, Paint outline, float lineWidth, String label, int anchor, Paint labelColor, Font font)
shape
- the shape to drawfill
- the paint to use to fill the shapeoutline
- the paint to use for the outlinelineWidth
- the width of the shape lines in pixelslabel
- the label text to be displayed with the figureanchor
- SwingConstants value for the label position (CENTER, EAST, ...)labelColor
- color of the labelfont
- the label's fontCanvasFigure makeLabel(Point2D.Double pos, String text, Paint color, Font font)
pos
- the label positiontext
- the text of the label to drawanchor
- SwingConstants value for the label position (CENTER, EAST, ...)color
- the paint to use to draw the textfont
- the font to use for the labelCanvasFigureGroup makeFigureGroup()
void add(CanvasFigure fig)
void remove(CanvasFigure fig)
void select(CanvasFigure fig)
void deselect(CanvasFigure fig)
void scheduleRemoval(CanvasFigure fig)
int getFigureCount()
void transform(AffineTransform trans)
void setInteractionMode(CanvasFigure fig, int mode)
void selectArea(SelectedAreaListener l)
void repaint()
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.