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

项目: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());
}
项目:openjfx-8u-dev-tests    文件:BaseStyleNodeTest.java   
public boolean checkBackgroundPosition(BackgroundPosition[] first, BackgroundPosition[] second) {
    if (first == second) {
        return true;
    }
    if (first.length != second.length) {
        return false;
    }
    for (int i = 0; i < first.length; i++) {
        BackgroundPosition firstPosition = first[i];
        BackgroundPosition secondPosition = second[i];
        if (firstPosition == secondPosition) {
            continue;
        }
        if (firstPosition.isHorizontalAsPercentage() != secondPosition.isHorizontalAsPercentage()) {
            return false;
        }
        if (firstPosition.isVerticalAsPercentage() != secondPosition.isVerticalAsPercentage()) {
            return false;
        }
        if (Double.valueOf(firstPosition.getHorizontalPosition()).longValue() != Double.valueOf(secondPosition.getHorizontalPosition()).longValue()) {
            return false;
        }
        if (Double.valueOf(firstPosition.getVerticalPosition()).longValue() != Double.valueOf(secondPosition.getVerticalPosition()).longValue()) {
            return false;
        }
        if (firstPosition.getHorizontalSide() != secondPosition.getHorizontalSide()) {
            return false;
        }
        if (firstPosition.getVerticalPosition() != secondPosition.getVerticalPosition()) {
            return false;
        }
    }
    return true;
}
项目: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());
}
项目: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!");
                            });
                        }
                    });
                });
            }
        });
    });
}
项目: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);
    }
}
项目: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;
}
项目: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)));
}
项目: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 })));
}