Search in sources :

Example 51 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)

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