ScrollPane Demo and Documentation

    

It may take a minute for the pictures to load.

This demo shows one application of a ScrollPane. You can drag the button in the thumbnail to see an enlarged portion of the flower. The thumbnail in the bottom of the sketch is a flower image overlayed with a transparent ScrollPane. The nearly transparent scroll button with the green frame can be dragged around the picture. The corresponding part of a larger image is shown in the top half of the sketch. If the thumbnail is clicked, then the scroll button will jump to the clicked location.

The setProcessClicks(true) options has been used so clicking the thumbnail will move the scroll button.

The page, DraggerDemo.html, includes a ScrollPane used in a different type of application.

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

class ScrollPane
extends Draggable
which extends ClickablePanel
which extends Clickable

A ScrollPane is basically a two dimensional scroll bar. It has a scroll button that can be dragged both horizontally and vertically. One application would be to drag some point in the pane. Another application would be control some external point. In this application in may to be useful to use a transparent panel and scroll button which is placed on top some other object.

Additional fields

int scrollBtnX, scrollBtnY - The upper left hand corner of the scroll button.
int scrollBtnW, scrollBtnH - Width and height of the scroll button.
float valX, valY - Values corresponding to the current button location.
float minValX, maxValX, valRangeX - Horizontal value limits and range.
float minValY, maxValY, valRangeY - Vertical value limits and range.
color scrollBtnFillColor, scrollBtnBorderColor - Fill and border colors of the button. Use 0x00FFFFFF for transparent pane and/or button.
Button scrollBtn - The ScrollPane's scroll button.
Clickable scrollBtnDragged - The button if is currently draggable.
int scrollW, scrollH -The amounts that the scroll button can be moved.
** ScrollPane (int leftX, int topY, int theWidth, int theHeight,
                    int btnW, int btnH,
                    color stdColor, color btnFillColor, color btnBorderColor,
                    float minValueX, float valueX, float maxValueX,
                    float minValueY, float valueY, float maxValueY)
- Constructor for ScrollPane - a two dimensional scroll bar. Includes a scroll button that can be moved both horizontally and vertically. To make the ScrollPane almost invisible use a transparent color 0x00FFFFFF (where the first "00" means transparent but starting with 0xFF would mean 100% opaque). Then display the ScrollPane panel on top of whatever should be seen.
Parameters:
int leftX, int topY: Location of ScrollPane panel.
int theWidth, int theHeight: Size of ScrollPane panel.
int btnW, int btnH: Size of scroll button.
color stdColor: Color of ScrollPane panel. (Use 0x00FFFFFF for transparent.)
color btnFillColor: Fill color of button. (0x00FFFFFF for transparent.)
color btnBorderColor: Border color of button.
float minValueX: Value corresponding to left side of the panel.
float valueX: Current horizontal value of panel.
float maxValueX: Value corresponding to right side of the panel.
          minValueX > maxValueX is OK
float minValueY: Value corresponding to the bottom of the panel.
float valueY: Current vertical value of panel.
float maxValueY: Value corresponding to top of the panel.
          minValueY > maxValueY is OK
** void setVisible(boolean b)
- Sets the ScrollPane as being visible true or false. The panel is non functional when visible is false.
** void setEnabled(boolean b)
- Sets the ScrollPane as being enabled true or false.
* void display()
- Displays the ScrollPane panel and button.
* boolean isOver()
- Determines if the cursor is over any part of the ScrollPane and returns true if so. Always returns false if stillSearching_ is false or if it is invisible or disabled.
* boolean checkForClick()
- Checks to see if any part of the "ScrollPane" has been clicked. If so, it updates the current "value" and sets "clicked" to true and then returns true. Uses the click as the center of the bottom subject limits on the button. isOver() must be called before checkForClick() but this is done automatically by the Dragger's checkForDrag().
* boolean hasBeenClicked()
- Determines if the ScrollPane has been clicked. If so, return true after "clicked" is set to false.
** boolean readyForDrag(Dragger theTracker)
- Determines if the ScrollPane button has experienced a mousePressed event and could be dragged. Ignores clicks on the panel outside of the button.
** boolean moved(Dragger theTracker)
- If the ScrollPane is the current draggable item, it moves the scroll button and returns true. It is called by mouseDragged().
** int getButtonX()
- Returns the x location (left side) of button
** int getButtonY()
- Returns the y location (top) of button
** int calcLocX(float value)
- Calculates and returns the location that corresponding to the x value The value is restricted to legal x values as specified by the minValX and maxValX. Does not change values or locations.
** void setValueX(float value)
- Sets value corresponding to x and the location that corresponds to it. The value is restricted to legal x values as specified by the minValX and maxValX.
** int calcLocY(float value)
- Calculates and returns the location that corresponding to the y value The value is restricted to legal y values as specified by the minValY and maxValY. Does not change values or locations.
** void setValueY(value)
- Sets value corresponding to y and the location that corresponds to it. The value is restricted to legal y values as specified by the minValY and maxValY.
** void setScrollBtnPos(int xLoc, int yLoc)
- Set the absolute position (x, y) of the Button constrained by the limits on the x and y values.
** void calcValues()
- Calculates and stores valX and valY (the X and Y values) based on the location of scrollBtn.
** float getValueX()
- Returns the current X value of the ScrollPane.
** float getMaxValueX()
- Returns the max X (right) value of the ScrollPane.
** float getMinValueX()
- Returns the min X (left) value of the ScrollPane.
** float getValueY()
- Returns the current Y value of the ScrollPane.
** float getMaxValueY()
- Returns the max Y (top) value of the ScrollPane.
** float getMinValueY()
- Returns the min Y (bottom) value of the ScrollPane.
** float setScrollBtnWidth(int theWidth)
- Set width of scrollBtn and recalculate.
** float setScrollBtnHeight(int theHeight)
- Set height of scrollBtn and recalculate.

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 DraggablePanel

Fields
upDownDivisor

Constructors
DraggablePanel, DraggablePanel

Methods
checkForClick, moved, readyForDrag


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