org.jgraph.plaf.basic
Class BasicGraphUI
- java.lang.Object
-
- javax.swing.plaf.ComponentUI
-
- org.jgraph.plaf.GraphUI
-
- org.jgraph.plaf.basic.BasicGraphUI
-
- All Implemented Interfaces:
- java.io.Serializable
public class BasicGraphUI extends GraphUI implements java.io.Serializable
The basic L&F for a graph data structure.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description classBasicGraphUI.CellEditorHandlerListener responsible for getting cell editing events and updating the graph accordingly.classBasicGraphUI.ComponentHandlerUpdates the preferred size when scrolling (if necessary).classBasicGraphUI.GraphDropTargetListenerGraph Drop Target ListenerclassBasicGraphUI.GraphIncrementActionGraphIncrementAction is used to handle up/down actions.classBasicGraphUI.GraphLayoutCacheHandlerListens for changes in the graph view and updates the size accordingly.classBasicGraphUI.GraphModelHandlerListens for changes in the graph model and updates the view accordingly.classBasicGraphUI.GraphSelectionHandlerListens for changes in the selection model and updates the display accordingly.classBasicGraphUI.KeyHandlerThis is used to get mutliple key down events to appropriately generate events.classBasicGraphUI.MouseHandlerTreeMouseListener is responsible for updating the selection based on mouse events.classBasicGraphUI.MouseInputHandlerMouseInputHandler handles passing all mouse events, including mouse motion events, until the mouse is released to the destination it is constructed with.classBasicGraphUI.PropertyChangeHandlerPropertyChangeListener for the graph.classBasicGraphUI.RootHandle
-
Field Summary
Fields Modifier and Type Field and Description static booleanDNDPREVIEWControls live-preview in dragEnabled mode.static intMAXCELLSThe maximum number of cells to paint when dragging.static intMAXCLIPCELLSMaximum number of cells to compute clipping bounds for.static intMAXHANDLESThe maximum number of handles to paint individually.static intSCROLLBORDERBorder in pixels to scroll if marquee or dragging are active.static floatSCROLLSTEPMultiplicator for width and height when autoscrolling (=stepsize).
-
Constructor Summary
Constructors Constructor and Description BasicGraphUI()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description static voidautoscroll(JGraph graph, java.awt.Point p)Scroll the graph for an event atp.voidcancelEditing(JGraph graph)Cancels all current editing sessions.CellHandlecreateHandle(GraphContext context)Constructs the "root handle" forcontext.static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent x)voiddrawGraph(java.awt.Graphics g, java.awt.geom.Rectangle2D clipBounds)Draws the graph to the specified graphics object within the specified clip bounds, if anyintgetDropAction()Returns the current drop action.java.lang.ObjectgetEditingCell(JGraph graph)Returns the element that is being edited.CellHandlegetHandle()Returns the handle that is currently active, or null, if no handle is currently active.java.awt.PointgetInsertionLocation()Returns the current location of the Drag-and-Drop activity.java.awt.DimensiongetMaximumSize(javax.swing.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.java.awt.DimensiongetMinimumSize(javax.swing.JComponent c)Returns the minimum size for this component.java.awt.DimensiongetPreferredMinSize()Returns the minimum preferred size.java.awt.DimensiongetPreferredSize(javax.swing.JComponent c)Returns the preferred size to properly display the graph.java.awt.geom.Dimension2DgetPreferredSize(JGraph graph, CellView view)Get the preferred Size for a cell view.voidinstallUI(javax.swing.JComponent c)booleanisAddToSelectionEvent(java.awt.event.MouseEvent e)Returning true signifies that cells are added to the selection.booleanisConstrainedMoveEvent(java.awt.event.MouseEvent event)Returning true signifies a move should only be applied to one direction.booleanisEditing(JGraph graph)Returns true if the graph is being edited.booleanisForceMarqueeEvent(java.awt.event.MouseEvent event)Returning true signifies the marquee handler has precedence over other handlers, and is receiving subsequent mouse events.booleanisSnapSelectedView()booleanisToggleSelectionEvent(java.awt.event.MouseEvent e)Returning true signifies a mouse event on the cell should toggle the selection of only the cell under mouse.voidpaint(java.awt.Graphics g, javax.swing.JComponent c)Main painting routine.voidpaintCell(java.awt.Graphics g, CellView view, java.awt.geom.Rectangle2D bounds, boolean preview)Paints the renderer ofviewtogatbounds.voidpaintPorts(java.awt.Graphics g, CellView[] ports)Paintports.voidselectCellForEvent(java.lang.Object cell, java.awt.event.MouseEvent event)Messaged to update the selection based on a MouseEvent over a particular cell.voidselectCellsForEvent(JGraph graph, java.lang.Object[] cells, java.awt.event.MouseEvent event)From GraphUI interface.voidselectCellsForEvent(java.lang.Object[] cells, java.awt.event.MouseEvent event)Messaged to update the selection based on a MouseEvent for a group of cells.voidsetInsertionLocation(java.awt.Point p)Sets the current location for Drag-and-Drop activity.voidsetPreferredMinSize(java.awt.Dimension newSize)Sets the preferred minimum size.voidsetSnapSelectedView(boolean snapSelectedView)Sets the mode of the snapSelectedView drag operation.voidstartEditingAtCell(JGraph graph, java.lang.Object cell)Selects the cell and tries to edit it.booleanstopEditing(JGraph graph)Stops the current editing session.voiduninstallUI(javax.swing.JComponent c)voidupdateHandle()Update the handle using createHandle.voidupdateSize()Messages the Graph withgraphDidChange.
-
-
-
Field Detail
-
DNDPREVIEW
public static final boolean DNDPREVIEW
Controls live-preview in dragEnabled mode. This is used to disable live-preview in dragEnabled mode on Java 1.4.0 to workaround a bug that cause the VM to hang during concurrent DnD and repaints. Is this still required?
-
SCROLLBORDER
public static int SCROLLBORDER
Border in pixels to scroll if marquee or dragging are active.
-
SCROLLSTEP
public static float SCROLLSTEP
Multiplicator for width and height when autoscrolling (=stepsize).
-
MAXCELLS
public static int MAXCELLS
The maximum number of cells to paint when dragging.
-
MAXHANDLES
public static int MAXHANDLES
The maximum number of handles to paint individually.
-
MAXCLIPCELLS
public static int MAXCLIPCELLS
Maximum number of cells to compute clipping bounds for.
-
-
Method Detail
-
createUI
public static javax.swing.plaf.ComponentUI createUI(javax.swing.JComponent x)
-
getHandle
public CellHandle getHandle()
Returns the handle that is currently active, or null, if no handle is currently active. Typically, the returned objects are instances of the RootHandle inner class.
-
getDropAction
public int getDropAction()
Returns the current drop action.- Specified by:
getDropActionin classGraphUI
-
getPreferredSize
public java.awt.geom.Dimension2D getPreferredSize(JGraph graph, CellView view)
Get the preferred Size for a cell view.- Specified by:
getPreferredSizein classGraphUI
-
getInsertionLocation
public java.awt.Point getInsertionLocation()
Returns the current location of the Drag-and-Drop activity.- Specified by:
getInsertionLocationin classGraphUI
-
setInsertionLocation
public void setInsertionLocation(java.awt.Point p)
Sets the current location for Drag-and-Drop activity. Should be set to null after a drop. Used from within DropTargetListener.- Specified by:
setInsertionLocationin classGraphUI
-
selectCellsForEvent
public void selectCellsForEvent(JGraph graph, java.lang.Object[] cells, java.awt.event.MouseEvent event)
From GraphUI interface.- Specified by:
selectCellsForEventin classGraphUI
-
selectCellsForEvent
public void selectCellsForEvent(java.lang.Object[] cells, java.awt.event.MouseEvent event)Messaged to update the selection based on a MouseEvent for a group of cells. If the event is a toggle selection event, the cells are either selected, or deselected. Otherwise the cells are selected.
-
selectCellForEvent
public void selectCellForEvent(java.lang.Object cell, java.awt.event.MouseEvent event)Messaged to update the selection based on a MouseEvent over a particular cell. If the event is a toggle selection event, the cell is either selected, or deselected. Otherwise the cell is selected.
-
isAddToSelectionEvent
public boolean isAddToSelectionEvent(java.awt.event.MouseEvent e)
Returning true signifies that cells are added to the selection.
-
isToggleSelectionEvent
public boolean isToggleSelectionEvent(java.awt.event.MouseEvent e)
Returning true signifies a mouse event on the cell should toggle the selection of only the cell under mouse.
-
isForceMarqueeEvent
public boolean isForceMarqueeEvent(java.awt.event.MouseEvent event)
Returning true signifies the marquee handler has precedence over other handlers, and is receiving subsequent mouse events.
-
isConstrainedMoveEvent
public boolean isConstrainedMoveEvent(java.awt.event.MouseEvent event)
Returning true signifies a move should only be applied to one direction.
-
isEditing
public boolean isEditing(JGraph graph)
Returns true if the graph is being edited. The item that is being edited can be returned by getEditingPath().
-
stopEditing
public boolean stopEditing(JGraph graph)
Stops the current editing session. This has no effect if the graph isn't being edited. Returns true if the editor allows the editing session to stop.- Specified by:
stopEditingin classGraphUI
-
cancelEditing
public void cancelEditing(JGraph graph)
Cancels all current editing sessions.- Specified by:
cancelEditingin classGraphUI
-
startEditingAtCell
public void startEditingAtCell(JGraph graph, java.lang.Object cell)
Selects the cell and tries to edit it. Editing will fail if the CellEditor won't allow it for the selected item.- Specified by:
startEditingAtCellin classGraphUI
-
getEditingCell
public java.lang.Object getEditingCell(JGraph graph)
Returns the element that is being edited.- Specified by:
getEditingCellin classGraphUI
-
installUI
public void installUI(javax.swing.JComponent c)
- Overrides:
installUIin classjavax.swing.plaf.ComponentUI
-
uninstallUI
public void uninstallUI(javax.swing.JComponent c)
- Overrides:
uninstallUIin classjavax.swing.plaf.ComponentUI
-
paint
public void paint(java.awt.Graphics g, javax.swing.JComponent c)Main painting routine.- Overrides:
paintin classjavax.swing.plaf.ComponentUI
-
drawGraph
public void drawGraph(java.awt.Graphics g, java.awt.geom.Rectangle2D clipBounds)Draws the graph to the specified graphics object within the specified clip bounds, if any- Parameters:
g- the graphics object to draw the graph toclipBounds- the bounds within graph cells must intersect to be redrawn
-
paintCell
public void paintCell(java.awt.Graphics g, CellView view, java.awt.geom.Rectangle2D bounds, boolean preview)Paints the renderer ofviewtogatbounds. Recursive implementation that paints the children first.The reciever should NOT modify
clipBounds, orinsets. Thepreviewflag is passed to the renderer, and is not used here.
-
paintPorts
public void paintPorts(java.awt.Graphics g, CellView[] ports)Paintports.- Specified by:
paintPortsin classGraphUI
-
updateHandle
public void updateHandle()
Update the handle using createHandle.- Specified by:
updateHandlein classGraphUI
-
createHandle
public CellHandle createHandle(GraphContext context)
Constructs the "root handle" forcontext.- Parameters:
context- reference to the context of the current selection.
-
updateSize
public void updateSize()
Messages the Graph withgraphDidChange.
-
setPreferredMinSize
public void setPreferredMinSize(java.awt.Dimension newSize)
Sets the preferred minimum size.
-
getPreferredMinSize
public java.awt.Dimension getPreferredMinSize()
Returns the minimum preferred size.
-
getPreferredSize
public java.awt.Dimension getPreferredSize(javax.swing.JComponent c)
Returns the preferred size to properly display the graph.- Overrides:
getPreferredSizein classjavax.swing.plaf.ComponentUI
-
getMinimumSize
public java.awt.Dimension getMinimumSize(javax.swing.JComponent c)
Returns the minimum size for this component. Which will be the min preferred size or 0, 0.- Overrides:
getMinimumSizein classjavax.swing.plaf.ComponentUI
-
getMaximumSize
public java.awt.Dimension getMaximumSize(javax.swing.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.- Overrides:
getMaximumSizein classjavax.swing.plaf.ComponentUI
-
autoscroll
public static void autoscroll(JGraph graph, java.awt.Point p)
Scroll the graph for an event atp.
-
isSnapSelectedView
public boolean isSnapSelectedView()
- 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.
-
setSnapSelectedView
public void setSnapSelectedView(boolean snapSelectedView)
Sets the mode of the snapSelectedView drag operation.- 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.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG