JGraph X 1.2.0.8


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
 
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
          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  Object[] dragCells
           
protected  ImageIcon dragImage
          Holds the image that is being used for the preview.
protected  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  Object initialCell
           
protected  boolean keepOnTop
          Specifies if this handler should be painted on top of all other components.
protected  mxCellMarker marker
           
static 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
 Point convertPoint(Point pt)
           
protected  MouseEvent createEvent(DropTargetEvent e)
           
protected  mxCellMarker createMarker()
           
 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)
           
 Object[] getCells(Object initialCell)
           
protected  Cursor getCursor(MouseEvent e)
           
protected static JComponent getDropTarget(DropTargetEvent e)
          Helper method to return the component for a drop target event.
 mxGraphComponent getGraphComponent()
           
protected static mxGraphTransferHandler getGraphTransferHandler(DropTargetEvent e)
          Helper method to return the component for a drop target event.
protected  Point getPreviewLocation(MouseEvent e, boolean gridEnabled)
           
 boolean isCenterPreview()
           
 boolean isCloneEnabled()
           
 boolean isImagePreview()
           
 boolean isMoveEnabled()
           
 boolean isRemoveCellsFromParent()
           
 boolean isSelectEnabled()
           
 void mouseDragged(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
           
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
protected  void moveCells(Object[] cells, double dx, double dy, Object target, MouseEvent e)
           
 void paint(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(Object parent, Object[] cells, MouseEvent e)
          Returns true if the given cells should be removed from the parent for the specified mousereleased event.
 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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 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.


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 Object[] cells
Holds the cells that are being moved by this handler.


dragImage

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


first

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


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.


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(Object[] cells)

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

mousePressed

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

getCells

public Object[] getCells(Object initialCell)

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()

shouldRemoveCellFromParent

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


moveCells

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

paint

public void paint(Graphics g)
Overrides:
paint 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 1.2.0.8


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