Java 类javafx.scene.layout.BackgroundImage 实例源码

项目:Incubator    文件:ImageLoader.java   
public Background loadOverlay(String imageName, String widthAsString, String heightAsString) {
    DebugConsole.getDefault().debug(this.getClass(), "Load Overlay image: " + imageName + " (" + widthAsString + ", " + heightAsString + ")"); // NOI18N

    final double width = this.convertStringToDouble(widthAsString);
    final double height = this.convertStringToDouble(heightAsString);

    final Image overlay = overlayImages.computeIfAbsent(
            imageName,
            image -> {
                return this.load(OverlayLoader.class, image, width, height);
            });

    final BackgroundSize backgroundSize = new BackgroundSize(width, height, false, false, false, false);
    final BackgroundImage backgroundImage = new BackgroundImage(overlay, BackgroundRepeat.REPEAT, 
            BackgroundRepeat.REPEAT, BackgroundPosition.CENTER, backgroundSize);
    final Background background = new Background(backgroundImage);

    return background;
}
项目:LoliXL    文件:ImageBackgroundProvider.java   
@Override
public ObservableObjectValue<Background> getBackground() {
    if (background == null) {
        synchronized (lock) {
            if (background == null) {
                ObservableObjectValue<Image> bgimg = getBackgroundImage();
                background = Bindings.createObjectBinding(() -> new Background(new BackgroundImage(
                        bgimg.get(),
                        BackgroundRepeat.NO_REPEAT,
                        BackgroundRepeat.NO_REPEAT,
                        BackgroundPosition.CENTER,
                        new BackgroundSize(BackgroundSize.AUTO, BackgroundSize.AUTO, true, true, true, true))), bgimg);
            }
        }
    }
    return background;
}
项目:org.csstudio.display.builder    文件:ColorMapDialog.java   
/** 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))));
}
项目:GameAuthoringEnvironment    文件:LevelRenderer.java   
protected void drawBackground (String url) {
    if (url == null) {
        return;
    }
    Image img = getImage(url);
    BackgroundImage background = new BackgroundImage(img,
                                                     BackgroundRepeat.NO_REPEAT,
                                                     BackgroundRepeat.NO_REPEAT,
                                                     BackgroundPosition.DEFAULT,
                                                     BackgroundSize.DEFAULT);
    myPane.setBackground(new Background(background));
    myPane.setMinWidth(img.getWidth());
    myPane.setMinHeight(img.getHeight());
}
项目:shuffleboard    文件:WidgetPane.java   
private static BackgroundImage makeTiledBackgroundImage(Image image) {
  if (image == null) {
    return null;
  } else {
    return new BackgroundImage(image, null, null, null, null);
  }
}
项目:FXGLGames    文件:Spike.java   
public Spike(float x, float y, float w, float h) {
    super(x, y, w, h, BodyType.STATIC, true);

    Region r = new Region();
    r.setPrefSize(w, h);
    r.setBackground(new Background(new BackgroundImage(Config.Images.SPIKE, null, null, null, null)));

    getChildren().add(r);
}
项目:FXGLGames    文件:Platform.java   
public Platform(float x, float y, float w, float h) {
    super(x, y, w, h, BodyType.STATIC, true);

    Region r = new Region();
    r.setPrefSize(w, h);
    r.setBackground(new Background(new BackgroundImage(Config.Images.PLATFORM, null, null, null, null)));

    getChildren().add(r);
}
项目:Simulizer    文件:CustomExtractIcon.java   
public CustomExtractIcon(final InternalWindow w) {
    getStyleClass().setAll("custom-close-icon");
    BackgroundImage img = new BackgroundImage(
            new Image(FileUtils.getResourceToExternalForm("/img/extract.png"), 15, 15, false, true),
       BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
         BackgroundSize.DEFAULT);
    setBackground(new Background(img));
    setOnAction((e) -> w.toggleWindowExtracted());
}
项目:LoliXL    文件:GameVersionsPresenter.java   
private Button makeDeleteMcdirButton(GameVersionProvider provider, Parent parent) {
    Button button = new Button();
    ObservableObjectValue<Image> deleteIcon = ImageLoading.load("img/org.to2mbn.lolixl.ui.sidebar.version/delete_mcdir.png");
    button.backgroundProperty().bind(Bindings.createObjectBinding(() -> new Background(new BackgroundImage(deleteIcon.get(), null, null, null, null)), deleteIcon));
    button.setOnAction(event -> provider.delete());
    return button;
}
项目:Signal-JDesktop    文件:RegistrationController.java   
@FXML
protected void handleDeviceNameOkPressed() {
    progressOverlay.setVisible(true);
    String deviceName = deviceNameField.getText();
    Main.getInstance().getSignalAccount().getQrCode(qr -> {
        Image img = new Image(new File(qr).toURI().toString(), 300, 300, true, false);
        BackgroundImage backgroundImg = new BackgroundImage(img, BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT,
                BackgroundPosition.CENTER, BackgroundSize.DEFAULT);
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                qrCodeViewer.setBackground(new Background(backgroundImg));
                step2.setVisible(false);
                step3.setVisible(true);
                progressOverlay.setVisible(false);
                Main.getInstance().getSignalAccount().finishRegistration(deviceName, (Void) -> {
                    Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            step3.setVisible(false);
                            step4.setVisible(true);
                            Main.getInstance().getSignalAccount().startPreKeysRefreshTimer((Void) -> {
                                System.out.println("Prekeys registered!");
                            });
                        }
                    });
                });
            }
        });
    });
}
项目:FXGLGames    文件:Spike.java   
public Spike(float x, float y, float w, float h) {
    super(x, y, w, h, BodyType.STATIC, true);

    Region r = new Region();
    r.setPrefSize(w, h);
    r.setBackground(new Background(new BackgroundImage(Config.Images.SPIKE, null, null, null, null)));

    getChildren().add(r);
}
项目:FXGLGames    文件:Platform.java   
public Platform(float x, float y, float w, float h) {
    super(x, y, w, h, BodyType.STATIC, true);

    Region r = new Region();
    r.setPrefSize(w, h);
    r.setBackground(new Background(new BackgroundImage(Config.Images.PLATFORM, null, null, null, null)));

    getChildren().add(r);
}
项目:metastone    文件:HandCard.java   
private void hideCard(boolean hide) {
    topPane.setVisible(!hide);
    centerPane.setVisible(!hide);
    bottomPane.setVisible(!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);
        setBackground(background);
    }
}
项目:StreamSis    文件:TargetImageWithActionsController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {
    // Let's add nice noise as background to target image.
    Image im = new Image(getClass().getResourceAsStream("/images/targetImageNoise.gif"));
    BackgroundImage bgim = new BackgroundImage(im, null, null, null, null);
    targetImageViewPane.setBackground(new Background(bgim));
    targetImageViewPane.setCache(true);
    targetImageView.setSmooth(true);
    targetImageView.setCache(true);
    allowedExtensions = RegionChecker.allowedExtensions.toArray(new String[0]);

    // Set tooltip with full size Target image on targetImageViewPane mouse hover.
    GUIUtil.setImageViewTooltip(targetImageViewPane, fullTargetImageView);

    // Setup selectTargetButton.
    selectTargetButton.setGraphic(crosshairIcon);
    selectTargetButtonOrigText = selectTargetButton.getText();
    selectTargetButton.sceneProperty().addListener((o, oldVal, newVal) -> {
        ObjectProperty<KeyCodeCombination> opkcc = HotkeyManager
                .getKeyCodeCombinationPropertyOfHotkey(Hotkey.SELECTIMAGE);
        if (newVal != null) {
            // If inside the Scene, add runnable of this button to Hotkey.
            HotkeyManager.setSelectImageRunnable(selectImageRunnable);
            // Change text of the button to show Hotkey.
            changeSelectTargetButtonBasedOnKeyCombination(opkcc.get());
            opkcc.addListener(selectImageHotkeyListener);
        } else {
            opkcc.removeListener(selectImageHotkeyListener);
            changeSelectTargetButtonBasedOnKeyCombination(null);
            // If outside the Scene, remove runnable of this button from Hotkey.
            HotkeyManager.setSelectImageRunnable(null);
        }
    });

    // Set a tooltip showing target file path.
    GUIUtil.createAndBindTooltipToTextfield(targetTextField);
}
项目:StreamSis    文件:RegionTargetCounterController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {
    // Let's add nice noise as background to target image.
    Image im = new Image(getClass().getResourceAsStream("/images/targetImageNoise.gif"));
    BackgroundImage bgim = new BackgroundImage(im, null, null, null, null);
    targetImageViewPane.setBackground(new Background(bgim));
    targetImageViewPane.setCache(true);
    targetImageView.setSmooth(true);
    targetImageView.setCache(true);
    allowedExtensions = RegionChecker.allowedExtensions.toArray(new String[0]);
    coordsVBox.getChildren().add(coordsController.getView());
    similarityVBox.getChildren().add(simController.getView());

    // Set tooltip with full size Target image on targetImageViewPane mouse hover.
    GUIUtil.setImageViewTooltip(targetImageViewPane, fullTargetImageView);

    // Setup selectTargetButton.
    selectTargetButton.setGraphic(crosshairIcon);
    selectTargetButtonOrigText = selectTargetButton.getText();
    selectTargetButton.sceneProperty().addListener((o, oldVal, newVal) -> {
        ObjectProperty<KeyCodeCombination> opkcc = HotkeyManager
                .getKeyCodeCombinationPropertyOfHotkey(Hotkey.SELECTIMAGE);
        if (newVal != null) {
            // If inside the Scene, add runnable of this button to Hotkey.
            HotkeyManager.setSelectImageRunnable(selectImageRunnable);
            // Change text of the button to show Hotkey.
            changeSelectTargetButtonBasedOnKeyCombination(opkcc.get());
            opkcc.addListener(selectImageHotkeyListener);
        } else {
            opkcc.removeListener(selectImageHotkeyListener);
            changeSelectTargetButtonBasedOnKeyCombination(null);
            // If outside the Scene, remove runnable of this button from Hotkey.
            HotkeyManager.setSelectImageRunnable(null);
        }
    });

    // Set tooltip showing file path.
    GUIUtil.createAndBindTooltipToTextfield(targetTextField);
}
项目:StreamSis    文件:RegionCheckerController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {
    // Let's add nice noise as background to target image.
    Image im = new Image(getClass().getResourceAsStream("/images/targetImageNoise.gif"));
    BackgroundImage bgim = new BackgroundImage(im, null, null, null, null);
    targetImageViewPane.setBackground(new Background(bgim));
    targetImageViewPane.setCache(true);
    targetImageView.setSmooth(true);
    targetImageView.setCache(true);
    allowedExtensions = RegionChecker.allowedExtensions.toArray(new String[0]);
    coordsVBox.getChildren().add(coordsController.getView());
    similarityVBox.getChildren().add(simController.getView());

    // Set tooltip with full size Target image on targetImageViewPane mouse hover.
    GUIUtil.setImageViewTooltip(targetImageViewPane, fullTargetImageView);

    // Setup selectTargetButton.
    selectTargetButton.setGraphic(crosshairIcon);
    selectTargetButtonOrigText = selectTargetButton.getText();
    selectTargetButton.sceneProperty().addListener((o, oldVal, newVal) -> {
        ObjectProperty<KeyCodeCombination> opkcc = HotkeyManager
                .getKeyCodeCombinationPropertyOfHotkey(Hotkey.SELECTIMAGE);
        if (newVal != null) {
            // If inside the Scene, add runnable of this button to Hotkey.
            HotkeyManager.setSelectImageRunnable(selectImageRunnable);
            // Change text of the button to show Hotkey.
            changeSelectTargetButtonBasedOnKeyCombination(opkcc.get());
            opkcc.addListener(selectImageHotkeyListener);
        } else {
            opkcc.removeListener(selectImageHotkeyListener);
            changeSelectTargetButtonBasedOnKeyCombination(null);
            // If outside the Scene, remove runnable of this button from Hotkey.
            HotkeyManager.setSelectImageRunnable(null);
        }
    });

    // Set a tooltip showing target file path.
    GUIUtil.createAndBindTooltipToTextfield(targetTextField);
}
项目:lib-tile    文件:TileProvider.java   
/**
 * Loads the given {@link com.github.naoghuman.lib.tile.core.Tile} with the
 * {@link com.github.naoghuman.lib.tile.core.TileLoader} as an
 * {@link javafx.scene.image.Image} which will be converted to a
 * {@link javafx.scene.layout.Background}.
 * 
 * @param  tileLoader loads the given {@link com.github.naoghuman.lib.tile.core.Tile} 
 *         as an {@link javafx.scene.image.Image} which will then be converted to a 
 *         {@link javafx.scene.layout.Background}.
 * @param  tile the {@link com.github.naoghuman.lib.tile.core.Tile} which should be 
 *         loaded as a {@link javafx.scene.layout.Background}.
 * @return the loaded {@link javafx.scene.layout.Background}.
 * @see    com.github.naoghuman.lib.tile.core.TileLoader
 * @see    com.github.naoghuman.lib.tile.core.Tile
 * @see    javafx.scene.layout.Background
 * @see    javafx.scene.image.Image
 */
public Optional<Background> loadAsBackground(final TileLoader tileLoader, final Tile tile) {
    Optional<Background> background = Optional.empty();
    final Optional<Image> image = TileProvider.getDefault().loadAsImage(tileLoader, tile);
    if (image.isPresent()) {
        final BackgroundSize backgroundSize = new BackgroundSize(
                tile.getWidth(), tile.getHeight(),
                false, false, false, false);
        final BackgroundImage backgroundImage = new BackgroundImage(
                image.get(), BackgroundRepeat.REPEAT, BackgroundRepeat.REPEAT,
                BackgroundPosition.CENTER, backgroundSize);
        background = Optional.ofNullable(new Background(backgroundImage));
    }

    return background;
}
项目:l2tool    文件:TextureView.java   
@Override
public void initialize(URL location, ResourceBundle resources) {
    javafx.scene.layout.Background W = new javafx.scene.layout.Background(new BackgroundFill(Color.WHITE, null, null));
    javafx.scene.layout.Background B = new javafx.scene.layout.Background(new BackgroundFill(Color.BLACK, null, null));
    javafx.scene.layout.Background G = new javafx.scene.layout.Background(new BackgroundFill(Color.GRAY, null, null));
    javafx.scene.layout.Background C = new javafx.scene.layout.Background(new BackgroundImage(new Image(getClass().getResource("bg_tr.png").toExternalForm()), null, null, null, null));
    pane.backgroundProperty().bind(Bindings.createObjectBinding(() -> {
        switch (getBackground()) {
            case WHITE:
                return W;
            case BLACK:
                return B;
            case GRAY:
                return G;
            case CHECKERBOARD:
                return C;
            default:
                return javafx.scene.layout.Background.EMPTY;
        }
    }, backgroundProperty()));

    alpha.selectedProperty().bindBidirectional(alphaEnabledProperty);
    background.getItems().addAll(Background.values());
    background.valueProperty().bindBidirectional(backgroundProperty());
    scale.getItems().addAll(Scale.values());
    scale.valueProperty().bindBidirectional(scaleProperty());

    image.imageProperty().bind(Bindings.createObjectBinding(() -> {
        BufferedImage img = getImage();
        if (img == null)
            return null;

        BufferedImage copy = new BufferedImage(img.getWidth(), img.getHeight(),
                alphaEnabledProperty().get() ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB);
        for (int x = 0; x < img.getWidth(); x++)
            for (int y = 0; y < img.getHeight(); y++)
                copy.setRGB(x, y, img.getRGB(x, y));

        WritableImage fxImage = new WritableImage(img.getWidth(), img.getHeight());
        SwingFXUtils.toFXImage(copy, fxImage);
        return fxImage;
    }, imageProperty(), alphaEnabledProperty()));
    image.fitWidthProperty().bind(Bindings.createDoubleBinding(() -> image.getImage() == null ? 0d : image.getImage().getWidth() * getScale().scale, image.imageProperty(), scaleProperty()));
    image.fitHeightProperty().bind(Bindings.createDoubleBinding(() -> image.getImage() == null ? 0d : image.getImage().getHeight() * getScale().scale, image.imageProperty(), scaleProperty()));
}
项目:JCardGamesFX    文件:KlondikeGameArea.java   
/**
 * Sets the background image for the tableau.
 *
 * @param tableauBackground The {@link Image} object to set.
 */
public void setTableauBackground(Image tableauBackground) {
  setBackground(new Background(new BackgroundImage(tableauBackground,
      BackgroundRepeat.REPEAT, BackgroundRepeat.REPEAT,
      BackgroundPosition.CENTER, BackgroundSize.DEFAULT)));
}
项目:StreamSis    文件:MultiTargetRegionCheckerController.java   
@Override
public void initialize(URL location, ResourceBundle resources) {
    coordsVBox.getChildren().add(coordsController.getView());
    fileListerHBox.getChildren().add(listerController.getView());
    similarityVBox.getChildren().add(simController.getView());
    listerController.replaceFileTypeNameTagInLabeledControls("Target image");
    listerController.sampleFileProperty().addListener((o, oldVal, newVal) -> {
        if (newVal != null) {
            updateViewBasedOnTargetImagePath(newVal.getAbsolutePath());
        } else {
            updateViewBasedOnTargetImagePath(null);
        }
    });

    // Let's add nice noise as background to target image.
    Image im = new Image(getClass().getResourceAsStream("/images/targetImageNoise.gif"));
    BackgroundImage bgim = new BackgroundImage(im, null, null, null, null);
    targetImageViewPane.setBackground(new Background(bgim));
    targetImageViewPane.setCache(true);
    targetImageView.setSmooth(true);
    targetImageView.setCache(true);

    allowedExtensions = RegionChecker.allowedExtensions.toArray(new String[0]);

    // Set tooltip with full size Target image on targetImageViewPane mouse hover.
    GUIUtil.setImageViewTooltip(targetImageViewPane, fullTargetImageView);

    // Setup selectTargetButton
    selectTargetButton.setGraphic(crosshairIcon);
    selectTargetButtonOrigText = selectTargetButton.getText();
    selectTargetButton.sceneProperty().addListener((o, oldVal, newVal) -> {
        ObjectProperty<KeyCodeCombination> opkcc = HotkeyManager
                .getKeyCodeCombinationPropertyOfHotkey(Hotkey.SELECTIMAGE);
        if (newVal != null) {
            // If inside the Scene, add runnable of this button to Hotkey.
            HotkeyManager.setSelectImageRunnable(selectImageRunnable);
            // Change text of the button to show Hotkey.
            changeSelectTargetButtonBasedOnKeyCombination(opkcc.get());
            opkcc.addListener(selectImageHotkeyListener);
        } else {
            opkcc.removeListener(selectImageHotkeyListener);
            changeSelectTargetButtonBasedOnKeyCombination(null);
            // If outside the Scene, remove runnable of this button from Hotkey.
            HotkeyManager.setSelectImageRunnable(null);
        }
    });
}
项目:Grow    文件:Grow.java   
/**
 * Effect: sets the background image of a region to be white with a
 * specified image on top of it.
 *
 * @param n
 *            the node
 * @param i
 *            the image
 */
private static void setBackground(Region n, Image i) {
    BackgroundImage back = new BackgroundImage(i, BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, new BackgroundSize(100, 100, true, true, true, false));
    Platform.runLater(() -> n.setBackground(new Background(new BackgroundFill[] { new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY) }, new BackgroundImage[] { back })));
}