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
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractFigure(FigureStyle normalStyle, FigureStyle selectedStyle) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChangeListener(FigureChangeListener listener) Adds a new change listener to this figure.booleanAdds a child figure at the given index to this figure.booleanAdds a child figure to this figure.protected booleanaddFigureImpl(int index, Figure figure) The default implementation throws an [@code IllegalStateException}.protected booleanaddFigureImpl(Figure figure) Figure[]addFigures(Figure... figures) Adds a child figure at the given index to this figure.protected Figure[]addFiguresImpl(Figure[] figures) voidaddSegment(int index, double[] segment) Adds the segment at the given vertex index.clone()booleanThe 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) voiddispose()Disposes this figure.protected voidprotected voidprotected voidfireFiguresAdded(Figure... figures) protected voidfireFiguresRemoved(Figure... figures) getFigure(int index) The default implementation throws an [@code IllegalStateException}.getFigure(Point2D p, AffineTransform m2v) The default implementation returnsnull.intThe default implementation returns0.intgetFigureIndex(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 FigureStyleintThe default implementation returns zero.double[]getSegment(int index) Gets the segment at the given vertex index.protected FigureStylebooleanThe default implementation returnsfalse.booleanTests if the figure is selected.voidmove(double dx, double dy) Moves the figure by the given delta in model coordinates.Figure[]Removes all child figures from this figure.voidremoveChangeListener(FigureChangeListener listener) Removes a change listener from this figure.booleanremoveFigure(Figure figure) Removes a child figure from this figure.protected booleanremoveFigureImpl(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) voidremoveSegment(int index) Removes the segment at the given vertex index.voidRotates the figure by the given angle.voidScales the figure by the given scale factors.voidsetMemento(Object memento) The default implementation does nothing.voidsetNormalStyle(FigureStyle normalStyle) Sets the style used for the "normal" state of the figure.voidsetSegment(int index, double[] segment) Sets the segment at the given vertex index.voidsetSelectable(boolean selectable) voidsetSelected(boolean selected) Sets the selected state.voidsetSelectedStyle(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:
isSelectablein interfaceFigure- Returns:
- Always
false.
-
setSelectable
public void setSelectable(boolean selectable) -
isSelected
public boolean isSelected()Description copied from interface:FigureTests if the figure is selected.- Specified by:
isSelectedin interfaceFigure- Returns:
true, if so.
-
setSelected
public void setSelected(boolean selected) Description copied from interface:FigureSets the selected state.- Specified by:
setSelectedin interfaceFigure- Parameters:
selected- The selected state.
-
getNormalStyle
- Specified by:
getNormalStylein interfaceFigure- Returns:
- The style used for the "normal" state of the figure.
-
setNormalStyle
Description copied from interface:FigureSets the style used for the "normal" state of the figure.- Specified by:
setNormalStylein interfaceFigure- Parameters:
normalStyle- The style used for the "normal" state of the figure.
-
getSelectedStyle
- Specified by:
getSelectedStylein interfaceFigure- Returns:
- The style used for the "selected" state of the figure.
-
setSelectedStyle
Description copied from interface:FigureSets the style used for the "selected" state of the figure.- Specified by:
setSelectedStylein interfaceFigure- Parameters:
selectedStyle- The style used for the "selected" state of the figure.
-
getEffectiveStyle
- Specified by:
getEffectiveStylein 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:
getFigureCountin interfaceFigure- Returns:
- Always
0.
-
getFigureIndex
The default implementation returns0.- Specified by:
getFigureIndexin 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:
getFiguresin 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:
getFiguresin interfaceFigure- Returns:
- Always an empty array.
-
addFigure
Description copied from interface:FigureAdds a child figure to this figure. -
addFigure
Description copied from interface:FigureAdds a child figure at the given index to this figure. -
addFigures
Description copied from interface:FigureAdds a child figure at the given index to this figure.- Specified by:
addFiguresin 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:FigureRemoves a child figure from this figure.- Specified by:
removeFigurein interfaceFigure- Parameters:
figure- The new child figure.- Returns:
true, if the child has been removed.
-
removeFigures
Description copied from interface:FigureRemoves the given child figures from this figure.- Specified by:
removeFiguresin 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:FigureRemoves all child figures from this figure.- Specified by:
removeAllFiguresin 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:FigureMoves the figure by the given delta in model coordinates. -
scale
Description copied from interface:FigureScales the figure by the given scale factors. -
rotate
Description copied from interface:FigureRotates the figure by the given angle. -
getSegment
public double[] getSegment(int index) Description copied from interface:FigureGets the segment at the given vertex index.- Specified by:
getSegmentin 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:FigureSets the segment at the given vertex index.- Specified by:
setSegmentin 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:FigureAdds the segment at the given vertex index.- Specified by:
addSegmentin 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:FigureRemoves the segment at the given vertex index.- Specified by:
removeSegmentin interfaceFigure- Parameters:
index- The vertex index.
-
getMaxSelectionStage
public int getMaxSelectionStage()The default implementation returns zero.- Specified by:
getMaxSelectionStagein 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:
createHandlesin 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:
createMementoin interfaceRestorable- Returns:
- Always
null.
-
setMemento
The default implementation does nothing. Clients should override in order to evaluate the passed inmemento. object.- Specified by:
setMementoin interfaceRestorable- Parameters:
memento- A memento object.
-
addChangeListener
Description copied from interface:FigureAdds a new change listener to this figure.- Specified by:
addChangeListenerin interfaceFigure- Parameters:
listener- The listener.
-
removeChangeListener
Description copied from interface:FigureRemoves a change listener from this figure.- Specified by:
removeChangeListenerin interfaceFigure- Parameters:
listener- The listener.
-
getChangeListeners
- Specified by:
getChangeListenersin interfaceFigure- Returns:
- The array of all change listeners registered with this figure.
-
dispose
public void dispose()Description copied from interface:FigureDisposes this figure. Indicates that it will no longer be used. -
clone
-
fireFiguresAdded
-
fireFiguresRemoved
-
fireFigureChanged
protected void fireFigureChanged() -
fireFigureChanged
-
createScaleHandles
-
getHandleStyle
-
getSelectedHandleStyle
-