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
 
 public abstract class AbstractFigure extends Object implements Figure Base class for allFigureimplementations.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.FigureFigure.Rank
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected static Figure[]NO_FIGURESprotected static Handle[]NO_HANDLES
 - 
Constructor SummaryConstructors Modifier Constructor Description protectedAbstractFigure()protectedAbstractFigure(FigureStyle normalStyle, FigureStyle selectedStyle)
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChangeListener(FigureChangeListener listener)Adds a new change listener to this figure.booleanaddFigure(int index, Figure figure)Adds a child figure at the given index to this figure.booleanaddFigure(Figure figure)Adds 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.Objectclone()booleancontains(Figure figure)The default implementation returnsfalse.Handle[]createHandles(int selectionStage)The default implementation returns an empty array.ObjectcreateMemento()The default implementation returns [@code null}.protected Handle[]createScaleHandles(double distance)voiddispose()Disposes this figure.protected voidfireFigureChanged()protected voidfireFigureChanged(FigureChangeEvent event)protected voidfireFiguresAdded(Figure... figures)protected voidfireFiguresRemoved(Figure... figures)FigureChangeListener[]getChangeListeners()FigureStylegetEffectiveStyle()FiguregetFigure(int index)The default implementation throws an [@code IllegalStateException}.FiguregetFigure(Point2D p, AffineTransform m2v)The default implementation returnsnull.intgetFigureCount()The default implementation returns0.intgetFigureIndex(Figure figure)The default implementation returns0.Figure[]getFigures()The default implementation returns an empty array.Figure[]getFigures(Shape shape)The default implementation returns an empty array.protected FigureStylegetHandleStyle()intgetMaxSelectionStage()The default implementation returns zero.FigureStylegetNormalStyle()double[]getSegment(int index)Gets the segment at the given vertex index.protected FigureStylegetSelectedHandleStyle()FigureStylegetSelectedStyle()booleanisSelectable()The default implementation returnsfalse.booleanisSelected()Tests if the figure is selected.voidmove(double dx, double dy)Moves the figure by the given delta in model coordinates.Figure[]removeAllFigures()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[]removeFiguresImpl()protected Figure[]removeFiguresImpl(Figure[] figures)voidremoveSegment(int index)Removes the segment at the given vertex index.voidrotate(Point2D point, double theta)Rotates the figure by the given angle.voidscale(Point2D point, double sx, double sy)Scales 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.
 
- 
- 
- 
Constructor Detail- 
AbstractFigureprotected AbstractFigure() 
 - 
AbstractFigureprotected AbstractFigure(FigureStyle normalStyle, FigureStyle selectedStyle) 
 
- 
 - 
Method Detail- 
isSelectablepublic boolean isSelectable() The default implementation returnsfalse.- Specified by:
- isSelectablein interface- Figure
- Returns:
- Always false.
 
 - 
setSelectablepublic void setSelectable(boolean selectable) 
 - 
isSelectedpublic boolean isSelected() Description copied from interface:FigureTests if the figure is selected.- Specified by:
- isSelectedin interface- Figure
- Returns:
- true, if so.
 
 - 
setSelectedpublic void setSelected(boolean selected) Description copied from interface:FigureSets the selected state.- Specified by:
- setSelectedin interface- Figure
- Parameters:
- selected- The selected state.
 
 - 
getNormalStylepublic FigureStyle getNormalStyle() - Specified by:
- getNormalStylein interface- Figure
- Returns:
- The style used for the "normal" state of the figure.
 
 - 
setNormalStylepublic void setNormalStyle(FigureStyle normalStyle) Description copied from interface:FigureSets the style used for the "normal" state of the figure.- Specified by:
- setNormalStylein interface- Figure
- Parameters:
- normalStyle- The style used for the "normal" state of the figure.
 
 - 
getSelectedStylepublic FigureStyle getSelectedStyle() - Specified by:
- getSelectedStylein interface- Figure
- Returns:
- The style used for the "selected" state of the figure.
 
 - 
setSelectedStylepublic void setSelectedStyle(FigureStyle selectedStyle) Description copied from interface:FigureSets the style used for the "selected" state of the figure.- Specified by:
- setSelectedStylein interface- Figure
- Parameters:
- selectedStyle- The style used for the "selected" state of the figure.
 
 - 
getEffectiveStylepublic FigureStyle getEffectiveStyle() - Specified by:
- getEffectiveStylein interface- Figure
- Returns:
- The effective style used for the current state of the figure.
 
 - 
containspublic boolean contains(Figure figure) The default implementation returnsfalse.
 - 
getFigureCountpublic int getFigureCount() The default implementation returns0.- Specified by:
- getFigureCountin interface- Figure
- Returns:
- Always 0.
 
 - 
getFigureIndexpublic int getFigureIndex(Figure figure) The default implementation returns0.- Specified by:
- getFigureIndexin interface- Figure
- Parameters:
- figure- The child figure to look up.
- Returns:
- Always 0.
 
 - 
getFigurepublic Figure getFigure(Point2D p, AffineTransform m2v) The default implementation returnsnull.
 - 
getFigurespublic Figure[] getFigures(Shape shape) The default implementation returns an empty array.- Specified by:
- getFiguresin interface- Figure
- Parameters:
- shape- The shape defining the area in which the figures must be contained.
- Returns:
- Always an empty array.
 
 - 
getFigurespublic Figure[] getFigures() The default implementation returns an empty array.- Specified by:
- getFiguresin interface- Figure
- Returns:
- Always an empty array.
 
 - 
addFigurepublic boolean addFigure(Figure figure) Description copied from interface:FigureAdds a child figure to this figure.
 - 
addFigurepublic boolean addFigure(int index, Figure figure)Description copied from interface:FigureAdds a child figure at the given index to this figure.
 - 
addFigurespublic Figure[] addFigures(Figure... figures) Description copied from interface:FigureAdds a child figure at the given index to this figure.- Specified by:
- addFiguresin interface- Figure
- Parameters:
- figures- The array of new child figures.
- Returns:
- The array of child figures that actually have been added.
 
 - 
removeFigurepublic boolean removeFigure(Figure figure) Description copied from interface:FigureRemoves a child figure from this figure.- Specified by:
- removeFigurein interface- Figure
- Parameters:
- figure- The new child figure.
- Returns:
- true, if the child has been removed.
 
 - 
removeFigurespublic Figure[] removeFigures(Figure... figures) Description copied from interface:FigureRemoves the given child figures from this figure.- Specified by:
- removeFiguresin interface- Figure
- Parameters:
- figures- The array of child figures to remove.
- Returns:
- The array of child figures that actually have been removed.
 
 - 
removeAllFigurespublic Figure[] removeAllFigures() Description copied from interface:FigureRemoves all child figures from this figure.- Specified by:
- removeAllFiguresin interface- Figure
- Returns:
- The array of child figures that actually have been removed.
 
 - 
getFigurepublic Figure getFigure(int index) The default implementation throws an [@code IllegalStateException}.
 - 
addFigureImplprotected boolean addFigureImpl(int index, Figure figure)The default implementation throws an [@code IllegalStateException}.- Parameters:
- index- The index.
- figure- The figure.
- Returns:
- Does never return normally.
 
 - 
addFigureImplprotected boolean addFigureImpl(Figure figure) 
 - 
removeFigureImplprotected boolean removeFigureImpl(Figure figure) The default implementation throws an [@code IllegalStateException}.- Parameters:
- figure- The figure.
- Returns:
- Does never return normally.
 
 - 
removeFiguresImplprotected Figure[] removeFiguresImpl() 
 - 
movepublic void move(double dx, double dy)Description copied from interface:FigureMoves the figure by the given delta in model coordinates.
 - 
scalepublic void scale(Point2D point, double sx, double sy) Description copied from interface:FigureScales the figure by the given scale factors.
 - 
rotatepublic void rotate(Point2D point, double theta) Description copied from interface:FigureRotates the figure by the given angle.
 - 
getSegmentpublic double[] getSegment(int index) Description copied from interface:FigureGets the segment at the given vertex index.- Specified by:
- getSegmentin interface- Figure
- Parameters:
- index- The vertex index.
- Returns:
- The segment coordinates. X is the first element, Y the second.
 
 - 
setSegmentpublic void setSegment(int index, double[] segment)Description copied from interface:FigureSets the segment at the given vertex index.- Specified by:
- setSegmentin interface- Figure
- Parameters:
- index- The vertex index.
- segment- The segment coordinates. X is the first element, Y the second.
 
 - 
addSegmentpublic void addSegment(int index, double[] segment)Description copied from interface:FigureAdds the segment at the given vertex index.- Specified by:
- addSegmentin interface- Figure
- Parameters:
- index- The vertex index.
- segment- The segment coordinates. X is the first element, Y the second.
 
 - 
removeSegmentpublic void removeSegment(int index) Description copied from interface:FigureRemoves the segment at the given vertex index.- Specified by:
- removeSegmentin interface- Figure
- Parameters:
- index- The vertex index.
 
 - 
getMaxSelectionStagepublic int getMaxSelectionStage() The default implementation returns zero.- Specified by:
- getMaxSelectionStagein interface- Figure
- Returns:
- Always 0.
 
 - 
createHandlespublic Handle[] createHandles(int selectionStage) 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 interface- Figure
- Parameters:
- selectionStage- The selection stage.- 1 <= selectionLevel <=- getMaxSelectionStage()
- Returns:
- The array of handles.
 
 - 
createMementopublic Object createMemento() The default implementation returns [@code null}. Clients should override in order to produce something more meaningful.- Specified by:
- createMementoin interface- Restorable
- Returns:
- Always null.
 
 - 
setMementopublic void setMemento(Object memento) The default implementation does nothing. Clients should override in order to evaluate the passed inmemento. object.- Specified by:
- setMementoin interface- Restorable
- Parameters:
- memento- A memento object.
 
 - 
addChangeListenerpublic void addChangeListener(FigureChangeListener listener) Description copied from interface:FigureAdds a new change listener to this figure.- Specified by:
- addChangeListenerin interface- Figure
- Parameters:
- listener- The listener.
 
 - 
removeChangeListenerpublic void removeChangeListener(FigureChangeListener listener) Description copied from interface:FigureRemoves a change listener from this figure.- Specified by:
- removeChangeListenerin interface- Figure
- Parameters:
- listener- The listener.
 
 - 
getChangeListenerspublic FigureChangeListener[] getChangeListeners() - Specified by:
- getChangeListenersin interface- Figure
- Returns:
- The array of all change listeners registered with this figure.
 
 - 
disposepublic void dispose() Description copied from interface:FigureDisposes this figure. Indicates that it will no longer be used.
 - 
clonepublic Object clone() 
 - 
fireFiguresAddedprotected void fireFiguresAdded(Figure... figures) 
 - 
fireFiguresRemovedprotected void fireFiguresRemoved(Figure... figures) 
 - 
fireFigureChangedprotected void fireFigureChanged() 
 - 
fireFigureChangedprotected void fireFigureChanged(FigureChangeEvent event) 
 - 
createScaleHandlesprotected Handle[] createScaleHandles(double distance) 
 - 
getHandleStyleprotected FigureStyle getHandleStyle() 
 - 
getSelectedHandleStyleprotected FigureStyle getSelectedHandleStyle() 
 
- 
 
-