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
public abstract class AbstractShapeFigure extends AbstractFigure implements ShapeFigure
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
Constructors Modifier Constructor Description protectedAbstractShapeFigure()protectedAbstractShapeFigure(Figure.Rank rank, FigureStyle normalStyle, FigureStyle selectedStyle)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddSegment(int index, double[] segment)Adds the segment at the given vertex index.Handle[]createHandles(int selectionStage)The default implementation returns an empty array.ObjectcreateMemento()The default implementation returns [@code null}.voiddraw(Rendering rendering)Draws this figure using the given rendering.protected voiddrawShape(Rendering rendering)Draws theshapeand other items that are used to graphically represent the figure, for example labels.Rectangle2DgetBounds()intgetMaxSelectionStage()The default implementation returns zero.Figure.RankgetRank()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.booleanisCollection()Tests 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.voidrotate(Point2D point, double theta)Rotates the figure by the given angle.voidscale(Point2D refPoint, double sx, double sy)Scales 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, 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 Detail
-
AbstractShapeFigure
protected AbstractShapeFigure()
-
AbstractShapeFigure
protected AbstractShapeFigure(Figure.Rank rank, FigureStyle normalStyle, FigureStyle selectedStyle)
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 Detail
-
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
public Figure.Rank getRank()
-
setRank
protected void setRank(Figure.Rank rank)
-
getBounds
public Rectangle2D getBounds()
-
draw
public void draw(Rendering rendering)
Description copied from interface:FigureDraws this figure using the given rendering.
-
drawShape
protected void drawShape(Rendering rendering)
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
public boolean isCloseTo(Point2D point, AffineTransform m2v)
Description copied from interface:FigureTests if the given point is "close to" this figure.
-
scale
public void scale(Point2D refPoint, double sx, double sy)
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
public void rotate(Point2D point, double theta)
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
public Object 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
public void setMemento(Object memento)
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
public Handle[] createHandles(int selectionStage)
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.
-
-