在创建GridPane
并调用Snapshot()
它之后,我得到的图像具有颜色和宽度似乎不同的网格线。越薄的颜色越浅,越厚的颜色越深。有什么想法吗?
//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);
}
}