Display sketch code: BarMeterDemo.pde | The BarMeter code is in the file ClickableMeter.pde |
A BarMeter is a simple extension of ClickableMeter and is almost the same except instead of a current value line, it has a bar that extends from the bottom or left end to the location of the current value.
The demo shows two vertical and one horizontal BarMeters. To convert a temperature, click on the left or center meter and the others will adjust accordingly. The left hand vertical meter uses the hashmark and value options. The horizontal meter uses the labels and value options. The minimum and maximum values are reversed to reverse the meter. The right hand vertical meter is an output only meter that doesn't respond to clicks. (Its a unclickable ClickableMeter!) It uses only the labels option.
Because BarMeter constructor has the same parameter list as ClickableMeter, it is easy to change sketches from one meter to the other by just changing the class names. In fact, this demo was created from the ClickableMeter Demo that way. Actually, this page was largely created that way after deletion of sections that were not appropriate and adding this paragraph.
The code for ClickableMeter and its extensions is found in ClickableMeter.pde.
class BarMeter
extends ClickableMeter
which extends ClickablePanel
which extends Clickable
The BarMeter is a standard vertical or horizontal Clickable barmeter. While it is designed for input as well as display, it can be used for display only purposes by not checking for clicks in the mouseReleased() method. (Typically that means omitting it from the ClickableGroup and calling its display method in the draw() method.) Its constructor uses the same argument list as ClickableMeter's constructor. Note: The orientation of the meter determined automatically. The meter has vertical orientation if its width <= its height.
** BarMeter(int leftX, int topY,
int theWidth, int theHeight, String theLabel, color stdColor, color overColor, color barColor, float minValue, float value, float maxValue) - Constructs a vertical or horizontal BarMeter given the upper, left corner, the width and height, the label (not shown), three colors, and the min, current, and max values. The min and max values can be reversed to reverse the display. The parameter list is the same for all the extensions of ClickableMeter: * leftX - x (pixel) value of left side of meter. * topY - y (pixel) value of top of meter. * theWidth - the width of the meter (in pixels). * theHeight - the height of the meter (in pixels). * theLabel - the label for the meter (not normally shown but may be useful for such things as debugging). * stdColor - the normal color of the meter. * overColor - the color used when mouse is over the meter. * barColor - the color used for the bar or value marker line on the meter. * minValue - the "minimum" (bottom or left) value displayed on the meter. * value - the initial value displayed on the meter. * maxValue - the "maximum" (top or right) value displayed on the meter. |
* void display() - Displays the bar meter vertically or horizontally and draws a bar from the min value to the current value of the meter using the barC, the bar color. The background is stdCol (overColor when the mouse is over the meter). It optionally displays hashmarks, labels and the value if requested by separate methods. |
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 ClickableMeter
Fields
val,
minVal, maxVal, valRange,
barLoc,
vertical,
hashShow, labelsShow, valueShow,
hashStart, labelsStart,
hashSpacing, labelsSpacing,
xHash, yHash,
xPixel, yPixel,
big,
barC
Constructors
ClickableMeter
Methods
display,
checkForClick,
calcLoc,
setValue,
calcVal,
showLabels,
showLabels,
showHashmarks,
showHashmarks,
showValue,
textLabel,
getValue,
getMaxValue,
getMinValue
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