Package org.apache.pivot.wtk
Class Viewport
- java.lang.Object
-
- org.apache.pivot.wtk.Component
-
- org.apache.pivot.wtk.Container
-
- org.apache.pivot.wtk.Viewport
-
- All Implemented Interfaces:
java.lang.Iterable<Component>
,Sequence<Component>
,ConstrainedVisual
,Visual
- Direct Known Subclasses:
Panorama
,ScrollPane
@DefaultProperty("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 theadd()
method. The component that gets the windowed (or scrollable) view should be added via thesetView()
method (or the "view" property).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Viewport.Skin
Viewport skin interface.-
Nested classes/interfaces inherited from class org.apache.pivot.wtk.Container
Container.EDTChecker
-
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
Constructors Constructor Description Viewport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getScrollLeft()
int
getScrollTop()
Component
getView()
Bounds
getViewportBounds()
ListenerList<ViewportListener>
getViewportListeners()
boolean
isConsumeRepaint()
Returns theconsumeRepaint
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 thesetView(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 newConsumeRepaint)
Sets theconsumeRepaint
flag, which controls whether the viewport will propagate repaints to its parent or consume them.void
setRepaintAllViewport(boolean newRepaintAllViewport)
Set the viewport painting mode.void
setScrollLeft(int newScrollLeft)
Set the new left scroll offset.void
setScrollTop(int newScrollTop)
Set the new top scroll offset.protected void
setSkin(Skin skin)
Sets the skin, replacing any previous skin.void
setView(Component newView)
Set the single component (typically aContainer
) 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
checkSkin, clearFocus, contains, copyStyle, copyStyle, 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, getScreenBounds, getSize, getSkin, getStyle, getStyle, getStyleBoolean, getStyleBoolean, getStyleColor, getStyleColor, getStyleFont, getStyleFont, getStyleInt, getStyleInt, getStyles, getTextInputMethodListener, 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, offsetToScreen, putStyle, putStyle, reenterMouse, repaint, repaint, repaint, repaint, repaint, scrollAreaToVisible, scrollAreaToVisible, setAttribute, setAutomationID, 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
-
-
-
-
Method Detail
-
setSkin
protected void setSkin(Skin skin)
Description copied from class:Component
Sets the skin, replacing any previous skin.
-
getScrollTop
public int getScrollTop()
- Returns:
- The current top scroll offset.
-
setScrollTop
public void setScrollTop(int newScrollTop)
Set the new top scroll offset.- Parameters:
newScrollTop
- The new top offset.
-
getScrollLeft
public int getScrollLeft()
- Returns:
- The current left scroll offset.
-
setScrollLeft
public void setScrollLeft(int newScrollLeft)
Set the new left scroll offset.- Parameters:
newScrollLeft
- The new left offset.
-
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 newView)
Set the single component (typically aContainer
) that we will provide a windowed (or scrollable) view of.- Parameters:
newView
- The new component (container) we are viewing.
-
isConsumeRepaint
public boolean isConsumeRepaint()
Returns theconsumeRepaint
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 newConsumeRepaint)
Sets theconsumeRepaint
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:
newConsumeRepaint
-true
to consume repaints that bubble up through this viewport;false
to propagate them up like normal.
-
getViewportBounds
public Bounds getViewportBounds()
- Returns:
- 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.
-
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 thesetView(org.apache.pivot.wtk.Component)
method instead. Any attempt to remove the "view" component with this method will result in an exception.
-
getViewportListeners
public ListenerList<ViewportListener> getViewportListeners()
- Returns:
- The current list of listeners for events on this viewport.
-
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 thesetRepaintAllViewport
method.- Returns:
false
if optimized, otherwisetrue
(repaint entire viewport)
-
setRepaintAllViewport
public void setRepaintAllViewport(boolean newRepaintAllViewport)
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 isfalse
).- Parameters:
newRepaintAllViewport
-false
means optimized (repaint only needed area, default), whiletrue
means repaint all
-
-