Package zero.community
Class SegmentedHealthBar
java.lang.Object
zero.community.SegmentedHealthBar
Presents app-owned health in up to ten visible segments. Create and update
on the JavaFX application thread. Segment boundaries divide the positive
integer maximum as evenly as possible; a segment can be partly filled.
-
Constructor Summary
ConstructorsConstructorDescriptionSegmentedHealthBar(int maximum) Creates a full segmented bar with caption "Health".SegmentedHealthBar(String caption, int maximum) Creates a full bar; each segment represents a positive integer capacity. -
Method Summary
-
Constructor Details
-
SegmentedHealthBar
public SegmentedHealthBar(int maximum) Creates a full segmented bar with caption "Health".- Parameters:
maximum- positive maximum health- Throws:
IllegalArgumentException- if maximum is not positive
-
SegmentedHealthBar
Creates a full bar; each segment represents a positive integer capacity.- Parameters:
caption- non-null display captionmaximum- positive maximum health- Throws:
NullPointerException- if caption is nullIllegalArgumentException- if maximum is not positive
-
-
Method Details
-
view
public javafx.scene.Node view()Returns this instance's stable ordinary JavaFX view.- Returns:
- label and segmented progress controls in a VBox
-
setHealth
public void setHealth(int health) Explicitly updates the amount; values are clamped to 0..maximum.- Parameters:
health- requested displayed health
-
getHealth
public int getHealth()Returns the last clamped displayed amount.- Returns:
- current health
-
getMaximum
public int getMaximum()Returns this instance's positive maximum.- Returns:
- maximum health
-