java.lang.Object
com.dua3.utility.fx.FxRefresh
A class intended for controlling possibly long-running update operations. Refreshs happen mutually exclusive, i.e.
the update tasks do not have to be explicitly synchronized as long as not called directly from other code.
An example is updating a JavaFX node. I.e., if redraw requests come in before the current drawing finishes,
the application becomes sluggish or burns CPU cycles for drawing outdated data. The FxRefresher automatically
skips intermediate frames if redraw requests come in too fast for the drawing to come up with.
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic FxRefreshCreate new instance.static FxRefreshCreate new instance.static FxRefreshCreate a refresher instance for a JavaFXNode.static FxRefreshCreate a refresher instance for a JavaFXNode.booleanisActive()Check active state.booleanCheck if the refresher has been started.voidrefresh()Request refresh.voidsetActive(boolean flag) Set active state.voidstop()Stop the refresher.
-
Methodendetails
-
stop
public void stop()Stop the refresher. -
create
Create new instance. The initial state is active.- Parameter:
name- the name for the instancetask- the task to call when refreshing- Gibt zurück:
- new instance
-
create
Create new instance.- Parameter:
name- the name for the instancetask- the task to call when refreshingactive- the initial active state- Gibt zurück:
- new instance
-
create
Create a refresher instance for a JavaFXNode. The refresher will prevent updates when the node is hidden. The refresher is stopped when the node is removed from the scene graph. The initial state is active.- Parameter:
name- the refresher nametask- the task to run on refreshnode- the node associated with this refresher- Gibt zurück:
- new instance
-
create
Create a refresher instance for a JavaFXNode. The refresher will prevent updates when the node is hidden. The refresher is stopped when the node is removed from the scene graph.- Parameter:
name- the refresher nametask- the task to run on refreshnode- the node associated with this refresheractive- the initial active state- Gibt zurück:
- new instance
-
isRunning
public boolean isRunning()Check if the refresher has been started. Note that it's possible that the refresher is running, but inactive, i.e. if the window is hidden.- Gibt zurück:
- true, if the refresher is running
-
isActive
public boolean isActive()Check active state.- Gibt zurück:
- true if active
-
setActive
public void setActive(boolean flag) Set active state.- Parameter:
flag- whether to activate or deactivate the refresher
-
refresh
public void refresh()Request refresh. The refresh will be performed as soon as all the following are met:- the refresher is running
- the refresher's state is "active"
- no other request is running
- no newer request was queued (in that case, the older request will be skipped)
-