Package zero.community
Class HealthBar
java.lang.Object
zero.community.HealthBar
Presents app-owned health using ordinary JavaFX controls. Create and update
this object on the JavaFX application thread. Each instance has its own view;
a JavaFX node can be displayed in only one parent at a time.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the last clamped displayed amount.intReturns this instance's positive maximum.voidsetHealth(int health) Explicitly updates the displayed amount; values are clamped to 0..maximum.javafx.scene.Nodeview()Returns this instance's stable ordinary JavaFX view.
-
Constructor Details
-
HealthBar
public HealthBar(int maximum) Creates a full bar with the caption "Health".- Parameters:
maximum- positive maximum health- Throws:
IllegalArgumentException- if maximum is not positive
-
HealthBar
Creates a full bar with an app-selected caption.- 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 progress controls in a VBox
-
setHealth
public void setHealth(int health) Explicitly updates the displayed 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
-