Search this API

y.view
Class AutoDragViewMode

java.lang.Object
  extended by y.view.ViewMode
      extended by y.view.AutoDragViewMode
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener

public class AutoDragViewMode
extends ViewMode

ViewMode implementation that adds automatic scrolling capabilities to Graph2DView. Automatic scrolling will be activated when dragging the mouse outside of the visible part of the view. Note that this view mode can be safely added registered with the view in parallel to other view modes that are provided by the yFiles view package.

Using this class is very simple, e.g.:

  // get the view instance
  Graph2DView view = getView();
  // create the view mode
  AutoDragViewMode adm = new AutoDragViewMode();
  // register it with the view
  view.addViewMode(adm);
 

 

Field Summary
 
Fields inherited from class y.view.ViewMode
ACTIVE_PROPERTY, ACTIVE_VIEW_PROPERTY, CHILD_MODE_PROPERTY, EDITING_PROPERTY, GRAB_FOCUS_ENABLED_PROPERTY, lastClickEvent, lastDragEvent, lastMoveEvent, lastPressEvent, lastReleaseEvent, MODIFIER_MASK_PROPERTY, NAME_PROPERTY, originalX, originalY, PARENT_MODE_PROPERTY, view
 
Constructor Summary
AutoDragViewMode()
          Creates a new AutoDragViewMode that can be added as a view mode to a GRaph2DView.
 
Method Summary
 void dispose()
          Stops automatic scrolling and disposes internal data structures.
 void mouseClicked(java.awt.event.MouseEvent mouseEvent)
          Initiates auto-drag.
 void mouseDragged(java.awt.event.MouseEvent mouseEvent)
          Updates auto-drag information.
 void mouseExited(java.awt.event.MouseEvent mouseEvent)
          Initiates auto-drag.
 void mousePressed(java.awt.event.MouseEvent mouseEvent)
          Initiates auto-drag.
 void mouseReleased(java.awt.event.MouseEvent mouseEvent)
          Initiates auto-drag.
 void setAutoDrag(int dx, int dy, java.awt.event.MouseEvent me)
          Initiates auto scrolling using the given direction vector.
 
Methods inherited from class y.view.ViewMode
activate, addPropertyChangeListener, addPropertyChangeListener, cancelEditing, deactivateChild, firePropertyChange, firePropertyChange, firePropertyChange, getChild, getGraph2D, getGridX, getGridY, getHitInfo, getHitInfo, getLastClickEvent, getLastDragEvent, getLastHitInfo, getLastMoveEvent, getLastPressEvent, getLastReleaseEvent, getModifierMask, getName, getParent, init, isActive, isEditing, isGrabFocusEnabled, isGridMode, isModifierPressed, mouseClicked, mouseDraggedLeft, mouseDraggedMiddle, mouseDraggedRight, mouseEntered, mouseMoved, mouseMoved, mousePressedLeft, mousePressedMiddle, mousePressedRight, mouseReleased, mouseReleasedLeft, mouseReleasedMiddle, mouseReleasedRight, mouseShiftPressedLeft, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedLeft, mouseShiftReleasedMiddle, mouseShiftReleasedRight, reactivateParent, removePropertyChangeListener, removePropertyChangeListener, setActiveView, setChild, setChild, setEditing, setGrabFocusEnabled, setGridMode, setLastHitInfo, setModifierMask, setName, setParent, translateX, translateY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoDragViewMode

public AutoDragViewMode()
Creates a new AutoDragViewMode that can be added as a view mode to a GRaph2DView.

Method Detail

dispose

public void dispose()
Stops automatic scrolling and disposes internal data structures.


setAutoDrag

public void setAutoDrag(int dx,
                        int dy,
                        java.awt.event.MouseEvent me)
Initiates auto scrolling using the given direction vector. The mouse event will be used for the subsequent creation of artificial MouseEvent.MOUSE_DRAGGED events, that will be dispatched to the view component during auto-scrolling. Calling this method with (dx,dy) = (0,0) will effectively stop the auto-scrolling.

Parameters:
dx - the delta x direction vector for the scrolling
dy - the delta y direction vector for the scrolling
me - the event that will be used for the artificial mouse events

mouseExited

public void mouseExited(java.awt.event.MouseEvent mouseEvent)
Initiates auto-drag.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Overrides:
mouseExited in class ViewMode

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent mouseEvent)
Initiates auto-drag.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class ViewMode

mousePressed

public void mousePressed(java.awt.event.MouseEvent mouseEvent)
Initiates auto-drag.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class ViewMode

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent mouseEvent)
Initiates auto-drag.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class ViewMode

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent mouseEvent)
Updates auto-drag information.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class ViewMode

© Copyright 2000-2022,
yWorks GmbH.
All rights reserved.