Search in sources :

Example 1 with ListWidget

use of il.ac.technion.cs.smarthouse.system.dashboard.widget.ListWidget 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

Tile (eu.hansolo.tilesfx.Tile)1 SystemGuiController (il.ac.technion.cs.smarthouse.gui.controllers.SystemGuiController)1 GuiController (il.ac.technion.cs.smarthouse.gui_controller.GuiController)1 SystemCore (il.ac.technion.cs.smarthouse.system.SystemCore)1 SystemMode (il.ac.technion.cs.smarthouse.system.SystemMode)1 InfoCollector (il.ac.technion.cs.smarthouse.system.dashboard.InfoCollector)1 WidgetType (il.ac.technion.cs.smarthouse.system.dashboard.WidgetType)1 BasicWidget (il.ac.technion.cs.smarthouse.system.dashboard.widget.BasicWidget)1 GraphWidget (il.ac.technion.cs.smarthouse.system.dashboard.widget.GraphWidget)1 ListWidget (il.ac.technion.cs.smarthouse.system.dashboard.widget.ListWidget)1 FileSystem (il.ac.technion.cs.smarthouse.system.file_system.FileSystem)1 ReadOnlyFileNode (il.ac.technion.cs.smarthouse.system.file_system.FileSystem.ReadOnlyFileNode)1 FileSystemEntries (il.ac.technion.cs.smarthouse.system.file_system.FileSystemEntries)1 PathBuilder (il.ac.technion.cs.smarthouse.system.file_system.PathBuilder)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1