Class DefaultFigureEditor
- java.lang.Object
-
- com.bc.ceres.core.ExtensibleObject
-
- com.bc.ceres.swing.figure.support.DefaultFigureEditor
-
- All Implemented Interfaces:
Extensible
,ViewportAware
,FigureEditor
,InteractorAware
,SelectionChangeEmitter
,SelectionContext
,SelectionSource
public class DefaultFigureEditor extends ExtensibleObject implements FigureEditor
A default implementation of a figure editor.- Since:
- Ceres 0.10
-
-
Constructor Summary
Constructors Constructor Description DefaultFigureEditor(JComponent editorComponent)
DefaultFigureEditor(JComponent editorComponent, Viewport viewport, UndoContext undoContext, FigureCollection figureCollection, FigureFactory figureFactory)
-
Method Summary
-
Methods inherited from class com.bc.ceres.core.ExtensibleObject
getExtension
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.bc.ceres.core.Extensible
getExtension
-
-
-
-
Constructor Detail
-
DefaultFigureEditor
public DefaultFigureEditor(JComponent editorComponent)
-
DefaultFigureEditor
public DefaultFigureEditor(JComponent editorComponent, Viewport viewport, UndoContext undoContext, FigureCollection figureCollection, FigureFactory figureFactory)
-
-
Method Detail
-
getUndoContext
public UndoContext getUndoContext()
- Specified by:
getUndoContext
in interfaceFigureEditor
-
getEditorComponent
public JComponent getEditorComponent()
- Specified by:
getEditorComponent
in interfaceFigureEditor
-
insertFigures
public void insertFigures(boolean performInsert, Figure... figures)
- Specified by:
insertFigures
in interfaceFigureEditor
-
deleteFigures
public void deleteFigures(boolean performDelete, Figure... figures)
- Specified by:
deleteFigures
in interfaceFigureEditor
-
changeFigure
public void changeFigure(Figure figure, Object figureMemento, String presentationName)
- Specified by:
changeFigure
in interfaceFigureEditor
-
getSelectionContext
public SelectionContext getSelectionContext()
- Specified by:
getSelectionContext
in interfaceFigureEditor
-
getSelectionRectangle
public Rectangle getSelectionRectangle()
- Specified by:
getSelectionRectangle
in interfaceFigureEditor
-
setSelectionRectangle
public void setSelectionRectangle(Rectangle newRect)
- Specified by:
setSelectionRectangle
in interfaceFigureEditor
-
getFigureCollection
public FigureCollection getFigureCollection()
- Specified by:
getFigureCollection
in interfaceFigureEditor
-
setFigureCollection
public void setFigureCollection(FigureCollection figureCollection)
-
getFigureSelection
public FigureSelection getFigureSelection()
- Specified by:
getFigureSelection
in interfaceFigureEditor
-
getFigureFactory
public FigureFactory getFigureFactory()
- Specified by:
getFigureFactory
in interfaceFigureEditor
-
setFigureFactory
public void setFigureFactory(FigureFactory figureFactory)
-
getSelection
public Selection getSelection()
- Specified by:
getSelection
in interfaceSelectionSource
- Returns:
- The current selection. The selection may be empty, but never
null
. - See Also:
Selection.EMPTY
,Selection.isEmpty()
-
setSelection
public void setSelection(Selection selection)
Description copied from interface:SelectionContext
Sets a new selection.- Specified by:
setSelection
in interfaceSelectionContext
- Parameters:
selection
- The new selection.
-
addSelectionChangeListener
public void addSelectionChangeListener(SelectionChangeListener listener)
Description copied from interface:SelectionChangeEmitter
Adds a selection change listener to this emitter.- Specified by:
addSelectionChangeListener
in interfaceSelectionChangeEmitter
- Parameters:
listener
- The listener.
-
removeSelectionChangeListener
public void removeSelectionChangeListener(SelectionChangeListener listener)
Description copied from interface:SelectionChangeEmitter
Removes a selection change listener from this emitter.- Specified by:
removeSelectionChangeListener
in interfaceSelectionChangeEmitter
- Parameters:
listener
- The listener.
-
getSelectionChangeListeners
public SelectionChangeListener[] getSelectionChangeListeners()
Description copied from interface:SelectionChangeEmitter
Gets all registered selection change listeners.- Specified by:
getSelectionChangeListeners
in interfaceSelectionChangeEmitter
- Returns:
- An array containing all registered listeners.
-
insert
public void insert(Transferable contents) throws IOException, UnsupportedFlavorException
Description copied from interface:SelectionContext
Inserts a selection represented by the givenTransferable
into this context.- Specified by:
insert
in interfaceSelectionContext
- Parameters:
contents
- The transferable object.- Throws:
IOException
- if an I/O error occursUnsupportedFlavorException
- See Also:
SelectionContext.canInsert(java.awt.datatransfer.Transferable)
,Selection.createTransferable(boolean)
,ClipboardOwner.lostOwnership(java.awt.datatransfer.Clipboard, java.awt.datatransfer.Transferable)
-
canDeleteSelection
public boolean canDeleteSelection()
- Specified by:
canDeleteSelection
in interfaceSelectionContext
- Returns:
true
if the current selection can be deleted.- See Also:
SelectionContext.deleteSelection()
-
deleteSelection
public void deleteSelection()
Description copied from interface:SelectionContext
Deletes the current selection.- Specified by:
deleteSelection
in interfaceSelectionContext
- See Also:
SelectionContext.canDeleteSelection()
-
canInsert
public boolean canInsert(Transferable contents)
Description copied from interface:SelectionContext
Tests whether the current contents (e.g. from clipboard, drag and drop) can be inserted into this selection context.- Specified by:
canInsert
in interfaceSelectionContext
- Parameters:
contents
- The contents.- Returns:
true
if the given contents can be inserted into this context.- See Also:
SelectionContext.insert(Transferable)
-
selectAll
public void selectAll()
Description copied from interface:SelectionContext
Selects all items.- Specified by:
selectAll
in interfaceSelectionContext
- See Also:
SelectionContext.canSelectAll()
-
canSelectAll
public boolean canSelectAll()
- Specified by:
canSelectAll
in interfaceSelectionContext
- Returns:
true
if all items can be selected.- See Also:
SelectionContext.selectAll()
-
getInteractor
public Interactor getInteractor()
- Specified by:
getInteractor
in interfaceInteractorAware
-
setInteractor
public void setInteractor(Interactor interactor)
- Specified by:
setInteractor
in interfaceFigureEditor
-
getViewport
public Viewport getViewport()
- Specified by:
getViewport
in interfaceViewportAware
- Returns:
- The viewport.
-
getDefaultLineStyle
public FigureStyle getDefaultLineStyle()
- Specified by:
getDefaultLineStyle
in interfaceFigureEditor
-
setDefaultLineStyle
public void setDefaultLineStyle(FigureStyle defaultLineStyle)
-
getDefaultPolygonStyle
public FigureStyle getDefaultPolygonStyle()
- Specified by:
getDefaultPolygonStyle
in interfaceFigureEditor
-
setDefaultPolygonStyle
public void setDefaultPolygonStyle(FigureStyle defaultPolygonStyle)
-
draw
public void draw(Rendering rendering)
CallsdrawFigureCollection(rendering); drawFigureSelection(rendering); drawSelectionRectangle(rendering);
- Parameters:
rendering
- The rendering.
-
drawFigureCollection
public void drawFigureCollection(Rendering rendering)
-
drawFigureSelection
public void drawFigureSelection(Rendering rendering)
-
drawSelectionRectangle
public void drawSelectionRectangle(Rendering rendering)
-
-