edu.mines.jtk.sgl
Class DragContext

java.lang.Object
  extended by edu.mines.jtk.sgl.DragContext

public class DragContext
extends java.lang.Object

A context for dragging. Dragable nodes use a drag context to implement dragging with a mouse.

A drag context is constructed from a pick result, which has a picked point in local coordinates, as well as transforms to world and pixel coordinates. Those local-to-world and and local-to-pixel transforms are assumed to be constant while the the mouse is being dragged. This assumption implies that the view must not change while dragging.

A drag context has a current mouse event and a current point, with local, world, and pixel coordinates. A mouse motion listener (not part of this context) is responsible for updating this context as the mouse is dragged. Updates modify the current mouse event and the current point maintained by this context.

Version:
2005.07.07
Author:
Dave Hale, Colorado School of Mines

Constructor Summary
DragContext(PickResult pr)
          Constructs a drag context for the specified pick result.
 
Method Summary
 Matrix44 getLocalToPixel()
          Gets the local-to-pixel coordinate transform matrix.
 Matrix44 getLocalToWorld()
          Gets the local-to-world coordinate transform matrix.
 java.awt.event.MouseEvent getMouseEvent()
          Gets the current mouse event.
 double getPixelZ()
          Gets the pixel z (depth) coordinate of the current point.
 Point3 getPointLocal()
          Gets the current point in local coordinates.
 Point3 getPointPixel()
          Gets the current point in pixel coordinates.
 Point3 getPointWorld()
          Gets the current point in world coordinates.
 View getView()
          Gets the view for which this context was constructed.
 ViewCanvas getViewCanvas()
          Gets the canvas for which this context was constructed.
 World getWorld()
          Gets the world for which this context was constructed.
 Matrix44 getWorldToPixel()
          Gets the world-to-pixel coordinate transform matrix.
 void update(java.awt.event.MouseEvent event)
          Updates this drag context for the specified mouse event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DragContext

public DragContext(PickResult pr)
Constructs a drag context for the specified pick result.

Parameters:
pr - the pick result.
Method Detail

update

public void update(java.awt.event.MouseEvent event)
Updates this drag context for the specified mouse event. Updates the current mouse event and the current point's local, world, and pixel coordinates. Mouse motion listeners call this method as the mouse is dragged.

Parameters:
event - the mouse event.

getViewCanvas

public ViewCanvas getViewCanvas()
Gets the canvas for which this context was constructed.

Returns:
the view canvas.

getView

public View getView()
Gets the view for which this context was constructed.

Returns:
the view.

getWorld

public World getWorld()
Gets the world for which this context was constructed.

Returns:
the world.

getMouseEvent

public java.awt.event.MouseEvent getMouseEvent()
Gets the current mouse event.

Returns:
the mouse event.

getPointLocal

public Point3 getPointLocal()
Gets the current point in local coordinates.

Returns:
the current point in local coordinates.

getPointWorld

public Point3 getPointWorld()
Gets the current point in world coordinates.

Returns:
the current point in world coordinates.

getPointPixel

public Point3 getPointPixel()
Gets the current point in pixel coordinates.

Returns:
the current point in pixel coordinates.

getPixelZ

public double getPixelZ()
Gets the pixel z (depth) coordinate of the current point. This depth depth coordinate increases from 0.0 at the near clipping plane to 1.0 at the far clipping plane.

Returns:
the pixel z coordinate.

getLocalToWorld

public Matrix44 getLocalToWorld()
Gets the local-to-world coordinate transform matrix.

Returns:
the local-to-world coordinate transform matrix.

getLocalToPixel

public Matrix44 getLocalToPixel()
Gets the local-to-pixel coordinate transform matrix.

Returns:
the local-to-pixel coordinate transform matrix.

getWorldToPixel

public Matrix44 getWorldToPixel()
Gets the world-to-pixel coordinate transform matrix.

Returns:
the world-to-pixel coordinate transform matrix.