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);
}
use of javafx.animation.AnimationTimer in project FXGL by AlmasB.
the class EditorApp method start.
@Override
public void start(Stage stage) throws Exception {
root = createContent();
var fxglPane = GameApplication.embeddedLaunch(new EditorGameApplication(root));
// TODO: allow notifying when FXGL is ready? so we can build UI for example
root.addPane(fxglPane);
var scene = new Scene(root);
stage.setScene(scene);
stage.setWidth(1600);
stage.setHeight(950);
stage.setMinWidth(800);
stage.setMinHeight(600);
stage.setTitle("FXGL Editor");
stage.show();
// this is the JavaFX app timer since we are running outside of the engine.
AnimationTimer timer = new AnimationTimer() {
@Override
public void handle(long now) {
root.onUpdate(0.016);
}
};
timer.start();
}
use of javafx.animation.AnimationTimer in project Board-Instrumentation-Framework by intel.
the class DemoDoubleRadialGauge method init.
@Override
public void init() {
control = DoubleRadialGaugeBuilder.create().titleOne("Title One").unitOne("°C").minValueOne(0).maxValueOne(100).ledVisibleOne(true).ledColorOne(Color.RED).needleColorOne(Color.DARKBLUE).sectionsVisibleOne(true).sectionsOne(new Section(0, 20, Color.rgb(200, 0, 0, 0.2)), new Section(20, 40, Color.rgb(200, 0, 0, 0.4)), new Section(40, 60, Color.rgb(200, 0, 0, 0.6)), new Section(60, 80, Color.rgb(200, 0, 0, 0.8)), new Section(80, 100, Color.rgb(200, 0, 0, 1.0))).areasVisibleOne(true).areasOne(new Section(80, 100, Color.rgb(200, 0, 0, 1.0))).titleTwo("Title Two").unitTwo("°F").minValueTwo(0).maxValueTwo(100).ledVisibleTwo(true).ledColorTwo(Color.BLUE).needleColorTwo(Color.DARKRED).sectionsVisibleTwo(true).sectionsTwo(new Section(0, 20, Color.rgb(0, 0, 200, 0.2)), new Section(20, 40, Color.rgb(0, 0, 200, 0.4)), new Section(40, 60, Color.rgb(0, 0, 200, 0.6)), new Section(60, 80, Color.rgb(0, 0, 200, 0.8)), new Section(80, 100, Color.rgb(0, 0, 200, 1.0))).areasVisibleTwo(true).areasTwo(new Section(80, 100, Color.rgb(0, 0, 200, 1.0))).build();
lastTimerCallOne = System.nanoTime() + 50_000_000l;
timerOne = new AnimationTimer() {
@Override
public void handle(long now) {
if (now > lastTimerCallOne + 4_200_000_000l) {
control.setValueOne(RND.nextDouble() * 100);
control.setBlinkingOne(control.getValueOne() > 50);
lastTimerCallOne = now;
}
}
};
lastTimerCallTwo = System.nanoTime() + 400_000_000l;
timerTwo = new AnimationTimer() {
@Override
public void handle(long now) {
if (now > lastTimerCallTwo + 3_500_000_000l) {
double value = RND.nextDouble() * 100;
control.setValueTwo(value);
control.setBlinkingTwo(control.getValueTwo() > 70);
lastTimerCallTwo = now;
}
}
};
}
use of javafx.animation.AnimationTimer in project Board-Instrumentation-Framework by intel.
the class DemoMulti method init.
@Override
public void init() {
rnd = new Random();
lastTimerCall = 0l;
timer = new AnimationTimer() {
@Override
public void handle(long now) {
if (now > lastTimerCall + 100_000_000l) {
for (SimpleGauge gauge : gauges) {
gauge.setValue(rnd.nextDouble() * 100.0);
}
lastTimerCall = now;
}
}
};
gauges = new SimpleGauge[100];
for (int i = 0; i < 100; i++) {
SimpleGauge gauge = SimpleGaugeBuilder.create().prefSize(50, 50).animationDuration(80).animated(false).sections(new Section(0, 100)).styleClass(SimpleGauge.STYLE_CLASS_BLUE_TO_RED_6).build();
gauges[i] = gauge;
}
}
use of javafx.animation.AnimationTimer in project Board-Instrumentation-Framework by intel.
the class DemoFlatGauge method init.
@Override
public void init() {
gauge = FlatGaugeBuilder.create().prefSize(600, 600).title("Temperature").unit("°C").minValue(0).maxValue(100).backgroundColor(Color.TRANSPARENT).barColor(Color.CYAN).animationDuration(2000).build();
lastTimerCall = System.nanoTime() + 3_000_000_000l;
timer = new AnimationTimer() {
@Override
public void handle(long now) {
if (now > lastTimerCall + 5_000_000_000l) {
gauge.setValue(RND.nextDouble() * (gauge.getMaxValue() - gauge.getMinValue()) + gauge.getMinValue());
lastTimerCall = now;
}
}
};
}
Aggregations