Package org.jgraph.graph
Class DefaultGraphCellEditor
java.lang.Object
org.jgraph.graph.DefaultGraphCellEditor
- All Implemented Interfaces:
ActionListener
,Serializable
,EventListener
,CellEditor
,GraphSelectionListener
,GraphCellEditor
public class DefaultGraphCellEditor
extends Object
implements ActionListener, GraphCellEditor, GraphSelectionListener, Serializable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
TextField used when no editor is supplied.class
Container responsible for placing the editingComponent. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Color
True if the border selection color should be drawn.protected boolean
Internal Note, maybe isCellEditable return true.protected Component
Component used in editing, obtained from the editingContainer.protected Container
Editing container, will contain the editorComponent.protected Icon
Icon to use when editing.protected Font
Font to paint with, null indicates font of renderer is to be used.protected JGraph
JTree instance listening too.protected Object
last path that was selected.protected int
Used in editing.protected int
protected GraphCellEditor
Editor handling the editing. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a DefaultTreeCellEditor object for a JGraph using the specified renderer and a default editor.Constructs a DefaultTreeCellEditor object for a JTree using the specified renderer and the specified editor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Messaged when the timer fires, this will start the editing session.void
Adds the CellEditorListener.void
Messages cancelCellEditing to the realEditor and removes it from this instance.protected boolean
canEditImmediately
(EventObject event) Returns true ifevent
is null, or it is a MouseEvent with a click count > 2 and inHitRegion returns true.protected Container
Creates the container to manage placement of editingComponent.protected GraphCellEditor
This is invoked if a TreeCellEditor is not supplied in the constructor.protected void
determineOffset
(JGraph graph, Object value, boolean isSelected) Returns the color the border is drawn.Returns the value currently being edited.getFont()
Gets the font used for editing.getGraphCellEditorComponent
(JGraph graph, Object cell, boolean isSelected) Configures the editor.protected boolean
inHitRegion
(double x, double y) Should return true if the passed in location is a valid mouse location to start editing from.boolean
isCellEditable
(EventObject event) If the realEditor returns true to this message, prepareForEditing is messaged and true is returned.protected void
Invoked just before editing is to start.void
Removes the previously added CellEditorListener l.void
setBorderSelectionColor
(Color newColor) Sets the color to use for the border.void
Sets the font to edit with.protected void
Sets the tree currently editing for.boolean
shouldSelectCell
(EventObject event) Messages the realEditor for the return value.protected boolean
Returns true ifevent
is a MouseEvent and the click count is 1.boolean
If the realEditor will allow editing to stop, the realEditor is removed and true is returned, otherwise false is returned.void
Resets lastPath.
-
Field Details
-
realEditor
Editor handling the editing. -
editingContainer
Editing container, will contain the editorComponent. -
editingComponent
Component used in editing, obtained from the editingContainer. -
canEdit
protected boolean canEditInternal Note, maybe isCellEditable return true. This is set in configure based on the path being edited and the selected selected path. -
offsetX
protected transient int offsetXUsed in editing. Indicates position to place editingComponent. -
offsetY
protected transient int offsetY -
graph
JTree instance listening too. -
lastCell
last path that was selected. -
borderSelectionColor
True if the border selection color should be drawn. -
editingIcon
Icon to use when editing. -
font
Font to paint with, null indicates font of renderer is to be used.
-
-
Constructor Details
-
DefaultGraphCellEditor
public DefaultGraphCellEditor()Constructs a DefaultTreeCellEditor object for a JGraph using the specified renderer and a default editor. (Use this constructor for normal editing.) -
DefaultGraphCellEditor
Constructs a DefaultTreeCellEditor object for a JTree using the specified renderer and the specified editor. (Use this constructor for specialized editing.)- Parameters:
editor
- a TreeCellEditor object
-
-
Method Details
-
setBorderSelectionColor
Sets the color to use for the border. -
getBorderSelectionColor
Returns the color the border is drawn. -
setFont
Sets the font to edit with.null
indicates the renderers font should be used. This will NOT override any font you have set in the editor the receiver was instantied with. If null for an editor was passed in a default editor will be created that will pick up this font.- Parameters:
font
- the editing Font- See Also:
-
getFont
Gets the font used for editing.- Returns:
- the editing Font
- See Also:
-
getGraphCellEditorComponent
Configures the editor. Passed onto the realEditor.- Specified by:
getGraphCellEditorComponent
in interfaceGraphCellEditor
- Parameters:
graph
- the JGraph that is asking the editor to edit This parameter can be null.cell
- the value of the cell to be edited.isSelected
- true if the cell is to be rendered with selection highlighting- Returns:
- the component for editing
-
getCellEditorValue
Returns the value currently being edited.- Specified by:
getCellEditorValue
in interfaceCellEditor
-
isCellEditable
If the realEditor returns true to this message, prepareForEditing is messaged and true is returned.- Specified by:
isCellEditable
in interfaceCellEditor
-
shouldSelectCell
Messages the realEditor for the return value.- Specified by:
shouldSelectCell
in interfaceCellEditor
-
stopCellEditing
public boolean stopCellEditing()If the realEditor will allow editing to stop, the realEditor is removed and true is returned, otherwise false is returned.- Specified by:
stopCellEditing
in interfaceCellEditor
-
cancelCellEditing
public void cancelCellEditing()Messages cancelCellEditing to the realEditor and removes it from this instance.- Specified by:
cancelCellEditing
in interfaceCellEditor
-
addCellEditorListener
Adds the CellEditorListener.- Specified by:
addCellEditorListener
in interfaceCellEditor
-
removeCellEditorListener
Removes the previously added CellEditorListener l.- Specified by:
removeCellEditorListener
in interfaceCellEditor
-
valueChanged
Resets lastPath.- Specified by:
valueChanged
in interfaceGraphSelectionListener
- Parameters:
e
- the event that characterizes the change.
-
actionPerformed
Messaged when the timer fires, this will start the editing session.- Specified by:
actionPerformed
in interfaceActionListener
-
setGraph
Sets the tree currently editing for. This is needed to add a selection listener. -
shouldStartEditingTimer
Returns true ifevent
is a MouseEvent and the click count is 1. -
canEditImmediately
Returns true ifevent
is null, or it is a MouseEvent with a click count > 2 and inHitRegion returns true. -
inHitRegion
protected boolean inHitRegion(double x, double y) Should return true if the passed in location is a valid mouse location to start editing from. This is implemented to return false ifx
is invalid input: '<'= the width of the icon and icon gap displayed by the renderer. In other words this returns true if the user clicks over the text part displayed by the renderer, and false otherwise. -
determineOffset
-
prepareForEditing
protected void prepareForEditing()Invoked just before editing is to start. Will add theeditingComponent
to theeditingContainer
. -
createContainer
Creates the container to manage placement of editingComponent. -
createGraphCellEditor
This is invoked if a TreeCellEditor is not supplied in the constructor. It returns a TextField editor.
-