Package com.bc.ceres.swing.figure
Class AbstractFigure
java.lang.Object
com.bc.ceres.swing.figure.AbstractFigure
- All Implemented Interfaces:
Figure
,Restorable
,Cloneable
- Direct Known Subclasses:
AbstractHandle
,AbstractPointFigure
,AbstractShapeFigure
,DefaultFigureCollection
Base class for all
Figure
implementations.
Provides support for the following properties:
selectable
, selected
, normalStyle
, selectedStyle
.
- Since:
- Ceres 0.10
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.bc.ceres.swing.figure.Figure
Figure.Rank
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
AbstractFigure
(FigureStyle normalStyle, FigureStyle selectedStyle) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addChangeListener
(FigureChangeListener listener) Adds a new change listener to this figure.boolean
Adds a child figure at the given index to this figure.boolean
Adds a child figure to this figure.protected boolean
addFigureImpl
(int index, Figure figure) The default implementation throws an [@code IllegalStateException}.protected boolean
addFigureImpl
(Figure figure) Figure[]
addFigures
(Figure... figures) Adds a child figure at the given index to this figure.protected Figure[]
addFiguresImpl
(Figure[] figures) void
addSegment
(int index, double[] segment) Adds the segment at the given vertex index.clone()
boolean
The default implementation returnsfalse
.Handle[]
createHandles
(int selectionStage) The default implementation returns an empty array.The default implementation returns [@code null}.protected Handle[]
createScaleHandles
(double distance) void
dispose()
Disposes this figure.protected void
protected void
protected void
fireFiguresAdded
(Figure... figures) protected void
fireFiguresRemoved
(Figure... figures) getFigure
(int index) The default implementation throws an [@code IllegalStateException}.getFigure
(Point2D p, AffineTransform m2v) The default implementation returnsnull
.int
The default implementation returns0
.int
getFigureIndex
(Figure figure) The default implementation returns0
.Figure[]
The default implementation returns an empty array.Figure[]
getFigures
(Shape shape) The default implementation returns an empty array.protected FigureStyle
int
The default implementation returns zero.double[]
getSegment
(int index) Gets the segment at the given vertex index.protected FigureStyle
boolean
The default implementation returnsfalse
.boolean
Tests if the figure is selected.void
move
(double dx, double dy) Moves the figure by the given delta in model coordinates.Figure[]
Removes all child figures from this figure.void
removeChangeListener
(FigureChangeListener listener) Removes a change listener from this figure.boolean
removeFigure
(Figure figure) Removes a child figure from this figure.protected boolean
removeFigureImpl
(Figure figure) The default implementation throws an [@code IllegalStateException}.Figure[]
removeFigures
(Figure... figures) Removes the given child figures from this figure.protected Figure[]
protected Figure[]
removeFiguresImpl
(Figure[] figures) void
removeSegment
(int index) Removes the segment at the given vertex index.void
Rotates the figure by the given angle.void
Scales the figure by the given scale factors.void
setMemento
(Object memento) The default implementation does nothing.void
setNormalStyle
(FigureStyle normalStyle) Sets the style used for the "normal" state of the figure.void
setSegment
(int index, double[] segment) Sets the segment at the given vertex index.void
setSelectable
(boolean selectable) void
setSelected
(boolean selected) Sets the selected state.void
setSelectedStyle
(FigureStyle selectedStyle) Sets the style used for the "selected" state of the figure.
-
Field Details
-
NO_FIGURES
-
NO_HANDLES
-
-
Constructor Details
-
AbstractFigure
protected AbstractFigure() -
AbstractFigure
-
-
Method Details
-
isSelectable
public boolean isSelectable()The default implementation returnsfalse
.- Specified by:
isSelectable
in interfaceFigure
- Returns:
- Always
false
.
-
setSelectable
public void setSelectable(boolean selectable) -
isSelected
public boolean isSelected()Description copied from interface:Figure
Tests if the figure is selected.- Specified by:
isSelected
in interfaceFigure
- Returns:
true
, if so.
-
setSelected
public void setSelected(boolean selected) Description copied from interface:Figure
Sets the selected state.- Specified by:
setSelected
in interfaceFigure
- Parameters:
selected
- The selected state.
-
getNormalStyle
- Specified by:
getNormalStyle
in interfaceFigure
- Returns:
- The style used for the "normal" state of the figure.
-
setNormalStyle
Description copied from interface:Figure
Sets the style used for the "normal" state of the figure.- Specified by:
setNormalStyle
in interfaceFigure
- Parameters:
normalStyle
- The style used for the "normal" state of the figure.
-
getSelectedStyle
- Specified by:
getSelectedStyle
in interfaceFigure
- Returns:
- The style used for the "selected" state of the figure.
-
setSelectedStyle
Description copied from interface:Figure
Sets the style used for the "selected" state of the figure.- Specified by:
setSelectedStyle
in interfaceFigure
- Parameters:
selectedStyle
- The style used for the "selected" state of the figure.
-
getEffectiveStyle
- Specified by:
getEffectiveStyle
in interfaceFigure
- Returns:
- The effective style used for the current state of the figure.
-
contains
The default implementation returnsfalse
. -
getFigureCount
public int getFigureCount()The default implementation returns0
.- Specified by:
getFigureCount
in interfaceFigure
- Returns:
- Always
0
.
-
getFigureIndex
The default implementation returns0
.- Specified by:
getFigureIndex
in interfaceFigure
- Parameters:
figure
- The child figure to look up.- Returns:
- Always
0
.
-
getFigure
The default implementation returnsnull
. -
getFigures
The default implementation returns an empty array.- Specified by:
getFigures
in interfaceFigure
- Parameters:
shape
- The shape defining the area in which the figures must be contained.- Returns:
- Always an empty array.
-
getFigures
The default implementation returns an empty array.- Specified by:
getFigures
in interfaceFigure
- Returns:
- Always an empty array.
-
addFigure
Description copied from interface:Figure
Adds a child figure to this figure. -
addFigure
Description copied from interface:Figure
Adds a child figure at the given index to this figure. -
addFigures
Description copied from interface:Figure
Adds a child figure at the given index to this figure.- Specified by:
addFigures
in interfaceFigure
- Parameters:
figures
- The array of new child figures.- Returns:
- The array of child figures that actually have been added.
-
removeFigure
Description copied from interface:Figure
Removes a child figure from this figure.- Specified by:
removeFigure
in interfaceFigure
- Parameters:
figure
- The new child figure.- Returns:
true
, if the child has been removed.
-
removeFigures
Description copied from interface:Figure
Removes the given child figures from this figure.- Specified by:
removeFigures
in interfaceFigure
- Parameters:
figures
- The array of child figures to remove.- Returns:
- The array of child figures that actually have been removed.
-
removeAllFigures
Description copied from interface:Figure
Removes all child figures from this figure.- Specified by:
removeAllFigures
in interfaceFigure
- Returns:
- The array of child figures that actually have been removed.
-
getFigure
The default implementation throws an [@code IllegalStateException}. -
addFigureImpl
The default implementation throws an [@code IllegalStateException}.- Parameters:
index
- The index.figure
- The figure.- Returns:
- Does never return normally.
-
addFigureImpl
-
addFiguresImpl
-
removeFigureImpl
The default implementation throws an [@code IllegalStateException}.- Parameters:
figure
- The figure.- Returns:
- Does never return normally.
-
removeFiguresImpl
-
removeFiguresImpl
-
move
public void move(double dx, double dy) Description copied from interface:Figure
Moves the figure by the given delta in model coordinates. -
scale
Description copied from interface:Figure
Scales the figure by the given scale factors. -
rotate
Description copied from interface:Figure
Rotates the figure by the given angle. -
getSegment
public double[] getSegment(int index) Description copied from interface:Figure
Gets the segment at the given vertex index.- Specified by:
getSegment
in interfaceFigure
- Parameters:
index
- The vertex index.- Returns:
- The segment coordinates. X is the first element, Y the second.
-
setSegment
public void setSegment(int index, double[] segment) Description copied from interface:Figure
Sets the segment at the given vertex index.- Specified by:
setSegment
in interfaceFigure
- Parameters:
index
- The vertex index.segment
- The segment coordinates. X is the first element, Y the second.
-
addSegment
public void addSegment(int index, double[] segment) Description copied from interface:Figure
Adds the segment at the given vertex index.- Specified by:
addSegment
in interfaceFigure
- Parameters:
index
- The vertex index.segment
- The segment coordinates. X is the first element, Y the second.
-
removeSegment
public void removeSegment(int index) Description copied from interface:Figure
Removes the segment at the given vertex index.- Specified by:
removeSegment
in interfaceFigure
- Parameters:
index
- The vertex index.
-
getMaxSelectionStage
public int getMaxSelectionStage()The default implementation returns zero.- Specified by:
getMaxSelectionStage
in interfaceFigure
- Returns:
- Always
0
.
-
createHandles
The default implementation returns an empty array. Clients should override in order to create an array of handles suitable for the given selection stage.- Specified by:
createHandles
in interfaceFigure
- Parameters:
selectionStage
- The selection stage.1 <= selectionLevel <=
getMaxSelectionStage()
- Returns:
- The array of handles.
-
createMemento
The default implementation returns [@code null}. Clients should override in order to produce something more meaningful.- Specified by:
createMemento
in interfaceRestorable
- Returns:
- Always
null
.
-
setMemento
The default implementation does nothing. Clients should override in order to evaluate the passed inmemento
. object.- Specified by:
setMemento
in interfaceRestorable
- Parameters:
memento
- A memento object.
-
addChangeListener
Description copied from interface:Figure
Adds a new change listener to this figure.- Specified by:
addChangeListener
in interfaceFigure
- Parameters:
listener
- The listener.
-
removeChangeListener
Description copied from interface:Figure
Removes a change listener from this figure.- Specified by:
removeChangeListener
in interfaceFigure
- Parameters:
listener
- The listener.
-
getChangeListeners
- Specified by:
getChangeListeners
in interfaceFigure
- Returns:
- The array of all change listeners registered with this figure.
-
dispose
public void dispose()Description copied from interface:Figure
Disposes this figure. Indicates that it will no longer be used. -
clone
-
fireFiguresAdded
-
fireFiguresRemoved
-
fireFigureChanged
protected void fireFigureChanged() -
fireFigureChanged
-
createScaleHandles
-
getHandleStyle
-
getSelectedHandleStyle
-