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
ConstructorsModifierConstructorDescriptionprotectedprotectedAbstractShapeFigure(Figure.Rank rank, FigureStyle normalStyle, FigureStyle selectedStyle) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSegment(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}.voidDraws this figure using the given rendering.protected voidDraws theshapeand other items that are used to graphically represent the figure, for example labels.intThe default implementation returns zero.getRank()double[]getSegment(int index) Gets the segment at the given vertex index.booleanisCloseTo(Point2D point, AffineTransform m2v) Tests if the given point is "close to" this figure.booleanTests if this figure is a figure collection.voidmove(double dx, double dy) Moves the figure by the given delta in model coordinates.voidremoveSegment(int index) Removes the segment at the given vertex index.voidRotates the figure by the given angle.voidScales the figure by the given scale factors.voidsetMemento(Object memento) The default implementation does nothing.protected voidsetRank(Figure.Rank rank) voidsetSegment(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, setSelectedStyleMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, setSelectedStyleMethods 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.AREAorFigure.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:FigureTests if this figure is a figure collection.- Specified by:
isCollectionin interfaceFigure- Returns:
true, if so.
-
getRank
-
setRank
-
getBounds
-
draw
Description copied from interface:FigureDraws this figure using the given rendering. -
drawShape
Draws theshapeand 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:FigureTests if the given point is "close to" this figure. -
scale
Description copied from interface:FigureScales the figure by the given scale factors.- Specified by:
scalein interfaceFigure- Overrides:
scalein 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:FigureMoves the figure by the given delta in model coordinates.- Specified by:
movein interfaceFigure- Overrides:
movein classAbstractFigure- Parameters:
dx- Delta X in model coordinates.dy- Delta Y in model coordinates.
-
rotate
Description copied from interface:FigureRotates the figure by the given angle.- Specified by:
rotatein interfaceFigure- Overrides:
rotatein 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:FigureGets the segment at the given vertex index.- Specified by:
getSegmentin interfaceFigure- Overrides:
getSegmentin 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:FigureSets the segment at the given vertex index.- Specified by:
setSegmentin interfaceFigure- Overrides:
setSegmentin 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:FigureAdds the segment at the given vertex index.- Specified by:
addSegmentin interfaceFigure- Overrides:
addSegmentin 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:FigureRemoves the segment at the given vertex index.- Specified by:
removeSegmentin interfaceFigure- Overrides:
removeSegmentin classAbstractFigure- Parameters:
index- The vertex index.
-
createMemento
Description copied from class:AbstractFigureThe default implementation returns [@code null}. Clients should override in order to produce something more meaningful.- Specified by:
createMementoin interfaceRestorable- Overrides:
createMementoin classAbstractFigure- Returns:
- Always
null.
-
setMemento
Description copied from class:AbstractFigureThe default implementation does nothing. Clients should override in order to evaluate the passed inmemento. object.- Specified by:
setMementoin interfaceRestorable- Overrides:
setMementoin classAbstractFigure- Parameters:
memento- A memento object.
-
getMaxSelectionStage
public int getMaxSelectionStage()Description copied from class:AbstractFigureThe default implementation returns zero.- Specified by:
getMaxSelectionStagein interfaceFigure- Overrides:
getMaxSelectionStagein classAbstractFigure- Returns:
- Always
0.
-
createHandles
Description copied from class:AbstractFigureThe 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 interfaceFigure- Overrides:
createHandlesin classAbstractFigure- Parameters:
selectionStage- The selection stage.1 <= selectionLevel <=AbstractFigure.getMaxSelectionStage()- Returns:
- The array of handles.
-