JGraph X 1.3.0.0


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:
java.awt.dnd.DropTargetListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener

public class mxGraphHandler
extends mxMouseControl
implements java.awt.dnd.DropTargetListener

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  mxRectangle bbox
          Scaled, translated bounding box of the selection cells.
protected  boolean canImport
           
protected  java.lang.Object cell
           
protected  mxRectangle cellBounds
          Scaled, translated bounds of the selection cells.
protected  java.lang.Object[] cells
          Holds the cells that are being moved by this handler.
protected  boolean centerPreview
          Specifies if the 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
          Specifies if cloning by control-drag is enabled.
protected  boolean constrainedEvent
          Workaround for shift-key-state not correct in mouseReleased.
protected  java.lang.Object[] dragCells
           
protected  javax.swing.ImageIcon dragImage
          Holds the image that is being used for the preview.
protected  java.awt.Point first
          Holds the start location of the mouse gesture.
protected  mxGraphComponent graphComponent
          Reference to the enclosing graph component.
protected  boolean imagePreview
          Specifies if an image should be used for preview.
protected  java.lang.Object initialCell
           
protected  boolean keepOnTop
          Specifies if this handler should be painted on top of all other components.
protected  mxCellMarker marker
           
static java.awt.Cursor MOVE_CURSOR
           
protected  boolean moveEnabled
          Specifies if moving is enabled.
protected  boolean removeCellsFromParent
          Specifies if cells may be moved out of their parents.
protected  boolean selectEnabled
          Specifies if moving is enabled.
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
 java.awt.Point convertPoint(java.awt.Point pt)
           
protected  java.awt.event.MouseEvent createEvent(java.awt.dnd.DropTargetEvent e)
           
protected  mxCellMarker createMarker()
           
 void dragEnter(java.awt.dnd.DropTargetDragEvent e)
           
 void dragExit(java.awt.dnd.DropTargetEvent e)
           
 void dragOver(java.awt.dnd.DropTargetDragEvent e)
           
 void drop(java.awt.dnd.DropTargetDropEvent e)
           
 void dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
           
protected  void fold(java.lang.Object cell)
           
 java.lang.Object[] getCells(java.lang.Object initialCell)
           
protected  java.awt.Cursor getCursor(java.awt.event.MouseEvent e)
           
protected static javax.swing.JComponent getDropTarget(java.awt.dnd.DropTargetEvent e)
          Helper method to return the component for a drop target event.
 mxGraphComponent getGraphComponent()
           
protected static mxGraphTransferHandler getGraphTransferHandler(java.awt.dnd.DropTargetEvent e)
          Helper method to return the component for a drop target event.
protected  java.awt.Point getPreviewLocation(java.awt.event.MouseEvent e, boolean gridEnabled)
           
 boolean isCenterPreview()
           
 boolean isCloneEnabled()
           
 boolean isImagePreview()
           
 boolean isMoveEnabled()
           
 boolean isRemoveCellsFromParent()
           
 boolean isSelectEnabled()
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
protected  void moveCells(java.lang.Object[] cells, double dx, double dy, java.lang.Object target, java.awt.event.MouseEvent e)
           
 void paint(java.awt.Graphics g)
           
 void reset()
           
 void setCenterPreview(boolean value)
           
 void setCloneEnabled(boolean value)
           
 void setImagePreview(boolean value)
           
 void setMoveEnabled(boolean value)
           
 void setRemoveCellsFromParent(boolean value)
           
 void setSelectEnabled(boolean value)
           
protected  boolean shouldRemoveCellFromParent(java.lang.Object parent, java.lang.Object[] cells, java.awt.event.MouseEvent e)
          Returns true if the given cells should be removed from the parent for the specified mousereleased event.
 void start(java.awt.event.MouseEvent e)
           
 void updateDragImage(java.lang.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, getBaseline, getBaselineResizeBehavior, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, 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

MOVE_CURSOR

public static java.awt.Cursor MOVE_CURSOR

graphComponent

protected mxGraphComponent graphComponent
Reference to the enclosing graph component.


cloneEnabled

protected boolean cloneEnabled
Specifies if cloning by control-drag is enabled. Default is true.


moveEnabled

protected boolean moveEnabled
Specifies if moving is enabled. Default is true.


selectEnabled

protected boolean selectEnabled
Specifies if moving is enabled. Default is true.


removeCellsFromParent

protected boolean removeCellsFromParent
Specifies if cells may be moved out of their parents. Default is true.


imagePreview

protected boolean imagePreview
Specifies if an image should be used for preview. Default is true.


centerPreview

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


keepOnTop

protected boolean keepOnTop
Specifies if this handler should be painted on top of all other components. Default is true.


cells

protected transient java.lang.Object[] cells
Holds the cells that are being moved by this handler.


dragImage

protected transient javax.swing.ImageIcon dragImage
Holds the image that is being used for the preview.


first

protected transient java.awt.Point first
Holds the start location of the mouse gesture.


cell

protected transient java.lang.Object cell

initialCell

protected transient java.lang.Object initialCell

dragCells

protected transient java.lang.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.


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.

Constructor Detail

mxGraphHandler

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

createMarker

protected mxCellMarker createMarker()

getGraphComponent

public mxGraphComponent getGraphComponent()

isCloneEnabled

public boolean isCloneEnabled()

setCloneEnabled

public void setCloneEnabled(boolean value)

isMoveEnabled

public boolean isMoveEnabled()

setMoveEnabled

public void setMoveEnabled(boolean value)

isSelectEnabled

public boolean isSelectEnabled()

setSelectEnabled

public void setSelectEnabled(boolean value)

isRemoveCellsFromParent

public boolean isRemoveCellsFromParent()

setRemoveCellsFromParent

public void setRemoveCellsFromParent(boolean value)

isImagePreview

public boolean isImagePreview()

setImagePreview

public void setImagePreview(boolean value)

isCenterPreview

public boolean isCenterPreview()

setCenterPreview

public void setCenterPreview(boolean value)

updateDragImage

public void updateDragImage(java.lang.Object[] cells)

mouseMoved

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

getCursor

protected java.awt.Cursor getCursor(java.awt.event.MouseEvent e)

dragEnter

public void dragEnter(java.awt.dnd.DropTargetDragEvent e)
Specified by:
dragEnter in interface java.awt.dnd.DropTargetListener

mousePressed

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

getCells

public java.lang.Object[] getCells(java.lang.Object initialCell)

start

public void start(java.awt.event.MouseEvent e)

dropActionChanged

public void dropActionChanged(java.awt.dnd.DropTargetDragEvent e)
Specified by:
dropActionChanged in interface java.awt.dnd.DropTargetListener

dragOver

public void dragOver(java.awt.dnd.DropTargetDragEvent e)
Specified by:
dragOver in interface java.awt.dnd.DropTargetListener
Parameters:
e -

convertPoint

public java.awt.Point convertPoint(java.awt.Point pt)

mouseDragged

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

getPreviewLocation

protected java.awt.Point getPreviewLocation(java.awt.event.MouseEvent e,
                                            boolean gridEnabled)

dragExit

public void dragExit(java.awt.dnd.DropTargetEvent e)
Specified by:
dragExit in interface java.awt.dnd.DropTargetListener
Parameters:
e -

drop

public void drop(java.awt.dnd.DropTargetDropEvent e)
Specified by:
drop in interface java.awt.dnd.DropTargetListener
Parameters:
e -

mouseReleased

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

fold

protected void fold(java.lang.Object cell)

reset

public void reset()

shouldRemoveCellFromParent

protected boolean shouldRemoveCellFromParent(java.lang.Object parent,
                                             java.lang.Object[] cells,
                                             java.awt.event.MouseEvent e)
Returns true if the given cells should be removed from the parent for the specified mousereleased event.


moveCells

protected void moveCells(java.lang.Object[] cells,
                         double dx,
                         double dy,
                         java.lang.Object target,
                         java.awt.event.MouseEvent e)
Parameters:
dx -
dy -
e -

paint

public void paint(java.awt.Graphics g)
Overrides:
paint in class javax.swing.JComponent

createEvent

protected java.awt.event.MouseEvent createEvent(java.awt.dnd.DropTargetEvent e)

getGraphTransferHandler

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


getDropTarget

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


JGraph X 1.3.0.0


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