Package gov.nasa.worldwind.util.tree
Class ScrollFrame
- java.lang.Object
-
- gov.nasa.worldwind.avlist.AVListImpl
-
- gov.nasa.worldwind.util.AbstractHotSpot
-
- gov.nasa.worldwind.util.tree.TreeHotSpot
-
- gov.nasa.worldwind.util.tree.DragControl
-
- gov.nasa.worldwind.util.tree.ScrollFrame
-
- All Implemented Interfaces:
AVList
,SelectListener
,PreRenderable
,Renderable
,HotSpot
,java.awt.event.KeyListener
,java.awt.event.MouseListener
,java.awt.event.MouseMotionListener
,java.awt.event.MouseWheelListener
,java.util.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
Fields Modifier and Type Field Description 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 java.awt.geom.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 java.awt.Rectangle
contentBounds
Bounds of the content part of the frame.protected Scrollable
contents
The contents of the frame.protected java.awt.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 java.awt.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 java.awt.Dimension
frameSize
Size of the frame.protected java.lang.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 java.lang.Object
iconImageSource
Image source for the icon drawn in the upper left corner of the frame.protected java.awt.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 java.awt.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 java.awt.Rectangle
scrollContentBounds
protected java.awt.Font
shortFrameTitleFont
Font used to generateshortTitle
.protected java.lang.String
shortTitle
Frame title that is actually drawn in the title bar.protected java.awt.geom.Rectangle2D
shortTitleBounds
Text bounds of theshortTitle
.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 java.lang.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 java.util.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 java.util.List<gov.nasa.worldwind.util.tree.ScrollFrame.TextureTile>
textureTiles
List to manage sub-tiles of the rendering texture.protected java.util.List<gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile>
tiles
protected int
titleBarHeight
The height, in pixels, of the frame title bar.protected java.nio.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
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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(java.awt.Point point)
Called when a drag begins.protected void
beginDrawing(DrawContext dc)
protected java.awt.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 invertexBuffer
according to the current screen bounds.protected java.awt.Dimension
computeFrameRectForContentRect(java.awt.Dimension contentSize)
Compute the size of the frame rectangle required to accommodate a given content size without displaying scroll bars.protected int
computeTileTextureDimension(java.awt.Dimension frameSize, java.awt.Dimension contentSize)
Compute the dimension of a texture large enough to represent the amount of the contents visible in the frame.protected com.jogamp.opengl.util.texture.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(java.awt.event.MouseWheelEvent e)
Handle a mouse wheel event.protected void
doScrollMacOS(java.awt.event.MouseWheelEvent e)
Handle a mouse wheel event on Mac OS X.void
drag(java.awt.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, java.awt.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, java.awt.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, java.lang.String frameTitle, int width, java.lang.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.java.awt.Rectangle
getBounds(DrawContext dc)
Get the bounds of the tree frame.Scrollable
getContents()
Indicates the frame contents.protected java.awt.Rectangle
getContentTileBounds(int row, int column)
Get the bounds of a tile in the frame content.java.awt.Dimension
getCurrentSize()
Return the amount of screen that space that the frame is currently using.java.lang.String
getFrameTitle()
Get the title of the tree frame.FrameAttributes
getHighlightAttributes()
Indicates the frame attributes used to draw the frame when it is highlighted.java.lang.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 java.awt.Dimension
getMinimumSize()
Get the smallest dimension that the frame can draw itself.protected int
getMouseWheelScrollUnit(java.lang.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 java.awt.geom.Point2D
getScreenPoint()
Get the location of the upper left corner of the frame, measured from the upper left corner of the screen.ScrollBar
getScrollBar(java.lang.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(java.awt.event.MouseWheelEvent e)
Forwards the event to the parent HotSpot if the parent is non-null.protected boolean
mustGenerateShortTitle(java.awt.Font titleFont, int titleAreaWidth)
Determine if a the shortened frame title needs to be regenerated.protected boolean
mustShowHorizontalScrollbar(java.awt.Dimension contentSize)
Determine if the horizontal scrollbar should be displayed.protected boolean
mustShowVerticalScrollbar(java.awt.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 thisRenderable
to render itself using the provided draw context.void
selected(SelectEvent event)
Handle aSelectEvent
and callDragControl.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(java.lang.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(java.lang.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, java.awt.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
-
-
-
-
Field Detail
-
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
-
DEFAULT_BUTTON_SIZE
protected static final int DEFAULT_BUTTON_SIZE
Default size of the minimize button.- See Also:
- Constant Field Values
-
DEFAULT_SCROLL_BAR_SIZE
protected static final int DEFAULT_SCROLL_BAR_SIZE
Default width of the scroll bars.- 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_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_LINE_WIDTH
protected static final int DEFAULT_LINE_WIDTH
Default width of lines used to draw the frame.- See Also:
- Constant Field Values
-
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_MAXIMIZED_SIZE
protected static final Size DEFAULT_MAXIMIZED_SIZE
Default size of the maximized frame.
-
normalAttributes
protected FrameAttributes normalAttributes
Attributes to use when the frame is not highlighted.
-
highlightAttributes
protected FrameAttributes highlightAttributes
Attributes to use when the frame is highlighted.
-
activeAttributes
protected FrameAttributes activeAttributes
Active attributes, either normal or highlight.
-
frameTitle
protected java.lang.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.
-
contents
protected Scrollable contents
The contents of the frame.
-
screenLocation
protected Offset screenLocation
Indicates the location of the upper left corner of the frame.
-
drawTitleBar
protected boolean drawTitleBar
Indicates whether or not to draw a title bar in the frame. Default is true.
-
enableResize
protected boolean enableResize
Indicates whether or not the user can resize the frame by dragging the edge. 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.
-
titleBarHeight
protected int titleBarHeight
The height, in pixels, of the frame title bar.
-
buttonSize
protected int buttonSize
The size, in pixels, of the frame's minimize button.
-
scrollBarSize
protected int scrollBarSize
The width of the frame scroll bar.
-
frameBorder
protected int frameBorder
The width of the frame border.
-
frameLineWidth
protected int frameLineWidth
The width of lines used to draw the frame.
-
BEogsh
protected OGLStackHandler BEogsh
Support for setting up and restoring OpenGL state during rendering.
-
pickSupport
protected PickSupport pickSupport
Support for setting up and restoring picking state, and resolving the picked object.
-
verticalScrollBar
protected ScrollBar verticalScrollBar
Scroll bar to control vertical scrolling.
-
horizontalScrollBar
protected ScrollBar horizontalScrollBar
Scroll bar to control horizontal scrolling.
-
minimized
protected boolean minimized
Indicates whether or not the frame is minimized.
-
maximizedSize
protected Size maximizedSize
The size of the maximized frame.
-
minimizedSize
protected Size minimizedSize
The size of the minimized frame.
-
activeSize
protected Size activeSize
The size of the active frame, minimized or maximized.
-
maxSize
protected Size maxSize
The maximum size of the frame. This is a constraint applied to the frame's size.
-
iconImageSource
protected java.lang.Object iconImageSource
Image source for the icon drawn in the upper left corner of the frame.
-
texture
protected BasicWWTexture texture
Texture for the icon displayed in the frame title bar. Loaded fromiconImageSource
.
-
minimizeAnimation
protected Animation minimizeAnimation
An animation to play when the frame is 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.
-
minimizeButton
protected HotSpot minimizeButton
HotSpot to handle user input on the minimize button.
-
frameResizeControl
protected FrameResizeControl frameResizeControl
Control to handle resizing the frame.
-
borderPickWidth
protected int borderPickWidth
Width of the pickable frame border.
-
vertexBuffer
protected java.nio.DoubleBuffer vertexBuffer
The frame geometry vertices passed to OpenGL.
-
rttSupport
protected OGLRenderToTextureSupport rttSupport
Support class used to render to an offscreen texture.
-
tiles
protected java.util.List<gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile> tiles
-
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.
-
textureCacheKey
protected final java.lang.Object textureCacheKey
Cache key used to locate the rendering texture in the DrawContext's texture cache.
-
textureTileMap
protected java.util.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 java.util.List<gov.nasa.worldwind.util.tree.ScrollFrame.TextureTile> textureTiles
List to manage sub-tiles of the rendering texture.
-
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.
-
shortTitle
protected java.lang.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.
-
frameTitleWidth
protected int frameTitleWidth
Width of the frame title area.
-
shortFrameTitleFont
protected java.awt.Font shortFrameTitleFont
Font used to generateshortTitle
.
-
shortTitleBounds
protected java.awt.geom.Rectangle2D shortTitleBounds
Text bounds of theshortTitle
.
-
frameNumber
protected long frameNumber
-
mustRecomputeFrameGeometry
protected boolean mustRecomputeFrameGeometry
Indicates that the frame must be regenerated because the size or attributes have changed.
-
awtScreenPoint
protected java.awt.geom.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.
-
frameBounds
protected java.awt.Rectangle frameBounds
Bounds of the full frame.
-
innerBounds
protected java.awt.Rectangle innerBounds
Bounds of the frame inside the frame border.
-
contentBounds
protected java.awt.Rectangle contentBounds
Bounds of the content part of the frame.
-
scrollContentBounds
protected java.awt.Rectangle scrollContentBounds
-
pickBounds
protected java.awt.Rectangle pickBounds
Bounds of the pickable area.
-
contentSize
protected java.awt.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.
-
frameSize
protected java.awt.Dimension frameSize
Size of the frame.
-
highlighted
protected boolean highlighted
Indicates whether or not the frame is highlighted.
-
showVerticalScrollbar
protected boolean showVerticalScrollbar
Indicates whether or not the vertical scroll bar must be drawn.
-
showHorizontalScrollbar
protected boolean showHorizontalScrollbar
Indicates whether or not the horizontal scroll bar must be drawn.
-
defaultAttributes
protected static final FrameAttributes defaultAttributes
The attributes used if attributes are not specified.
-
-
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
-
getContents
public Scrollable getContents()
Indicates the frame contents.- Returns:
- the contents of the frame.
-
setContents
public void setContents(Scrollable contents)
Specifies the frame contents.- Parameters:
contents
- new frame contents.
-
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.
-
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.
-
isHighlighted
public boolean isHighlighted()
Indicates whether or not the frame is highlighted.- Returns:
true
if the frame is highlighted, otherwisefalse
.
-
setHighlighted
public void setHighlighted(boolean highlighted)
Sets the frame its highlighted or not highlighted state.- Parameters:
highlighted
-true
if the frame is now highlighted.
-
getFrameTitle
public java.lang.String getFrameTitle()
Get the title of the tree frame.- Returns:
- The frame title.
- See Also:
setFrameTitle(String)
-
setFrameTitle
public void setFrameTitle(java.lang.String frameTitle)
Set the title of the tree frame.- Parameters:
frameTitle
- New frame title.- See Also:
getFrameTitle()
-
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()
-
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)
-
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.
-
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. Setnull
to use the same size in maximized and minimized states.
-
getMaxSize
public Size getMaxSize()
Indicates the maximum size of frame. This size is applied as a constraint to the tree's normal size (indicated bygetSize()
).- Returns:
- the maximum size of the frame.
null
indicates no maximum.
-
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 bygetSize()
).- Parameters:
size
- the maximum size of the minimized frame. Setnull
for no maximum.
-
getCurrentSize
public java.awt.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.
-
getTitleBarHeight
public int getTitleBarHeight()
Indicates the height, in pixels, of the frame title bar.- Returns:
- height of the title bar.
- See Also:
isDrawTitleBar()
-
setTitleBarHeight
public void setTitleBarHeight(int titleBarHeight)
Specifies the height, in pixels, of the frame title bar.- Parameters:
titleBarHeight
- new height, in pixels.
-
isDrawTitleBar
public boolean isDrawTitleBar()
Does the frame have a title bar?- Returns:
- True if the frame will draw a title bar.
-
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)
-
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.
-
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.
-
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.
-
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.
-
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)
-
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()
-
getIconImageSource
public java.lang.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)
-
setIconImageSource
public void setIconImageSource(java.lang.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.
-
getBounds
public java.awt.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).
-
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.
-
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.
-
getScreenPoint
protected java.awt.geom.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.
-
getAttributes
public FrameAttributes getAttributes()
Indicates the frame attributes used to draw the frame when it is not highlighted.- Returns:
- normal frame attributes.
-
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.
-
getHighlightAttributes
public FrameAttributes getHighlightAttributes()
Indicates the frame attributes used to draw the frame when it is highlighted.- Returns:
- highlight frame attributes.
-
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.
-
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.
-
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.
-
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 returnsfalse
if the tile is not visible in the current frame bounds.
-
updateTiles
protected void updateTiles(DrawContext dc)
Update content tiles that have been rendered to a texture.- Parameters:
dc
- Current draw context.
-
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.
-
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.
-
updateTile
protected void updateTile(DrawContext dc, gov.nasa.worldwind.util.tree.ScrollFrame.ContentTile tile, java.awt.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.
-
forceTileUpdate
protected void forceTileUpdate()
Force all tiles to update on the next frame.
-
createTileTexture
protected com.jogamp.opengl.util.texture.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:
dc
- The draw context.width
- the texture's width, in pixels.height
- the texture's height, in pixels.- Returns:
- a new texture with the specified width and height.
-
computeTileTextureDimension
protected int computeTileTextureDimension(java.awt.Dimension frameSize, java.awt.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.
-
preRender
public void preRender(DrawContext dc)
- Specified by:
preRender
in interfacePreRenderable
-
render
public void render(DrawContext dc)
Causes thisRenderable
to render itself using the provided draw context.- Specified by:
render
in interfaceRenderable
- Parameters:
dc
- theDrawContext
to be used- See Also:
DrawContext
-
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, otherwisefalse
.
-
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.
-
getContentTileBounds
protected java.awt.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}.
-
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.
-
computeFrameRectForContentRect
protected java.awt.Dimension computeFrameRectForContentRect(java.awt.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.
-
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 ofsize
depends on the size of the frame content.
-
mustShowVerticalScrollbar
protected boolean mustShowVerticalScrollbar(java.awt.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, otherwisefalse
.
-
mustShowHorizontalScrollbar
protected boolean mustShowHorizontalScrollbar(java.awt.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, otherwisefalse
.
-
isAnimating
protected boolean isAnimating()
Determines if the frame is currently animating.- Returns:
true
if an animation is in progress, otherwisefalse
.
-
computeBounds
protected java.awt.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 invertexBuffer
according to the current screen bounds.
-
getMinimumSize
protected java.awt.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.
-
isDrawMinimized
protected boolean isDrawMinimized()
Determines if the frame should draw in its minimized form.- Returns:
true
if the frame should draw minimized, otherwisefalse
.
-
drawMaximized
protected void drawMaximized(DrawContext dc)
Draw the frame in its maximized state.- Parameters:
dc
- Current draw context.
-
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.
-
drawMinimized
protected void drawMinimized(DrawContext dc)
Draw the frame in its minimized state.- Parameters:
dc
- Current draw context.
-
drawFrame
protected void drawFrame(DrawContext dc)
Draw the frame, scroll bars, and title bar.- 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
-
drawIcon
protected void drawIcon(DrawContext dc, java.awt.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 contextdrawPoint
- 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.
-
drawTitleText
protected void drawTitleText(DrawContext dc, java.awt.Point drawPoint)
Draw text in the frame title.- Parameters:
dc
- Draw contextdrawPoint
- Point at which to draw text. This point is relative to the lower left corner of the title bar.
-
mustGenerateShortTitle
protected boolean mustGenerateShortTitle(java.awt.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, otherwisefalse
.
-
generateShortTitle
protected void generateShortTitle(DrawContext dc, java.lang.String frameTitle, int width, java.lang.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 fieldsshortTitle
,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...".
-
drawMinimizeButton
protected void drawMinimizeButton(DrawContext dc)
Draw the minimize/maximize button in the frame title bar.- Parameters:
dc
- Current draw context.
-
beginDrawing
protected void beginDrawing(DrawContext dc)
-
endDrawing
protected void endDrawing(DrawContext dc)
-
getActiveAttributes
protected FrameAttributes getActiveAttributes()
Get the currently active frame attributes.- Returns:
- attributes that are active for this frame.
-
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.
-
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.
-
determineSize
protected void determineSize()
Determine the frame size to use for the current frame.
-
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.
-
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.
-
getScrollBar
public ScrollBar getScrollBar(java.lang.String direction)
Get a reference to one of the frame's scroll bars.- Parameters:
direction
- Determines which scroll bar to get. EitherAVKey.VERTICAL
orAVKey.HORIZONTAL
.- Returns:
- The horizontal or vertical scroll bar.
-
beginDrag
protected void beginDrag(java.awt.Point point)
Description copied from class:DragControl
Called when a drag begins. This implementation saves the first drag point toDragControl.dragRefPoint
.- Overrides:
beginDrag
in classDragControl
- Parameters:
point
- Point at which dragging started.
-
drag
public void drag(java.awt.Point point)
Description copied from class:DragControl
Called for each point within a drag action.- Specified by:
drag
in classDragControl
- Parameters:
point
- Current drag point.
-
selected
public void selected(SelectEvent event)
Description copied from class:DragControl
Handle aSelectEvent
and callDragControl.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 interfaceHotSpot
- Specified by:
selected
in interfaceSelectListener
- Overrides:
selected
in classDragControl
- Parameters:
event
- Select event.
-
mouseWheelMoved
public void mouseWheelMoved(java.awt.event.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 interfaceHotSpot
- Specified by:
mouseWheelMoved
in interfacejava.awt.event.MouseWheelListener
- Overrides:
mouseWheelMoved
in classTreeHotSpot
- Parameters:
e
- The event to handle.
-
doScroll
protected void doScroll(java.awt.event.MouseWheelEvent e)
Handle a mouse wheel event.- Parameters:
e
- Mouse event that triggered the scroll.
-
doScrollMacOS
protected void doScrollMacOS(java.awt.event.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.
-
getMouseWheelScrollUnit
protected int getMouseWheelScrollUnit(java.lang.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.
-
-