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;
}
Aggregations