org.jgraph.plaf.basic
public class BasicGraphUI extends GraphUI implements Serializable
Nested Class Summary | |
---|---|
class | BasicGraphUI.CellEditorHandler
Listener responsible for getting cell editing events and updating the
graph accordingly. |
class | BasicGraphUI.ComponentHandler
Updates the preferred size when scrolling (if necessary). |
class | BasicGraphUI.GraphDropTargetListener
Graph Drop Target Listener |
class | BasicGraphUI.GraphIncrementAction
GraphIncrementAction is used to handle up/down actions. |
class | BasicGraphUI.GraphLayoutCacheHandler
Listens for changes in the graph view and updates the size accordingly. |
class | BasicGraphUI.GraphModelHandler
Listens for changes in the graph model and updates the view accordingly. |
class | BasicGraphUI.GraphSelectionHandler
Listens for changes in the selection model and updates the display
accordingly. |
class | BasicGraphUI.KeyHandler
This is used to get mutliple key down events to appropriately generate
events. |
class | BasicGraphUI.MouseHandler
TreeMouseListener is responsible for updating the selection based on
mouse events. |
class | BasicGraphUI.MouseInputHandler
MouseInputHandler handles passing all mouse events, including mouse
motion events, until the mouse is released to the destination it is
constructed with. |
class | BasicGraphUI.PropertyChangeHandler
PropertyChangeListener for the graph. |
class | BasicGraphUI.RootHandle |
Field Summary | |
---|---|
protected GraphCellEditor | cellEditor Current editor for the graph. |
protected CellEditorListener | cellEditorListener Listens for CellEditor events. |
protected ComponentListener | componentListener Listens for Component events. |
protected BasicGraphUI.GraphDropTargetListener | defaultDropTargetListener The default DropTargetListener. |
protected TransferHandler | defaultTransferHandler The default TransferHandler. |
protected int | dropAction
Needed to exchange information between DropTargetHandler and
TransferHandler. |
protected DropTarget | dropTarget The drop target where the default listener was last installed. |
static boolean | DNDPREVIEW
Controls live-preview in dragEnabled mode. |
protected Object | editingCell Path that is being edited. |
protected Component | editingComponent
When editing, this will be the Component that is doing the actual
editing. |
protected boolean | editorHasDifferentSize Set to true if the editor has a different size than the renderer. |
protected CellView | focus The focused cell under the mousepointer and the last focused cell. |
protected JGraph | graph Component that we're going to be drawing into. |
protected GraphLayoutCache | graphLayoutCache Reference to the graph's view (geometric pattern). |
protected GraphLayoutCacheListener | graphLayoutCacheListener Updates the display when the view has changed. |
protected GraphModel | graphModel Used to determine what to display. |
protected GraphModelListener | graphModelListener Is responsible for updating the view based on model events. |
protected GraphSelectionListener | graphSelectionListener Updates the display when the selection changes. |
protected GraphSelectionModel | graphSelectionModel Model maintaining the selection. |
protected CellHandle | handle Handle that we are going to use. |
protected Point | insertionLocation Needed to exchange information between Transfer- and MouseListener. |
protected KeyListener | keyListener Listens for KeyListener events. |
protected CellView | lastFocus The focused cell under the mousepointer and the last focused cell. |
protected BasicMarqueeHandler | marquee Marquee that we are going to use. |
protected MouseListener | mouseListener Listens for Mouse events. |
static int | MAXCELLS The maximum number of cells to paint when dragging. |
static int | MAXCLIPCELLS Maximum number of cells to compute clipping bounds for. |
static int | MAXHANDLES The maximum number of handles to paint individually. |
protected Dimension | preferredMinSize Minimum preferred size. |
protected Dimension | preferredSize Size needed to completely display all the cells. |
protected PropertyChangeListener | propertyChangeListener Listens for JGraph property changes and updates display. |
protected CellRendererPane | rendererPane Used to paint the CellRenderer. |
protected boolean | snapSelectedView
If ture, a the view under mousepointer will be snapped to the grid lines
during a drag operation. |
protected boolean | stopEditingInCompleteEditing
Set to false when editing and shouldSelectCell() returns true meaning the
node should be selected before editing, used in completeEditing. |
static int | SCROLLBORDER Border in pixels to scroll if marquee or dragging are active. |
static float | SCROLLSTEP Multiplicator for width and height when autoscrolling (=stepsize). |
protected boolean | validCachedPreferredSize Is the preferredSize valid? |
Constructor Summary | |
---|---|
BasicGraphUI() |
Method Summary | |
---|---|
static void | autoscroll(JGraph graph, Point p)
Scroll the graph for an event at p . |
void | cancelEditing(JGraph graph)
Cancels all current editing sessions. |
protected void | completeEditing()
Messages to stop the editing session. |
protected void | completeEditing(boolean messageStop, boolean messageCancel, boolean messageGraph)
Stops the editing session. |
protected void | completeUIInstall()
Invoked from installUI after all the defaults/listeners have been
installed. |
protected void | completeUIUninstall() |
protected CellEditorListener | createCellEditorListener()
Creates a listener to handle events from the current editor. |
protected CellRendererPane | createCellRendererPane()
Returns the renderer pane that renderer components are placed in. |
protected ComponentListener | createComponentListener()
Creates and returns a new ComponentHandler. |
protected GraphContext | createContext(JGraph graph, Object[] cells) |
protected GraphLayoutCacheListener | createGraphLayoutCacheListener()
Returns a listener that can update the graph when the view changes. |
protected GraphModelListener | createGraphModelListener()
Returns a listener that can update the graph when the model changes. |
protected GraphSelectionListener | createGraphSelectionListener()
Creates the listener that updates the display based on selection change
methods. |
CellHandle | createHandle(GraphContext context)
Constructs the "root handle" for context .
|
protected KeyListener | createKeyListener()
Creates the listener reponsible for getting key events from the graph. |
protected MouseListener | createMouseListener()
Creates the listener responsible for calling the correct handlers based
on mouse events, and to select invidual cells. |
protected PropertyChangeListener | createPropertyChangeListener()
Creates a listener that is responsible to update the UI based on how the
graph's bounds properties change. |
protected TransferHandler | createTransferHandler()
Creates an instance of TransferHandler. |
static ComponentUI | createUI(JComponent x) |
void | drawGraph(Graphics g, Rectangle2D clipBounds)
Draws the graph to the specified graphics object within the specified
clip bounds, if any
|
int | getDropAction()
Returns the current drop action. |
Object | getEditingCell(JGraph graph)
Returns the element that is being edited. |
protected Point2D | getEditorLocation(Object cell, Dimension2D editorSize, Point2D pt)
Subclassers may override this to provide a better location for the
in-place editing of edges (if you do not inherit from the EdgeRenderer
class). |
protected Object | getFocusedCell()
Returns the cell that has the focus. |
CellHandle | getHandle()
Returns the handle that is currently active, or null, if no handle is
currently active. |
Point | getInsertionLocation()
Returns the current location of the Drag-and-Drop activity. |
Dimension | getMaximumSize(JComponent c)
Returns the maximum size for this component, which will be the preferred
size if the instance is currently in a JGraph, or 0, 0. |
Dimension | getMinimumSize(JComponent c)
Returns the minimum size for this component. |
Dimension | getPreferredMinSize()
Returns the minimum preferred size. |
Dimension2D | getPreferredSize(JGraph graph, CellView view) Get the preferred Size for a cell view. |
Dimension | getPreferredSize(JComponent c)
Returns the preferred size to properly display the graph. |
protected void | installComponents()
Intalls the subcomponents of the graph, which is the renderer pane. |
protected void | installDefaults()
Invoked as part from the boilerplate install block. |
protected void | installKeyboardActions()
Invoked as part from the boilerplate install block. |
protected void | installListeners()
Invoked as part from the boilerplate install block. |
void | installUI(JComponent c) |
boolean | isAddToSelectionEvent(MouseEvent e)
Returning true signifies that cells are added to the selection. |
boolean | isConstrainedMoveEvent(MouseEvent event)
Returning true signifies a move should only be applied to one direction. |
boolean | isEditing(JGraph graph)
Returns true if the graph is being edited. |
boolean | isForceMarqueeEvent(MouseEvent event)
Returning true signifies the marquee handler has precedence over other
handlers, and is receiving subsequent mouse events. |
boolean | isSnapSelectedView() |
boolean | isToggleSelectionEvent(MouseEvent e)
Returning true signifies a mouse event on the cell should toggle the
selection of only the cell under mouse. |
void | paint(Graphics g, JComponent c)
Main painting routine. |
protected void | paintBackground(Graphics g)
Paint the background of this graph. |
protected void | paintBackgroundComponent(Graphics g, Component component)
Requests that the component responsible for painting the background paint
itself
|
protected void | paintBackgroundComponent(Graphics g, Component component, Rectangle clip)
Requests that the component responsible for painting the background paint
itself
|
protected void | paintBackgroundImage(Graphics g, Rectangle clip)
Hook for subclassers to paint the background image.
|
void | paintCell(Graphics g, CellView view, Rectangle2D bounds, boolean preview)
Paints the renderer of view to g at
bounds . |
protected void | paintCells(Graphics g, Rectangle2D realClipBounds)
Hook method to allow subclassers to alter just the cell painting
functionality |
protected void | paintForeground(Graphics g)
Paint the foreground of this graph. |
protected void | paintGrid(double gs, Graphics g, Rectangle2D clipBounds)
Paint the grid. |
protected void | paintOverlay(Graphics g)
Hook method to paints the overlay
|
void | paintPorts(Graphics g, CellView[] ports)
Paint ports . |
protected void | prepareForUIInstall()
Invoked after the graph instance variable has been set,
but before any defaults/listeners have been installed. |
void | selectCellForEvent(Object cell, MouseEvent event)
Messaged to update the selection based on a MouseEvent over a particular
cell. |
void | selectCellsForEvent(JGraph graph, Object[] cells, MouseEvent event)
From GraphUI interface. |
void | selectCellsForEvent(Object[] cells, MouseEvent event)
Messaged to update the selection based on a MouseEvent for a group of
cells. |
protected void | setGraphLayoutCache(GraphLayoutCache cache)
Sets the GraphLayoutCache (geometric pattern). |
void | setInsertionLocation(Point p)
Sets the current location for Drag-and-Drop activity. |
protected void | setMarquee(BasicMarqueeHandler marqueeHandler)
Sets the marquee handler. |
protected void | setModel(GraphModel model)
Sets the GraphModel. |
void | setPreferredMinSize(Dimension newSize)
Sets the preferred minimum size. |
protected void | setSelectionModel(GraphSelectionModel newLSM)
Resets the selection model. |
void | setSnapSelectedView(boolean snapSelectedView)
Sets the mode of the snapSelectedView drag operation.
|
protected boolean | startEditing(Object cell, MouseEvent event)
Will start editing for cell if there is a cellEditor and shouldSelectCell
returns true.
|
void | startEditingAtCell(JGraph graph, Object cell)
Selects the cell and tries to edit it. |
boolean | stopEditing(JGraph graph)
Stops the current editing session. |
protected void | toggleSelectionCellForEvent(Object cell, MouseEvent event)
Messaged to update the selection based on a toggle selection event, which
means the cell's selection state is inverted. |
protected void | uninstallComponents()
Uninstalls the renderer pane. |
protected void | uninstallKeyboardActions() |
protected void | uninstallListeners() |
void | uninstallUI(JComponent c) |
protected void | updateCachedPreferredSize()
Updates the preferredSize instance variable, which is
returned from getPreferredSize() . |
void | updateHandle()
Update the handle using createHandle. |
void | updateSize()
Messages the Graph with graphDidChange . |
p
.getInvokesStopCellEditing
, stopCellEditing will invoked
on the current editor. Then completeEditing will be messaged with false,
true, false to cancel any lingering editing.context
.
Parameters: context reference to the context of the current selection.
Parameters: g the graphics object to draw the graph to clipBounds the bounds within graph cells must intersect to be redrawn
Returns: true if snapSelectedView mode is enabled during the drag
operation. If it is enabled, the view, that is returned by the
findViewForPoint(Point pt), will be snapped to the grid lines.
By default, findViewForPoint() returns the first view from the
GraphContext whose bounds intersect with snap proximity of a
mouse pointer. If snap-to-grid mode is disabled, views are moved
by a snap increment.
Parameters: g The graphics object to paint the image on. component the component to be painted onto the background image
Parameters: g The graphics object to paint the image on. component the component to be painted onto the background image clip The clipping region to draw into
Parameters: g The graphics object to paint the image on. clip The clipping region to draw into
view
to g
at
bounds
. Recursive implementation that paints the children
first.
The reciever should NOT modify clipBounds
, or
insets
. The preview
flag is passed to the
renderer, and is not used here.
Parameters: g the graphics object to paint to realClipBounds the bounds of the region being repainted
Parameters: g the graphics object to paint the overlay to
ports
.graph
instance variable has been set,
but before any defaults/listeners have been installed.updateSize
.updateSize
.Parameters: snapSelectedView
specifies if the snap-to-grid mode should be applied during a
drag operation. If it is enabled, the view, that is returned
by the findViewForPoint(Point pt), will be snapped to the grid
lines.
By default, findViewForPoint() returns the first view from the
GraphContext whose bounds intersect with snap proximity of a
mouse pointer. If snap-to-grid mode is disabled, views are
moved by a snap increment.
This assumes that cell is valid and visible.
preferredSize
instance variable, which is
returned from getPreferredSize()
.graphDidChange
.