HanSolo / tilesfx

A JavaFX library containing tiles that can be used for dashboards.
Apache License 2.0
1.42k stars 199 forks source link

Resize / stretch to fill only triggered when FlowGridPane table dimensions change. #5

Closed geometrikal closed 7 years ago

geometrikal commented 7 years ago

I was trying to get the tiles to stretch and resize like in the demo video. I made the following changes in Demo.java

@Override public void start(Stage stage) {
    // FlowPane pane = new FlowPane(Orientation.HORIZONTAL, 5, 5,
    //                               percentageTile, clockTile, gaugeTile, sparkLineTile, areaChartTile,
    //                               lineChartTile, timerControlTile, numberTile, textTile,
    //                               highLowTile, plusMinusTile, sliderTile, switchTile, timeTile,
    //                               barChartTile, customTile, leaderBoardTile, worldTile, mapTile);//, weatherTile);
    // pane.setPrefWrapLength(1);
    // pane.setAlignment(Pos.CENTER);
    // pane.setCenterShape(true);
    // pane.setPadding(new Insets(5));
    // pane.setPrefSize(780, 395);
    // pane.setBackground(new Background(new BackgroundFill(Color.web("#101214"), CornerRadii.EMPTY, Insets.EMPTY)));

    FlowGridPane pane = new FlowGridPane(5, 4,
                                  percentageTile, clockTile, gaugeTile, sparkLineTile, areaChartTile,
                                  lineChartTile, timerControlTile, numberTile, textTile,
                                  highLowTile, plusMinusTile, sliderTile, switchTile, timeTile,
                                  barChartTile, customTile, leaderBoardTile, mapTile);//, weatherTile);
    // pane.setPrefWrapLength(1);
    pane.setAlignment(Pos.CENTER);
    pane.setAlignment(Pos.CENTER); 
    pane.setHgap(5); 
    pane.setVgap(5); 
    pane.setCenterShape(true);
    pane.setPrefSize(1200, 800); 
    pane.setBackground(new Background(new BackgroundFill(Color.web("#101214"), CornerRadii.EMPTY, Insets.EMPTY)));

    Scene scene = new Scene(pane);

    stage.setTitle("TilesFX");
    stage.setScene(scene);
    stage.show();

    timer.start();

    mapTile.addPoiLocation(new Location(51.85, 7.75, "Test"));
    mapTile.removePoiLocation(new Location(51.85, 7.75, "Test"));
}

When the demo is run (gradlew Demo) the tiles are not stretched to the full extent:

capture

If one drags the bottom edge up, the tiles will compress:

capture4

If one drags the right edge across such that the FlowGridPane changes from 4 rows by 5 cols to 5 rows by 4 cols, and then drags the right edge back to the original position, the tiles are now fully stretched.

capture2

capture3

Not sure if this is a bug or I've missed a setting somewhere?

HanSolo commented 7 years ago

That's probably a bug, so the FlowGridPane is in an experimental state atm.

HanSolo commented 7 years ago

Ok, you might want to try to set the prefSize of the Tiles to a bigger value. So the Tiles will only be resized to their preferred size but not bigger than that.

geometrikal commented 7 years ago

Thanks. Really nice library btw.