Slider Demo and Documentation

    

The Slider is one of three extensions of the very general abstract class Scroller. See ScrollBar and SimpleScrollBar for the other scrollable devices. Like SimpleScrollBars, Sliders are simpler because they lack the up/right and down/left buttons at the end of the Slider.

To show some of the possibilities, this demo shows several Sliders. They differ in orientation and the options used. The table below shows which options were used with which Sliders.

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 slider uses this option,

The sketch code is in the file SliderDemo.pde. The ScrollPane code is in the file Dragger.pde.

SliderOptions
Horizontal Red It uses 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.
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 Slider.)
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 slider 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 Slider. This setting applies to all the Sliders untill it is changed. (The default is 100 pixels.)

It only takes one Dragger object to handle all the Sliders because only one dragging operation can occur at a time..

class Slider
extends Scroller
which extends ClickablePanel
which extends Clickable

The Slider class creates a simplified scroll bar with many options. The bar can be either vertical or horizontal. It features a narrow bar and a circular 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.

** Slider(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 slider.
Parameters:
boolean vert: True for vertical orientation, false for horizontal orientation.
int leftX, int topY: Location of Slider panel.
int theSize: Length (height or width depending on orientation)) of Slider bar.
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

Return to the top of the page

Revised: 04/11/2014