Search in sources :

Example 1 with WidgetsRegionBuilder

use of il.ac.technion.cs.smarthouse.developers_api.application_builder.WidgetsRegionBuilder in project Smartcity-Smarthouse by TechnionYP5777.

the class WidgetsRegionBuilderImpl method addWidget.

/*
     * (non-Javadoc)
     * 
     * @see il.ac.technion.cs.smarthouse.developers_api.application_builder.
     * WidgetsRegionBuilder#addWidget(il.ac.technion.cs.smarthouse.system.
     * dashboard.WidgetType,
     * il.ac.technion.cs.smarthouse.system.dashboard.InfoCollector,
     * il.ac.technion.cs.smarthouse.system.services.sensors_service.SensorApi,
     * java.util.function.Function)
     */
@Override
public <T extends SensorData> WidgetsRegionBuilder addWidget(final WidgetType t, final InfoCollector c, final SensorApi<T> a, final Function<T, Map<String, Object>> sensorProcessor) {
    if (!canAdd())
        return this;
    BasicWidget bw = t.createWidget(tileSize, c);
    a.subscribe(data -> sensorProcessor.apply(data).forEach((path, val) -> bw.update(val, path)));
    widgetsHbox.getChildren().add(core.createWidget(bw).get());
    return this;
}
Also used : HBox(javafx.scene.layout.HBox) Function(java.util.function.Function) InfoCollector(il.ac.technion.cs.smarthouse.system.dashboard.InfoCollector) DashboardCore(il.ac.technion.cs.smarthouse.system.dashboard.DashboardCore) WidgetsRegionBuilder(il.ac.technion.cs.smarthouse.developers_api.application_builder.WidgetsRegionBuilder) SensorApi(il.ac.technion.cs.smarthouse.system.services.sensors_service.SensorApi) Insets(javafx.geometry.Insets) ScrollPane(javafx.scene.control.ScrollPane) SensorData(il.ac.technion.cs.smarthouse.system.services.sensors_service.SensorData) ScrollBarPolicy(javafx.scene.control.ScrollPane.ScrollBarPolicy) BasicWidget(il.ac.technion.cs.smarthouse.system.dashboard.widget.BasicWidget) Map(java.util.Map) WidgetType(il.ac.technion.cs.smarthouse.system.dashboard.WidgetType) BasicWidget(il.ac.technion.cs.smarthouse.system.dashboard.widget.BasicWidget)

Aggregations

WidgetsRegionBuilder (il.ac.technion.cs.smarthouse.developers_api.application_builder.WidgetsRegionBuilder)1 DashboardCore (il.ac.technion.cs.smarthouse.system.dashboard.DashboardCore)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 SensorApi (il.ac.technion.cs.smarthouse.system.services.sensors_service.SensorApi)1 SensorData (il.ac.technion.cs.smarthouse.system.services.sensors_service.SensorData)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Insets (javafx.geometry.Insets)1 ScrollPane (javafx.scene.control.ScrollPane)1 ScrollBarPolicy (javafx.scene.control.ScrollPane.ScrollBarPolicy)1 HBox (javafx.scene.layout.HBox)1