public class DivaImageGraphics extends Object implements CanvasGraphics
MOVE, RESIZE, ROTATE, SELECT
Constructor and Description |
---|
DivaImageGraphics(DivaGraphicsImageDisplay imageDisplay)
Construct an object for drawing on the given image display.
|
Modifier and Type | Method and Description |
---|---|
void |
add(CanvasFigure fig)
Add the given figure to the canvas.
|
void |
clearSelection()
Clear the selection.
|
void |
deselect(CanvasFigure fig)
Deselect the given figure.
|
DragInteractor |
getDragInteractor()
Return an interactor that allows dragging figures
|
int |
getFigureCount()
Return the number of figures.
|
SelectionInteractor |
getFixedSelectionInteractor()
Return an interactor that allows selecting figures, but not dragging or resizing
|
GraphicsPane |
getGraphicsPane()
Return the Diva graphics pane.
|
ImageLayer |
getImageLayer()
Return the Diva layer containing the image
|
SelectionInteractor |
getLineInteractor()
Return an interactor for lines
|
SelectionDragger |
getSelectionDragger()
Used for selecting all objects in a rectangular region
|
SelectionInteractor |
getSelectionInteractor()
Return an interactor that allows selection, dragging and resizing figures
|
static void |
main(String[] args)
test main: usage: java GraphicsImageDisplay
|
CanvasFigure |
makeEllipse(Ellipse2D.Double ellipse,
int coordType,
Paint fill,
Paint outline,
float lineWidth,
Interactor interactor)
This is a convenience method for drawing ellipses that allows you to
specify the type of the coordinates given by the ellipse argument.
|
CanvasFigure |
makeFigure(Shape shape,
Paint fill,
Paint outline,
float lineWidth)
Make and return a figure with the given shape, fill, outline and line width.
|
CanvasFigure |
makeFigure(Shape shape,
Paint fill,
Paint outline,
float lineWidth,
Interactor interactor)
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.
|
CanvasFigureGroup |
makeFigureGroup(Interactor interactor)
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 |
makeLabel(Point2D.Double pos,
String text,
Paint color,
Font font,
Interactor interactor)
Make and return a canvas label.
|
CanvasFigure |
makeLabeledEllipse(Ellipse2D.Double ellipse,
int coordType,
Paint fill,
Paint outline,
float lineWidth,
String label,
int anchor,
Paint labelColor,
Font font,
Interactor interactor)
This is a convenience method for drawing a labeled ellipse that allows you to
specify the type of the coordinates given by the ellipse argument.
|
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.
|
CanvasFigure |
makeLabeledFigure(Shape shape,
Paint fill,
Paint outline,
float lineWidth,
String label,
int anchor,
Paint labelColor,
Font font,
Interactor interactor)
Make and return a labeled figure with the given shape, fill, outline and
line width.
|
CanvasFigure |
makeLabeledRectangle(Rectangle2D.Double rect,
int coordType,
Paint fill,
Paint outline,
float lineWidth,
String label,
int anchor,
Paint labelColor,
Font font,
Interactor interactor)
This is a convenience method for making a labeled rectangle that allows you to
specify the type of the coordinates given by the rect argument.
|
CanvasFigure |
makeRectangle(Rectangle2D.Double rect,
int coordType,
Paint fill,
Paint outline,
float lineWidth,
Interactor interactor)
This is a convenience method for making rectangles that allows you to
specify the type of the coordinates given by the rect argument.
|
void |
remove(CanvasFigure fig)
Remove the given figure from the display.
|
void |
repaint()
Schedule a repaint of the window containing the graphics.
|
void |
repaint(Rectangle2D region)
Schedule a repaint of the given area 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 image 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.
|
public DivaImageGraphics(DivaGraphicsImageDisplay imageDisplay)
public GraphicsPane getGraphicsPane()
public ImageLayer getImageLayer()
public SelectionDragger getSelectionDragger()
public DragInteractor getDragInteractor()
public SelectionInteractor getSelectionInteractor()
public SelectionInteractor getLineInteractor()
public SelectionInteractor getFixedSelectionInteractor()
public CanvasFigure makeLabeledFigure(Shape shape, Paint fill, Paint outline, float lineWidth, String label, int anchor, Paint labelColor, Font font, Interactor interactor)
The CoordinateConverter object in the image display class may be used while constructing the shape to convert to screen coordinates.
Event handling for figures is done through Diva Interactors. A number of common interactors are defined in this class for dragging and selecting figures. When selecting figures, the Diva SelectionModel class can also be used to get notification whenever the selection changes. When dragging figures, the DragIterator class has listener methods that can notify you whenever a figure is dragged.
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
- an optional label text to be displayed with the figure (may be null)anchor
- SwingConstants value for label positionlabelColor
- color of the labelfont
- the label's fontinteractor
- determines the behavior of the figure (may be null)CoordinateConverter
,
GraphicsImageDisplay
public CanvasFigure makeFigure(Shape shape, Paint fill, Paint outline, float lineWidth, Interactor interactor)
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 pixelsinteractor
- determines the behavior of the figure (may be null)public CanvasFigure makeLabeledFigure(Shape shape, Paint fill, Paint outline, float lineWidth, String label, int anchor, Paint labelColor, Font font)
makeLabeledFigure
in interface CanvasGraphics
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
- an optional label text to be displayed with the figure (may be null)anchor
- SwingConstants value for label positionlabelColor
- color of the labelfont
- the label's fontpublic CanvasFigure makeFigure(Shape shape, Paint fill, Paint outline, float lineWidth)
makeFigure
in interface CanvasGraphics
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
public CanvasFigure makeLabeledRectangle(Rectangle2D.Double rect, int coordType, Paint fill, Paint outline, float lineWidth, String label, int anchor, Paint labelColor, Font font, Interactor interactor)
public CanvasFigure makeRectangle(Rectangle2D.Double rect, int coordType, Paint fill, Paint outline, float lineWidth, Interactor interactor)
public CanvasFigure makeLabeledEllipse(Ellipse2D.Double ellipse, int coordType, Paint fill, Paint outline, float lineWidth, String label, int anchor, Paint labelColor, Font font, Interactor interactor)
public CanvasFigure makeEllipse(Ellipse2D.Double ellipse, int coordType, Paint fill, Paint outline, float lineWidth, Interactor interactor)
public CanvasFigure makeLabel(Point2D.Double pos, String text, Paint color, Font font, Interactor interactor)
pos
- the label positiontext
- the text of the label to drawcolor
- the paint to use to draw the textfont
- the font to use for the labelinteractor
- determines the behavior of the figure (may be null)public CanvasFigure makeLabel(Point2D.Double pos, String text, Paint color, Font font)
makeLabel
in interface CanvasGraphics
text
- the text of the label to drawpos
- the label positionfill
- the paint to use to draw the textfont
- the font to use for the labelpublic CanvasFigureGroup makeFigureGroup(Interactor interactor)
interactor
- determines the selection behavior of the figure group (may be null)public CanvasFigureGroup makeFigureGroup()
makeFigureGroup
in interface CanvasGraphics
public void add(CanvasFigure fig)
add
in interface CanvasGraphics
public void remove(CanvasFigure fig)
remove
in interface CanvasGraphics
public void select(CanvasFigure fig)
select
in interface CanvasGraphics
public void deselect(CanvasFigure fig)
deselect
in interface CanvasGraphics
public void clearSelection()
public void scheduleRemoval(CanvasFigure fig)
scheduleRemoval
in interface CanvasGraphics
public int getFigureCount()
getFigureCount
in interface CanvasGraphics
public void transform(AffineTransform trans)
transform
in interface CanvasGraphics
public void setInteractionMode(CanvasFigure fig, int mode)
setInteractionMode
in interface CanvasGraphics
public void selectArea(SelectedAreaListener l)
selectArea
in interface CanvasGraphics
public void repaint()
repaint
in interface CanvasGraphics
public void repaint(Rectangle2D region)
public static void main(String[] args)
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.