Search in sources :

Example 1 with AnimationTimer

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);
}
Also used : AnimationTimer(javafx.animation.AnimationTimer) Random(java.util.Random) GraphWidget(il.ac.technion.cs.smarthouse.applications.dashboard.model.widget.GraphWidget)

Example 2 with AnimationTimer

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();
}
Also used : AnimationTimer(javafx.animation.AnimationTimer)

Example 3 with AnimationTimer

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;
            }
        }
    };
}
Also used : AnimationTimer(javafx.animation.AnimationTimer)

Example 4 with AnimationTimer

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;
            }
        }
    };
}
Also used : AnimationTimer(javafx.animation.AnimationTimer) Marker(eu.hansolo.enzo.common.Marker) Section(eu.hansolo.enzo.common.Section)

Example 5 with AnimationTimer

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;
            }
        }
    };
}
Also used : AnimationTimer(javafx.animation.AnimationTimer) Stop(javafx.scene.paint.Stop)

Aggregations

AnimationTimer (javafx.animation.AnimationTimer)51 Scene (javafx.scene.Scene)16 Group (javafx.scene.Group)15 PerspectiveCamera (javafx.scene.PerspectiveCamera)15 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)14 KeyCode (javafx.scene.input.KeyCode)14 MouseEvent (javafx.scene.input.MouseEvent)14 PointLight (javafx.scene.PointLight)13 Rotate (javafx.scene.transform.Rotate)11 Point3D (org.fxyz.geometry.Point3D)8 Section (eu.hansolo.enzo.common.Section)7 AmbientLight (javafx.scene.AmbientLight)7 Color (javafx.scene.paint.Color)7 ArrayList (java.util.ArrayList)6 KeyFrame (javafx.animation.KeyFrame)5 KeyValue (javafx.animation.KeyValue)5 Timeline (javafx.animation.Timeline)5 Stage (javafx.stage.Stage)5 OBJWriter (org.fxyz.utils.OBJWriter)5 Random (java.util.Random)4