-
Notifications
You must be signed in to change notification settings - Fork 88
Percentage Bar
Languages: Duch (Nederlands)
A percentage bar is used for showing a certain amount of a whole. This UI element will fill a certain part of the entire space as represented by the set percentage.
You can create a percentage bar by calling its constructor:
PercentageBar percentageBar = new PercentageBar(0, 0, 9, 6);
To set its percentage you can call setPercentage
with the desired percentage. The percentage is represented as a float within the range (0,1). 0.5, for example, would equal 50%. If you don't set a percentage, it will be equal to 0.
percentageBar.setPercentage(0.5F);
By default the percentage bar will be displayed horizontally. This means that the bar will fill up in a horizontal manner. You can also specify that it should fill up vertically, by changing its orientation as follows:
percentageBar.setOrientation(Orientable.Orientation.VERTICAL);
In both cases, however, the bar will fill up starting at the left hand side for horizontal orientations and at the top for vertical orientations. You can however also flip these to start at the right or at the bottom and fill up the other way around. You can do so by making use of the flipHorizontally
and flipVertically
methods:
percentageBar.flipHorizontally(true);
percentageBar.flipVertically(true);
All attributes shown in Panes are also applicable here
The element name for the percentage bar is percentagebar
:
<percentagebar x="0" y="0" length="9" height="6"/>
You can specify the percentage the pane should currently be at by making use of the percentage
attribute:
<percentagebar x="0" y="0" length="9" height="6" percentage="0.5"/>
By default is the percentage set at zero.
You can also specify the orientation with the orientation
attribute:
<percentagebar x="0" y="0" length="9" height="6" orientation="vertical"/>
And specify that it should flip by using the flipHorizontally
and flipVertically
attributes:
<percentagebar x="0" y="0" length="9" height="6" flipHorizontally="true"/>
<percentagebar x="0" y="0" length="9" height="6" flipVertically="true"/>