Package com.bc.ceres.swing.figure
Class AbstractShapeFigure
java.lang.Object
com.bc.ceres.swing.figure.AbstractFigure
com.bc.ceres.swing.figure.AbstractShapeFigure
- All Implemented Interfaces:
Figure
,ShapeFigure
,Restorable
,Cloneable
- Direct Known Subclasses:
DefaultShapeFigure
A figure that is based on a Java AWT shape geometry.
Sub-classes have to provide the actual shape (lines or areas) in model coordinates.
- Since:
- Ceres 0.10
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.bc.ceres.swing.figure.Figure
Figure.Rank
-
Field Summary
Fields inherited from class com.bc.ceres.swing.figure.AbstractFigure
NO_FIGURES, NO_HANDLES
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
AbstractShapeFigure
(Figure.Rank rank, FigureStyle normalStyle, FigureStyle selectedStyle) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSegment
(int index, double[] segment) Adds the segment at the given vertex index.Handle[]
createHandles
(int selectionStage) The default implementation returns an empty array.The default implementation returns [@code null}.void
Draws this figure using the given rendering.protected void
Draws theshape
and other items that are used to graphically represent the figure, for example labels.int
The default implementation returns zero.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.void
move
(double dx, double dy) Moves the figure by the given delta in model coordinates.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
setMemento
(Object memento) The default implementation does nothing.protected void
setRank
(Figure.Rank rank) void
setSegment
(int index, double[] newSeg) Sets the segment at the given vertex index.Methods inherited from class com.bc.ceres.swing.figure.AbstractFigure
addChangeListener, addFigure, addFigure, addFigureImpl, addFigureImpl, addFigures, addFiguresImpl, clone, contains, createScaleHandles, dispose, fireFigureChanged, fireFigureChanged, fireFiguresAdded, fireFiguresRemoved, getChangeListeners, getEffectiveStyle, getFigure, getFigure, getFigureCount, getFigureIndex, getFigures, getFigures, getHandleStyle, getNormalStyle, getSelectedHandleStyle, getSelectedStyle, isSelectable, isSelected, removeAllFigures, removeChangeListener, removeFigure, removeFigureImpl, removeFigures, removeFiguresImpl, removeFiguresImpl, setNormalStyle, setSelectable, setSelected, setSelectedStyle
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.bc.ceres.swing.figure.Figure
addChangeListener, addFigure, addFigure, addFigures, clone, contains, dispose, getChangeListeners, getEffectiveStyle, getFigure, getFigure, getFigureCount, getFigureIndex, getFigures, getFigures, getNormalStyle, getSelectedStyle, isSelectable, isSelected, removeAllFigures, removeChangeListener, removeFigure, removeFigures, setNormalStyle, setSelected, setSelectedStyle
Methods inherited from interface com.bc.ceres.swing.figure.ShapeFigure
getShape, setShape
-
Constructor Details
-
AbstractShapeFigure
protected AbstractShapeFigure() -
AbstractShapeFigure
Constructor.- Parameters:
rank
- The rank, must be eitherFigure.Rank.AREA
orFigure.Rank.LINE
.normalStyle
- The style used for the "normal" state of the figure.selectedStyle
- The style used for the "selected" state of the figure.
-
-
Method Details
-
isCollection
public boolean isCollection()Description copied from interface:Figure
Tests if this figure is a figure collection.- Specified by:
isCollection
in interfaceFigure
- Returns:
true
, if so.
-
getRank
-
setRank
-
getBounds
-
draw
Description copied from interface:Figure
Draws this figure using the given rendering. -
drawShape
Draws theshape
and other items that are used to graphically represent the figure, for example labels. For convenience, the rendering's drawing context is pre-transformed, so that drawing of the shape can be performed in model coordinates.- Parameters:
rendering
- The rendering.
-
isCloseTo
Description copied from interface:Figure
Tests if the given point is "close to" this figure. -
scale
Description copied from interface:Figure
Scales the figure by the given scale factors.- Specified by:
scale
in interfaceFigure
- Overrides:
scale
in classAbstractFigure
- Parameters:
refPoint
- The reference point in model coordinates.sx
- Scale X factor.sy
- Scale Y factor.
-
move
public void move(double dx, double dy) Description copied from interface:Figure
Moves the figure by the given delta in model coordinates.- Specified by:
move
in interfaceFigure
- Overrides:
move
in classAbstractFigure
- Parameters:
dx
- Delta X in model coordinates.dy
- Delta Y in model coordinates.
-
rotate
Description copied from interface:Figure
Rotates the figure by the given angle.- Specified by:
rotate
in interfaceFigure
- Overrides:
rotate
in classAbstractFigure
- Parameters:
point
- The reference point in model coordinates.theta
- The rotation angle in degree.
-
getSegment
public double[] getSegment(int index) Description copied from interface:Figure
Gets the segment at the given vertex index.- Specified by:
getSegment
in interfaceFigure
- Overrides:
getSegment
in classAbstractFigure
- Parameters:
index
- The vertex index.- Returns:
- The segment coordinates. X is the first element, Y the second.
-
setSegment
public void setSegment(int index, double[] newSeg) Description copied from interface:Figure
Sets the segment at the given vertex index.- Specified by:
setSegment
in interfaceFigure
- Overrides:
setSegment
in classAbstractFigure
- Parameters:
index
- The vertex index.newSeg
- The segment coordinates. X is the first element, Y the second.
-
addSegment
public void addSegment(int index, double[] segment) Description copied from interface:Figure
Adds the segment at the given vertex index.- Specified by:
addSegment
in interfaceFigure
- Overrides:
addSegment
in classAbstractFigure
- 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:Figure
Removes the segment at the given vertex index.- Specified by:
removeSegment
in interfaceFigure
- Overrides:
removeSegment
in classAbstractFigure
- Parameters:
index
- The vertex index.
-
createMemento
Description copied from class:AbstractFigure
The default implementation returns [@code null}. Clients should override in order to produce something more meaningful.- Specified by:
createMemento
in interfaceRestorable
- Overrides:
createMemento
in classAbstractFigure
- Returns:
- Always
null
.
-
setMemento
Description copied from class:AbstractFigure
The default implementation does nothing. Clients should override in order to evaluate the passed inmemento
. object.- Specified by:
setMemento
in interfaceRestorable
- Overrides:
setMemento
in classAbstractFigure
- Parameters:
memento
- A memento object.
-
getMaxSelectionStage
public int getMaxSelectionStage()Description copied from class:AbstractFigure
The default implementation returns zero.- Specified by:
getMaxSelectionStage
in interfaceFigure
- Overrides:
getMaxSelectionStage
in classAbstractFigure
- Returns:
- Always
0
.
-
createHandles
Description copied from class:AbstractFigure
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:
createHandles
in interfaceFigure
- Overrides:
createHandles
in classAbstractFigure
- Parameters:
selectionStage
- The selection stage.1 <= selectionLevel <=
AbstractFigure.getMaxSelectionStage()
- Returns:
- The array of handles.
-