edu.umd.cs.piccolox.swing
Class PViewport

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JViewport
                  extended by edu.umd.cs.piccolox.swing.PViewport
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class PViewport
extends JViewport

A subclass of JViewport that talks to the scroll director to negotiate the view positions and sizes.

Author:
Lance Good
See Also:
Serialized Form

Nested Class Summary
static class PViewport.PViewportLayout
          A simple layout manager to give the ZCanvas the same size as the Viewport.
 
Nested classes/interfaces inherited from class javax.swing.JViewport
JViewport.AccessibleJViewport, JViewport.ViewListener
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
(package private)  PScrollDirector scrollDirector
          Controls what happens when scrolling occurs.
 
Fields inherited from class javax.swing.JViewport
backingStore, BACKINGSTORE_SCROLL_MODE, backingStoreImage, BLIT_SCROLL_MODE, isViewSizeSet, lastPaintPosition, scrollUnderway, SIMPLE_SCROLL_MODE
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PViewport()
          Pass constructor info to super.
 
Method Summary
protected  LayoutManager createLayoutManager()
          Subclasses can override this to install a different layout manager (or null) in the constructor.
protected  PScrollDirector createScrollDirector()
          Subclasses can override this to install a different scroll director in the constructor.
 void fireStateChanged()
          Notifies all ChangeListeners when the views size, position, or the viewports extent size has changed.
 PScrollDirector getScrollDirector()
          Returns the scroll director on this viewport.
 Point getViewPosition()
          Gets the view position from the scroll director based on the current extent size.
 Dimension getViewSize()
          Gets the view size from the scroll director based on the current extent size.
 Dimension getViewSize(Rectangle2D r)
          Gets the view size from the scroll director based on the specified extent size.
 void setScrollDirector(PScrollDirector scrollDirector)
          Set the scroll director on this viewport.
 void setView(Component view)
          Overridden to throw an exception if the view is not a PCanvas.
 void setViewPosition(Point p)
          Sets the view coordinates that appear in the upper left hand corner of the viewport, does nothing if there's no view.
 
Methods inherited from class javax.swing.JViewport
addChangeListener, addImpl, computeBlit, createViewListener, firePropertyChange, getAccessibleContext, getChangeListeners, getExtentSize, getInsets, getInsets, getScrollMode, getUI, getUIClassID, getView, getViewRect, isBackingStoreEnabled, isOptimizedDrawingEnabled, paint, paramString, remove, removeChangeListener, repaint, reshape, scrollRectToVisible, setBackingStoreEnabled, setBorder, setExtentSize, setScrollMode, setUI, setViewSize, toViewCoordinates, toViewCoordinates, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

scrollDirector

PScrollDirector scrollDirector
Controls what happens when scrolling occurs.

Constructor Detail

PViewport

public PViewport()
Pass constructor info to super.

Method Detail

createLayoutManager

protected LayoutManager createLayoutManager()
Subclasses can override this to install a different layout manager (or null) in the constructor. Returns a new ViewportLayout object.

Overrides:
createLayoutManager in class JViewport
Returns:
a LayoutManager

createScrollDirector

protected PScrollDirector createScrollDirector()
Subclasses can override this to install a different scroll director in the constructor. Returns a new PScrollDirector object.

Returns:
a PScrollDirector

setScrollDirector

public void setScrollDirector(PScrollDirector scrollDirector)
Set the scroll director on this viewport.

Parameters:
scrollDirector - The new scroll director

getScrollDirector

public PScrollDirector getScrollDirector()
Returns the scroll director on this viewport.

Returns:
The scroll director on this viewport

setView

public void setView(Component view)
Overridden to throw an exception if the view is not a PCanvas.

Overrides:
setView in class JViewport
Parameters:
view - The new view - it better be a ZCanvas!

fireStateChanged

public void fireStateChanged()
Notifies all ChangeListeners when the views size, position, or the viewports extent size has changed. PDefaultScrollDirector calls this so it needs to be public.

Overrides:
fireStateChanged in class JViewport

setViewPosition

public void setViewPosition(Point p)
Sets the view coordinates that appear in the upper left hand corner of the viewport, does nothing if there's no view.

Overrides:
setViewPosition in class JViewport
Parameters:
p - a Point object giving the upper left coordinates

getViewPosition

public Point getViewPosition()
Gets the view position from the scroll director based on the current extent size.

Overrides:
getViewPosition in class JViewport
Returns:
The new view's position

getViewSize

public Dimension getViewSize()
Gets the view size from the scroll director based on the current extent size.

Overrides:
getViewSize in class JViewport
Returns:
The new view size

getViewSize

public Dimension getViewSize(Rectangle2D r)
Gets the view size from the scroll director based on the specified extent size.

Parameters:
r - The extent size from which the view is computed
Returns:
The new view size


Copyright © 1995-2010 Piccolo2D. All Rights Reserved.