edu.umd.cs.jazz.util
Class ZDefaultScrollDirector

java.lang.Object
  |
  +--edu.umd.cs.jazz.util.ZDefaultScrollDirector
All Implemented Interfaces:
java.util.EventListener, ZCameraListener, ZNodeListener, ZScrollDirector

public class ZDefaultScrollDirector
extends java.lang.Object
implements ZScrollDirector, ZCameraListener, ZNodeListener

The default implementation of the scroll director that follows the widely accepted model of scrolling - namely the scrollbars control the movement of the window over the document rather than the movement of the document under the window.

Author:
Lance Good

Field Summary
protected  ZCamera camera
          The canvas' camera
protected  ZRoot root
          The canvas' root
protected  boolean scrollInProgress
          Flag to indicate when scrolling is currently in progress
protected  ZScrollPane scrollPane
          The scrollpane that contains the viewport
protected  ZCanvas view
          The canvas that this class directs
protected  ZViewport viewPort
          The viewport that signals this scroll director
 
Constructor Summary
ZDefaultScrollDirector()
          The default constructor
 
Method Summary
 void boundsChanged(ZNodeEvent e)
          Invoked when a node has its bounds changed.
 java.awt.Point getViewPosition(java.awt.geom.Rectangle2D viewBounds)
          Get the View position given the specified camera bounds
 java.awt.Dimension getViewSize(java.awt.geom.Rectangle2D viewBounds)
          Get the size of the view based on the specified camera bounds
 void globalBoundsChanged(ZNodeEvent e)
          Invoked when a node has its global bounds changed.
 void install(ZViewport viewPort, ZCanvas view)
          Installs the scroll director and adds the appropriate listeners
 void setViewPosition(double x, double y)
          Set the view position in a manner consistent with standardized scrolling
 boolean shouldRevalidateScrollPane()
          Should the ScrollPane be revalidated? - This occurs when either the scrollbars are showing and should be remove or are note showing and should be added
 void unInstall()
          Uninstall the scroll director from the viewport
 void viewChanged(ZCameraEvent e)
          Invoked when the camera's view transform changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viewPort

protected ZViewport viewPort
The viewport that signals this scroll director


scrollPane

protected ZScrollPane scrollPane
The scrollpane that contains the viewport


view

protected ZCanvas view
The canvas that this class directs


camera

protected ZCamera camera
The canvas' camera


root

protected ZRoot root
The canvas' root


scrollInProgress

protected boolean scrollInProgress
Flag to indicate when scrolling is currently in progress

Constructor Detail

ZDefaultScrollDirector

public ZDefaultScrollDirector()
The default constructor

Method Detail

install

public void install(ZViewport viewPort,
                    ZCanvas view)
Installs the scroll director and adds the appropriate listeners

Specified by:
install in interface ZScrollDirector
Parameters:
viewPort - The viewport on which this director directs
view - The ZCanvas that the viewport looks at

unInstall

public void unInstall()
Uninstall the scroll director from the viewport

Specified by:
unInstall in interface ZScrollDirector

getViewPosition

public java.awt.Point getViewPosition(java.awt.geom.Rectangle2D viewBounds)
Get the View position given the specified camera bounds

Specified by:
getViewPosition in interface ZScrollDirector
Parameters:
viewBounds - The bounds for which the view position will be computed
Returns:
The view position

getViewSize

public java.awt.Dimension getViewSize(java.awt.geom.Rectangle2D viewBounds)
Get the size of the view based on the specified camera bounds

Specified by:
getViewSize in interface ZScrollDirector
Parameters:
viewBounds - The view bounds for which the view size will be computed
Returns:
The view size

setViewPosition

public void setViewPosition(double x,
                            double y)
Set the view position in a manner consistent with standardized scrolling

Specified by:
setViewPosition in interface ZScrollDirector
Parameters:
x - The new x position
y - The new y position

viewChanged

public void viewChanged(ZCameraEvent e)
Invoked when the camera's view transform changes.

Specified by:
viewChanged in interface ZCameraListener
Parameters:
e - The view changed camera event

boundsChanged

public void boundsChanged(ZNodeEvent e)
Invoked when a node has its bounds changed.

Specified by:
boundsChanged in interface ZNodeListener
Parameters:
e - The bounds changed event

globalBoundsChanged

public void globalBoundsChanged(ZNodeEvent e)
Invoked when a node has its global bounds changed. These can be ignored since a global bounds change will have a corresponding bounds change on the root

Specified by:
globalBoundsChanged in interface ZNodeListener
Parameters:
e - The ignored global bounds event

shouldRevalidateScrollPane

public boolean shouldRevalidateScrollPane()
Should the ScrollPane be revalidated? - This occurs when either the scrollbars are showing and should be remove or are note showing and should be added

Returns:
Whether the scroll pane should be revalidated


Copyright � 2003 by University of Maryland, College Park, MD 20742, USA All rights reserved.