use of javafx.animation.AnimationTimer in project Smartcity-Smarthouse by TechnionYP5777.
the class ConfigurationController method addTimer.
private static void addTimer(String key, WidgetType type, final BasicWidget widget) {
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).getTitle());
@Override
public void handle(long now) {
if (now > lastTimerCall + 500_000_000) {
if (isGraph)
GraphWidget.getDefaultSerie().getData().stream().forEach(data -> widget.updateExisting(RND.nextInt(100), data.getXValue()));
else
widget.updateExisting(RND.nextDouble() * 100, null);
lastTimerCall = now;
}
}
});
timers.put(key, where);
}
use of javafx.animation.AnimationTimer in project FXGL by AlmasB.
the class GameApplication method startMainLoop.
private void startMainLoop() {
log.debug("Starting main loop");
mainLoop = new AnimationTimer() {
@Override
public void handle(long now) {
tpf = tpfCompute(now);
// if we are not in play state run as normal
if (!(getStateMachine().isInPlay() && getSettings().isSingleStep())) {
stepLoop();
}
}
};
mainLoop.start();
}
use of javafx.animation.AnimationTimer in project Board-Instrumentation-Framework by intel.
the class Demo1 method init.
@Override
public void init() {
led = LedBuilder.create().ledColor(Color.MAGENTA).prefWidth(64).prefHeight(64).build();
toggle = false;
lastTimerCall = System.nanoTime();
timer = new AnimationTimer() {
@Override
public void handle(long now) {
if (now > lastTimerCall + 500_000_000l) {
toggle ^= true;
led.setOn(toggle);
lastTimerCall = now;
}
}
};
}
use of javafx.animation.AnimationTimer in project Board-Instrumentation-Framework by intel.
the class DemoGauge method init.
@Override
public void init() {
control = GaugeBuilder.create().prefSize(400, 400).animated(false).startAngle(330).angleRange(300).minValue(0).maxValue(100).sectionsVisible(true).sections(new Section(0, 15), new Section(15, 25), new Section(25, 35)).areas(new Section(25, 35, Color.rgb(255, 0, 0, 0.5))).majorTickSpace(10).plainValue(false).tickLabelOrientation(Gauge.TickLabelOrientation.HORIZONTAL).threshold(70).thresholdVisible(true).minMeasuredValueVisible(true).maxMeasuredValueVisible(true).title("Title").unit("Unit").build();
// control.setStyle("-tick-label-fill: blue;");
// control.setMinorTickSpaceOne(2);
// control.setHistogramEnabled(true);
// control.setOnThresholdExceeded(observable -> System.out.println("Threshold exceeded") );
// control.setOnThresholdUnderrun(observable -> System.out.println("Threshold underrun"));
marker0 = new Marker(25);
// marker0.setOnMarkerExceeded(observable -> System.out.println("Marker exceeded"));
// marker0.setOnMarkerUnderrun(observable -> System.out.println("Marker underrun"));
control.addMarker(marker0);
control.setMarkerFill0(Color.RED);
lastTimerCall = System.nanoTime() + 3_000_000_000l;
timer = new AnimationTimer() {
@Override
public void handle(long now) {
if (now > lastTimerCall + 2_000_000_000l) {
control.setValue(RND.nextDouble() * (control.getMaxValue() - control.getMinValue()) + control.getMinValue());
System.out.println(control.getValue());
lastTimerCall = now;
}
}
};
}
use of javafx.animation.AnimationTimer in project Board-Instrumentation-Framework by intel.
the class DemoOneEightyGauge method init.
@Override
public void init() {
gauge = OneEightyGaugeBuilder.create().animated(true).title("Temperature").unit("°C").maxValue(40).dynamicBarColor(true).stops(new Stop(0.00, Color.BLUE), new Stop(0.25, Color.CYAN), new Stop(0.50, Color.LIME), new Stop(0.75, Color.YELLOW), new Stop(1.00, Color.RED)).build();
lastTimerCall = System.nanoTime();
timer = new AnimationTimer() {
@Override
public void handle(long now) {
if (now > lastTimerCall + 2_000_000_000l) {
gauge.setValue(RND.nextDouble() * gauge.getMaxValue() + gauge.getMinValue());
lastTimerCall = now;
}
}
};
}
Aggregations