mxGraph 1.10.2.1


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:
DropTargetListener, MouseListener, MouseMotionListener, EventListener

public class mxGraphHandler
extends mxMouseAdapter
implements DropTargetListener


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  DropTarget currentDropTarget
          Reference to the current drop target.
static Cursor DEFAULT_CURSOR
          Default is Cursor.DEFAULT_CURSOR.
protected  Object[] dragCells
           
protected  ImageIcon dragImage
          Holds the image that is being used for the preview.
protected  boolean enabled
          Specifies if the handler is enabled.
protected  Point first
          Holds the start location of the mouse gesture.
static Cursor FOLD_CURSOR
          Default is Cursor.HAND_CURSOR.
protected  mxGraphComponent graphComponent
          Reference to the enclosing graph component.
protected  boolean gridEnabledEvent
          Workaround for alt-key-state not correct in mouseReleased.
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  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 Cursor MOVE_CURSOR
          Default is Cursor.MOVE_CURSOR.
protected  boolean moveEnabled
          Specifies if moving is enabled.
protected  mxMovePreview movePreview
           
protected  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
 Point convertPoint(Point pt)
           
protected  MouseEvent createEvent(DropTargetEvent e)
           
protected  mxCellMarker createMarker()
           
protected  mxMovePreview createMovePreview()
           
 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.
 mxCellMarker getMarker()
           
 mxMovePreview getMovePreview()
           
protected  Point getPreviewLocation(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(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 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(Rectangle bounds)
           
 void setRemoveCellsFromParent(boolean value)
           
 void setSelectEnabled(boolean value)
           
 void setVisible(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.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 Cursor DEFAULT_CURSOR
Default is Cursor.DEFAULT_CURSOR.


MOVE_CURSOR

public static Cursor MOVE_CURSOR
Default is Cursor.MOVE_CURSOR.


FOLD_CURSOR

public static 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 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.


visible

protected transient boolean visible

previewBounds

protected transient Rectangle previewBounds

gridEnabledEvent

protected transient boolean gridEnabledEvent
Workaround for alt-key-state not correct in mouseReleased. Note: State of the alt-key is not available during drag-and-drop.


constrainedEvent

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


currentDropTarget

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

mouseMoved

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

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 mxMouseAdapter

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 mxMouseAdapter

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 mxMouseAdapter

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)

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.


mxGraph 1.10.2.1


Copyright (c) 2010 Gaudenz Alder, David Benson. All rights reserved.