public class DefaultGraphCellEditor extends java.lang.Object implements java.awt.event.ActionListener, GraphCellEditor, GraphSelectionListener, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
class |
DefaultGraphCellEditor.DefaultTextField
TextField used when no editor is supplied.
|
class |
DefaultGraphCellEditor.EditorContainer
Container responsible for placing the editingComponent.
|
Modifier and Type | Field and Description |
---|---|
protected java.awt.Color |
borderSelectionColor
True if the border selection color should be drawn.
|
protected boolean |
canEdit
Internal Note, maybe isCellEditable return true.
|
protected java.awt.Component |
editingComponent
Component used in editing, obtained from the editingContainer.
|
protected java.awt.Container |
editingContainer
Editing container, will contain the editorComponent.
|
protected javax.swing.Icon |
editingIcon
Icon to use when editing.
|
protected java.awt.Font |
font
Font to paint with, null indicates font of renderer is to be used.
|
protected JGraph |
graph
JTree instance listening too.
|
protected java.lang.Object |
lastCell
last path that was selected.
|
protected int |
offsetX
Used in editing.
|
protected int |
offsetY |
protected GraphCellEditor |
realEditor
Editor handling the editing.
|
Constructor and Description |
---|
DefaultGraphCellEditor()
Constructs a DefaultTreeCellEditor object for a JGraph using the
specified renderer and a default editor.
|
DefaultGraphCellEditor(GraphCellEditor editor)
Constructs a DefaultTreeCellEditor object for a JTree using the
specified renderer and the specified editor.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Messaged when the timer fires, this will start the editing
session.
|
void |
addCellEditorListener(javax.swing.event.CellEditorListener l)
Adds the CellEditorListener.
|
void |
cancelCellEditing()
Messages cancelCellEditing to the realEditor and removes it from this
instance.
|
protected boolean |
canEditImmediately(java.util.EventObject event)
Returns true if
event is null, or it is a MouseEvent
with a click count > 2 and inHitRegion returns true. |
protected java.awt.Container |
createContainer()
Creates the container to manage placement of editingComponent.
|
protected GraphCellEditor |
createGraphCellEditor()
This is invoked if a TreeCellEditor is not supplied in the constructor.
|
protected void |
determineOffset(JGraph graph,
java.lang.Object value,
boolean isSelected) |
java.awt.Color |
getBorderSelectionColor()
Returns the color the border is drawn.
|
java.lang.Object |
getCellEditorValue()
Returns the value currently being edited.
|
java.awt.Font |
getFont()
Gets the font used for editing.
|
java.awt.Component |
getGraphCellEditorComponent(JGraph graph,
java.lang.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(java.util.EventObject event)
If the realEditor returns true to this message, prepareForEditing
is messaged and true is returned.
|
protected void |
prepareForEditing()
Invoked just before editing is to start.
|
void |
removeCellEditorListener(javax.swing.event.CellEditorListener l)
Removes the previously added CellEditorListener l.
|
void |
setBorderSelectionColor(java.awt.Color newColor)
Sets the color to use for the border.
|
void |
setFont(java.awt.Font font)
Sets the font to edit with.
|
protected void |
setGraph(JGraph newGraph)
Sets the tree currently editing for.
|
boolean |
shouldSelectCell(java.util.EventObject event)
Messages the realEditor for the return value.
|
protected boolean |
shouldStartEditingTimer(java.util.EventObject event)
Returns true if
event is a MouseEvent and the click
count is 1. |
boolean |
stopCellEditing()
If the realEditor will allow editing to stop, the realEditor is
removed and true is returned, otherwise false is returned.
|
void |
valueChanged(GraphSelectionEvent e)
Resets lastPath.
|
protected GraphCellEditor realEditor
protected java.awt.Container editingContainer
protected transient java.awt.Component editingComponent
protected boolean canEdit
protected transient int offsetX
protected transient int offsetY
protected transient JGraph graph
protected transient java.lang.Object lastCell
protected java.awt.Color borderSelectionColor
protected transient javax.swing.Icon editingIcon
protected java.awt.Font font
public DefaultGraphCellEditor()
public DefaultGraphCellEditor(GraphCellEditor editor)
editor
- a TreeCellEditor objectpublic void setBorderSelectionColor(java.awt.Color newColor)
public java.awt.Color getBorderSelectionColor()
public void setFont(java.awt.Font font)
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.font
- the editing FontgetFont()
public java.awt.Font getFont()
setFont(java.awt.Font)
public java.awt.Component getGraphCellEditorComponent(JGraph graph, java.lang.Object cell, boolean isSelected)
getGraphCellEditorComponent
in interface GraphCellEditor
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 highlightingpublic java.lang.Object getCellEditorValue()
getCellEditorValue
in interface javax.swing.CellEditor
public boolean isCellEditable(java.util.EventObject event)
isCellEditable
in interface javax.swing.CellEditor
public boolean shouldSelectCell(java.util.EventObject event)
shouldSelectCell
in interface javax.swing.CellEditor
public boolean stopCellEditing()
stopCellEditing
in interface javax.swing.CellEditor
public void cancelCellEditing()
cancelCellEditing
in interface javax.swing.CellEditor
public void addCellEditorListener(javax.swing.event.CellEditorListener l)
addCellEditorListener
in interface javax.swing.CellEditor
public void removeCellEditorListener(javax.swing.event.CellEditorListener l)
removeCellEditorListener
in interface javax.swing.CellEditor
public void valueChanged(GraphSelectionEvent e)
valueChanged
in interface GraphSelectionListener
e
- the event that characterizes the change.public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
protected void setGraph(JGraph newGraph)
protected boolean shouldStartEditingTimer(java.util.EventObject event)
event
is a MouseEvent and the click
count is 1.protected boolean canEditImmediately(java.util.EventObject event)
event
is null, or it is a MouseEvent
with a click count > 2 and inHitRegion returns true.protected boolean inHitRegion(double x, double y)
x
is <= 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.protected void determineOffset(JGraph graph, java.lang.Object value, boolean isSelected)
protected void prepareForEditing()
editingComponent
to the
editingContainer
.protected java.awt.Container createContainer()
protected GraphCellEditor createGraphCellEditor()
Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.