Class DefaultFigureSelection
- java.lang.Object
-
- com.bc.ceres.swing.figure.AbstractFigure
-
- com.bc.ceres.swing.figure.support.DefaultFigureCollection
-
- com.bc.ceres.swing.figure.support.DefaultFigureSelection
-
- All Implemented Interfaces:
Extensible
,Figure
,FigureCollection
,FigureSelection
,Selection
,Restorable
,ClipboardOwner
,Cloneable
public class DefaultFigureSelection extends DefaultFigureCollection implements FigureSelection
-
-
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 DefaultFigureSelection()
-
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 Figure[]
addFiguresImpl(Figure[] figures)
FigureSelection
clone()
Creates and returns a copy of this selection.Transferable
createTransferable(boolean copy)
Creates a transferable representation of this selection.void
draw(Rendering rendering)
Draws this figure using the given rendering.<E> E
getExtension(Class<E> extensionType)
Gets the extension for this object corresponding to a specified extension type.Handle[]
getHandles()
Gets the handles associated with the current selection stage.String
getPresentationName()
Returns a localized, human-readable description of this selection, suitable for use in a change log or menu entry, for example.Handle
getSelectedHandle()
Object
getSelectedValue()
Gets the selected value.Object[]
getSelectedValues()
Gets the selected values of a multiple selection.int
getSelectionStage()
Gets the current selection stage.boolean
isEmpty()
boolean
isSelectable()
The default implementation returnsfalse
.boolean
isSelected()
Tests if the figure is selected.void
lostOwnership(Clipboard clipboard, Transferable contents)
Notifies this object that it is no longer the clipboard owner.Figure[]
removeAllFigures()
Removes all child figures from this figure.protected boolean
removeFigureImpl(Figure figure)
The default implementation throws an [@code IllegalStateException}.protected Figure[]
removeFiguresImpl()
void
setSelected(boolean selected)
Sets the selected state.void
setSelectedHandle(Handle handle)
void
setSelectionStage(int selectionStage)
Sets the current selection stage.String
toString()
-
Methods inherited from class com.bc.ceres.swing.figure.support.DefaultFigureCollection
addFigureImpl, computeBounds, contains, createHandles, createMemento, dispose, getBounds, getFigure, getFigure, getFigureCount, getFigureIndex, getFigures, getFigures, getMaxSelectionStage, getRank, isCloseTo, isCollection, move, rotate, scale, setMemento
-
Methods inherited from class com.bc.ceres.swing.figure.AbstractFigure
addChangeListener, addFigure, addFigure, addFigures, addSegment, createScaleHandles, fireFigureChanged, fireFigureChanged, fireFiguresAdded, fireFiguresRemoved, getChangeListeners, getEffectiveStyle, getHandleStyle, getNormalStyle, getSegment, getSelectedHandleStyle, getSelectedStyle, removeChangeListener, removeFigure, removeFigures, removeFiguresImpl, removeSegment, setNormalStyle, setSegment, setSelectable, setSelectedStyle
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.bc.ceres.swing.figure.Figure
addChangeListener, addFigure, addFigure, addFigures, addSegment, contains, createHandles, dispose, getBounds, getChangeListeners, getEffectiveStyle, getFigure, getFigure, getFigureCount, getFigureIndex, getFigures, getFigures, getMaxSelectionStage, getNormalStyle, getRank, getSegment, getSelectedStyle, isCloseTo, isCollection, move, removeChangeListener, removeFigure, removeFigures, removeSegment, rotate, scale, setNormalStyle, setSegment, setSelectedStyle
-
Methods inherited from interface com.bc.ceres.swing.undo.Restorable
createMemento, setMemento
-
-
-
-
Method Detail
-
getExtension
public <E> E getExtension(Class<E> extensionType)
Description copied from interface:Extensible
Gets the extension for this object corresponding to a specified extension type.- Specified by:
getExtension
in interfaceExtensible
- Parameters:
extensionType
- the extension type.- Returns:
- the extension for this object corresponding to the specified type,
or
null
if an extension of typeextensionType
cannot be delivered.
-
getSelectionStage
public int getSelectionStage()
Description copied from interface:FigureSelection
Gets the current selection stage. The maximum selection stage is given by the selected figure(s).- Specified by:
getSelectionStage
in interfaceFigureSelection
- Returns:
- The current selection stage.
- See Also:
Figure.getMaxSelectionStage()
,Figure.createHandles(int)
-
setSelectionStage
public void setSelectionStage(int selectionStage)
Description copied from interface:FigureSelection
Sets the current selection stage. The maximum selection stage is given by the selected figure(s).- Specified by:
setSelectionStage
in interfaceFigureSelection
- Parameters:
selectionStage
- The current selection stage.
-
getHandles
public Handle[] getHandles()
Description copied from interface:FigureSelection
Gets the handles associated with the current selection stage.- For a single selection, the handles are the ones created by the selected figure's
Figure.createHandles(int)
factory method. - For a multiple selection, the handles are the ones created by this figure selection's
Figure.createHandles(int)
factory method. - If the selection is empty, an empty handle array is returned.
- Specified by:
getHandles
in interfaceFigureSelection
- Returns:
- The handles associated with the current selection stage.
- See Also:
FigureSelection.getSelectionStage()
- For a single selection, the handles are the ones created by the selected figure's
-
getSelectedHandle
public Handle getSelectedHandle()
- Specified by:
getSelectedHandle
in interfaceFigureSelection
-
setSelectedHandle
public void setSelectedHandle(Handle handle)
- Specified by:
setSelectedHandle
in interfaceFigureSelection
-
isSelectable
public boolean isSelectable()
Description copied from class:AbstractFigure
The default implementation returnsfalse
.- Specified by:
isSelectable
in interfaceFigure
- Overrides:
isSelectable
in classDefaultFigureCollection
- 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 classDefaultFigureCollection
- 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 classDefaultFigureCollection
- Parameters:
selected
- The selected state.
-
getPresentationName
public String getPresentationName()
Description copied from interface:Selection
Returns a localized, human-readable description of this selection, suitable for use in a change log or menu entry, for example.- Specified by:
getPresentationName
in interfaceSelection
- Returns:
- A presentation name for this selection.
-
getSelectedValue
public Object getSelectedValue()
Description copied from interface:Selection
Gets the selected value. The method returnsnull
if this selectionis empty
.- Specified by:
getSelectedValue
in interfaceSelection
- Returns:
- The selected value, or
null
.
-
getSelectedValues
public Object[] getSelectedValues()
Description copied from interface:Selection
Gets the selected values of a multiple selection. The method returns an empty array if this selectionis empty
.- Specified by:
getSelectedValues
in interfaceSelection
- Returns:
- The array of selected values.
-
isEmpty
public boolean isEmpty()
-
createTransferable
public Transferable createTransferable(boolean copy)
Description copied from interface:Selection
Creates a transferable representation of this selection.- Specified by:
createTransferable
in interfaceSelection
- Parameters:
copy
- Iftrue
, the returnedTransferable
should hold a copy-of rather than a reference-to the selection.- Returns:
- A transferable representation of this selection or
null
if this is not possible.
-
addFigureImpl
protected boolean addFigureImpl(int index, Figure figure)
Description copied from class:AbstractFigure
The default implementation throws an [@code IllegalStateException}.- Overrides:
addFigureImpl
in classDefaultFigureCollection
- Parameters:
index
- The index.figure
- The figure.- Returns:
- Does never return normally.
-
addFiguresImpl
protected Figure[] addFiguresImpl(Figure[] figures)
- Overrides:
addFiguresImpl
in classAbstractFigure
-
removeFigureImpl
protected boolean removeFigureImpl(Figure figure)
Description copied from class:AbstractFigure
The default implementation throws an [@code IllegalStateException}.- Overrides:
removeFigureImpl
in classDefaultFigureCollection
- Parameters:
figure
- The figure.- Returns:
- Does never return normally.
-
removeFiguresImpl
protected Figure[] removeFiguresImpl()
- Overrides:
removeFiguresImpl
in classDefaultFigureCollection
-
lostOwnership
public void lostOwnership(Clipboard clipboard, Transferable contents)
Notifies this object that it is no longer the clipboard owner. This method will be called when another application or another object within this application asserts ownership of the clipboard.- Specified by:
lostOwnership
in interfaceClipboardOwner
- Parameters:
clipboard
- the clipboard that is no longer ownedcontents
- the contents which this owner had placed on the clipboard
-
clone
public FigureSelection clone()
Description copied from interface:Selection
Creates and returns a copy of this selection.
-
removeAllFigures
public Figure[] removeAllFigures()
Description copied from interface:Figure
Removes all child figures from this figure.- Specified by:
removeAllFigures
in interfaceFigure
- Overrides:
removeAllFigures
in classAbstractFigure
- Returns:
- The array of child figures that actually have been removed.
-
-