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 theirHandle
s.Clients should not implement this interface directly, because it may change in the future. Instead they should derive their
Figure
implementation fromAbstractFigure
.- Since:
- Ceres 0.10
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Figure.Rank
The rang of a figure.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addChangeListener(FigureChangeListener listener)
Adds a new change listener to this figure.boolean
addFigure(int index, Figure figure)
Adds a child figure at the given index to this figure.boolean
addFigure(Figure figure)
Adds a child figure to this figure.Figure[]
addFigures(Figure... figures)
Adds a child figure at the given index to this figure.void
addSegment(int index, double[] segment)
Adds the segment at the given vertex index.Object
clone()
boolean
contains(Figure figure)
Tests if this figure fully contains the given figure.Handle[]
createHandles(int selectionStage)
Creates the handles for a given selection stage.void
dispose()
Disposes this figure.void
draw(Rendering rendering)
Draws this figure using the given rendering.Rectangle2D
getBounds()
FigureChangeListener[]
getChangeListeners()
FigureStyle
getEffectiveStyle()
Figure
getFigure(int index)
Gets the child figure at the given index.Figure
getFigure(Point2D point, AffineTransform m2v)
Gets the "nearest" figure for the given point.int
getFigureCount()
int
getFigureIndex(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.int
getMaxSelectionStage()
Gets the maximum number of selection stages offered by this figure.FigureStyle
getNormalStyle()
Figure.Rank
getRank()
double[]
getSegment(int index)
Gets the segment at the given vertex index.FigureStyle
getSelectedStyle()
boolean
isCloseTo(Point2D point, AffineTransform m2v)
Tests if the given point is "close to" this figure.boolean
isCollection()
Tests if this figure is a figure collection.boolean
isSelectable()
Tests if the figure is selectable.boolean
isSelected()
Tests if the figure is selected.void
move(double dx, double dy)
Moves the figure by the given delta in model coordinates.Figure[]
removeAllFigures()
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.Figure[]
removeFigures(Figure... figures)
Removes the given child figures from this figure.void
removeSegment(int index)
Removes the segment at the given vertex index.void
rotate(Point2D point, double theta)
Rotates the figure by the given angle.void
scale(Point2D point, double sx, double sy)
Scales the figure by the given scale factors.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
setSelected(boolean selected)
Sets the selected state.void
setSelectedStyle(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.
-
-