NASA World Wind

gov.nasa.worldwind.util.tree
Class ScrollFrame

java.lang.Object
  extended by gov.nasa.worldwind.avlist.AVListImpl
      extended by gov.nasa.worldwind.util.AbstractHotSpot
          extended by gov.nasa.worldwind.util.tree.TreeHotSpot
              extended by gov.nasa.worldwind.util.tree.DragControl
                  extended by gov.nasa.worldwind.util.tree.ScrollFrame
All Implemented Interfaces:
AVList, SelectListener, PreRenderable, Renderable, HotSpot, KeyListener, MouseListener, MouseMotionListener, MouseWheelListener, EventListener

public class ScrollFrame
extends DragControl
implements PreRenderable, Renderable

A frame that can scroll its contents. The frame can be interactively resized by dragging the border, and be moved by dragging the frame or title bar. The frame can be minimized. The frame displays scroll bars if the size of the content exceeds the size of the frame, and optionally displays a title bar with a text string and an icon.

The frame renders its contents into a texture, and then draws the texture when the frame is rendered. This provides good performance for content that is expensive to draw, and changes infrequently. If the frame is sized so large that the visible portion of the contents cannot be rendered into a single texture, then the contents will be drawn directly when the frame is rendered.


Field Summary
protected  FrameAttributes activeAttributes
          Active attributes, either normal or highlight.
protected  Size activeSize
          The size of the active frame, minimized or maximized.
protected  Animation animation
          The active animation that is currently playing.
protected  int animationDelay
          Delay in milliseconds between frames of an animation.
protected  Point2D awtScreenPoint
          Indicates the location of the upper left corner of the frame, in AWT coordinates (origin at the upper left corner of the screen.
protected  OGLStackHandler BEogsh
          Support for setting up and restoring OpenGL state during rendering.
protected  int borderPickWidth
          Width of the pickable frame border.
protected  int buttonSize
          The size, in pixels, of the frame's minimize button.
protected  Rectangle contentBounds
          Bounds of the content part of the frame.
protected  Scrollable contents
          The contents of the frame.
protected  Dimension contentSize
          Total size of the frame content.
protected static int DEFAULT_ANIMATION_DELAY
          Default delay (in milliseconds) between frame when the frame is animating.
protected static int DEFAULT_BUTTON_SIZE
          Default size of the minimize button.
protected static int DEFAULT_FRAME_BORDER_PICK_WIDTH
          Default width of the pickable frame border.
protected static int DEFAULT_FRAME_BORDER_WIDTH
          Default width of the frame border.
protected static int DEFAULT_LINE_WIDTH
          Default width of lines used to draw the frame.
protected static Size DEFAULT_MAXIMIZED_SIZE
          Default size of the maximized frame.
protected static int DEFAULT_SCROLL_BAR_SIZE
          Default width of the scroll bars.
protected static int DEFAULT_TEXTURE_TILE_DIMENSION
          Default dimension of tiles in the backing texture.
protected static int DEFAULT_TITLE_BAR_HEIGHT
          Default height of the frame title bar.
protected static FrameAttributes defaultAttributes
          The attributes used if attributes are not specified.
protected  boolean drawTitleBar
          Indicates whether or not to draw a title bar in the frame.
protected  boolean enableMove
          Indicates whether or not the user can move the frame by dragging with the mouse.
protected  boolean enableResize
          Indicates whether or not the user can resize the frame by dragging the edge.
protected  int frameBorder
          The width of the frame border.
protected  Rectangle frameBounds
          Bounds of the full frame.
protected  int frameLineWidth
          The width of lines used to draw the frame.
protected  long frameNumber
           
protected  FrameResizeControl frameResizeControl
          Control to handle resizing the frame.
protected  Dimension frameSize
          Size of the frame.
protected  String frameTitle
          The full frame title.
protected  int frameTitleWidth
          Width of the frame title area.
protected  FrameAttributes highlightAttributes
          Attributes to use when the frame is highlighted.
protected  boolean highlighted
          Indicates whether or not the frame is highlighted.
protected  ScrollBar horizontalScrollBar
          Scroll bar to control horizontal scrolling.
protected  Object iconImageSource
          Image source for the icon drawn in the upper left corner of the frame.
protected  Rectangle innerBounds
          Bounds of the frame inside the frame border.
protected  Size maximizedSize
          The size of the maximized frame.
protected  Size maxSize
          The maximum size of the frame.
protected  Animation minimizeAnimation
          An animation to play when the frame is minimized or maximized.
protected  HotSpot minimizeButton
          HotSpot to handle user input on the minimize button.
protected  boolean minimized
          Indicates whether or not the frame is minimized.
protected  Size minimizedSize
          The size of the minimized frame.
protected  boolean mustRecomputeFrameGeometry
          Indicates that the frame must be regenerated because the size or attributes have changed.
protected  FrameAttributes normalAttributes
          Attributes to use when the frame is not highlighted.
protected  Rectangle pickBounds
          Bounds of the pickable area.
protected  PickSupport pickSupport
          Support for setting up and restoring picking state, and resolving the picked object.
protected  boolean renderToTexture
          Indicates whether the contents should be rendered into a texture and cached, or rendered directly.
protected  OGLRenderToTextureSupport rttSupport
          Support class used to render to an offscreen texture.
protected  Offset screenLocation
          Indicates the location of the upper left corner of the frame.
protected  int scrollBarSize
          The width of the frame scroll bar.
protected  Rectangle scrollContentBounds
           
protected  Font shortFrameTitleFont
          Font used to generate shortTitle.
protected  String shortTitle
          Frame title that is actually drawn in the title bar.
protected  Rectangle2D shortTitleBounds
          Text bounds of the shortTitle.
protected  boolean showHorizontalScrollbar
          Indicates whether or not the horizontal scroll bar must be drawn.
protected  boolean showVerticalScrollbar
          Indicates whether or not the vertical scroll bar must be drawn.
protected  BasicWWTexture texture
          Texture for the icon displayed in the frame title bar.
protected  Object textureCacheKey
          Cache key used to locate the rendering texture in the DrawContext's texture cache.
protected  int textureDimension
          Dimension of the texture used to render the scrollable content.
protected  int textureTileDimension
          Dimension of a sub-tile in the rendering texture.
protected  Map<gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile,gov.nasa.worldwind.util.tree.ScrollFrame.TextureTile> textureTileMap
          Map that associates logical tiles in the scrollable content with allocated tiles in the texture used to render the content.
protected  List<gov.nasa.worldwind.util.tree.ScrollFrame.TextureTile> textureTiles
          List to manage sub-tiles of the rendering texture.
protected  List<gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile> tiles
           
protected  int titleBarHeight
          The height, in pixels, of the frame title bar.
protected  DoubleBuffer vertexBuffer
          The frame geometry vertices passed to OpenGL.
protected  ScrollBar verticalScrollBar
          Scroll bar to control vertical scrolling.
 
Fields inherited from class gov.nasa.worldwind.util.tree.DragControl
dragging, dragRefPoint
 
Fields inherited from class gov.nasa.worldwind.util.tree.TreeHotSpot
parent
 
Fields inherited from class gov.nasa.worldwind.util.AbstractHotSpot
active
 
Constructor Summary
ScrollFrame()
          Create a new scroll frame.
ScrollFrame(int x, int y)
          Create a scroll frame with a position.
ScrollFrame(Offset screenLocation)
          Create a scroll positioned with an Offset.
 
Method Summary
protected  gov.nasa.worldwind.util.tree.ScrollFrame.TextureTile allocateTextureTile(gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile tile)
          Allocate a texture tile for a ContentTile.
protected  void assembleTiles(int rows, int columns)
          Build the list of ContentTile that represents the logical tiles in the frame contents.
protected  void beginDrag(Point point)
          Called when a drag begins.
protected  void beginDrawing(DrawContext dc)
           
protected  Rectangle computeBounds(boolean showVerticalScrollBar, boolean showHorizontalScrollBar)
          Compute the content bounds, taking into account the frame size and the presence of scroll bars.
protected  void computeFrameGeometry()
          Updates the frame's screen-coordinate geometry in vertexBuffer according to the current screen bounds.
protected  Dimension computeFrameRectForContentRect(Dimension contentSize)
          Compute the size of the frame rectangle required to accommodate a given content size without displaying scroll bars.
protected  int computeTileTextureDimension(Dimension frameSize, Dimension contentSize)
          Compute the dimension of a texture large enough to represent the amount of the contents visible in the frame.
protected  Texture createTileTexture(DrawContext dc, int width, int height)
          Returns a new tile texture with the specified width and height.
protected  void determineActiveAttributes()
          Determines which attributes -- normal, highlight or default -- to use each frame.
protected  void determineScrollbarAttributes()
          Update the attributes of the scroll bars to match the frame's highlight state.
protected  void determineSize()
          Determine the frame size to use for the current frame.
protected  void doScroll(MouseWheelEvent e)
          Handle a mouse wheel event.
protected  void doScrollMacOS(MouseWheelEvent e)
          Handle a mouse wheel event on Mac OS X.
 void drag(Point point)
          Called for each point within a drag action.
protected  void drawContentDirect(DrawContext dc)
          Draw the frame contents directly (not using previously generated tiles).
protected  void drawContentTiles(DrawContext dc)
          Draw the frame contents using previously build texture tiles.
protected  void drawFrame(DrawContext dc)
          Draw the frame, scroll bars, and title bar.
protected  void drawIcon(DrawContext dc, Point drawPoint)
          Draw an icon in the upper left corner of the title bar.
protected  void drawMaximized(DrawContext dc)
          Draw the frame in its maximized state.
protected  void drawMinimizeButton(DrawContext dc)
          Draw the minimize/maximize button in the frame title bar.
protected  void drawMinimized(DrawContext dc)
          Draw the frame in its minimized state.
protected  void drawScrollBars(DrawContext dc)
          Draw visible scroll bars for the frame.
protected  void drawTitleBar(DrawContext dc)
          Draw the title bar.
protected  void drawTitleText(DrawContext dc, Point drawPoint)
          Draw text in the frame title.
protected  void endDrawing(DrawContext dc)
           
protected  void forceTileUpdate()
          Force all tiles to update on the next frame.
protected  void generateShortTitle(DrawContext dc, String frameTitle, int width, String cutOff)
          Generate a shortened version of the frame title that will fit in the frame title area.
protected  FrameAttributes getActiveAttributes()
          Get the currently active frame attributes.
protected  Size getActiveSize()
          Indicates the size that applies to the frame for this frame, either the maximumed or the minimized size.
 FrameAttributes getAttributes()
          Indicates the frame attributes used to draw the frame when it is not highlighted.
 Rectangle getBounds(DrawContext dc)
          Get the bounds of the tree frame.
 Scrollable getContents()
          Indicates the frame contents.
protected  Rectangle getContentTileBounds(int row, int column)
          Get the bounds of a tile in the frame content.
 Dimension getCurrentSize()
          Return the amount of screen that space that the frame is currently using.
 String getFrameTitle()
          Get the title of the tree frame.
 FrameAttributes getHighlightAttributes()
          Indicates the frame attributes used to draw the frame when it is highlighted.
 Object getIconImageSource()
          Get the image source for the frame icon.
 Size getMaxSize()
          Indicates the maximum size of frame.
 Animation getMinimizeAnimation()
          Get the animation that is played when the tree frame is minimized.
 Size getMinimizedSize()
          Indicates the size of the minimized tree frame.
protected  Dimension getMinimumSize()
          Get the smallest dimension that the frame can draw itself.
protected  int getMouseWheelScrollUnit(String direction)
          Get the scroll unit that the mouse wheel scrolls by.
 Offset getScreenLocation()
          Get the location of the upper left corner of the tree, measured in screen coordinates with the origin at the upper left corner of the screen.
protected  Point2D getScreenPoint()
          Get the location of the upper left corner of the frame, measured from the upper left corner of the screen.
 ScrollBar getScrollBar(String direction)
          Get a reference to one of the frame's scroll bars.
 Size getSize()
          Get the size of tree frame.
protected  BasicWWTexture getTexture()
          Get the texture loaded for the icon image source.
protected  gov.nasa.worldwind.util.tree.ScrollFrame.TextureTile getTextureTile(gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile tile)
          Get the texture tile allocated for a ContentTile in the frame content.
 int getTitleBarHeight()
          Indicates the height, in pixels, of the frame title bar.
protected  BasicWWTexture initializeTexture()
          Create and initialize the texture from the image source.
protected  void initializeUIControls()
          Initialize controls to resizing the frame, minimizing the frame, etc.
protected  boolean intersectsFrustum(DrawContext dc)
          Determines whether the frame intersects the view frustum.
protected  boolean isAnimating()
          Determines if the frame is currently animating.
protected  boolean isDrawMinimized()
          Determines if the frame should draw in its minimized form.
 boolean isDrawTitleBar()
          Does the frame have a title bar?
 boolean isEnableMove()
          Specifies whether the user can move the frame by dragging the title bar.
 boolean isEnableResizeControl()
          Indicates whether or not the user can resize the frame by dragging the frame border.
 boolean isHighlighted()
          Indicates whether or not the frame is highlighted.
 boolean isMinimized()
          Indicates if the frame is minimized.
protected  boolean isRelativeSize(Size size)
          Determines if the frame size is relative to the size of the scrollable content (as opposed to an absolute pixel value, or a fraction of the viewport).
 void mouseWheelMoved(MouseWheelEvent e)
          Forwards the event to the parent HotSpot if the parent is non-null.
protected  boolean mustGenerateShortTitle(Font titleFont, int titleAreaWidth)
          Determine if a the shortened frame title needs to be regenerated.
protected  boolean mustShowHorizontalScrollbar(Dimension contentSize)
          Determine if the horizontal scrollbar should be displayed.
protected  boolean mustShowVerticalScrollbar(Dimension contentSize)
          Determine if the vertical scrollbar should be displayed.
protected  boolean mustUpdateTile(gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile tile, long contentUpdateTime)
          Determine if a tile in the content layout needs to be updated.
protected  boolean mustUpdateTiles(DrawContext dc)
          Indicates whether or not any of the the rendered tiles must be updated.
 void preRender(DrawContext dc)
          
 void render(DrawContext dc)
          Causes this Renderable to render itself using the provided draw context.
 void selected(SelectEvent event)
          Handle a SelectEvent and call DragControl.beginDrag(java.awt.Point), DragControl.drag(java.awt.Point), DragControl.endDrag() as appropriate.
 void setAttributes(FrameAttributes attributes)
          Specifies the frame attributes used to draw the frame when it is not highlighted.
 void setContents(Scrollable contents)
          Specifies the frame contents.
 void setDrawTitleBar(boolean drawTitleBar)
          Set whether the frame has a title bar.
 void setEnableMove(boolean enable)
          Specifies whether the user can move the frame by dragging the title bar.
 void setEnableResizeControl(boolean enable)
          Specifies whether the user can resize the frame by dragging the border.
 void setFrameTitle(String frameTitle)
          Set the title of the tree frame.
 void setHighlightAttributes(FrameAttributes attributes)
          Specifies the frame attributes used to draw the frame when it is highlighted.
 void setHighlighted(boolean highlighted)
          Sets the frame its highlighted or not highlighted state.
 void setIconImageSource(Object imageSource)
          Set the image source of the frame icon.
 void setMaxSize(Size size)
          Specifies the maximum size of the frame.
 void setMinimizeAnimation(Animation minimizeAnimation)
          Set the animation that is played when the tree frame is minimized.
 void setMinimized(boolean minimized)
          Sets the frame to its minimized or maximized state.
 void setMinimizedSize(Size size)
          Specifies the size of the minimized tree frame.
 void setScreenLocation(Offset screenLocation)
          Set the location of the upper left corner of the tree, measured in screen coordinates with the origin at the upper left corner of the screen.
 void setSize(Size size)
          Set the size of the frame.
 void setTitleBarHeight(int titleBarHeight)
          Specifies the height, in pixels, of the frame title bar.
protected  void stepAnimation(DrawContext dc)
          Increment the active animation.
 void updateBounds(DrawContext dc)
          Compute the bounds of the content frame, and the extents of the scroll range.
protected  void updateTile(DrawContext dc, gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile tile, Rectangle tileBounds)
          Draws the current list of ScrollableTiles into the texture tiles.
protected  void updateTiles(DrawContext dc)
          Update content tiles that have been rendered to a texture.
 
Methods inherited from class gov.nasa.worldwind.util.tree.DragControl
endDrag, isDragging
 
Methods inherited from class gov.nasa.worldwind.util.tree.TreeHotSpot
mouseClicked, mousePressed, mouseReleased
 
Methods inherited from class gov.nasa.worldwind.util.AbstractHotSpot
getCursor, isActive, isConsumed, keyPressed, keyReleased, keyTyped, mouseDragged, mouseEntered, mouseExited, mouseMoved, setActive
 
Methods inherited from class gov.nasa.worldwind.avlist.AVListImpl
addPropertyChangeListener, addPropertyChangeListener, clearList, copy, firePropertyChange, firePropertyChange, getBooleanValue, getBooleanValue, getChangeSupport, getDoubleValue, getDoubleValue, getEntries, getIntegerValue, getIntegerValue, getLongValue, getLongValue, getRestorableStateForAVPair, getStringValue, getStringValue, getStringValue, getValue, getValues, hasKey, removeKey, removePropertyChangeListener, removePropertyChangeListener, setValue, setValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activeAttributes

protected FrameAttributes activeAttributes
Active attributes, either normal or highlight.


activeSize

protected Size activeSize
The size of the active frame, minimized or maximized.


animation

protected Animation animation
The active animation that is currently playing.


animationDelay

protected int animationDelay
Delay in milliseconds between frames of an animation.


awtScreenPoint

protected Point2D awtScreenPoint
Indicates the location of the upper left corner of the frame, in AWT coordinates (origin at the upper left corner of the screen.


BEogsh

protected OGLStackHandler BEogsh
Support for setting up and restoring OpenGL state during rendering.


borderPickWidth

protected int borderPickWidth
Width of the pickable frame border.


buttonSize

protected int buttonSize
The size, in pixels, of the frame's minimize button.


contentBounds

protected Rectangle contentBounds
Bounds of the content part of the frame.


contents

protected Scrollable contents
The contents of the frame.


contentSize

protected Dimension contentSize
Total size of the frame content. This size may exceed the size of the frame, in which case scroll bars will be displayed.


DEFAULT_ANIMATION_DELAY

protected static final int DEFAULT_ANIMATION_DELAY
Default delay (in milliseconds) between frame when the frame is animating.

See Also:
Constant Field Values

DEFAULT_BUTTON_SIZE

protected static final int DEFAULT_BUTTON_SIZE
Default size of the minimize button.

See Also:
Constant Field Values

DEFAULT_FRAME_BORDER_PICK_WIDTH

protected static final int DEFAULT_FRAME_BORDER_PICK_WIDTH
Default width of the pickable frame border.

See Also:
Constant Field Values

DEFAULT_FRAME_BORDER_WIDTH

protected static final int DEFAULT_FRAME_BORDER_WIDTH
Default width of the frame border.

See Also:
Constant Field Values

DEFAULT_LINE_WIDTH

protected static final int DEFAULT_LINE_WIDTH
Default width of lines used to draw the frame.

See Also:
Constant Field Values

DEFAULT_MAXIMIZED_SIZE

protected static final Size DEFAULT_MAXIMIZED_SIZE
Default size of the maximized frame.


DEFAULT_SCROLL_BAR_SIZE

protected static final int DEFAULT_SCROLL_BAR_SIZE
Default width of the scroll bars.

See Also:
Constant Field Values

DEFAULT_TEXTURE_TILE_DIMENSION

protected static final int DEFAULT_TEXTURE_TILE_DIMENSION
Default dimension of tiles in the backing texture.

See Also:
Constant Field Values

DEFAULT_TITLE_BAR_HEIGHT

protected static final int DEFAULT_TITLE_BAR_HEIGHT
Default height of the frame title bar.

See Also:
Constant Field Values

defaultAttributes

protected static final FrameAttributes defaultAttributes
The attributes used if attributes are not specified.


drawTitleBar

protected boolean drawTitleBar
Indicates whether or not to draw a title bar in the frame. Default is true.


enableMove

protected boolean enableMove
Indicates whether or not the user can move the frame by dragging with the mouse. Default is true.


enableResize

protected boolean enableResize
Indicates whether or not the user can resize the frame by dragging the edge. Default is true.


frameBorder

protected int frameBorder
The width of the frame border.


frameBounds

protected Rectangle frameBounds
Bounds of the full frame.


frameLineWidth

protected int frameLineWidth
The width of lines used to draw the frame.


frameNumber

protected long frameNumber

frameResizeControl

protected FrameResizeControl frameResizeControl
Control to handle resizing the frame.


frameSize

protected Dimension frameSize
Size of the frame.


frameTitle

protected String frameTitle
The full frame title. This title may be displayed in a truncated form if the frame is too small to accommodate the full title.


frameTitleWidth

protected int frameTitleWidth
Width of the frame title area.


highlightAttributes

protected FrameAttributes highlightAttributes
Attributes to use when the frame is highlighted.


highlighted

protected boolean highlighted
Indicates whether or not the frame is highlighted.


horizontalScrollBar

protected ScrollBar horizontalScrollBar
Scroll bar to control horizontal scrolling.


iconImageSource

protected Object iconImageSource
Image source for the icon drawn in the upper left corner of the frame.


innerBounds

protected Rectangle innerBounds
Bounds of the frame inside the frame border.


maximizedSize

protected Size maximizedSize
The size of the maximized frame.


maxSize

protected Size maxSize
The maximum size of the frame. This is a constraint applied to the frame's size.


minimizeAnimation

protected Animation minimizeAnimation
An animation to play when the frame is minimized or maximized.


minimizeButton

protected HotSpot minimizeButton
HotSpot to handle user input on the minimize button.


minimized

protected boolean minimized
Indicates whether or not the frame is minimized.


minimizedSize

protected Size minimizedSize
The size of the minimized frame.


mustRecomputeFrameGeometry

protected boolean mustRecomputeFrameGeometry
Indicates that the frame must be regenerated because the size or attributes have changed.


normalAttributes

protected FrameAttributes normalAttributes
Attributes to use when the frame is not highlighted.


pickBounds

protected Rectangle pickBounds
Bounds of the pickable area.


pickSupport

protected PickSupport pickSupport
Support for setting up and restoring picking state, and resolving the picked object.


renderToTexture

protected boolean renderToTexture
Indicates whether the contents should be rendered into a texture and cached, or rendered directly. The frame renders into a texture if the frame size can be accommodated by a single texture. If the size is too large to render using a single texture, the contents are drawn directly.


rttSupport

protected OGLRenderToTextureSupport rttSupport
Support class used to render to an offscreen texture.


screenLocation

protected Offset screenLocation
Indicates the location of the upper left corner of the frame.


scrollBarSize

protected int scrollBarSize
The width of the frame scroll bar.


scrollContentBounds

protected Rectangle scrollContentBounds

shortFrameTitleFont

protected Font shortFrameTitleFont
Font used to generate shortTitle.


shortTitle

protected String shortTitle
Frame title that is actually drawn in the title bar. If the frame is too narrow to display the entire title, the title will be truncated. This title must be regenerated if the frame size or the title font change.


shortTitleBounds

protected Rectangle2D shortTitleBounds
Text bounds of the shortTitle.


showHorizontalScrollbar

protected boolean showHorizontalScrollbar
Indicates whether or not the horizontal scroll bar must be drawn.


showVerticalScrollbar

protected boolean showVerticalScrollbar
Indicates whether or not the vertical scroll bar must be drawn.


texture

protected BasicWWTexture texture
Texture for the icon displayed in the frame title bar. Loaded from iconImageSource.


textureCacheKey

protected final Object textureCacheKey
Cache key used to locate the rendering texture in the DrawContext's texture cache.


textureDimension

protected int textureDimension
Dimension of the texture used to render the scrollable content. Must be a power of two.


textureTileDimension

protected int textureTileDimension
Dimension of a sub-tile in the rendering texture. Also the dimension of logical tiles in the scrollable content that are rendered into the texture tiles.


textureTileMap

protected Map<gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile,gov.nasa.worldwind.util.tree.ScrollFrame.TextureTile> textureTileMap
Map that associates logical tiles in the scrollable content with allocated tiles in the texture used to render the content.


textureTiles

protected List<gov.nasa.worldwind.util.tree.ScrollFrame.TextureTile> textureTiles
List to manage sub-tiles of the rendering texture.


tiles

protected List<gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile> tiles

titleBarHeight

protected int titleBarHeight
The height, in pixels, of the frame title bar.


vertexBuffer

protected DoubleBuffer vertexBuffer
The frame geometry vertices passed to OpenGL.


verticalScrollBar

protected ScrollBar verticalScrollBar
Scroll bar to control vertical scrolling.

Constructor Detail

ScrollFrame

public ScrollFrame()
Create a new scroll frame.


ScrollFrame

public ScrollFrame(int x,
                   int y)
Create a scroll frame with a position.

Parameters:
x - x coordinate of the upper left corner of the frame, in AWT screen coordinates (origin upper left corner of the screen).
y - y coordinate of the upper left corner of the frame, in AWT screen coordinates (origin upper left corner of the screen).

ScrollFrame

public ScrollFrame(Offset screenLocation)
Create a scroll positioned with an Offset.

Parameters:
screenLocation - initial location of the upper left corner of the frame.
Method Detail

allocateTextureTile

protected gov.nasa.worldwind.util.tree.ScrollFrame.TextureTile allocateTextureTile(gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile tile)
Allocate a texture tile for a ContentTile. There are a limited number of texture tiles. If no tiles are free, the least recently used texture tile will be reallocated.

Parameters:
tile - ScrollableTile for which to allocate a texture tile.
Returns:
TextureTile allocated for the ScrollableTile.

assembleTiles

protected void assembleTiles(int rows,
                             int columns)
Build the list of ContentTile that represents the logical tiles in the frame contents.

Parameters:
rows - Number of rows of tiles in the contents.
columns - Number of columns of tiles.

beginDrag

protected void beginDrag(Point point)
Description copied from class: DragControl
Called when a drag begins. This implementation saves the first drag point to DragControl.dragRefPoint.

Overrides:
beginDrag in class DragControl
Parameters:
point - Point at which dragging started.

beginDrawing

protected void beginDrawing(DrawContext dc)

computeBounds

protected Rectangle computeBounds(boolean showVerticalScrollBar,
                                  boolean showHorizontalScrollBar)
Compute the content bounds, taking into account the frame size and the presence of scroll bars.

Parameters:
showVerticalScrollBar - True if the frame will have a vertical scroll bar. A vertical scroll bar will make the content frame narrower.
showHorizontalScrollBar - True if the frame will have a horizontal scroll bar. A horizontal scroll bar will make the content frame shorter.
Returns:
The bounds of the content frame.

computeFrameGeometry

protected void computeFrameGeometry()
Updates the frame's screen-coordinate geometry in vertexBuffer according to the current screen bounds.


computeFrameRectForContentRect

protected Dimension computeFrameRectForContentRect(Dimension contentSize)
Compute the size of the frame rectangle required to accommodate a given content size without displaying scroll bars.

Parameters:
contentSize - Size of the frame content.
Returns:
Frame size required to display the content without scrollbars.

computeTileTextureDimension

protected int computeTileTextureDimension(Dimension frameSize,
                                          Dimension contentSize)
Compute the dimension of a texture large enough to represent the amount of the contents visible in the frame.

Parameters:
frameSize - Size of the frame content area.
contentSize - Size of the frame content.
Returns:
Dimension of a texture large enough to render the full frame content area. This method always returns a power of two dimension.

createTileTexture

protected Texture createTileTexture(DrawContext dc,
                                    int width,
                                    int height)
Returns a new tile texture with the specified width and height.

The returned texture's internal format is RGBA8.

Parameters:
width - the texture's width, in pixels.
height - the texture's height, in pixels.
Returns:
a new texture with the specified width and height.

determineActiveAttributes

protected void determineActiveAttributes()
Determines which attributes -- normal, highlight or default -- to use each frame.


determineScrollbarAttributes

protected void determineScrollbarAttributes()
Update the attributes of the scroll bars to match the frame's highlight state.


determineSize

protected void determineSize()
Determine the frame size to use for the current frame.


doScroll

protected void doScroll(MouseWheelEvent e)
Handle a mouse wheel event.

Parameters:
e - Mouse event that triggered the scroll.

doScrollMacOS

protected void doScrollMacOS(MouseWheelEvent e)
Handle a mouse wheel event on Mac OS X. This method correctly handles the Magic Mouse and Magic Trackpad devices, which support horizontal scrolling.

Parameters:
e - Mouse event that triggered the scroll.

drag

public void drag(Point point)
Description copied from class: DragControl
Called for each point within a drag action.

Specified by:
drag in class DragControl
Parameters:
point - Current drag point.

drawContentDirect

protected void drawContentDirect(DrawContext dc)
Draw the frame contents directly (not using previously generated tiles).

Parameters:
dc - Current draw context.

drawContentTiles

protected void drawContentTiles(DrawContext dc)
Draw the frame contents using previously build texture tiles.

Parameters:
dc - Current draw context.

drawFrame

protected void drawFrame(DrawContext dc)
Draw the frame, scroll bars, and title bar.

Parameters:
dc - Current draw context.

drawIcon

protected void drawIcon(DrawContext dc,
                        Point drawPoint)
Draw an icon in the upper left corner of the title bar. This method takes a point relative to lower left corner of the title bar. This point is modified to indicate how much horizontal space is consumed by the icon.

Parameters:
dc - Draw context
drawPoint - Point at which to draw the icon. This point is relative to the lower left corner of the title bar. This point will be modified to indicate how much horizontal space was consumed by drawing the icon. After drawing the icon, the x value with point to the first available space to the right of the icon.

drawMaximized

protected void drawMaximized(DrawContext dc)
Draw the frame in its maximized state.

Parameters:
dc - Current draw context.

drawMinimizeButton

protected void drawMinimizeButton(DrawContext dc)
Draw the minimize/maximize button in the frame title bar.

Parameters:
dc - Current draw context.

drawMinimized

protected void drawMinimized(DrawContext dc)
Draw the frame in its minimized state.

Parameters:
dc - Current draw context.

drawScrollBars

protected void drawScrollBars(DrawContext dc)
Draw visible scroll bars for the frame. Scroll bars that are not visible will not be drawn.

Parameters:
dc - Current draw context.

drawTitleBar

protected void drawTitleBar(DrawContext dc)
Draw the title bar.

Parameters:
dc - Draw context

drawTitleText

protected void drawTitleText(DrawContext dc,
                             Point drawPoint)
Draw text in the frame title.

Parameters:
dc - Draw context
drawPoint - Point at which to draw text. This point is relative to the lower left corner of the title bar.

endDrawing

protected void endDrawing(DrawContext dc)

forceTileUpdate

protected void forceTileUpdate()
Force all tiles to update on the next frame.


generateShortTitle

protected void generateShortTitle(DrawContext dc,
                                  String frameTitle,
                                  int width,
                                  String cutOff)
Generate a shortened version of the frame title that will fit in the frame title area. If the frame is wide enough to accommodate the full title, then the short title will be the same as the full title. The method sets the fields shortTitle, shortFrameTitleFont, frameTitleWidth.

Parameters:
dc - Current draw context.
frameTitle - Full frame title.
width - Width in pixels of the frame title area.
cutOff - String to append to title to indicate that text has been cut off due to a small frame. For example, if the cut off string is "...", the string "Frame Title" might be shortened to "Frame T...".

getActiveAttributes

protected FrameAttributes getActiveAttributes()
Get the currently active frame attributes.

Returns:
attributes that are active for this frame.

getActiveSize

protected Size getActiveSize()
Indicates the size that applies to the frame for this frame, either the maximumed or the minimized size.

Returns:
the frame size for the duration of this frame.

getAttributes

public FrameAttributes getAttributes()
Indicates the frame attributes used to draw the frame when it is not highlighted.

Returns:
normal frame attributes.

getBounds

public Rectangle getBounds(DrawContext dc)
Get the bounds of the tree frame.

Parameters:
dc - Draw context
Returns:
The bounds of the tree frame on screen, in screen coordinates (origin at upper left).

getContents

public Scrollable getContents()
Indicates the frame contents.

Returns:
the contents of the frame.

getContentTileBounds

protected Rectangle getContentTileBounds(int row,
                                         int column)
Get the bounds of a tile in the frame content.

Parameters:
row - Row of the tile to get the bounds of.
column - Column of the tile to get the bounds of.
Returns:
Bounds of the desired tile, relative to the lower left corner of {#link contentBounds}.

getCurrentSize

public Dimension getCurrentSize()
Return the amount of screen that space that the frame is currently using. The frame size may change due to a window resize, or an animation.

Returns:
The size of the frame on screen, in pixels. This method will return null until the frame has been rendered at least once.

getFrameTitle

public String getFrameTitle()
Get the title of the tree frame.

Returns:
The frame title.
See Also:
setFrameTitle(String)

getHighlightAttributes

public FrameAttributes getHighlightAttributes()
Indicates the frame attributes used to draw the frame when it is highlighted.

Returns:
highlight frame attributes.

getIconImageSource

public Object getIconImageSource()
Get the image source for the frame icon.

Returns:
The icon image source, or null if no image source has been set.
See Also:
setIconImageSource(Object)

getMaxSize

public Size getMaxSize()
Indicates the maximum size of frame. This size is applied as a constraint to the tree's normal size (indicated by getSize()).

Returns:
the maximum size of the frame. null indicates no maximum.

getMinimizeAnimation

public Animation getMinimizeAnimation()
Get the animation that is played when the tree frame is minimized.

Returns:
Animation played when the frame is minimized.
See Also:
setMinimizeAnimation(Animation)

getMinimizedSize

public Size getMinimizedSize()
Indicates the size of the minimized tree frame. This size is used when the tree is minimized or animating.

Returns:
the size of the minimized frame. null indicates that there is no minimized size, in which case the normal maximized frame size is used in the minimized state.

getMinimumSize

protected Dimension getMinimumSize()
Get the smallest dimension that the frame can draw itself. This user is not allowed to resize the frame to be smaller than this dimension.

Returns:
The frame's minimum size.

getMouseWheelScrollUnit

protected int getMouseWheelScrollUnit(String direction)
Get the scroll unit that the mouse wheel scrolls by.

Parameters:
direction - Direction of scroll.
Returns:
The scroll unit that will be applied when the mouse wheel is moved.

getScreenLocation

public Offset getScreenLocation()
Get the location of the upper left corner of the tree, measured in screen coordinates with the origin at the upper left corner of the screen.

Returns:
Screen location, measured in pixels from the upper left corner of the screen.

getScreenPoint

protected Point2D getScreenPoint()
Get the location of the upper left corner of the frame, measured from the upper left corner of the screen.

Returns:
The location of the upper left corner of the frame. This method will return null until the has been rendered.

getScrollBar

public ScrollBar getScrollBar(String direction)
Get a reference to one of the frame's scroll bars.

Parameters:
direction - Determines which scroll bar to get. Either AVKey.VERTICAL or AVKey.HORIZONTAL.
Returns:
The horizontal or vertical scroll bar.

getSize

public Size getSize()
Get the size of tree frame. The size determines the size of the frame when the frame is maximized.

Returns:
the size of the tree frame.
See Also:
getMinimizedSize()

getTexture

protected BasicWWTexture getTexture()
Get the texture loaded for the icon image source. If the texture has not been loaded, this method will attempt to load it in the background.

Returns:
The icon texture, or no image source has been set, or if the icon has not been loaded yet.

getTextureTile

protected gov.nasa.worldwind.util.tree.ScrollFrame.TextureTile getTextureTile(gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile tile)
Get the texture tile allocated for a ContentTile in the frame content.

Parameters:
tile - ContentTile for which to get a texture tile.
Returns:
TextureTile allocated for the given ContentTile, or null if no TextureTile has been allocated.

getTitleBarHeight

public int getTitleBarHeight()
Indicates the height, in pixels, of the frame title bar.

Returns:
height of the title bar.
See Also:
isDrawTitleBar()

initializeTexture

protected BasicWWTexture initializeTexture()
Create and initialize the texture from the image source. If the image is not in memory this method will request that it be loaded and return null.

Returns:
The texture, or null if the texture is not yet available.

initializeUIControls

protected void initializeUIControls()
Initialize controls to resizing the frame, minimizing the frame, etc.


intersectsFrustum

protected boolean intersectsFrustum(DrawContext dc)
Determines whether the frame intersects the view frustum.

Parameters:
dc - the current draw context.
Returns:
true If the frame intersects the frustum, otherwise false.

isAnimating

protected boolean isAnimating()
Determines if the frame is currently animating.

Returns:
true if an animation is in progress, otherwise false.

isDrawMinimized

protected boolean isDrawMinimized()
Determines if the frame should draw in its minimized form.

Returns:
true if the frame should draw minimized, otherwise false.

isDrawTitleBar

public boolean isDrawTitleBar()
Does the frame have a title bar?

Returns:
True if the frame will draw a title bar.

isEnableMove

public boolean isEnableMove()
Specifies whether the user can move the frame by dragging the title bar.

Returns:
true if the user can allowed to move the frame by dragging the title bar.

isEnableResizeControl

public boolean isEnableResizeControl()
Indicates whether or not the user can resize the frame by dragging the frame border.

Returns:
true if the user can resize the frame by dragging.

isHighlighted

public boolean isHighlighted()
Indicates whether or not the frame is highlighted.

Returns:
true if the frame is highlighted, otherwise false.

isMinimized

public boolean isMinimized()
Indicates if the frame is minimized. If the frame is not minimized, it is either maximized or animating toward a maximized state.

Returns:
true if the frame is minimized.

isRelativeSize

protected boolean isRelativeSize(Size size)
Determines if the frame size is relative to the size of the scrollable content (as opposed to an absolute pixel value, or a fraction of the viewport).

Parameters:
size - Size to test.
Returns:
true if the absolute size of size depends on the size of the frame content.

mouseWheelMoved

public void mouseWheelMoved(MouseWheelEvent e)
Description copied from class: TreeHotSpot
Forwards the event to the parent HotSpot if the parent is non-null. Otherwise does nothing. Override this method to handle mouse wheel events.

Specified by:
mouseWheelMoved in interface HotSpot
Specified by:
mouseWheelMoved in interface MouseWheelListener
Overrides:
mouseWheelMoved in class TreeHotSpot
Parameters:
e - The event to handle.

mustGenerateShortTitle

protected boolean mustGenerateShortTitle(Font titleFont,
                                         int titleAreaWidth)
Determine if a the shortened frame title needs to be regenerated.

Parameters:
titleFont - Title font.
titleAreaWidth - Width in pixels of the frame title area.
Returns:
true if the shortened title needs to be regenerated, otherwise false.

mustShowHorizontalScrollbar

protected boolean mustShowHorizontalScrollbar(Dimension contentSize)
Determine if the horizontal scrollbar should be displayed.

Parameters:
contentSize - The total size, in pixels, of the scrollable content.
Returns:
true if the horizontal scrollbar should be displayed, otherwise false.

mustShowVerticalScrollbar

protected boolean mustShowVerticalScrollbar(Dimension contentSize)
Determine if the vertical scrollbar should be displayed.

Parameters:
contentSize - The total size, in pixels, of the scrollable content.
Returns:
true if the vertical scrollbar should be displayed, otherwise false.

mustUpdateTile

protected boolean mustUpdateTile(gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile tile,
                                 long contentUpdateTime)
Determine if a tile in the content layout needs to be updated.

Parameters:
tile - Tile to test.
contentUpdateTime - Time at which the content was last updated.
Returns:
true if the tile needs to be updated. Always returns false if the tile is not visible in the current frame bounds.

mustUpdateTiles

protected boolean mustUpdateTiles(DrawContext dc)
Indicates whether or not any of the the rendered tiles must be updated.

Parameters:
dc - Current draw context.
Returns:
true if any of the tiles need to be updated.

preRender

public void preRender(DrawContext dc)

Specified by:
preRender in interface PreRenderable

render

public void render(DrawContext dc)
Causes this Renderable to render itself using the provided draw context.

Specified by:
render in interface Renderable
Parameters:
dc - the DrawContext to be used
See Also:
DrawContext

selected

public void selected(SelectEvent event)
Description copied from class: DragControl
Handle a SelectEvent and call DragControl.beginDrag(java.awt.Point), DragControl.drag(java.awt.Point), DragControl.endDrag() as appropriate. Subclasses may override this method if they need to handle events other than drag events.

Specified by:
selected in interface SelectListener
Specified by:
selected in interface HotSpot
Overrides:
selected in class DragControl
Parameters:
event - Select event.

setAttributes

public void setAttributes(FrameAttributes attributes)
Specifies the frame attributes used to draw the frame when it is not highlighted.

Parameters:
attributes - new attributes bundle for normal state.

setContents

public void setContents(Scrollable contents)
Specifies the frame contents.

Parameters:
contents - new frame contents.

setDrawTitleBar

public void setDrawTitleBar(boolean drawTitleBar)
Set whether the frame has a title bar.

Parameters:
drawTitleBar - True if the frame will draw a title bar.
See Also:
setTitleBarHeight(int)

setEnableMove

public void setEnableMove(boolean enable)
Specifies whether the user can move the frame by dragging the title bar.

Parameters:
enable - true if the user is allowed to move the frame by dragging.

setEnableResizeControl

public void setEnableResizeControl(boolean enable)
Specifies whether the user can resize the frame by dragging the border.

Parameters:
enable - true to allow the user to resize the frame by dragging the border.

setFrameTitle

public void setFrameTitle(String frameTitle)
Set the title of the tree frame.

Parameters:
frameTitle - New frame title.
See Also:
getFrameTitle()

setHighlightAttributes

public void setHighlightAttributes(FrameAttributes attributes)
Specifies the frame attributes used to draw the frame when it is highlighted.

Parameters:
attributes - new attributes bundle for highlight state.

setHighlighted

public void setHighlighted(boolean highlighted)
Sets the frame its highlighted or not highlighted state.

Parameters:
highlighted - true if the frame is now highlighted.

setIconImageSource

public void setIconImageSource(Object imageSource)
Set the image source of the frame icon. This icon is drawn in the upper right hand corner of the tree frame.

Parameters:
imageSource - New image source. May be a String, URL, or BufferedImage.

setMaxSize

public void setMaxSize(Size size)
Specifies the maximum size of the frame. This size is applied as a constraint to the tree's normal size (indicated by getSize()).

Parameters:
size - the maximum size of the minimized frame. Set null for no maximum.

setMinimizeAnimation

public void setMinimizeAnimation(Animation minimizeAnimation)
Set the animation that is played when the tree frame is minimized.

Parameters:
minimizeAnimation - New minimize animation.
See Also:
getMinimizeAnimation()

setMinimized

public void setMinimized(boolean minimized)
Sets the frame to its minimized or maximized state. If the frame is not already in the desired state it will animate to the desired state.

Parameters:
minimized - true if the frame must be minimized. false if the frame must not be minimized.

setMinimizedSize

public void setMinimizedSize(Size size)
Specifies the size of the minimized tree frame. This size is used when the tree is minimized or animating. An animation can use this field to manipulate the size of the frame as the animation runs without interfering with the frame's normal maximized size.

Parameters:
size - the size of the minimized frame. Set null to use the same size in maximized and minimized states.

setScreenLocation

public void setScreenLocation(Offset screenLocation)
Set the location of the upper left corner of the tree, measured in screen coordinates with the origin at the upper left corner of the screen.

Parameters:
screenLocation - New screen location.

setSize

public void setSize(Size size)
Set the size of the frame. The size determines the size of the frame when the frame is maximized.

Parameters:
size - New size.
See Also:
setMinimizedSize(gov.nasa.worldwind.render.Size)

setTitleBarHeight

public void setTitleBarHeight(int titleBarHeight)
Specifies the height, in pixels, of the frame title bar.

Parameters:
titleBarHeight - new height, in pixels.

stepAnimation

protected void stepAnimation(DrawContext dc)
Increment the active animation. Has no effect if there is no active animation. This method must be called once per frame.

Parameters:
dc - Current draw context.

updateBounds

public void updateBounds(DrawContext dc)
Compute the bounds of the content frame, and the extents of the scroll range. Calling this method updates the frame and scroll model to match the size of the scrollable content. Bounds are only computed once per frame. Multiple calls in the same frame will not change the computed bounds.

Parameters:
dc - Current draw context.

updateTile

protected void updateTile(DrawContext dc,
                          gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile tile,
                          Rectangle tileBounds)
Draws the current list of ScrollableTiles into the texture tiles. The tiles are updated when necessary.

Parameters:
dc - the draw context the tile relates to.
tile - the tile to update. A new texture tile will be allocated for the tile, if the tile does not have a texture.
tileBounds - bounds of the tile being updated, within the larger texture.

updateTiles

protected void updateTiles(DrawContext dc)
Update content tiles that have been rendered to a texture.

Parameters:
dc - Current draw context.

NASA World Wind