1

After creating a GridPane and calling Snapshot() on it, the image that I get has gridlines that appear to vary in color and width. The thinner ones are lighter, the thicker are darker. Any thoughts?

     //Create the gridpane
     GridPane gPane = new GridPane();
     gPane.setSnapToPixel(true);

     //Set background, padding, and hgap and vgap to create the "border"
     gPane.setStyle("-fx-background-color: DARKGREY; -fx-padding: 1;"
                    +"-fx-hgap: 1; -fx-vgap: 1;");

     //Populate the gridpane with colored rectangles
     for(int i=0; i<mainApp.getItemList().size(); i++){ // rows
         for(int j=0; j<mainApp.getItemList().get(0).size(); j++){ //columns


             Color color = mainApp.getItemList().get(i).get(j).getValue().getDisplayColor();
                int r = (int) (color.getRed() * 255);
                int g = (int) (color.getGreen() * 255);
                int b = (int) (color.getBlue() * 255);

             Rectangle rect = new Rectangle(5,5);

             rect.setStyle("-fx-fill: rgb(" + r + "," + g + "," + b + ");");
             gPane.add(rect, j, i);
         }
     }
Risky_91
  • 81
  • 3
  • 9
  • Ever tried using `setGridLinesVisible(true)` instead of the background-color trick? – eckig Dec 23 '14 at 09:00
  • Yes. They don't show up in the `snapshot()`. I should probably also mention that the image that I create is resized. – Risky_91 Dec 23 '14 at 11:05
  • As far as I know `setGridLinesVisible(true)`is supposed to be used for developing purposes only, therefore I wouldn't use it to do anything with it, like `snapshot()`. I think this is a rendering problem by JavaFX, I'm not too sure about it though, thus only a comment. – Maverick283 Dec 25 '14 at 17:04
  • I think it's actually a problem with the resizing algorithm. The problem goes away if a smaller size grid is exported and resized. – Risky_91 Dec 25 '14 at 22:25

0 Answers0