本文整理汇总了Java中javafx.scene.layout.BackgroundPosition类的典型用法代码示例。如果您正苦于以下问题:Java BackgroundPosition类的具体用法?Java BackgroundPosition怎么用?Java BackgroundPosition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BackgroundPosition类属于javafx.scene.layout包,在下文中一共展示了BackgroundPosition类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBackground
import javafx.scene.layout.BackgroundPosition; //导入依赖的package包/类
@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;
}
示例2: loadOverlay
import javafx.scene.layout.BackgroundPosition; //导入依赖的package包/类
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;
}
示例3: updateColorBar
import javafx.scene.layout.BackgroundPosition; //导入依赖的package包/类
/** 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))));
}
示例4: drawBackground
import javafx.scene.layout.BackgroundPosition; //导入依赖的package包/类
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());
}
示例5: checkBackgroundPosition
import javafx.scene.layout.BackgroundPosition; //导入依赖的package包/类
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;
}
示例6: CustomExtractIcon
import javafx.scene.layout.BackgroundPosition; //导入依赖的package包/类
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());
}
示例7: handleDeviceNameOkPressed
import javafx.scene.layout.BackgroundPosition; //导入依赖的package包/类
@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!");
});
}
});
});
}
});
});
}
示例8: hideCard
import javafx.scene.layout.BackgroundPosition; //导入依赖的package包/类
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);
}
}
示例9: loadAsBackground
import javafx.scene.layout.BackgroundPosition; //导入依赖的package包/类
/**
* 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;
}
示例10: setTableauBackground
import javafx.scene.layout.BackgroundPosition; //导入依赖的package包/类
/**
* 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)));
}
示例11: setBackground
import javafx.scene.layout.BackgroundPosition; //导入依赖的package包/类
/**
* 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 })));
}