javafx.scene.image.ImageView.setPreserveRatio()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(227)

本文整理了Java中javafx.scene.image.ImageView.setPreserveRatio()方法的一些代码示例,展示了ImageView.setPreserveRatio()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.setPreserveRatio()方法的具体详情如下:
包路径:javafx.scene.image.ImageView
类名称:ImageView
方法名:setPreserveRatio

ImageView.setPreserveRatio介绍

暂无

代码示例

代码示例来源:origin: speedment/speedment

@Override
public ImageView createNode() {
  final ImageView view = new ImageView();
  view.setPreserveRatio(true);
  view.setFitHeight(48);
  brand.logoLarge()
    .map(Image::new)
    .ifPresent(view::setImage);
  return view;
}

代码示例来源:origin: jfoenixadmin/JFoenix

/**
 * Creates a container with the given animation type and duration.
 *
 * @param duration          the duration of the animation
 * @param animationProducer the {@link KeyFrame} instances that define the animation
 */
public ExtendedAnimatedFlowContainer(Duration duration, Function<AnimatedFlowContainer, List<KeyFrame>>
  animationProducer) {
  this.view = new StackPane();
  this.duration = duration;
  this.animationProducer = animationProducer;
  placeholder = new ImageView();
  placeholder.setPreserveRatio(true);
  placeholder.setSmooth(true);
}

代码示例来源:origin: stackoverflow.com

public Image scale(Image source, int targetWidth, int targetHeight, boolean preserveRatio) {
  ImageView imageView = new ImageView(source);
  imageView.setPreserveRatio(preserveRatio);
  imageView.setFitWidth(targetWidth);
  imageView.setFitHeight(targetHeight);
  return imageView.snapshot(null, null);
}

代码示例来源:origin: stackoverflow.com

ColorAdjust colorAdjust = new ColorAdjust();
colorAdjust.setContrast(0.1);
colorAdjust.setHue(-0.05);
colorAdjust.setBrightness(0.1);
colorAdjust.setSaturation(0.2);

ImageView imageView = new ImageView(image);
imageView.setFitWidth(image.getWidth());
imageView.setPreserveRatio(true);
imageView.setEffect(colorAdjust);

代码示例来源:origin: stackoverflow.com

ImageView imageView = new ImageView(new Image("/images/Wim_F.png"));
imageView.setPreserveRatio(true);
imageView.fitWidthProperty().bind(lsduController1.oneWIM.widthProperty().subtract(10d));
imageView.fitHeightProperty().bind(lsduController1.oneWIM.heightProperty().subtract(10d));
lsduController1.oneWIM.setGraphic(imageView);

代码示例来源:origin: stackoverflow.com

iconImageView.setPreserveRatio(true);
setGraphic(iconImageView);

代码示例来源:origin: io.datafx/flow

/**
 *    Creates a container with the given animation type and duration
 * @param duration  the duration of the animation
 * @param animationProducer   the {@link KeyFrame} instances that define the animation
 */
public AnimatedFlowContainer(Duration duration, Function<AnimatedFlowContainer, List<KeyFrame>> animationProducer) {
  this.root = new StackPane();
  this.duration = duration;
  this.animationProducer = animationProducer;
  placeholder = new ImageView();
  placeholder.setPreserveRatio(true);
  placeholder.setSmooth(true);
}

代码示例来源:origin: stackoverflow.com

"img/Remove.png")));
imgv.setFitWidth(15);
imgv.setPreserveRatio(true);
imgv.setSmooth(true);
hb.setGraphic(imgv);

代码示例来源:origin: stackoverflow.com

imageView.setPreserveRatio(true);
imageView.setEffect(colorAdjust);

代码示例来源:origin: stackoverflow.com

ImageView img = new ImageView(new Image(getClass().getResource("unlock24.png").toExternalForm()));
img.setFitHeight(10d);
img.setPreserveRatio(true);
img.setSmooth(true);
setGraphic(img);

代码示例来源:origin: stackoverflow.com

// resizes the image to have width and height of 100 while preserving the ratio and using
 // higher quality filtering method; this ImageView is also cached to 
// improve performance

ImageView iv2 =newImageView();     iv2.setImage(image);
iv2.setFitHeight(100);  iv2.setFitWidth(100);  iv2.setPreserveRatio(true); iv2.setSmooth(true); iv2.setCache(true);

代码示例来源:origin: stackoverflow.com

iview1.setFitWidth(300);
iview1.setFitHeight(300);
iview1.setPreserveRatio(true);

代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay

@PostConstruct
  private void initializeDialog() {
    setTitle(messageSource.getMessage("ch.sahits.game.openpatrician.display.dialog.guild.GuildMediterraneanMapDialog.title",
        new Object[]{}, locale.getCurrentLocal()));
    IMediterreanMap map = guildSettings.getMediterreanMap();
    Image image = imageUtilities.createMediterraneanMap(city.getPlayer(), map);
    ImageView imgView = new ImageView(image);
    imgView.setId("mediterraneanMap");
    imgView.setFitWidth(WRAPPING_WIDTH);
    imgView.setPreserveRatio(true);
    VBox box = new VBox(imgView);
    box.setLayoutX(2 * FRAME_BORDER);
    box.setLayoutY(CLOSE_BTN_Y_POS - 500);
    getContent().add(box);
  }
}

代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay

@PostConstruct
private void initializeControl() {
  clientServerEventBus.register(this);
  clientEventBus.register(this);
  setManaged(false);
  mapPane = new Pane();
  imgView = new ImageView();
  imgView.setFitWidth(236);
  imgView.setFitHeight(192);
  imgView.setPreserveRatio(false);
  // scale the map to the correct size add white dots on cities that have ship in them
  // clicking on the city changes into the other city (if there is a ship or kontor
  // right clicking on a point on the map sends the active ship to that location
  mapPane.getChildren().addAll(imgView);
  getChildren().add(mapPane);
  addEventHandlers();
}
public void setDialogContoller(IDialogContoller dialogContoller) {

代码示例来源:origin: com.bitplan.gui/com.bitplan.javafx

/**
 * helper function for images
 * @param icon
 * @return the BoderPane that wraps the given icon
 */
public BorderPane wrapImageView(ImageView icon) {
 BorderPane pane = new BorderPane();
 pane.setCenter(icon);
 // resize images automatically
 // https://stackoverflow.com/a/12635224/1497139
 icon.setPreserveRatio(true);
 icon.fitHeightProperty().bind(pane.heightProperty());
 icon.fitWidthProperty().bind(pane.widthProperty());
 return pane;
}

代码示例来源:origin: org.controlsfx/controlsfx

/**
   * {@inheritDoc}
   */
  @Override protected void updateItem(Image item, boolean empty) {
    super.updateItem(item, empty);
    
    if (empty) {
      setGraphic(null);
    } else {
      if (preserveImageProperties) {
        imageView.setPreserveRatio(item.isPreserveRatio());
        imageView.setSmooth( item.isSmooth());
      }
      imageView.setImage(item);
      setGraphic(imageView);
    }
  }
}

代码示例来源:origin: stackoverflow.com

public GridPane moonpane() {
   GridPane Moonpane = new GridPane();
   Moonpane.setId("moonpane");
   Moonpane.getColumnConstraints().setAll(
       ColumnConstraintsBuilder.create().prefWidth(160).minWidth(160).build(),
       ColumnConstraintsBuilder.create().prefWidth(100).minWidth(100).build()     
   );
   Moonpane.setHgap(10);
   Moonpane.setMaxHeight(50);
   ImageView Moon_img = new ImageView(new Image(getClass().getResourceAsStream("/Images/Moon/100%.png")));      
   Moon_img.setFitWidth(100);
   Moon_img.setFitHeight(100);
   Moon_img.setPreserveRatio(true);
   Moon_img.setSmooth(true);
   Moon_Image_Label.setGraphic(Moon_img);
   Moonpane.setConstraints(Moon_Image_Label, 1, 0);
   Moonpane.getChildren().add(Moon_Image_Label); 
   Moon_Date_Label.setId("moon-text-english");
   Moonpane.setConstraints(Moon_Date_Label, 0, 0);
   Moonpane.getChildren().add(Moon_Date_Label);
   Reflection r = new Reflection();
   r.setFraction(0.15f);
   Moonpane.setEffect(r);
   Moonpane.setGridLinesVisible(true);
   return Moonpane;
 }

代码示例来源:origin: Tristan971/Lyrebird

@Override
public void initialize() {
  followButton.setDisable(true);
  userBanner.fitWidthProperty().bind(userDetailsVBox.widthProperty());
  userBanner.fitHeightProperty().bind(userDetailsVBox.heightProperty());
  userBanner.setPreserveRatio(false);
  userBanner.setImage(ImageResources.BACKGROUND_DARK_1PX.getImage());
  userProfilePictureImageView.setImage(ImageResources.GENERAL_USER_AVATAR_LIGHT.getImage());
  final Rectangle profilePictureClip = Clipping.getSquareClip(290.0, 50.0);
  userProfilePictureImageView.setClip(profilePictureClip);
  if (targetUserProp.getValue() == null) {
    this.targetUserProp.addListener((o, prev, cur) -> displayTargetUser());
  } else {
    displayTargetUser();
  }
}

代码示例来源:origin: com.guigarage/imaging

imageView.setPreserveRatio(true);
imageView.setSmooth(true);
imageView.fitWidthProperty().bind(widthProperty());

代码示例来源:origin: ch.sahits.game/OpenPatricianDisplay

ImageView background = new ImageView(img);
background.setFitWidth(200);
background.setPreserveRatio(true);
String portraitResouce = state.getSpouse().getPortraitResourceName();
ImageView portrait = new ImageView(imgLoader.loadImage(portraitResouce));
portrait.setFitWidth(200);
portrait.setPreserveRatio(true);
img = imgLoader.getImage("images/retro-gold-frame-oval");
ImageView frame = new ImageView(img);
frame.setFitWidth(200);
frame.setPreserveRatio(true);
pane.getChildren().addAll(background, portrait, frame);
PlaceHolder ph = new PlaceHolder((WRAPPING_WIDTH - 200)/2, 1);

相关文章