Package com.bc.ceres.swing.figure
Interface Figure
-
- All Superinterfaces:
Cloneable,Restorable
- All Known Subinterfaces:
FigureCollection,FigureSelection,Handle,PointFigure,ShapeFigure
- All Known Implementing Classes:
AbstractFigure,AbstractHandle,AbstractPointFigure,AbstractShapeFigure,DefaultFigureCollection,DefaultFigureSelection,DefaultPointFigure,DefaultShapeFigure,PointHandle,RotateHandle,ScaleHandle,VertexHandle
public interface Figure extends Restorable, Cloneable
A figure represents a graphical object. Figures are graphically modified by theirHandles.Clients should not implement this interface directly, because it may change in the future. Instead they should derive their
Figureimplementation fromAbstractFigure.- Since:
- Ceres 0.10
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classFigure.RankThe rang of a figure.
-
Method Summary
All Methods Instance Methods Abstract 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.Figure[]addFigures(Figure... figures)Adds a child figure at the given index to this figure.voidaddSegment(int index, double[] segment)Adds the segment at the given vertex index.Objectclone()booleancontains(Figure figure)Tests if this figure fully contains the given figure.Handle[]createHandles(int selectionStage)Creates the handles for a given selection stage.voiddispose()Disposes this figure.voiddraw(Rendering rendering)Draws this figure using the given rendering.Rectangle2DgetBounds()FigureChangeListener[]getChangeListeners()FigureStylegetEffectiveStyle()FiguregetFigure(int index)Gets the child figure at the given index.FiguregetFigure(Point2D point, AffineTransform m2v)Gets the "nearest" figure for the given point.intgetFigureCount()intgetFigureIndex(Figure figure)Gets the index of the given child figure.Figure[]getFigures()Figure[]getFigures(Shape shape)Gets child figures that have an intersection with the given shape.intgetMaxSelectionStage()Gets the maximum number of selection stages offered by this figure.FigureStylegetNormalStyle()Figure.RankgetRank()double[]getSegment(int index)Gets the segment at the given vertex index.FigureStylegetSelectedStyle()booleanisCloseTo(Point2D point, AffineTransform m2v)Tests if the given point is "close to" this figure.booleanisCollection()Tests if this figure is a figure collection.booleanisSelectable()Tests if the figure is selectable.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.Figure[]removeFigures(Figure... figures)Removes the given child figures from this figure.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.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.voidsetSelected(boolean selected)Sets the selected state.voidsetSelectedStyle(FigureStyle selectedStyle)Sets the style used for the "selected" state of the figure.-
Methods inherited from interface com.bc.ceres.swing.undo.Restorable
createMemento, setMemento
-
-
-
-
Method Detail
-
getNormalStyle
FigureStyle getNormalStyle()
- Returns:
- The style used for the "normal" state of the figure.
- Since:
- Ceres 0.13
-
setNormalStyle
void setNormalStyle(FigureStyle normalStyle)
Sets the style used for the "normal" state of the figure.- Parameters:
normalStyle- The style used for the "normal" state of the figure.- Since:
- Ceres 0.13
-
getSelectedStyle
FigureStyle getSelectedStyle()
- Returns:
- The style used for the "selected" state of the figure.
- Since:
- Ceres 0.13
-
setSelectedStyle
void setSelectedStyle(FigureStyle selectedStyle)
Sets the style used for the "selected" state of the figure.- Parameters:
selectedStyle- The style used for the "selected" state of the figure.- Since:
- Ceres 0.13
-
getEffectiveStyle
FigureStyle getEffectiveStyle()
- Returns:
- The effective style used for the current state of the figure.
- Since:
- Ceres 0.13
-
isCollection
boolean isCollection()
Tests if this figure is a figure collection.- Returns:
true, if so.
-
contains
boolean contains(Figure figure)
Tests if this figure fully contains the given figure.- Parameters:
figure- A figure.- Returns:
true, if the given figure is fully contained in this figure.
-
isCloseTo
boolean isCloseTo(Point2D point, AffineTransform m2v)
Tests if the given point is "close to" this figure.- Parameters:
point- Point in model coordinates.m2v- Current model-to-view transformation.- Returns:
true, if the point is close to this figure.
-
getBounds
Rectangle2D getBounds()
- Returns:
- The figure bounds in model coordinates.
-
getRank
Figure.Rank getRank()
- Returns:
- The figure's rank.
-
move
void move(double dx, double dy)Moves the figure by the given delta in model coordinates.- Parameters:
dx- Delta X in model coordinates.dy- Delta Y in model coordinates.
-
scale
void scale(Point2D point, double sx, double sy)
Scales the figure by the given scale factors.- Parameters:
point- The reference point in model coordinates.sx- Scale X factor.sy- Scale Y factor.
-
rotate
void rotate(Point2D point, double theta)
Rotates the figure by the given angle.- Parameters:
point- The reference point in model coordinates.theta- The rotation angle in degree.
-
getSegment
double[] getSegment(int index)
Gets the segment at the given vertex index.- Parameters:
index- The vertex index.- Returns:
- The segment coordinates. X is the first element, Y the second.
-
setSegment
void setSegment(int index, double[] segment)Sets the segment at the given vertex index.- Parameters:
index- The vertex index.segment- The segment coordinates. X is the first element, Y the second.
-
addSegment
void addSegment(int index, double[] segment)Adds the segment at the given vertex index.- Parameters:
index- The vertex index.segment- The segment coordinates. X is the first element, Y the second.
-
removeSegment
void removeSegment(int index)
Removes the segment at the given vertex index.- Parameters:
index- The vertex index.
-
isSelectable
boolean isSelectable()
Tests if the figure is selectable.- Returns:
true, if so.
-
isSelected
boolean isSelected()
Tests if the figure is selected.- Returns:
true, if so.
-
setSelected
void setSelected(boolean selected)
Sets the selected state.- Parameters:
selected- The selected state.
-
draw
void draw(Rendering rendering)
Draws this figure using the given rendering.- Parameters:
rendering- The rendering used to draw the figure.
-
getFigureCount
int getFigureCount()
- Returns:
- The number of child figures this figure has.
-
getFigureIndex
int getFigureIndex(Figure figure)
Gets the index of the given child figure.- Parameters:
figure- The child figure to look up.- Returns:
- The index,
-1, if the figure ios not a child.
-
getFigure
Figure getFigure(int index)
Gets the child figure at the given index.- Parameters:
index- The child index.- Returns:
- The child figure.
-
getFigure
Figure getFigure(Point2D point, AffineTransform m2v)
Gets the "nearest" figure for the given point.- Parameters:
point- Point in model coordinates.m2v- Current model-to-view transformation.- Returns:
- The figure, or
null.
-
getFigures
Figure[] getFigures()
- Returns:
- The array of child figures. An empty array, if this figure does not have child figures.
-
getFigures
Figure[] getFigures(Shape shape)
Gets child figures that have an intersection with the given shape.- Parameters:
shape- The shape in model coordinates.- Returns:
- The array of child figures that have an intersection with the given shape.
-
addFigure
boolean addFigure(Figure figure)
Adds a child figure to this figure.- Parameters:
figure- The new child figure.- Returns:
true, if the child has been added.
-
addFigure
boolean addFigure(int index, Figure figure)Adds a child figure at the given index to this figure.- Parameters:
index- The index.figure- The new child figure.- Returns:
true, if the child has been added.
-
addFigures
Figure[] addFigures(Figure... figures)
Adds a child figure at the given index to this figure.- Parameters:
figures- The array of new child figures.- Returns:
- The array of child figures that actually have been added.
-
removeFigure
boolean removeFigure(Figure figure)
Removes a child figure from this figure.- Parameters:
figure- The new child figure.- Returns:
true, if the child has been removed.
-
removeFigures
Figure[] removeFigures(Figure... figures)
Removes the given child figures from this figure.- Parameters:
figures- The array of child figures to remove.- Returns:
- The array of child figures that actually have been removed.
-
removeAllFigures
Figure[] removeAllFigures()
Removes all child figures from this figure.- Returns:
- The array of child figures that actually have been removed.
-
getMaxSelectionStage
int getMaxSelectionStage()
Gets the maximum number of selection stages offered by this figure. A figure may enter into a new selection stage if it is already selected and is then selected again (e.g. by clicking it once more).- Returns:
- The maximum number of selection stages.
-
createHandles
Handle[] createHandles(int selectionStage)
Creates the handles for a given selection stage.- Parameters:
selectionStage- The selection stage.- Returns:
- The array of handles.
-
addChangeListener
void addChangeListener(FigureChangeListener listener)
Adds a new change listener to this figure.- Parameters:
listener- The listener.
-
removeChangeListener
void removeChangeListener(FigureChangeListener listener)
Removes a change listener from this figure.- Parameters:
listener- The listener.
-
getChangeListeners
FigureChangeListener[] getChangeListeners()
- Returns:
- The array of all change listeners registered with this figure.
-
dispose
void dispose()
Disposes this figure. Indicates that it will no longer be used.
-
clone
Object clone()
- Returns:
- A clone of this figure.
-
-