edu.umd.cs.piccolox.swing
Class PDefaultScrollDirector

java.lang.Object
  extended by edu.umd.cs.piccolox.swing.PDefaultScrollDirector
All Implemented Interfaces:
PScrollDirector, java.beans.PropertyChangeListener, java.util.EventListener

public class PDefaultScrollDirector
extends java.lang.Object
implements PScrollDirector, java.beans.PropertyChangeListener

The default scroll director implementation. This default implementation 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  PCamera camera
          The canvas' camera
protected  PRoot root
          The canvas' root
protected  boolean scrollInProgress
          Flag to indicate when scrolling is currently in progress
protected  PScrollPane scrollPane
          The scrollpane that contains the viewport
protected  PCanvas view
          The canvas that this class directs
protected  PViewport viewPort
          The viewport that signals this scroll director
 
Constructor Summary
PDefaultScrollDirector()
          The default constructor
 
Method Summary
 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 install(PViewport viewPort, PCanvas view)
          Installs the scroll director and adds the appropriate listeners
 void propertyChange(java.beans.PropertyChangeEvent pce)
          Invoked when the camera's view changes, or the bounds of the root or camera changes
 void setViewPosition(double x, double y)
          Set the view position in a manner consistent with standardized scrolling
 boolean shouldRevalidateScrollPane()
          Should the ScrollPane be revalidated.
 void unInstall()
          Uninstall the scroll director from the viewport
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

viewPort

protected PViewport viewPort
The viewport that signals this scroll director


scrollPane

protected PScrollPane scrollPane
The scrollpane that contains the viewport


view

protected PCanvas view
The canvas that this class directs


camera

protected PCamera camera
The canvas' camera


root

protected PRoot root
The canvas' root


scrollInProgress

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

Constructor Detail

PDefaultScrollDirector

public PDefaultScrollDirector()
The default constructor

Method Detail

install

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

Specified by:
install in interface PScrollDirector
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 PScrollDirector

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 PScrollDirector
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 PScrollDirector
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 PScrollDirector
Parameters:
x - The new x position
y - The new y position

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent pce)
Invoked when the camera's view changes, or the bounds of the root or camera changes

Specified by:
propertyChange in interface java.beans.PropertyChangeListener

shouldRevalidateScrollPane

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

Returns:
Whether the scroll pane should be revalidated


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

Web Accessibility