public class CanvasDraw extends Object implements MouseInputListener
Modifier and Type | Field and Description |
---|---|
protected ChangeEvent |
changeEvent
Event fired for changes
|
protected AbstractAction |
clearAction
Action to use to remove all figures.
|
static String[] |
COLOR_NAMES
Colors names corresponding to the above array
|
static Color[] |
COLORS
Colors for color change actions
|
protected Composite |
composite
Current composite
|
static String[] |
COMPOSITE_NAMES
Display names for Composites
|
protected AbstractAction[] |
compositeActions
Actions to use to set the composite
|
static Composite[] |
COMPOSITES
Composites
|
protected AbstractAction |
deleteSelectedAction
Action to use to delete the selected figure.
|
static String[] |
DRAWING_MODES
Drawing mode action names
|
protected int |
drawingMode
Current drawing mode
|
protected AbstractAction[] |
drawingModeActions
Drawing mode actions
|
static int |
ELLIPSE
Mode to draw an ellipse
|
protected AbstractFigure |
figure
Current figure (during figure creation)
|
protected LinkedList |
figureList
List of figures created by this instance
|
protected Paint |
fill
Current fill paint
|
protected AbstractAction[] |
fillActions
Actions to use to set the fill color
|
protected Font |
font
Default font for text items (labels can be resized afterwards)
|
protected AbstractAction[] |
fontActions
Actions to use to set the font
|
static Font[] |
FONTS
Fonts for font change actions
|
protected Polyline2D.Double |
freehand
Used while drawing freehand
|
static int |
FREEHAND
Mode to draw a free-hand figure
|
protected DivaImageGraphics |
graphics
Object managing image graphics
|
protected AbstractAction |
hideGraphicsAction
Action to use to toggle the visibility of all figures.
|
protected DivaMainImageDisplay |
imageDisplay
The target image display.
|
static int |
LINE
Mode to draw a line
|
static int[] |
LINE_WIDTHS
Supported line widths
|
protected int |
lineWidth
Current line width
|
protected AbstractAction[] |
lineWidthActions
Actions to use to set the line width
|
protected EventListenerList |
listenerList
list of listeners for change events
|
protected boolean |
mouseClicked
True if mouse was clicked
|
static int |
NUM_COLORS
The number of colors for which fill and outline actions are defined.
|
static int |
NUM_COMPOSITES
The number of composites defined above
|
static int |
NUM_DRAWING_MODES
The number of drawing modes.
|
static int |
NUM_FONTS
The number of fonts for which actions are defined.
|
static int |
NUM_LINE_WIDTHS
Number of Supported line widths
|
protected Paint |
outline
Current outline paint
|
protected AbstractAction[] |
outlineActions
Actions to use to set the outline color
|
protected Polygon2D.Double |
polygon
Used while drawing a polygon
|
static int |
POLYGON
Mode to draw a polygon
|
protected Polyline2D.Double |
polyline
Used while drawing a polyline
|
static int |
POLYLINE
Mode to draw a polyline
|
static int |
RECTANGLE
Mode to draw a rectangle
|
static int |
REGION
Mode to select objects in a rectangular region
|
static int |
SELECT
Mode to select an object
|
protected int |
startX
Starting point of drag
|
protected int |
startY
Starting point of drag
|
static int |
TEXT
Mode to insert a text label
|
protected boolean |
visible
Used to toggle the visibility of all figures
|
Constructor and Description |
---|
CanvasDraw(DivaMainImageDisplay imageDisplay)
Create a menu with graphics related items.
|
Modifier and Type | Method and Description |
---|---|
void |
addChangeListener(ChangeListener l)
register to receive change events from this object whenever the
drawing settings are changed.
|
void |
addFigure(CanvasFigure fig)
Add the given figure to the list of managed figures.
|
void |
clear()
Remove all figures created by this instance.
|
void |
deleteSelected()
Delete the selected figures.
|
protected void |
finishFigure()
Finish off the current figure and select it
|
protected void |
fireChange()
Notify any listeners of a change in the image or cut levels.
|
Composite |
getComposite()
Return the current composite composite for drawing.
|
AbstractAction |
getCompositeAction(int i)
Return the action for the given composite composite
|
int |
getDrawingMode()
Return the current drawing mode
|
AbstractAction |
getDrawingModeAction(int drawingMode)
Return the action for the given mode
|
LinkedList |
getFigureList()
Return a list of figures managed by this instance.
|
Paint |
getFill()
Return the current fill color for drawing.
|
AbstractAction |
getFillAction(int i)
Return the action for the given fill color
|
Font |
getFont()
Return the current font color for drawing.
|
AbstractAction |
getFontAction(int i)
Return the action for the given font color
|
DivaMainImageDisplay |
getImageDisplay()
Return the target image display.
|
int |
getLineWidth()
Return the current line width for drawing.
|
AbstractAction |
getLineWidthAction(int i)
Return the action for the given line width
|
Paint |
getOutline()
Return the current outline color for drawing.
|
AbstractAction |
getOutlineAction(int i)
Return the action for the given outline color
|
void |
hideGraphics()
Toggle the visibility all figures created by this instance.
|
void |
mouseClicked(MouseEvent e) |
void |
mouseDragged(MouseEvent e) |
void |
mouseEntered(MouseEvent e) |
void |
mouseExited(MouseEvent e) |
void |
mouseMoved(MouseEvent e) |
void |
mousePressed(MouseEvent e) |
void |
mouseReleased(MouseEvent e) |
void |
removeChangeListener(ChangeListener l)
Stop receiving change events from this object.
|
void |
setComposite(Composite composite)
Set the composite (transparency).
|
void |
setDrawingMode(int drawingMode)
Set the drawing mode.
|
void |
setFill(Paint fill)
Set the fill color.
|
void |
setFont(Font font)
Set the font to use for labels.
|
void |
setLineWidth(int lineWidth)
Set the line width.
|
void |
setOutline(Paint outline)
Set the outline color.
|
protected DivaMainImageDisplay imageDisplay
protected DivaImageGraphics graphics
protected EventListenerList listenerList
protected ChangeEvent changeEvent
protected boolean mouseClicked
protected int startX
protected int startY
protected Polyline2D.Double polyline
protected Polygon2D.Double polygon
protected Polyline2D.Double freehand
protected AbstractFigure figure
protected LinkedList figureList
public static final int SELECT
public static final int REGION
public static final int LINE
public static final int RECTANGLE
public static final int ELLIPSE
public static final int POLYLINE
public static final int POLYGON
public static final int FREEHAND
public static final int TEXT
public static final String[] DRAWING_MODES
public static final int NUM_DRAWING_MODES
protected AbstractAction[] drawingModeActions
protected int drawingMode
protected boolean visible
public static final Color[] COLORS
public static final String[] COLOR_NAMES
public static final int NUM_COLORS
protected Paint fill
protected Paint outline
protected AbstractAction[] outlineActions
protected AbstractAction[] fillActions
public static final Composite[] COMPOSITES
public static final String[] COMPOSITE_NAMES
public static final int NUM_COMPOSITES
protected AbstractAction[] compositeActions
protected Composite composite
public static final Font[] FONTS
public static final int NUM_FONTS
protected AbstractAction[] fontActions
protected Font font
public static final int[] LINE_WIDTHS
public static final int NUM_LINE_WIDTHS
protected int lineWidth
protected AbstractAction[] lineWidthActions
protected AbstractAction deleteSelectedAction
protected AbstractAction clearAction
protected AbstractAction hideGraphicsAction
public CanvasDraw(DivaMainImageDisplay imageDisplay)
imageDisplay
- used to access the JCanvas and DivaImageGraphics objectspublic DivaMainImageDisplay getImageDisplay()
public void setDrawingMode(int drawingMode)
mode
- one of the mode constants defined in this classpublic int getDrawingMode()
public AbstractAction getDrawingModeAction(int drawingMode)
public void setLineWidth(int lineWidth)
public int getLineWidth()
public AbstractAction getLineWidthAction(int i)
public void setOutline(Paint outline)
public Paint getOutline()
public AbstractAction getOutlineAction(int i)
public void setFill(Paint fill)
public Paint getFill()
public AbstractAction getFillAction(int i)
public void setComposite(Composite composite)
public Composite getComposite()
public AbstractAction getCompositeAction(int i)
public void setFont(Font font)
public Font getFont()
public AbstractAction getFontAction(int i)
public void addChangeListener(ChangeListener l)
public void removeChangeListener(ChangeListener l)
protected void fireChange()
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
public void mouseExited(MouseEvent e)
mouseExited
in interface MouseListener
public void mousePressed(MouseEvent e)
mousePressed
in interface MouseListener
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
public void mouseDragged(MouseEvent e)
mouseDragged
in interface MouseMotionListener
public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
protected void finishFigure()
public void clear()
public void deleteSelected()
public void hideGraphics()
public LinkedList getFigureList()
public void addFigure(CanvasFigure fig)
Copyright © 2023 Central Laboratory of the Research Councils. All Rights Reserved.