use of javafx.animation.AnimationTimer in project Smartcity-Smarthouse by TechnionYP5777.
the class ConfigConsumer method addWidgetTimer.
private void addWidgetTimer(final BasicWidget w) {
final String key = w.getTitle();
final List<AnimationTimer> where = timers.getOrDefault(key, new ArrayList<>());
where.add(new AnimationTimer() {
private long lastTimerCall;
final Random RND = new Random();
final Boolean isGraph = key.equals(new GraphWidget(WidgetType.AREA_GRAPH, w.getTileSize(), w.getInitalInfo()).getTitle());
final Boolean isList = key.equals(new ListWidget(WidgetType.BAR_CHART, w.getTileSize(), w.getInitalInfo()).getTitle());
@Override
public void handle(final long now) {
if (now <= lastTimerCall + 500_000_000)
return;
if (isGraph) {
final GraphWidget realW = (GraphWidget) w;
realW.getUpdateKeys().forEach(updateKey -> realW.update(RND.nextInt(100) + 0.0, updateKey));
} else if (!isList)
w.update(100 * RND.nextDouble(), null);
else {
final ListWidget realW = (ListWidget) w;
realW.getUpdateKeys().forEach(updateKey -> realW.update(RND.nextInt(100) + 0.0, updateKey));
}
lastTimerCall = now;
}
});
timers.put(key, where);
}
Aggregations