Class 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 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.
      • 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
      • 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
      • 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 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()
      • 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)
      • 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.