use of javafx.scene.layout.BackgroundSize in project org.csstudio.display.builder by kasemir.
the class ColorMapDialog method updateColorBar.
/**
* Update color bar in UI from current 'map'
*/
private void updateColorBar() {
// On Mac OS X it was OK to create an image sized 256 x 1:
// 256 wide to easily set the 256 colors,
// 1 pixel height which is then stretched via the BackgroundSize().
// On Linux, the result was garbled unless the image height matched the
// actual height, so it's now fixed to COLOR_BAR_HEIGHT
final WritableImage colors = new WritableImage(256, COLOR_BAR_HEIGHT);
final PixelWriter writer = colors.getPixelWriter();
for (int x = 0; x < 256; ++x) {
final int arfb = ColorMappingFunction.getRGB(map.getColor(x));
for (int y = 0; y < COLOR_BAR_HEIGHT; ++y) writer.setArgb(x, y, arfb);
}
// Stretch image to fill color_bar
color_bar.setBackground(new Background(new BackgroundImage(colors, BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT, new BackgroundSize(BackgroundSize.AUTO, BackgroundSize.AUTO, true, true, true, true))));
}
Aggregations