Search in sources :

Example 1 with Tile

use of eu.hansolo.tilesfx.Tile in project Smartcity-Smarthouse by TechnionYP5777.

the class Controller method updateTile.

private void updateTile(WidgetType type, final String path, Integer position) {
    log.info("creating tile for: type=[" + type + "], path=[" + path + "], pos=[" + position + "]");
    final BasicWidget w;
    try {
        w = (BasicWidget) type.getImplementingClass().getConstructor(type.getClass()).newInstance(type);
    } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
        e.printStackTrace();
        return;
    }
    Tile tile = w.getTile();
    setTileEventHandlers(tile, position);
    pane.getChildren().set(position, tile);
    if (path == null || "".equals(path))
        return;
    fileSystem.subscribe((rPath, data) -> {
        log.info("dashbord rquested to be notified on " + path + " got notified on (p,d)=(" + rPath + "," + data + ").");
        if (rPath.equals(path))
            w.updateExisting(Double.valueOf((String) data), path);
    }, path);
}
Also used : Tile(eu.hansolo.tilesfx.Tile) BasicWidget(il.ac.technion.cs.smarthouse.applications.dashboard.model.widget.BasicWidget) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with Tile

use of eu.hansolo.tilesfx.Tile in project Smartcity-Smarthouse by TechnionYP5777.

the class TempDashboard method updateTile.

public void updateTile(String type) {
    switch(type) {
        case "Clock":
            Tile clockTile = TileBuilder.create().prefSize(150, 150).skinType(SkinType.CLOCK).title("Clock Tile").text("Whatever text").dateVisible(true).locale(Locale.US).running(true).build();
            clockTile.setOnMouseClicked(e -> {
                openConfiguration();
            });
            pane.getChildren().set(lastLoc, clockTile);
        case "Numeric":
            break;
        case "Pie Chart":
            break;
        default:
            break;
    }
}
Also used : Tile(eu.hansolo.tilesfx.Tile)

Example 3 with Tile

use of eu.hansolo.tilesfx.Tile in project Smartcity-Smarthouse by TechnionYP5777.

the class ConfigurationController method setListeners.

private static void setListeners(final BasicWidget widget) {
    Tile t = widget.getTile();
    t.setOnMouseEntered(e -> {
        if (!chosenColor.equals(t.getForegroundColor()))
            t.setForegroundBaseColor(enteredTileColor);
    });
    t.setOnMouseExited(e -> {
        if (!chosenColor.equals(t.getForegroundColor()))
            t.setForegroundBaseColor(normalTileColor);
    });
    t.setOnMouseClicked(e -> {
        chosenType = widget.getType();
        widgets.get(widget.getTitle()).stream().forEach(otherT -> otherT.getTile().setForegroundBaseColor(normalTileColor));
        t.setForegroundBaseColor(chosenColor);
    });
}
Also used : Tile(eu.hansolo.tilesfx.Tile)

Example 4 with Tile

use of eu.hansolo.tilesfx.Tile in project Smartcity-Smarthouse by TechnionYP5777.

the class Controller method initialize.

@Override
public void initialize(final URL location, final ResourceBundle __) {
    pane.setPrefSize(1200, 800);
    List<Tile> tiles = new ArrayList<>();
    for (int i = 0; i < ROWS_NUM * TILES_IN_ROW; ++i) {
        final Integer loc = i;
        final Tile t = TileBuilder.create().prefSize(TILE_SIZE, TILE_SIZE).skinType(SkinType.TEXT).description("Choose a widget:\nClick me!\t\t").descriptionAlignment(Pos.CENTER).textVisible(true).build();
        setTileEventHandlers(t, loc);
        tiles.add(t);
    }
    pane.getChildren().addAll(tiles);
    pane.setBackground(new Background(new BackgroundFill(Tile.BACKGROUND.darker(), null, null)));
// pane.setPadding(new Insets(5));
// pane.setPrefHeight((TILE_SIZE+8)*ROWS_NUM);
// pane.setPrefWidth((TILE_SIZE+8)*TILES_IN_ROW);
}
Also used : Background(javafx.scene.layout.Background) BackgroundFill(javafx.scene.layout.BackgroundFill) ArrayList(java.util.ArrayList) Tile(eu.hansolo.tilesfx.Tile)

Aggregations

Tile (eu.hansolo.tilesfx.Tile)4 BasicWidget (il.ac.technion.cs.smarthouse.applications.dashboard.model.widget.BasicWidget)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 Background (javafx.scene.layout.Background)1 BackgroundFill (javafx.scene.layout.BackgroundFill)1