Package gov.nasa.worldwind.util.tree
Class ScrollBar
- java.lang.Object
-
- gov.nasa.worldwind.util.tree.ScrollBar
-
- All Implemented Interfaces:
Renderable
public class ScrollBar extends java.lang.Object implements Renderable
A scrollbar component. The scrollable range is defined by four values: min, max, value, and extent.valueis the current position of the scroll bar.extentrepresents the visible region. The four values must always satisfy this relationship:min <= value <= value + extent <= max
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classScrollBar.ScrollControlControl for the scroll arrows and areas of the scroll bar above and below the knob.classScrollBar.ScrollKnobControl for dragging the scroll knob.
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.InsetsarrowInsetsInsets used to position the triangle in the scroll arrow box.protected intautoScrollDelayDelay in milliseconds between each step in auto-scroll operation is effect.protected java.lang.StringautoScrollIncrementThe amount and direction that the bar scrolls while auto-scrolling.protected booleanautoScrollingIndicates whether an auto-scroll operation is active (such as when the user has clicked and held the mouse on the scroll arrow).static java.lang.StringBLOCK_DOWNScroll increment for one page down.static java.lang.StringBLOCK_UPScroll increment for one page up.protected java.awt.RectangleboundsFull bounds of the scroll bar.protected static java.awt.InsetsDEFAULT_ARROW_INSETSDefault insets that position the triangle of the scroll arrow in its box.protected static intDEFAULT_AUTO_SCROLL_DELAYDefault delay, in milliseconds, between auto scroll steps.protected static java.awt.ColorDEFAULT_LINE_COLORDefault color used to draw lines in the scroll bar.protected static intDEFAULT_MAX_VALUEDefault scroll range maximum value.protected static intDEFAULT_MIN_SCROLL_KNOB_SIZEDefault minimum size, in pixels, of the scroll knob.protected static intDEFAULT_MIN_VALUEDefault scroll range minimum value.protected static doubleDEFAULT_OPACITYDefault opacity.protected static java.awt.ColorDEFAULT_SCROLL_KNOB_COLOR1Default first color in the scroll knob gradient.protected static java.awt.ColorDEFAULT_SCROLL_KNOB_COLOR2Default second color in the scroll knob gradient.protected static intDEFAULT_UNIT_INCREMENTDefault unit increment.protected intextentThe amount of the scroll region that is visible in the frame.protected longframeNumberIdentifies frame used to calculate per-frame values.protected java.awt.ColorknobColor1First color of the gradient used to fill the scroll knob.protected java.awt.ColorknobColor2Second color of the gradient used to fill the scroll knob.protected java.awt.ColorlineColorColor applied to lines in the scroll bar.protected intmaxValueMaximum value in the scroll range.protected intminScrollKnobSizeThe minimum size of the scroll knob.protected intminValueMinimum value in the scroll range.protected longnextAutoScrollTime at which the scrollbar should automatically update itself.protected doubleopacityOpacity of the scroll bar knob.protected java.lang.StringorientationScroll bar orientation, eitherAVKey.HORIZONTALorAVKey.VERTICAL.protected PickSupportpickSupportSupport for setting up and restoring picking state, and resolving the picked object.protected intscrollArrowSizeSize, in pixels, of the scroll arrow square.protected java.awt.RectanglescrollBoundsBounds of the scroll track part of the scroll bar.protected java.awt.RectanglescrollDownBarBoundsBounds of the scroll bar area below the knob.protected HotSpotscrollDownBlockControlHotSpot to handle input on page down control.protected HotSpotscrollDownControlHotSpot to handle input on the scroll down control.protected java.awt.RectanglescrollDownControlBoundsBounds of the "down arrow" control.protected java.awt.RectanglescrollKnobBoundsBounds of the scroll knob.protected ScrollBar.ScrollKnobscrollKnobControlHotSpot to handle input on the scroll knob.protected java.awt.RectanglescrollUpBarBoundsBounds of the scroll bar area above the knob.protected HotSpotscrollUpBlockControlHotSpot to handle input on page up control.protected HotSpotscrollUpControlHotSpot to handle input on the scroll up control.protected java.awt.RectanglescrollUpControlBoundsBounds of the "up arrow" control.static java.lang.StringUNIT_DOWNScroll increment for one unit down.static java.lang.StringUNIT_UPScroll increment for one unit up.protected intunitIncrementAmount that the scroll bar scrolls when the up or down arrow is clicked.protected intvalueCurrent scroll bar value.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanDrawInBounds()Determines if the scrollbar is able to draw within its bounds.protected voidcomputeBounds()Compute the bounds of the scroll bar.protected voiddoPick(DrawContext dc)Pick the scroll bar.protected voiddraw(DrawContext dc)Draw the scroll bar.protected voiddrawPickableQuad(DrawContext dc, java.lang.Object pickObject, java.awt.Rectangle bounds)Draw a filled quad in a unique pick color.protected voiddrawQuad(DrawContext dc, java.awt.Rectangle bounds)Draw the vertices of a quadrilateral.protected voiddrawTriangle(DrawContext dc, float rotation, java.awt.Rectangle bounds, java.awt.Insets insets)Draw a triangle for one of the scroll bar controls.intgetAutoScrollDelay()Indicates how frequently the scrollbar updates while one of the scroll arrows is pressed.intgetBlockIncrement()Get the block increment.java.awt.RectanglegetBounds()Get the bounds of the scroll bar.intgetExtent()Get the extent.java.awt.Color[]getKnobColor()Get the color of scroll knob.protected intgetKnobSize(int scrollAreaSize)Get the size of the scroll knob, in pixels.java.awt.ColorgetLineColor()Get the color used to draw the lines of the scroll bar boundary and the scroll arrows.intgetMaxValue()Get the maximum value in the scroll range.intgetMinScrollKnobSize()Indicates the minimum size of the scrollbar knob, in pixels.intgetMinValue()Get the minimum value in the scroll range.doublegetOpacity()Indicates the opacity of the scroll knob.java.lang.StringgetOrientation()Get the scroll bar orientation.protected intgetScrollArrowSize()Get the height of the scroll arrow controls at the top and bottom of the scroll bar.intgetUnitIncrement()Get the unit increment.intgetValue()Get the current value of the scroll bar.doublegetValueAsPercentage()Get the value as a percentage of the scroll range.protected voidinitializeUIControls(HotSpot parent)Initialize the objects that represent the UI controls.booleanisAutoScrolling()Is the scroll bar auto-scrolling?voidrender(DrawContext dc)Draw the scroll bar.voidscroll(int amount)Adjust the scroll value.voidscroll(java.lang.String amount)Adjust the scroll bar by the unit amount or the block amount.voidsetAutoScrollDelay(int delay)Specifies how often the scrollbar will update itself when one of the scroll arrows is pressed.voidsetBounds(java.awt.Rectangle bounds)Set the bounds of the scroll bar.voidsetExtent(int extent)Set the extent.voidsetKnobColor(java.awt.Color color1, java.awt.Color color2)Set the color of scroll knob.voidsetLineColor(java.awt.Color color)Set the color of the lines of the scroll bar boundary.voidsetMaxValue(int maxValue)Set the maximum value in the scroll range.voidsetMinScrollKnobSize(int minSize)Specifies the minimum size of the scrollbar knob, in pixels.voidsetMinValue(int minValue)Set the minimum value in the scroll range.voidsetOpacity(double opacity)Specifies the opacity of the scroll knob.voidsetOrientation(java.lang.String orientation)Set the scroll bar orientation.voidsetUnitIncrement(int unitIncrement)Set the unit increment.voidsetValue(int value)Set the value of the scroll bar.voidstartAutoScroll(java.lang.String increment)Start an auto-scroll operation.voidstopAutoScroll()Stop an auto-scroll operation.
-
-
-
Field Detail
-
UNIT_UP
public static final java.lang.String UNIT_UP
Scroll increment for one unit up.- See Also:
- Constant Field Values
-
UNIT_DOWN
public static final java.lang.String UNIT_DOWN
Scroll increment for one unit down.- See Also:
- Constant Field Values
-
BLOCK_UP
public static final java.lang.String BLOCK_UP
Scroll increment for one page up.- See Also:
- Constant Field Values
-
BLOCK_DOWN
public static final java.lang.String BLOCK_DOWN
Scroll increment for one page down.- See Also:
- Constant Field Values
-
DEFAULT_MIN_VALUE
protected static final int DEFAULT_MIN_VALUE
Default scroll range minimum value.- See Also:
- Constant Field Values
-
DEFAULT_MAX_VALUE
protected static final int DEFAULT_MAX_VALUE
Default scroll range maximum value.- See Also:
- Constant Field Values
-
DEFAULT_UNIT_INCREMENT
protected static final int DEFAULT_UNIT_INCREMENT
Default unit increment.- See Also:
- Constant Field Values
-
DEFAULT_MIN_SCROLL_KNOB_SIZE
protected static final int DEFAULT_MIN_SCROLL_KNOB_SIZE
Default minimum size, in pixels, of the scroll knob.- See Also:
- Constant Field Values
-
DEFAULT_AUTO_SCROLL_DELAY
protected static final int DEFAULT_AUTO_SCROLL_DELAY
Default delay, in milliseconds, between auto scroll steps.- See Also:
- Constant Field Values
-
DEFAULT_ARROW_INSETS
protected static final java.awt.Insets DEFAULT_ARROW_INSETS
Default insets that position the triangle of the scroll arrow in its box.
-
DEFAULT_OPACITY
protected static final double DEFAULT_OPACITY
Default opacity.- See Also:
- Constant Field Values
-
DEFAULT_LINE_COLOR
protected static final java.awt.Color DEFAULT_LINE_COLOR
Default color used to draw lines in the scroll bar.
-
DEFAULT_SCROLL_KNOB_COLOR1
protected static final java.awt.Color DEFAULT_SCROLL_KNOB_COLOR1
Default first color in the scroll knob gradient.
-
DEFAULT_SCROLL_KNOB_COLOR2
protected static final java.awt.Color DEFAULT_SCROLL_KNOB_COLOR2
Default second color in the scroll knob gradient.
-
minValue
protected int minValue
Minimum value in the scroll range.
-
maxValue
protected int maxValue
Maximum value in the scroll range.
-
value
protected int value
Current scroll bar value.
-
extent
protected int extent
The amount of the scroll region that is visible in the frame.
-
unitIncrement
protected int unitIncrement
Amount that the scroll bar scrolls when the up or down arrow is clicked.
-
scrollArrowSize
protected int scrollArrowSize
Size, in pixels, of the scroll arrow square.
-
minScrollKnobSize
protected int minScrollKnobSize
The minimum size of the scroll knob. The size of the knob will adjust to the scroll extent, but will never get smaller than this size. This prevents the knob from shrinking to a single pixels if the scroll range is very large.
-
pickSupport
protected PickSupport pickSupport
Support for setting up and restoring picking state, and resolving the picked object.
-
bounds
protected java.awt.Rectangle bounds
Full bounds of the scroll bar.
-
scrollBounds
protected java.awt.Rectangle scrollBounds
Bounds of the scroll track part of the scroll bar. This is the region in which the scroll knob moves, and excludes the scroll up and down arrows.
-
arrowInsets
protected java.awt.Insets arrowInsets
Insets used to position the triangle in the scroll arrow box.
-
orientation
protected java.lang.String orientation
Scroll bar orientation, eitherAVKey.HORIZONTALorAVKey.VERTICAL.
-
opacity
protected double opacity
Opacity of the scroll bar knob.
-
lineColor
protected java.awt.Color lineColor
Color applied to lines in the scroll bar.
-
knobColor1
protected java.awt.Color knobColor1
First color of the gradient used to fill the scroll knob.
-
knobColor2
protected java.awt.Color knobColor2
Second color of the gradient used to fill the scroll knob.
-
autoScrollDelay
protected int autoScrollDelay
Delay in milliseconds between each step in auto-scroll operation is effect. When auto-scrolling the bar will scroll by theautoScrollIncrementeveryautoScrollDelaymilliseconds.
-
autoScrolling
protected boolean autoScrolling
Indicates whether an auto-scroll operation is active (such as when the user has clicked and held the mouse on the scroll arrow).
-
autoScrollIncrement
protected java.lang.String autoScrollIncrement
The amount and direction that the bar scrolls while auto-scrolling. One ofUNIT_UP,UNIT_DOWN,BLOCK_UP,BLOCK_DOWN.
-
scrollUpControl
protected HotSpot scrollUpControl
HotSpot to handle input on the scroll up control.
-
scrollDownControl
protected HotSpot scrollDownControl
HotSpot to handle input on the scroll down control.
-
scrollUpBlockControl
protected HotSpot scrollUpBlockControl
HotSpot to handle input on page up control.
-
scrollDownBlockControl
protected HotSpot scrollDownBlockControl
HotSpot to handle input on page down control.
-
scrollKnobControl
protected ScrollBar.ScrollKnob scrollKnobControl
HotSpot to handle input on the scroll knob.
-
frameNumber
protected long frameNumber
Identifies frame used to calculate per-frame values.
-
scrollUpControlBounds
protected java.awt.Rectangle scrollUpControlBounds
Bounds of the "up arrow" control.
-
scrollDownControlBounds
protected java.awt.Rectangle scrollDownControlBounds
Bounds of the "down arrow" control.
-
scrollKnobBounds
protected java.awt.Rectangle scrollKnobBounds
Bounds of the scroll knob.
-
scrollUpBarBounds
protected java.awt.Rectangle scrollUpBarBounds
Bounds of the scroll bar area above the knob.
-
scrollDownBarBounds
protected java.awt.Rectangle scrollDownBarBounds
Bounds of the scroll bar area below the knob.
-
nextAutoScroll
protected long nextAutoScroll
Time at which the scrollbar should automatically update itself.
-
-
Constructor Detail
-
ScrollBar
public ScrollBar(HotSpot parent)
Create a scroll bar in the vertical orientation.- Parameters:
parent- The screen component that contains the scroll bar. Input events that cannot be handled by the scroll bar will be passed to this component. May be null.
-
ScrollBar
public ScrollBar(HotSpot parent, java.lang.String orientation)
Create a scroll bar with an orientation.- Parameters:
orientation- EitherAVKey.VERTICALorAVKey.HORIZONTAL.parent- The screen component that contains the scroll bar. Input events that cannot be handled by the scroll bar will be passed to this component. May be null.
-
-
Method Detail
-
initializeUIControls
protected void initializeUIControls(HotSpot parent)
Initialize the objects that represent the UI controls.- Parameters:
parent- The screen component that contains the scroll bar. Input events that cannot be handled by the scroll bar will be passed to this component. May be null.
-
getBounds
public java.awt.Rectangle getBounds()
Get the bounds of the scroll bar.- Returns:
- Scroll bar bounds.
-
setBounds
public void setBounds(java.awt.Rectangle bounds)
Set the bounds of the scroll bar.- Parameters:
bounds- New bounds.
-
getMinValue
public int getMinValue()
Get the minimum value in the scroll range.- Returns:
- Minimum value.
-
setMinValue
public void setMinValue(int minValue)
Set the minimum value in the scroll range.- Parameters:
minValue- New minimum.
-
getMaxValue
public int getMaxValue()
Get the maximum value in the scroll range.- Returns:
- Maximum value.
- See Also:
getMinValue(),setMaxValue(int)
-
setMaxValue
public void setMaxValue(int maxValue)
Set the maximum value in the scroll range.- Parameters:
maxValue- New maximum.
-
getValue
public int getValue()
Get the current value of the scroll bar.- Returns:
- Current value. The value is clamped to the range [minValue : maxValue - extent].
-
setValue
public void setValue(int value)
Set the value of the scroll bar. The value is clamped to the range [minValue : maxValue - extent].- Parameters:
value- New value.
-
getUnitIncrement
public int getUnitIncrement()
Get the unit increment. This is the amount that the scroll bar scrolls by when one of the arrow controls is clicked.- Returns:
- Unit increment.
- See Also:
setUnitIncrement(int)
-
setUnitIncrement
public void setUnitIncrement(int unitIncrement)
Set the unit increment.- Parameters:
unitIncrement- New unit increment. Must be a positive number.- See Also:
getUnitIncrement()
-
getBlockIncrement
public int getBlockIncrement()
Get the block increment. This is the amount that the scroll bar scrolls by when the bar is clicked above or below the knob.- Returns:
- The block increment. This implementation returns the extent, so the scroll bar will adjust by a full visible page.
-
getOrientation
public java.lang.String getOrientation()
Get the scroll bar orientation.- Returns:
- The scroll bar orientation, either
AVKey.VERTICALorAVKey.HORIZONTAL.
-
setOrientation
public void setOrientation(java.lang.String orientation)
Set the scroll bar orientation.- Parameters:
orientation- The scroll bar orientation, eitherAVKey.VERTICALorAVKey.HORIZONTAL.
-
getExtent
public int getExtent()
Get the extent. The extent the amount of the scrollable region that is visible.- Returns:
- The extent.
- See Also:
setExtent(int)
-
setExtent
public void setExtent(int extent)
Set the extent. The extent the amount of the scrollable region that is visible. This method may change the value of the scroll bar to maintain the relationship:min <= value <= value + extent <= max
- Parameters:
extent- New extent. Ifextentis greater than the range of the scroll bar (max - min), then the extent will be set to the maximum valid value.- See Also:
getExtent()
-
getValueAsPercentage
public double getValueAsPercentage()
Get the value as a percentage of the scroll range.- Returns:
- Current value as percentage.
-
getMinScrollKnobSize
public int getMinScrollKnobSize()
Indicates the minimum size of the scrollbar knob, in pixels.- Returns:
- Minimum size of the knob in pixels.
-
setMinScrollKnobSize
public void setMinScrollKnobSize(int minSize)
Specifies the minimum size of the scrollbar knob, in pixels.- Parameters:
minSize- Minimum size of the knob in pixels.
-
getKnobSize
protected int getKnobSize(int scrollAreaSize)
Get the size of the scroll knob, in pixels.- Parameters:
scrollAreaSize- The size of the scroll area, in pixels.- Returns:
- Size of the scroll knob, in pixels.
-
getScrollArrowSize
protected int getScrollArrowSize()
Get the height of the scroll arrow controls at the top and bottom of the scroll bar.- Returns:
- Height of arrow control, in pixels.
-
getLineColor
public java.awt.Color getLineColor()
Get the color used to draw the lines of the scroll bar boundary and the scroll arrows.- Returns:
- Color used for the scroll bar lines.
- See Also:
setLineColor(java.awt.Color),getKnobColor()
-
setLineColor
public void setLineColor(java.awt.Color color)
Set the color of the lines of the scroll bar boundary. This color is also used for the arrows in the scroll controls.- Parameters:
color- Color for lines and scroll arrows.- See Also:
getLineColor(),setKnobColor(java.awt.Color, java.awt.Color)
-
setKnobColor
public void setKnobColor(java.awt.Color color1, java.awt.Color color2)Set the color of scroll knob. The knob is drawn with a gradient made up of two colors.- Parameters:
color1- First color in the gradient.color2- Second color in the gradient.- See Also:
getKnobColor(),setLineColor(java.awt.Color)
-
getKnobColor
public java.awt.Color[] getKnobColor()
Get the color of scroll knob. The knob is drawn with a gradient made up of two colors.- Returns:
- Two element array containing the two colors that form the gradient.
- See Also:
setKnobColor(java.awt.Color, java.awt.Color),getLineColor()
-
getOpacity
public double getOpacity()
Indicates the opacity of the scroll knob.- Returns:
- Scroll knob opacity.
-
setOpacity
public void setOpacity(double opacity)
Specifies the opacity of the scroll knob.- Parameters:
opacity- New opacity.
-
getAutoScrollDelay
public int getAutoScrollDelay()
Indicates how frequently the scrollbar updates while one of the scroll arrows is pressed.- Returns:
- The delay, in milliseconds, between scrollbar updates.
-
setAutoScrollDelay
public void setAutoScrollDelay(int delay)
Specifies how often the scrollbar will update itself when one of the scroll arrows is pressed.- Parameters:
delay- Delay in milliseconds between scrollbar updates. A smaller number makes the scrollbar scroll faster, a larger number makes it scroll slower. The delay may not be negative.
-
scroll
public void scroll(int amount)
Adjust the scroll value.- Parameters:
amount- Amount to add to the current value. A positive value indicates a scroll down; a negative value indicates a scroll up.
-
scroll
public void scroll(java.lang.String amount)
Adjust the scroll bar by the unit amount or the block amount.- Parameters:
amount- One ofUNIT_UP,UNIT_DOWN,BLOCK_UP, orBLOCK_DOWN.
-
startAutoScroll
public void startAutoScroll(java.lang.String increment)
Start an auto-scroll operation. During auto-scroll, the scroll bar will adjust its value and repaint continuously until the auto-scroll is stopped.- Parameters:
increment- Amount to adjust scroll bar each time. One ofUNIT_UP,UNIT_DOWN,BLOCK_UP, orBLOCK_DOWN.- See Also:
stopAutoScroll(),isAutoScrolling(),scroll(String)
-
stopAutoScroll
public void stopAutoScroll()
Stop an auto-scroll operation.- See Also:
startAutoScroll(String),isAutoScrolling()
-
isAutoScrolling
public boolean isAutoScrolling()
Is the scroll bar auto-scrolling?- Returns:
- True if an auto-scroll operation is in progress.
- See Also:
startAutoScroll(String),stopAutoScroll()
-
render
public void render(DrawContext dc)
Draw the scroll bar. The scroll will not draw its bounds are too small to draw without distortion.- Specified by:
renderin interfaceRenderable- Parameters:
dc- theDrawContextto be used- See Also:
DrawContext
-
canDrawInBounds
protected boolean canDrawInBounds()
Determines if the scrollbar is able to draw within its bounds.- Returns:
trueif the scroll bar is able to draw within the bounds, orfalseif the bounds are too small to draw without distortion.
-
computeBounds
protected void computeBounds()
Compute the bounds of the scroll bar.
-
draw
protected void draw(DrawContext dc)
Draw the scroll bar.- Parameters:
dc- Current draw context.
-
doPick
protected void doPick(DrawContext dc)
Pick the scroll bar.- Parameters:
dc- Current draw context.
-
drawPickableQuad
protected void drawPickableQuad(DrawContext dc, java.lang.Object pickObject, java.awt.Rectangle bounds)
Draw a filled quad in a unique pick color. This method must be called betweenglBegin(GL.GL_QUADS)andglEnd().- Parameters:
dc- Current draw context.pickObject- User object to attach to the picked object.bounds- Bounds of the quad.
-
drawQuad
protected void drawQuad(DrawContext dc, java.awt.Rectangle bounds)
Draw the vertices of a quadrilateral. This method must be called betweenglBegin(GL.GL_QUADS)andglEnd().- Parameters:
dc- Current draw context.bounds- Bounds of the quad.
-
drawTriangle
protected void drawTriangle(DrawContext dc, float rotation, java.awt.Rectangle bounds, java.awt.Insets insets)
Draw a triangle for one of the scroll bar controls.- Parameters:
dc- Draw context.rotation- Rotation to apply to the triangle. 0 rotation produces a triangle pointing to the right. Rotation must be one of: 0, 90, -90, or 180.bounds- The bounds of the scroll control. The arrow must be drawn within this rectangle.insets- Insets to apply to the bounds.
-
-