JGraph X 1.9.2.5


com.mxgraph.swing.handler
Class mxGraphHandler

java.lang.Object
  extended by com.mxgraph.swing.util.mxMouseAdapter
      extended by com.mxgraph.swing.handler.mxGraphHandler
All Implemented Interfaces:
java.awt.dnd.DropTargetListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener

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


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.awt.dnd.DropTarget currentDropTarget
          Reference to the current drop target.
static java.awt.Cursor DEFAULT_CURSOR
          Default is Cursor.DEFAULT_CURSOR.
protected  java.lang.Object[] dragCells
           
protected  javax.swing.ImageIcon dragImage
          Holds the image that is being used for the preview.
protected  boolean enabled
          Specifies if the handler is enabled.
protected  java.awt.Point first
          Holds the start location of the mouse gesture.
static java.awt.Cursor FOLD_CURSOR
          Default is Cursor.HAND_CURSOR.
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  boolean livePreview
          Specifies if live preview should be used if possible.
protected  mxCellMarker marker
           
protected  boolean markerEnabled
          Specifies if the cell marker should be called (for splitting edges and dropping cells into groups).
static java.awt.Cursor MOVE_CURSOR
          Default is Cursor.MOVE_CURSOR.
protected  boolean moveEnabled
          Specifies if moving is enabled.
protected  mxMovePreview movePreview
           
protected  java.awt.Rectangle previewBounds
           
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.
protected  boolean visible
           
 
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()
           
protected  mxMovePreview createMovePreview()
           
 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.
 mxCellMarker getMarker()
           
 mxMovePreview getMovePreview()
           
protected  java.awt.Point getPreviewLocation(java.awt.event.MouseEvent e, boolean gridEnabled)
           
protected  void installDragGestureHandler()
           
protected  void installDropTargetHandler()
           
 boolean isCenterPreview()
           
 boolean isCloneEnabled()
           
 boolean isEnabled()
           
 boolean isImagePreview()
           
 boolean isLivePreview()
           
 boolean isMarkerEnabled()
           
 boolean isMoveEnabled()
           
 boolean isRemoveCellsFromParent()
           
 boolean isSelectEnabled()
           
 boolean isVisible()
           
 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 setEnabled(boolean value)
           
 void setImagePreview(boolean value)
           
 void setLivePreview(boolean value)
           
 void setMarker(mxCellMarker value)
           
 void setMarkerEnabled(boolean value)
           
 void setMoveEnabled(boolean value)
           
 void setPreviewBounds(java.awt.Rectangle bounds)
           
 void setRemoveCellsFromParent(boolean value)
           
 void setSelectEnabled(boolean value)
           
 void setVisible(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.mxMouseAdapter
mouseClicked, mouseEntered, mouseExited
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CURSOR

public static java.awt.Cursor DEFAULT_CURSOR
Default is Cursor.DEFAULT_CURSOR.


MOVE_CURSOR

public static java.awt.Cursor MOVE_CURSOR
Default is Cursor.MOVE_CURSOR.


FOLD_CURSOR

public static java.awt.Cursor FOLD_CURSOR
Default is Cursor.HAND_CURSOR.


graphComponent

protected mxGraphComponent graphComponent
Reference to the enclosing graph component.


enabled

protected boolean enabled
Specifies if the handler is enabled. Default is true.


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.


markerEnabled

protected boolean markerEnabled
Specifies if the cell marker should be called (for splitting edges and dropping cells into groups). Default is true.


removeCellsFromParent

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


movePreview

protected mxMovePreview movePreview

livePreview

protected boolean livePreview
Specifies if live preview should be used if possible. Default is false.


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.


visible

protected transient boolean visible

previewBounds

protected transient java.awt.Rectangle previewBounds

constrainedEvent

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


currentDropTarget

protected transient java.awt.dnd.DropTarget currentDropTarget
Reference to the current drop target.

Constructor Detail

mxGraphHandler

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

installDragGestureHandler

protected void installDragGestureHandler()

installDropTargetHandler

protected void installDropTargetHandler()

isVisible

public boolean isVisible()

setVisible

public void setVisible(boolean value)

setPreviewBounds

public void setPreviewBounds(java.awt.Rectangle bounds)

createMovePreview

protected mxMovePreview createMovePreview()

getMovePreview

public mxMovePreview getMovePreview()

createMarker

protected mxCellMarker createMarker()

getGraphComponent

public mxGraphComponent getGraphComponent()

isEnabled

public boolean isEnabled()

setEnabled

public void setEnabled(boolean value)

isCloneEnabled

public boolean isCloneEnabled()

setCloneEnabled

public void setCloneEnabled(boolean value)

isMoveEnabled

public boolean isMoveEnabled()

setMoveEnabled

public void setMoveEnabled(boolean value)

isMarkerEnabled

public boolean isMarkerEnabled()

setMarkerEnabled

public void setMarkerEnabled(boolean value)

getMarker

public mxCellMarker getMarker()

setMarker

public void setMarker(mxCellMarker value)

isSelectEnabled

public boolean isSelectEnabled()

setSelectEnabled

public void setSelectEnabled(boolean value)

isRemoveCellsFromParent

public boolean isRemoveCellsFromParent()

setRemoveCellsFromParent

public void setRemoveCellsFromParent(boolean value)

isLivePreview

public boolean isLivePreview()

setLivePreview

public void setLivePreview(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 mxMouseAdapter

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 mxMouseAdapter

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 mxMouseAdapter

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 mxMouseAdapter

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)

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.9.2.5


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