Class DefaultFigureCollection
- java.lang.Object
-
- com.bc.ceres.swing.figure.AbstractFigure
-
- com.bc.ceres.swing.figure.support.DefaultFigureCollection
-
- All Implemented Interfaces:
Figure
,FigureCollection
,Restorable
,Cloneable
- Direct Known Subclasses:
DefaultFigureSelection
public class DefaultFigureCollection extends AbstractFigure implements FigureCollection
-
-
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 Constructor Description DefaultFigureCollection()
DefaultFigureCollection(Figure[] figures)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
addFigureImpl(int index, Figure figure)
The default implementation throws an [@code IllegalStateException}.protected boolean
addFigureImpl(Figure figure)
Object
clone()
protected Rectangle2D
computeBounds()
boolean
contains(Figure figure)
The default implementation returnsfalse
.Handle[]
createHandles(int selectionStage)
The default implementation returns an empty array.Object
createMemento()
The default implementation returns [@code null}.void
dispose()
Disposes this figure.void
draw(Rendering rendering)
Draws this figure using the given rendering.Rectangle2D
getBounds()
Figure
getFigure(int index)
The default implementation throws an [@code IllegalStateException}.Figure
getFigure(Point2D p, AffineTransform m2v)
The default implementation returnsnull
.int
getFigureCount()
The default implementation returns0
.int
getFigureIndex(Figure figure)
The default implementation returns0
.Figure[]
getFigures()
The default implementation returns an empty array.Figure[]
getFigures(Shape shape)
The default implementation returns an empty array.int
getMaxSelectionStage()
The default implementation returns zero.Figure.Rank
getRank()
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()
The default implementation returnsfalse
.boolean
isSelected()
Tests if the figure is selected.void
move(double dx, double dy)
Moves the figure by the given delta in model coordinates.protected boolean
removeFigureImpl(Figure figure)
The default implementation throws an [@code IllegalStateException}.protected Figure[]
removeFiguresImpl()
void
rotate(Point2D point, double theta)
Rotates the figure by the given angle.void
scale(Point2D refPoint, double sx, double sy)
Scales the figure by the given scale factors.void
setMemento(Object memento)
The default implementation does nothing.void
setSelected(boolean selected)
Sets the selected state.-
Methods inherited from class com.bc.ceres.swing.figure.AbstractFigure
addChangeListener, addFigure, addFigure, addFigures, addFiguresImpl, addSegment, createScaleHandles, fireFigureChanged, fireFigureChanged, fireFiguresAdded, fireFiguresRemoved, getChangeListeners, getEffectiveStyle, getHandleStyle, getNormalStyle, getSegment, getSelectedHandleStyle, getSelectedStyle, removeAllFigures, removeChangeListener, removeFigure, removeFigures, removeFiguresImpl, removeSegment, setNormalStyle, setSegment, setSelectable, 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, addSegment, getChangeListeners, getEffectiveStyle, getNormalStyle, getSegment, getSelectedStyle, removeAllFigures, removeChangeListener, removeFigure, removeFigures, removeSegment, setNormalStyle, setSegment, setSelectedStyle
-
-
-
-
Constructor Detail
-
DefaultFigureCollection
public DefaultFigureCollection()
-
DefaultFigureCollection
public DefaultFigureCollection(Figure[] figures)
-
-
Method Detail
-
isSelectable
public boolean isSelectable()
Description copied from class:AbstractFigure
The default implementation returnsfalse
.- Specified by:
isSelectable
in interfaceFigure
- Overrides:
isSelectable
in classAbstractFigure
- Returns:
- Always
false
.
-
isSelected
public boolean isSelected()
Description copied from interface:Figure
Tests if the figure is selected.- Specified by:
isSelected
in interfaceFigure
- Overrides:
isSelected
in classAbstractFigure
- Returns:
true
, if so.
-
setSelected
public void setSelected(boolean selected)
Description copied from interface:Figure
Sets the selected state.- Specified by:
setSelected
in interfaceFigure
- Overrides:
setSelected
in classAbstractFigure
- Parameters:
selected
- The selected state.
-
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
public Figure.Rank getRank()
-
dispose
public void dispose()
Description copied from interface:Figure
Disposes this figure. Indicates that it will no longer be used.- Specified by:
dispose
in interfaceFigure
- Overrides:
dispose
in classAbstractFigure
-
clone
public Object clone()
- Specified by:
clone
in interfaceFigure
- Overrides:
clone
in classAbstractFigure
- Returns:
- A clone of this figure.
-
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
public Handle[] createHandles(int selectionStage)
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.
-
isCloseTo
public boolean isCloseTo(Point2D point, AffineTransform m2v)
Description copied from interface:Figure
Tests if the given point is "close to" this figure.
-
contains
public boolean contains(Figure figure)
Description copied from class:AbstractFigure
The default implementation returnsfalse
.- Specified by:
contains
in interfaceFigure
- Overrides:
contains
in classAbstractFigure
- Parameters:
figure
- A figure.- Returns:
- Always
false
.
-
getFigureCount
public int getFigureCount()
Description copied from class:AbstractFigure
The default implementation returns0
.- Specified by:
getFigureCount
in interfaceFigure
- Overrides:
getFigureCount
in classAbstractFigure
- Returns:
- Always
0
.
-
getFigureIndex
public int getFigureIndex(Figure figure)
Description copied from class:AbstractFigure
The default implementation returns0
.- Specified by:
getFigureIndex
in interfaceFigure
- Overrides:
getFigureIndex
in classAbstractFigure
- Parameters:
figure
- The child figure to look up.- Returns:
- Always
0
.
-
getFigure
public Figure getFigure(int index)
Description copied from class:AbstractFigure
The default implementation throws an [@code IllegalStateException}.- Specified by:
getFigure
in interfaceFigure
- Overrides:
getFigure
in classAbstractFigure
- Parameters:
index
- The child index.- Returns:
- Does never return normally.
-
getFigure
public Figure getFigure(Point2D p, AffineTransform m2v)
Description copied from class:AbstractFigure
The default implementation returnsnull
.- Specified by:
getFigure
in interfaceFigure
- Overrides:
getFigure
in classAbstractFigure
- Parameters:
p
- Point in model coordinates.m2v
- Current model-to-view transformation.- Returns:
- Always
null
.
-
getFigures
public Figure[] getFigures(Shape shape)
Description copied from class:AbstractFigure
The default implementation returns an empty array.- Specified by:
getFigures
in interfaceFigure
- Overrides:
getFigures
in classAbstractFigure
- Parameters:
shape
- The shape defining the area in which the figures must be contained.- Returns:
- Always an empty array.
-
getFigures
public Figure[] getFigures()
Description copied from class:AbstractFigure
The default implementation returns an empty array.- Specified by:
getFigures
in interfaceFigure
- Overrides:
getFigures
in classAbstractFigure
- Returns:
- Always an empty array.
-
addFigureImpl
protected boolean addFigureImpl(Figure figure)
- Overrides:
addFigureImpl
in classAbstractFigure
-
addFigureImpl
protected boolean addFigureImpl(int index, Figure figure)
Description copied from class:AbstractFigure
The default implementation throws an [@code IllegalStateException}.- Overrides:
addFigureImpl
in classAbstractFigure
- Parameters:
index
- The index.figure
- The figure.- Returns:
- Does never return normally.
-
removeFigureImpl
protected boolean removeFigureImpl(Figure figure)
Description copied from class:AbstractFigure
The default implementation throws an [@code IllegalStateException}.- Overrides:
removeFigureImpl
in classAbstractFigure
- Parameters:
figure
- The figure.- Returns:
- Does never return normally.
-
removeFiguresImpl
protected Figure[] removeFiguresImpl()
- Overrides:
removeFiguresImpl
in classAbstractFigure
-
getBounds
public Rectangle2D getBounds()
-
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.
-
scale
public void scale(Point2D refPoint, double sx, double sy)
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.
-
rotate
public void rotate(Point2D point, double theta)
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.
-
draw
public void draw(Rendering rendering)
Description copied from interface:Figure
Draws this figure using the given rendering.
-
createMemento
public Object 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
public void setMemento(Object memento)
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.
-
computeBounds
protected Rectangle2D computeBounds()
-
-