org.apache.pivot.wtk
Class Viewport

java.lang.Object
  extended by org.apache.pivot.wtk.Component
      extended by org.apache.pivot.wtk.Container
          extended by org.apache.pivot.wtk.Viewport
All Implemented Interfaces:
Iterable<Component>, Sequence<Component>, ConstrainedVisual, Visual
Direct Known Subclasses:
Panorama, ScrollPane

@DefaultProperty(value="view")
public abstract class Viewport
extends Container

Abstract base class for viewport components. Viewports provide a windowed view on a component (called the "view") that is too large to fit within a given area. They are generally scrollable.

Even though this class is a Container, no components should be added to it via the add() method. The component that gets the windowed (or scrollable) view should be added via the setView() method (or the "view" property).


Nested Class Summary
static interface Viewport.Skin
          Viewport skin interface.
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Container
Container.EDT_Checker
 
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Component
Component.DecoratorSequence, Component.StyleDictionary, Component.UserDataDictionary
 
Nested classes/interfaces inherited from interface org.apache.pivot.collections.Sequence
Sequence.Tree<T>
 
Constructor Summary
Viewport()
           
 
Method Summary
 int getScrollLeft()
           
 int getScrollTop()
           
 Component getView()
          Returns the (single) component (typically a Container) that we are providing a windowed (or scrollable) view of.
 Bounds getViewportBounds()
          The bounds of the Viewport within the container, for example, in ScrollPaneSkin, this excludes the scrollbars.
 ListenerList<ViewportListener> getViewportListeners()
           
 boolean isConsumeRepaint()
          Returns the consumeRepaint flag, which controls whether the viewport will propagate repaints to its parent or consume them.
 boolean isRepaintAllViewport()
          Tell if the viewport painting mode is optimized (repaint only needed area, default), or repaint all.
 Sequence<Component> remove(int index, int count)
          This method should not be called to remove child components from the Viewport because the viewable child(ren) are set by the setView(org.apache.pivot.wtk.Component) method instead.
 void repaint(int x, int y, int width, int height, boolean immediate)
          Flags an area as needing to be repainted.
 void setConsumeRepaint(boolean consumeRepaint)
          Sets the consumeRepaint flag, which controls whether the viewport will propagate repaints to its parent or consume them.
 void setRepaintAllViewport(boolean repaintAllViewport)
          Set the viewport painting mode.
 void setScrollLeft(int scrollLeft)
           
 void setScrollTop(int scrollTop)
           
protected  void setSkin(Skin skin)
          Sets the skin, replacing any previous skin.
 void setView(Component view)
          Set the single component (typically a Container) that we will provide a windowed (or scrollable) view of.
 
Methods inherited from class org.apache.pivot.wtk.Container
add, assertEventDispatchThread, assertEventDispatchThread, clear, containsFocus, descendantAdded, descendantGainedFocus, descendantLostFocus, descendantRemoved, get, getComponentAt, getContainerListeners, getContainerMouseListeners, getDescendantAt, getFocusTraversalPolicy, getGraphics, getLength, getNamedComponent, indexOf, insert, invalidate, isAncestor, isDoubleBuffered, iterator, layout, load, mouseClick, mouseDown, mouseMove, mouseOut, mouseUp, mouseWheel, move, paint, remove, removeAll, requestFocus, setDoubleBuffered, setEventDispatchThreadChecker, setFocusTraversalPolicy, setParent, setVisible, store, transferFocus, update
 
Methods inherited from class org.apache.pivot.wtk.Component
clearFocus, contains, getAncestor, getAncestor, getAttribute, getAutomationID, getBaseline, getBaseline, getBounds, getComponentClassListeners, getComponentDataListeners, getComponentDecoratorListeners, getComponentKeyListeners, getComponentListeners, getComponentMouseButtonListeners, getComponentMouseListeners, getComponentMouseWheelListeners, getComponentStateListeners, getComponentStyleListeners, getComponentTooltipListeners, getCursor, getDecoratedBounds, getDecorators, getDisplay, getDragSource, getDropTarget, getFocusedComponent, getHeight, getHeightLimits, getLocation, getMaximumHeight, getMaximumWidth, getMenuHandler, getMinimumHeight, getMinimumWidth, getMouseLocation, getName, getNamedStyles, getParent, getPreferredHeight, getPreferredHeight, getPreferredSize, getPreferredWidth, getPreferredWidth, getSize, getSkin, getStyles, getTooltipDelay, getTooltipText, getTooltipWrapText, getTypedStyles, getUserData, getVisibleArea, getVisibleArea, getVisibleArea, getWidth, getWidthLimits, getWindow, getX, getY, indexBoundsCheck, installSkin, isBlocked, isEnabled, isFocusable, isFocused, isMouseOver, isOpaque, isPreferredHeightSet, isPreferredSizeSet, isPreferredWidthSet, isShowing, isValid, isVisible, keyPressed, keyReleased, keyTyped, mapPointFromAncestor, mapPointFromAncestor, mapPointToAncestor, mapPointToAncestor, mouseOver, reenterMouse, repaint, repaint, repaint, repaint, repaint, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, setCursor, setDragSource, setDropTarget, setEnabled, setFocused, setHeight, setHeightLimits, setHeightLimits, setLocation, setLocation, setMaximumHeight, setMaximumWidth, setMenuHandler, setMinimumHeight, setMinimumWidth, setName, setPreferredHeight, setPreferredSize, setPreferredSize, setPreferredWidth, setSize, setSize, setStyleName, setStyleNames, setStyleNames, setStyles, setStyles, setTooltipDelay, setTooltipText, setTooltipWrapText, setWidth, setWidthLimits, setWidthLimits, setX, setY, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Viewport

public Viewport()
Method Detail

setSkin

protected void setSkin(Skin skin)
Description copied from class: Component
Sets the skin, replacing any previous skin.

Overrides:
setSkin in class Component
Parameters:
skin - The new skin.

getScrollTop

public int getScrollTop()

setScrollTop

public void setScrollTop(int scrollTop)

getScrollLeft

public int getScrollLeft()

setScrollLeft

public void setScrollLeft(int scrollLeft)

getView

public Component getView()
Returns the (single) component (typically a Container) that we are providing a windowed (or scrollable) view of.


setView

public void setView(Component view)
Set the single component (typically a Container) that we will provide a windowed (or scrollable) view of.


isConsumeRepaint

public boolean isConsumeRepaint()
Returns the consumeRepaint flag, which controls whether the viewport will propagate repaints to its parent or consume them. This flag enables skins to optimize viewport scrolling by blitting the display to reduce the required repaint area.

Returns:
true if this viewport will consume repaints that bubble up through it; false if it will propagate them up like normal.

setConsumeRepaint

public void setConsumeRepaint(boolean consumeRepaint)
Sets the consumeRepaint flag, which controls whether the viewport will propagate repaints to its parent or consume them. This flag enables skins to optimize viewport scrolling by blitting the display to reduce the required repaint area.

Parameters:
consumeRepaint - true to consume repaints that bubble up through this viewport; false to propagate them up like normal.

getViewportBounds

public Bounds getViewportBounds()
The bounds of the Viewport within the container, for example, in ScrollPaneSkin, this excludes the scrollbars.


repaint

public void repaint(int x,
                    int y,
                    int width,
                    int height,
                    boolean immediate)
Description copied from class: Component
Flags an area as needing to be repainted.

Overrides:
repaint in class Container

remove

public Sequence<Component> remove(int index,
                                  int count)
This method should not be called to remove child components from the Viewport because the viewable child(ren) are set by the setView(org.apache.pivot.wtk.Component) method instead. Any attempt to remove the "view" component with this method will result in an exception.

Specified by:
remove in interface Sequence<Component>
Overrides:
remove in class Container
Parameters:
index - The starting index to remove.
count - The number of items to remove, beginning with index.
Returns:
A sequence containing the items that were removed.

getViewportListeners

public ListenerList<ViewportListener> getViewportListeners()

isRepaintAllViewport

public boolean isRepaintAllViewport()
Tell if the viewport painting mode is optimized (repaint only needed area, default), or repaint all.

This is implemented as a workaround for various painting issues on some platforms. So, if you experience problems with the scrolled-in area not being painted properly by default, consider setting this property true using the setRepaintAllViewport method.

Returns:
false if optimized, otherwise true (repaint entire viewport)

setRepaintAllViewport

public void setRepaintAllViewport(boolean repaintAllViewport)
Set the viewport painting mode.

This is implemented as a workaround for various painting issues on some platforms. So, if you experience problems with the scrolled-in area not being painted properly by default, consider setting this property true (default is false).

Parameters:
repaintAllViewport - false means optimized (repaint only needed area, default), while true means repaint all