Class mxGraphHandler

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

public class mxGraphHandler extends mxMouseAdapter implements DropTargetListener
  • Field Details

    • 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 Details

    • mxGraphHandler

      public mxGraphHandler(mxGraphComponent graphComponent)
      Parameters:
      graphComponent -
  • Method Details

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