Search in sources :

Example 41 with AnimationTimer

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);
}
Also used : Button(javafx.scene.control.Button) FontWeight(javafx.scene.text.FontWeight) Arrays(java.util.Arrays) URL(java.net.URL) GuiController(il.ac.technion.cs.smarthouse.gui_controller.GuiController) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) ReadOnlyFileNode(il.ac.technion.cs.smarthouse.system.file_system.FileSystem.ReadOnlyFileNode) FXCollections(javafx.collections.FXCollections) HashMap(java.util.HashMap) Random(java.util.Random) InfoCollector(il.ac.technion.cs.smarthouse.system.dashboard.InfoCollector) ArrayList(java.util.ArrayList) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) ScrollPane(javafx.scene.control.ScrollPane) ResourceBundle(java.util.ResourceBundle) ComboBox(javafx.scene.control.ComboBox) AlertType(javafx.scene.control.Alert.AlertType) BasicWidget(il.ac.technion.cs.smarthouse.system.dashboard.widget.BasicWidget) Map(java.util.Map) TableView(javafx.scene.control.TableView) Tooltip(javafx.scene.control.Tooltip) FileSystemEntries(il.ac.technion.cs.smarthouse.system.file_system.FileSystemEntries) WidgetType(il.ac.technion.cs.smarthouse.system.dashboard.WidgetType) PathBuilder(il.ac.technion.cs.smarthouse.system.file_system.PathBuilder) Tile(eu.hansolo.tilesfx.Tile) Alert(javafx.scene.control.Alert) HBox(javafx.scene.layout.HBox) Color(javafx.scene.paint.Color) TextField(javafx.scene.control.TextField) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) GraphWidget(il.ac.technion.cs.smarthouse.system.dashboard.widget.GraphWidget) FileSystem(il.ac.technion.cs.smarthouse.system.file_system.FileSystem) Font(javafx.scene.text.Font) Collectors(java.util.stream.Collectors) SystemMode(il.ac.technion.cs.smarthouse.system.SystemMode) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) SystemCore(il.ac.technion.cs.smarthouse.system.SystemCore) AnimationTimer(javafx.animation.AnimationTimer) List(java.util.List) SystemGuiController(il.ac.technion.cs.smarthouse.gui.controllers.SystemGuiController) Stream(java.util.stream.Stream) Stage(javafx.stage.Stage) ListWidget(il.ac.technion.cs.smarthouse.system.dashboard.widget.ListWidget) Optional(java.util.Optional) ObservableList(javafx.collections.ObservableList) AnimationTimer(javafx.animation.AnimationTimer) Random(java.util.Random) GraphWidget(il.ac.technion.cs.smarthouse.system.dashboard.widget.GraphWidget) ListWidget(il.ac.technion.cs.smarthouse.system.dashboard.widget.ListWidget)

Example 42 with AnimationTimer

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

Example 43 with AnimationTimer

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

Example 44 with AnimationTimer

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

Example 45 with AnimationTimer

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

Aggregations

AnimationTimer (javafx.animation.AnimationTimer)53 Scene (javafx.scene.Scene)18 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