JGraph X 0.15.0.3


com.mxgraph.swing.handler
Class mxGraphHandler

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by com.mxgraph.swing.util.mxMouseControl
                  extended by com.mxgraph.swing.handler.mxGraphHandler
All Implemented Interfaces:
DropTargetListener, MouseListener, MouseMotionListener, ImageObserver, MenuContainer, Serializable, EventListener

public class mxGraphHandler
extends mxMouseControl
implements DropTargetListener

See Also:
Serialized Form

Nested Class Summary
 class mxGraphHandler.MouseRedirector
           
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  mxRectangle bbox
          Scaled, translated bounding box of the selection cells.
protected  boolean canImport
           
protected  Object cell
           
protected  mxRectangle cellBounds
          Scaled, translated bounds of the selection cells.
protected  Object[] cells
           
protected  boolean centerPreview
          Specifies if preview should be centered around the mouse cursor if there was no mouse click to define the offset within the shape (eg.
protected  boolean cloneEnabled
           
protected  boolean constrainedEvent
          Workaround for shift-key-state not correct in mouseReleased.
static Cursor DEFAULT_CURSOR
           
static int DEFAULT_MAX_HANDLES
           
protected  Object[] dragCells
           
protected  ImageIcon dragImage
           
protected  mxGraphComponent graphComponent
           
protected  Map handlers
          Maps from cells to handlers in the order of the selection cells.
protected  boolean imagePreview
           
protected  Object initialCell
           
protected  boolean keepOnTop
           
protected  mxCellMarker marker
           
protected  int maxHandles
          Defines the maximum number of handles to paint individually.
protected  JComponent preview
           
protected  mxRectangle previewBbox
           
protected  mxRectangle previewBounds
           
protected  mxEventSource.mxEventListener refreshHandler
           
protected  Point start
           
protected  mxRectangle transferBounds
          Unscaled, untranslated bounding box of the selection cells.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
mxGraphHandler(mxGraphComponent graphComponent)
           
 
Method Summary
 Point convertPoint(Point pt)
           
protected  MouseEvent createEvent(DropTargetEvent e)
           
protected  void createPreview()
           
protected  void destroyPreview()
           
 void dispatchMousePressed(MouseEvent e)
          Dispatches the mousepressed event to the subhandles.
 void dragEnter(DropTargetDragEvent e)
           
 void dragExit(DropTargetEvent e)
           
 void dragOver(DropTargetDragEvent e)
           
 void drop(DropTargetDropEvent e)
           
 void dropActionChanged(DropTargetDragEvent e)
           
protected  void fold(Object cell)
           
protected  Cursor getCursor(MouseEvent e)
           
protected static JComponent getDropTarget(DropTargetEvent e)
          Helper method to return the component for a drop target event.
protected static mxGraphTransferHandler getGraphTransferHandler(DropTargetEvent e)
          Helper method to return the component for a drop target event.
 mxCellHandler getHandler(Object cell)
           
 String getHandleToolTipText(MouseEvent e)
          Redirects a tooltip request from the graph component to the handles.
 int getMaxHandles()
           
protected  Collection getMovableCells(Collection cells)
           
 JComponent getPreview()
          Returns the component that is used for drawing the preview.
protected  Point getPreviewLocation(MouseEvent e, boolean gridEnabled)
           
 String getToolTipText(MouseEvent e)
          Redirects the tooltip handling of the JComponent to the graph component, which in turn may use getHandleToolTipText in this class to find a tooltip associated with a handle.
 boolean isCenterPreview()
           
 boolean isCloneEnabled()
           
 boolean isImagePreview()
           
 boolean isKeepOnTop()
           
 void mouseDragged(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
protected  void move(Object[] cells, double dx, double dy, MouseEvent e)
           
 void paintComponent(Graphics g)
           
 void refresh()
           
 void reset()
           
 void setCenterPreview(boolean centerPreview)
           
 void setCloneEnabled(boolean cloneEnabled)
           
 void setImagePreview(boolean imagePreview)
           
 void setKeepOnTop(boolean keepOnTop)
           
 void setMaxHandles(int maxHandles)
           
 void start(MouseEvent e)
           
 void updateDragImage(Object[] cells)
           
 
Methods inherited from class com.mxgraph.swing.util.mxMouseControl
mouseClicked, mouseEntered, mouseExited
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_CURSOR

public static Cursor DEFAULT_CURSOR

DEFAULT_MAX_HANDLES

public static int DEFAULT_MAX_HANDLES

graphComponent

protected mxGraphComponent graphComponent

cloneEnabled

protected boolean cloneEnabled

imagePreview

protected boolean imagePreview

maxHandles

protected int maxHandles
Defines the maximum number of handles to paint individually. Default is DEFAULT_MAX_HANDLES.


centerPreview

protected boolean centerPreview
Specifies if preview should be centered around the mouse cursor if there was no mouse click to define the offset within the shape (eg. drag from library). Default is true.


keepOnTop

protected boolean keepOnTop

handlers

protected transient Map handlers
Maps from cells to handlers in the order of the selection cells.


cells

protected transient Object[] cells

preview

protected transient JComponent preview

dragImage

protected transient ImageIcon dragImage

start

protected transient Point start

cell

protected transient Object cell

initialCell

protected transient Object initialCell

dragCells

protected transient Object[] dragCells

marker

protected transient mxCellMarker marker

canImport

protected transient boolean canImport

cellBounds

protected transient mxRectangle cellBounds
Scaled, translated bounds of the selection cells.


bbox

protected transient mxRectangle bbox
Scaled, translated bounding box of the selection cells.


previewBounds

protected transient mxRectangle previewBounds

previewBbox

protected transient mxRectangle previewBbox

transferBounds

protected transient mxRectangle transferBounds
Unscaled, untranslated bounding box of the selection cells.


constrainedEvent

protected transient boolean constrainedEvent
Workaround for shift-key-state not correct in mouseReleased.


refreshHandler

protected transient mxEventSource.mxEventListener refreshHandler
Constructor Detail

mxGraphHandler

public mxGraphHandler(mxGraphComponent graphComponent)
Parameters:
graphComponent -
Method Detail

getPreview

public JComponent getPreview()
Returns the component that is used for drawing the preview.


setKeepOnTop

public void setKeepOnTop(boolean keepOnTop)

isKeepOnTop

public boolean isKeepOnTop()

setCloneEnabled

public void setCloneEnabled(boolean cloneEnabled)

isCloneEnabled

public boolean isCloneEnabled()

setImagePreview

public void setImagePreview(boolean imagePreview)

isImagePreview

public boolean isImagePreview()

setCenterPreview

public void setCenterPreview(boolean centerPreview)

isCenterPreview

public boolean isCenterPreview()

getMaxHandles

public int getMaxHandles()

setMaxHandles

public void setMaxHandles(int maxHandles)

createPreview

protected void createPreview()

updateDragImage

public void updateDragImage(Object[] cells)

destroyPreview

protected void destroyPreview()

mouseMoved

public void mouseMoved(MouseEvent e)
Specified by:
mouseMoved in interface MouseMotionListener
Overrides:
mouseMoved in class mxMouseControl

getCursor

protected Cursor getCursor(MouseEvent e)

dragEnter

public void dragEnter(DropTargetDragEvent e)
Specified by:
dragEnter in interface DropTargetListener

getToolTipText

public String getToolTipText(MouseEvent e)
Redirects the tooltip handling of the JComponent to the graph component, which in turn may use getHandleToolTipText in this class to find a tooltip associated with a handle.

Overrides:
getToolTipText in class JComponent

getHandleToolTipText

public String getHandleToolTipText(MouseEvent e)
Redirects a tooltip request from the graph component to the handles. This is called from the graph component in getToolTipText which in turn may be called from getToolTipText in this class.


dispatchMousePressed

public void dispatchMousePressed(MouseEvent e)
Dispatches the mousepressed event to the subhandles. This is called from the connection handler as subhandles have precedence over the connection handler.


mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class mxMouseControl

start

public void start(MouseEvent e)

dropActionChanged

public void dropActionChanged(DropTargetDragEvent e)
Specified by:
dropActionChanged in interface DropTargetListener

dragOver

public void dragOver(DropTargetDragEvent e)
Specified by:
dragOver in interface DropTargetListener
Parameters:
e -

convertPoint

public Point convertPoint(Point pt)

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener
Overrides:
mouseDragged in class mxMouseControl

getPreviewLocation

protected Point getPreviewLocation(MouseEvent e,
                                   boolean gridEnabled)

dragExit

public void dragExit(DropTargetEvent e)
Specified by:
dragExit in interface DropTargetListener
Parameters:
e -

drop

public void drop(DropTargetDropEvent e)
Specified by:
drop in interface DropTargetListener
Parameters:
e -

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class mxMouseControl

fold

protected void fold(Object cell)

reset

public void reset()

move

protected void move(Object[] cells,
                    double dx,
                    double dy,
                    MouseEvent e)
Parameters:
dx -
dy -
e -

getHandler

public mxCellHandler getHandler(Object cell)

refresh

public void refresh()

getMovableCells

protected final Collection getMovableCells(Collection cells)

paintComponent

public void paintComponent(Graphics g)
Overrides:
paintComponent in class JComponent

createEvent

protected MouseEvent createEvent(DropTargetEvent e)

getGraphTransferHandler

protected static final mxGraphTransferHandler getGraphTransferHandler(DropTargetEvent e)
Helper method to return the component for a drop target event.


getDropTarget

protected static final JComponent getDropTarget(DropTargetEvent e)
Helper method to return the component for a drop target event.


JGraph X 0.15.0.3


Copyright (c) 2008 Gaudenz Alder. All rights reserved.