edu.umd.cs.piccolox.swing
Class PDefaultScrollDirector

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

public class PDefaultScrollDirector
extends Object
implements PScrollDirector, 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
 Point getViewPosition(Rectangle2D viewBounds)
          Get the View position given the specified camera bounds.
 Dimension getViewSize(Rectangle2D viewBounds)
          Get the size of the view based on the specified camera bounds.
 void install(PViewport targetViewPort, PCanvas targetView)
          Installs the scroll director and adds the appropriate listeners.
 void propertyChange(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 targetViewPort,
                    PCanvas targetView)
Installs the scroll director and adds the appropriate listeners.

Specified by:
install in interface PScrollDirector
Parameters:
targetViewPort - viewport on which this director directs
targetView - PCanvas that the viewport looks at

unInstall

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

Specified by:
unInstall in interface PScrollDirector

getViewPosition

public Point getViewPosition(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 Dimension getViewSize(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(PropertyChangeEvent pce)
Invoked when the camera's view changes, or the bounds of the root or camera changes.

Specified by:
propertyChange in interface PropertyChangeListener
Parameters:
pce - property change event to examine

shouldRevalidateScrollPane

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

Returns:
Whether the scroll pane should be revalidated


Copyright © 1995-2010 Piccolo2D. All Rights Reserved.