The SimpleScrollBar is one of three extensions of the very general abstract class Scroller. See ScrollBar and Slider for the other scrollable devices. SimpleScrollBars are simpler because they lack the up/right and down/left buttons at the end of the bar. To show some of the possibilities, this demo shows several SimpleScrollBars. They differ in orientation and the options used. The table below shows which options were used with which SimpleScrollBars. Unfortunately dragging the scroll button on scroll bars probably will not work on touch screens. While the operating system typically passes taps on to the application as clicks, it captures the swiping actions and does not let applications see them without using special techniques which unfortunately are often system dependent. Consequently, there is an option to have scrollbars to respond to clicks (and hence taps). The horizontal green bar uses this option. In addition the width of the scroll button was set to -1 meaning the resulting line does not respond to drags. The button's border color was set to green to make it more obvious. |
The sketch code is in the file SimpleScrollBarDemo.pde. | The ScrollPane code is in the file Dragger.pde. |
SimpleScrollBar | Options |
---|---|
Horizontal Red | It uses the showLabels(64) and showHashmarks(32) in the setup method. It also uses displayOneLabel(255) in the draw method in order to provide the "255" label. |
Horizontal Green | It uses the showValue() in the setup method. setProcessClicks(true) makes the bar respond to clicks. setSizes(-1) reduces the button to a line that does not respond to drags while setButtonBorderColor(#00FF00) set the resulting line color to green. |
Horizontal Blue | The constructor specifies the max value 0 and min value 255 to reverse the scroll bar. It uses the showLabels(64) in the setup method. It also uses displayOneLabel(255) in the draw method in order to provide the "255" label. |
Vertical Red | (No options. This is the default SimpleScrollBar.) |
Vertical Green | It uses the showLabels(64) and showHashmarks(32) in the setup method. That method also specifies that the button will have shades of green (setButtonFillColors(#00FF00, #00CC00)). It also uses displayOneLabel(255) in the draw method in order to provide the "255" label. |
Vertical Blue | The minVal is set to 255 and the maxVal to 0 to reverse the direction of the bar. The setup method uses showHashmarks(32), showLabels(255) which draws labels at 0 and 255, and showValue(). Also, when this bar is dragged the code in the mousePressed() method sets the dragger's outside limit to 20 which means drags will terminate if the mouse is moved more than 20 pixels outside a SimpleScrollBar. This setting applies to all the SimpleScrollBars untill it is changed. (The default is 100 pixels.) |
It only takes one Dragger object to handle all the SimpleScrollBars because only one dragging operation can occur at a time.
class SimpleScrollBar
extends Scroller
which extends ClickablePanel
which extends Clickable
The SimpleScrollBar class creates a simplified scroll bar with many options. The bar can be either vertical or horizontal. It is includes a draggable scroll button but does not have up/right and down/left buttons. The Scroller class provides labeling and other options. See the ScrollerDemo for a description of those options. There is one constructor.
** SimpleScrollBar(boolean vert, int leftX, int topY, int theSize, float minValue, float maxValue) - Constructor for SimpleScrollBar. Its orientation can be either vertical or horizontal. There are no buttons at the ends of the bar. Parameters: boolean vert: True for vertical orientation, false for horizontal orientation. int leftX, int topY: Location of SimpleScrollBar panel. int theSize: Length (height or width depending on orientation) of SimpleScrollBar panel. float minValue: Value corresponding to the bottom/left end of the panel. float maxValue: Value corresponding to the top/right end of the panel. minValue > maxValue is OK and just reverses the orientation of the bar. |
Method use codes:
** This constructor or method is designed to be called in the user sketch.
* This method is normally not called in the user's sketch unless the Clickable item was not been included in a ClickableGroup. ClickableGroup automatically uses the method as needed. Exception: This method may be needed if the user is extending Clickable with a new class.
# This constructor or method is rarely used in the user program. In Java, it would probably marked "private". Clickable, ScrollBar, and some other abstract constructors would never be called directly by the user sketch because they do nothing useful unless the user is extending a class.
Inherited from Scroller
Fields
BUTTON_SIZE,
biggerVal,
canBeDragged,
circleAdjust
downBtn,
hashShow,
hashSpacing,
hashStart,
labelsShow,
labelsSpacing,
labelsStart,
maxVal,
minVal,
scrollBtn,
scrollBtnBorderColor,
scrollBtnFillColor,
scrollBtnPos,
scrollBtnSize,
scrollLength,
scrollMin,
smallerVal,
upBtn,
upDownBtnSize,
upDownDivisor,
val,
valRange,
valueShow,
vertical
Constructors
Scroller
Methods
adjustForCircleScrollBtn,
calcMinMaxRelatedValues,
checkForClick,
calcLoc,
calcValue,
display,
displayBtnLine,
displayHashMarks,
displayLabels,
displayOneLabel,
displayValue,
getButtonPos,
getMaxValue,
getMinValue,
getValue,
hasBeenClicked,
isOver,
moved,
readyForDrag,
setBarColors,
setButtonBorderColor,
setButtonFillColors,
setEnabled,
setMaxValue,
setMinValue,
setScrollable,
setScrollBtnPos
setScrollValues,
setSizes,
setValue,
setVisible,
showHashmarks,
showHashmarks,
showLabels,
showLabels,
showValue
Inherited from ClickablePanel
Fields
clickX,
clickY,
invisible,
wholeSkectch
Constructors
ClickablePanel, ClickablePanel, ClickablePanel
Methods
adjustPanel,
checkForClick,
display,
drawOnPanel,
getClickX,
getClickY,
getPanelX,
getPanelY,
isOver,
setClickX,
setClickY,
setColor
Inherited from Clickable
Fields
NOTHING_CLICKED,
COMBO_BUTTON,
DISABLED_COLOR,
borderColor,
c,
clicked,
clickedItemNum,
colorState,
enabled,
h,
label,
over,
overC,
scrollable,
selected,
selectedItemNum,
visible,
w,
x,
y
Constructors
Clickable
Methods
checkForClick,
display,
doNotSelect,
getClickedItemNum,
getColorState,
getH,
getItem,
getLabel,
getSelected,
getSelectedItem,
getSelectedItemLabel,
getSelectedItemNum,
getW,
getX,
getY,
hasBeenClicked,
hideSomething,
isOver,
setBorderColor,
setColorState,
setH,
setLabel,
setScrollable,
setSelected,
setSelectedItemNum,
setEnabled,
setVisible,
setW,
setX,
setY,
sX,
sY
Revised: 04/11/2014