Java Code Examples for javafx.scene.layout.BackgroundImage

The following examples show how to use javafx.scene.layout.BackgroundImage. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: phoebus   Source File:    License: Eclipse Public License 1.0 6 votes vote down vote up
/** 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,
                                new BackgroundSize(BackgroundSize.AUTO, BackgroundSize.AUTO, true, true, true, true))));
Example 2
private static String backgroundImageToString(BackgroundImage backgroundImage) {
    return "image=" + backgroundImage.getImage()
        + " position=" + backgroundPositionToString(backgroundImage.getPosition())
        + " repeatX=" + backgroundImage.getRepeatX()
        + " repeatY=" + backgroundImage.getRepeatY()
        + " size=" + backgroundSizeToString(backgroundImage.getSize());
Example 3
Source Project: gef   Source File:    License: Eclipse Public License 2.0 5 votes vote down vote up
 * Repaints the tile image that depends on the grid cell size only. The tile
 * image is repeated when repainting the grid.
protected void repaintGrid() {
	Image tile = createGridTile();
	// create a background fill for this node from the tile image
	BackgroundPosition backgroundPosition = new BackgroundPosition(
			Side.LEFT, 0, false, Side.TOP, 0, false);
	BackgroundImage backgroundImage = new BackgroundImage(tile,
			BackgroundRepeat.REPEAT, BackgroundRepeat.REPEAT,
			backgroundPosition, BackgroundSize.DEFAULT);
	Background background = new Background(backgroundImage);
	// apply that background fill
Example 4
Source Project: metastone   Source File:    License: GNU General Public License v2.0 5 votes vote down vote up
private void hideCard(boolean hide) {
	if (hide) {
		BackgroundSize size = new BackgroundSize(getWidth(), getHeight(), false, false, true, false);
		BackgroundImage image = new BackgroundImage(IconFactory.getDefaultCardBack(), BackgroundRepeat.NO_REPEAT,
				BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, size);
		Background background = new Background(image);