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
A figure represents a graphical object.
Figures are graphically modified by their
Handle
s.
Clients should not implement this interface directly, because it may change in the future.
Instead they should derive their Figure
implementation from AbstractFigure
.
- Since:
- Ceres 0.10
-
Nested Class Summary
Nested Classes -
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.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.clone()
boolean
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
Draws this figure using the given rendering.getFigure
(int index) Gets the child figure at the given index.getFigure
(Point2D point, AffineTransform m2v) Gets the "nearest" figure for the given point.int
int
getFigureIndex
(Figure figure) Gets the index of the given child figure.Figure[]
Figure[]
getFigures
(Shape shape) Gets child figures that have an intersection with the given shape.int
Gets the maximum number of selection stages offered by this figure.getRank()
double[]
getSegment
(int index) Gets the segment at the given vertex index.boolean
isCloseTo
(Point2D point, AffineTransform m2v) Tests if the given point is "close to" this figure.boolean
Tests if this figure is a figure collection.boolean
Tests if the figure is selectable.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.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
Rotates the figure by the given angle.void
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 Details
-
getNormalStyle
FigureStyle getNormalStyle()- Returns:
- The style used for the "normal" state of the figure.
- Since:
- Ceres 0.13
-
setNormalStyle
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
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
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
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
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
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
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
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
Gets the child figure at the given index.- Parameters:
index
- The child index.- Returns:
- The child figure.
-
getFigure
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
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
Adds a child figure to this figure.- Parameters:
figure
- The new child figure.- Returns:
true
, if the child has been added.
-
addFigure
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
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
Removes a child figure from this figure.- Parameters:
figure
- The new child figure.- Returns:
true
, if the child has been removed.
-
removeFigures
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
Creates the handles for a given selection stage.- Parameters:
selectionStage
- The selection stage.- Returns:
- The array of handles.
-
addChangeListener
Adds a new change listener to this figure.- Parameters:
listener
- The listener.
-
removeChangeListener
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.
-