public class DrawActions extends Object implements MouseInputListener
Modifier and Type | Class and Description |
---|---|
protected class |
DrawActions.CompositeAction
Local class used to set the transparency for figures.
|
protected class |
DrawActions.CurveAction
Local class used to set the interpolated curve type.
|
protected class |
DrawActions.DrawingModeAction
Local class used to set the drawing mode.
|
protected class |
DrawActions.FillAction
Local class used to set the fill color for figures.
|
protected class |
DrawActions.FontAction
Local class used to set the label font.
|
protected class |
DrawActions.GraphicsAction
Local base class for creating menu/toolbar actions.
|
protected class |
DrawActions.LineWidthAction
Local class used to set the line width.
|
protected class |
DrawActions.OutlineAction
Local class used to set the outline color for figures.
|
Modifier and Type | Field and Description |
---|---|
protected Draw |
canvas
The target drawble canvas
|
protected ChangeEvent |
changeEvent
Event fired for changes
|
protected AbstractAction |
clearAction
Action to use to remove all figures.
|
static ArrayList |
colors
Colors for color change actions
|
protected AlphaComposite |
composite
Current composite
|
static String[] |
COMPOSITE_NAMES
Display names for Composites
|
protected AbstractAction[] |
compositeActions
Actions to use to set the composite
|
static AlphaComposite[] |
COMPOSITES
Composites
|
protected InterpolatedCurve2D |
curve
Used while drawing an interpolated curve
|
static int |
CURVE |
protected AbstractAction[] |
curveActions
Actions used to create a curve
|
protected AbstractAction |
deleteSelectedAction
Action to use to delete the selected figure.
|
protected int |
drawingMode
Current drawing mode
|
protected ArrayList |
drawingModeActions
Drawing mode actions
|
static int |
EDIT
Mode to edit an object
|
protected DrawLabelFigure |
editLabelFigure
Figure to be modified during an edit
|
static int |
ELLIPSE |
protected Figure |
figure
Current figure (during figure creation)
|
protected DrawFigureFactory |
figureFactory
The DrawFigureFactory
|
protected LinkedList |
figureList
List of figures created by this instance
|
protected EventListenerList |
figureListenerList
List of listeners for figure creation events
|
protected Paint |
fill
Current fill paint
|
protected ArrayList |
fillActions
Actions to use to set the fill color
|
protected Font |
font
Default font for text items
|
protected ArrayList |
fontActions
Actions for choosing a preset font
|
static ArrayList |
fonts
Fixed fonts for font change actions
|
protected Polyline2D.Double |
freehand
Used while drawing freehand
|
static int |
FREEHAND |
protected DrawGraphicsPane |
graphics
Object managing image graphics
|
protected AbstractAction |
hideGraphicsAction
Action to use to toggle the visibility of all figures.
|
protected int |
interpolator
Current curve interpolator.
|
protected InterpolatorFactory |
interpolatorFactory
The default InterpolatorFactory
|
protected Line2D.Double |
line
Used while drawing a line
|
static int |
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 AbstractAction |
lowerSelectedAction
Action to lower selected Figures
|
protected boolean |
mouseClicked
True if mouse was clicked
|
static int |
NUM_COMPOSITES
The number of composites defined above
|
static int |
NUM_DRAWING_MODES
The number of "drawing mode", that's type of Figures plus
selection modes.
|
static int |
NUM_LINE_WIDTHS
Number of Supported line widths
|
protected Paint |
outline
Current outline paint
|
protected ArrayList |
outlineActions
Actions to use to set the outline color
|
protected Polygon2D.Double |
polygon
Used while drawing a polygon
|
static int |
POLYGON |
protected Polyline2D.Double |
polyline
Used while drawing a polyline
|
static int |
POLYLINE |
protected AbstractAction |
raiseSelectedAction
Action to raise selected Figures
|
static int |
RECTANGLE |
protected AbstractAction |
saveRestoreAction
Action to save or restore the figures
|
static int |
SELECT
Mode to select an object
|
protected int |
startX
Starting point of drag
|
protected int |
startY
Starting point of drag
|
protected FigureStore |
store
FigureStore instance
|
static int |
TEXT |
protected boolean |
visible
Used to toggle the visibility of all figures
|
static int |
XRANGE |
Constructor and Description |
---|
DrawActions(Draw canvas,
FigureStore store)
Create an instance for use with a specified Draw
|
DrawActions(Draw canvas,
FigureStore store,
InterpolatorFactory factory)
Create an instance for use with a specified Draw and
InterpolatorFactory.
|
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 |
addColor(Color color)
Add a new color.
|
void |
addDrawFigure(DrawFigure figure)
Add a DrawFigure created to the managed list.
|
void |
addFigureListener(FigureListener l)
Register to receive figure change events from this object whenever
a figure has been created.
|
void |
addFont(Font font)
Add a new font.
|
void |
clear()
Remove all figures created by this instance.
|
DrawFigure |
createDrawFigure(int type,
FigureProps props)
Create a DrawFigure using preset properties.
|
void |
deleteFigure(DrawFigure figure)
Delete a given figure, if displayed.
|
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.
|
protected void |
fireFigureEvent(DrawFigure figure,
int type)
Notify any figure listeners of a figure created event.
|
int |
fontCount()
Return the number of fonts
|
Action |
getClearAction() |
Color |
getColor(int i)
Get a Color by index.
|
int |
getColorCount()
Return the number of colours.
|
AlphaComposite |
getComposite()
Return the current composite composite for drawing.
|
AbstractAction |
getCompositeAction(int i)
Return the action for the given composite composite.
|
int |
getCurve()
Return the current curve type.
|
AbstractAction |
getCurveAction(int i)
Return the action for a given curve interpolation type.
|
Action |
getDeleteSelectedAction() |
Draw |
getDraw()
Return the Draw instance.
|
int |
getDrawingMode()
Return the current drawing mode.
|
AbstractAction |
getDrawingModeAction(int drawingMode)
Return the action for the given mode.
|
FigureStore |
getFigureStore()
Get the
FigureStore . |
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.
|
Font |
getFont(int i)
Return a given font.
|
AbstractAction |
getFontAction(int i)
Return the action for the given font.
|
Action |
getHideAction() |
InterpolatorFactory |
getInterpolatorFactory()
Get the InterpolatorFactory.
|
int |
getLineWidth()
Return the current line width for drawing.
|
AbstractAction |
getLineWidthAction(int i)
Return the action for the given line width
|
ListIterator |
getListIterator(boolean forward)
Return a ListIterator over the figures.
|
Action |
getLowerSelectedAction() |
Paint |
getOutline()
Return the current outline color for drawing.
|
AbstractAction |
getOutlineAction(int i)
Return the action for the given outline color
|
Action |
getRaiseSelectedAction() |
static TypedDecorator |
getTypedDecorator()
Create and return a TypedDecorator suitable for manipulating
the various types of figures in natural ways.
|
void |
hideGraphics()
Toggle the visibility all figures created by this instance.
|
void |
lowerFigure(DrawFigure figure)
Lower the given figure.
|
void |
lowerSelected()
Lower the selected figures.
|
Interpolator |
makeInterpolator()
Make an instance of the current interpolator.
|
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 |
raiseFigure(DrawFigure figure)
Raise the given figure.
|
void |
raiseSelected()
Raise the selected figures.
|
void |
removeChangeListener(ChangeListener l)
Stop receiving change events from this object.
|
void |
removeFigureListener(FigureListener l)
Stop receiving figure change events from this object.
|
protected void |
saveRestore()
Interact with the object for saving and restoring figures from
an XML store of some kind.
|
void |
setComposite(AlphaComposite composite)
Set the composite (transparency).
|
void |
setCurve(int interpolator)
Set the interpolated curve type.
|
void |
setDrawingMode(int drawingMode)
Set the drawing mode.
|
void |
setFigureStore(FigureStore store)
Set the
FigureStore . |
void |
setFill(Paint fill)
Set the fill color.
|
void |
setFont(Font font)
Set the font to use for labels.
|
void |
setInterpolatorFactory(InterpolatorFactory factory)
Set the InterpolatorFactory.
|
void |
setLineWidth(int lineWidth)
Set the line width.
|
void |
setOutline(Paint outline)
Set the outline color.
|
protected Draw canvas
protected DrawGraphicsPane graphics
protected EventListenerList listenerList
protected ChangeEvent changeEvent
protected EventListenerList figureListenerList
protected boolean mouseClicked
protected int startX
protected int startY
protected Polyline2D.Double polyline
protected Polygon2D.Double polygon
protected Polyline2D.Double freehand
protected InterpolatedCurve2D curve
protected Line2D.Double line
protected Figure figure
protected LinkedList figureList
public static final int SELECT
public static final int EDIT
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 int CURVE
public static final int XRANGE
public static final int NUM_DRAWING_MODES
protected ArrayList drawingModeActions
protected int drawingMode
protected boolean visible
public static ArrayList colors
protected Paint fill
protected Paint outline
protected ArrayList outlineActions
protected ArrayList fillActions
public static final AlphaComposite[] COMPOSITES
public static final String[] COMPOSITE_NAMES
public static final int NUM_COMPOSITES
protected AbstractAction[] compositeActions
protected AlphaComposite composite
public static ArrayList fonts
protected ArrayList fontActions
protected Font font
protected DrawLabelFigure editLabelFigure
public static final int[] LINE_WIDTHS
public static final int NUM_LINE_WIDTHS
protected int lineWidth
protected AbstractAction[] lineWidthActions
protected InterpolatorFactory interpolatorFactory
protected AbstractAction[] curveActions
protected int interpolator
protected DrawFigureFactory figureFactory
protected FigureStore store
protected AbstractAction deleteSelectedAction
protected AbstractAction clearAction
protected AbstractAction hideGraphicsAction
protected AbstractAction raiseSelectedAction
protected AbstractAction lowerSelectedAction
protected AbstractAction saveRestoreAction
public DrawActions(Draw canvas, FigureStore store)
canvas
- on which graphics will be drawn.store
- used to save and restore graphics, null for none.public DrawActions(Draw canvas, FigureStore store, InterpolatorFactory factory)
canvas
- on which graphics will be drawn.store
- used to save and restore graphics, null for none.factory
- an InterpolatorFactory
.public Draw getDraw()
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 int getColorCount()
public Color getColor(int i)
public void addColor(Color color)
public void setComposite(AlphaComposite composite)
public AlphaComposite getComposite()
public AbstractAction getCompositeAction(int i)
public void setFont(Font font)
public void addFont(Font font)
public Font getFont()
public Font getFont(int i)
public AbstractAction getFontAction(int i)
public int fontCount()
public void setInterpolatorFactory(InterpolatorFactory factory)
public InterpolatorFactory getInterpolatorFactory()
public void setCurve(int interpolator)
public int getCurve()
public AbstractAction getCurveAction(int i)
public Interpolator makeInterpolator()
public void addChangeListener(ChangeListener l)
public void removeChangeListener(ChangeListener l)
protected void fireChange()
public void addFigureListener(FigureListener l)
public void removeFigureListener(FigureListener l)
protected void fireFigureEvent(DrawFigure figure, int type)
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 deleteFigure(DrawFigure figure)
public void hideGraphics()
public void raiseSelected()
public void raiseFigure(DrawFigure figure)
public void lowerSelected()
public void lowerFigure(DrawFigure figure)
public ListIterator getListIterator(boolean forward)
public DrawFigure createDrawFigure(int type, FigureProps props)
public void addDrawFigure(DrawFigure figure)
public static TypedDecorator getTypedDecorator()
protected void saveRestore()
public void setFigureStore(FigureStore store)
FigureStore
.public FigureStore getFigureStore()
FigureStore
.public Action getDeleteSelectedAction()
public Action getClearAction()
public Action getHideAction()
public Action getRaiseSelectedAction()
public Action getLowerSelectedAction()
Copyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.