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

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

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

ImageView.setFitWidth介绍

暂无

代码示例

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

private void updatePlaceholder(Node newView) {
    if (view.getWidth() > 0 && view.getHeight() > 0) {
      SnapshotParameters parameters = new SnapshotParameters();
      parameters.setFill(Color.TRANSPARENT);
      Image placeholderImage = view.snapshot(parameters,
        new WritableImage((int) view.getWidth(), (int) view.getHeight()));
      placeholder.setImage(placeholderImage);
      placeholder.setFitWidth(placeholderImage.getWidth());
      placeholder.setFitHeight(placeholderImage.getHeight());
    } else {
      placeholder.setImage(null);
    }
    placeholder.setVisible(true);
    placeholder.setOpacity(1.0);
    view.getChildren().setAll(placeholder, newView);
    placeholder.toFront();
  }
}

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

Image fullImage = new Image(imageURL);

// define crop in image coordinates:
Rectangle2D croppedPortion = new Rectangle2D(x, y, width, height);

// target width and height:
double scaledWidth = ... ;
double scaledHeight = ... ;

ImageView imageView = new ImageView(fullImage);
imageView.setViewport(croppedPortion);
imageView.setFitWidth(scaledWidth);
imageView.setFitHeight(scaledHeight);
imageView.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: com.bitplan.radolan/com.bitplan.radolan

/**
 * add a size Listener
 */
public void addSizeListener(ObservableValue<Number> widthProperty,
  ObservableValue<Number> heightProperty) {
 ChangeListener<Number> widthListener = (observable, oldValue, newValue) -> {
  imageView.setFitWidth((double) newValue);
  if (debug)
   LOGGER.log(Level.INFO,
     String.format("width %.0f->%.0f", oldValue, newValue));
 };
 ChangeListener<Number> heightListener = (observable, oldValue,
   newValue) -> {
  imageView.setFitHeight((double) newValue);
  if (debug)
   LOGGER.log(Level.INFO,
     String.format("height %.0f->%.0f", oldValue, newValue));
 };
 widthProperty.addListener(widthListener);
 heightProperty.addListener(heightListener);
}

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

ImageView imgv = new ImageView(new Image(new FileInputStream(
    "img/Remove.png")));
imgv.setFitWidth(15);
imgv.setPreserveRatio(true);
imgv.setSmooth(true);

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

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

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

final ImageView imageView = new ImageView();
imageView.setFitHeight(MEDIA_PREVIEW_IMAGE_SIZE);
imageView.setFitWidth(MEDIA_PREVIEW_IMAGE_SIZE);
final URL imageUrl = previewedFile.toURI().toURL();
final Image image = new Image(

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

ImageView iconImage = new ImageView(iconUrl.toString());
iconImage.setFitHeight(fontSize);
iconImage.setFitWidth(fontSize);
iconImage.setId(name);
icon = iconImage;

代码示例来源: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

Image img = new Image("file:c:\\users\\sandy\\pictures\\IMG_0127.jpg");
ImageView iview1 = new ImageView(img);
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: stackoverflow.com

imgHolder.setVisible(false);
imgHolder.setFitHeight(100);
imgHolder.setFitWidth(100);

代码示例来源: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

imageView.setFitWidth(EMBEDDED_MEDIA_RECTANGLE_SIDE);
imageView.setFitHeight(EMBEDDED_MEDIA_RECTANGLE_SIDE);

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

private void updatePlaceholder(Node newView) {
    if (root.getWidth() > 0 && root.getHeight() > 0) {
      Image placeholderImage = root.snapshot(null, new WritableImage((int) root.getWidth(), (int) root.getHeight()));
      placeholder.setImage(placeholderImage);
      placeholder.setFitWidth(placeholderImage.getWidth());
      placeholder.setFitHeight(placeholderImage.getHeight());
    } else {
      placeholder.setImage(null);
    }
    placeholder.setVisible(true);
    placeholder.setOpacity(1.0);
    root.getChildren().setAll(placeholder);
    root.getChildren().add(newView);
    placeholder.toFront();

  }
}

代码示例来源:origin: com.github.giulianini.jestures/jestures

/**
 * Create a {@link JFXListView} for the templates.
 *
 * @param listView
 *            the {@link JFXListView}
 * @param imageProfile
 *            the {@link Image} profile
 * @param index
 *            the {@link Integer} index
 */
// CHECKSTYLE:OFF AH DI MI TOCCA FARE COSI
public static void addVectorToListView(final JFXListView<BorderPane> listView, final Image imageProfile,
    final int index) {
  final BorderPane pane = new BorderPane();
  final Label label = new Label(" " + index);
  final ImageView imageView = new ImageView(imageProfile);
  JFXDepthManager.setDepth(pane, 1);
  label.setId("player-listView-label");
  pane.setId("player-listView-border");
  imageView.setFitHeight(150);
  imageView.setFitWidth(200);
  BorderPane.setAlignment(imageView, Pos.CENTER);
  BorderPane.setAlignment(label, Pos.CENTER_LEFT);
  pane.setCenter(imageView);
  pane.setLeft(label);
  listView.getItems().add(pane);
  listView.scrollTo(index);
}
// CHECKSTYLE:ON

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

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);

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

public UiNoReportOpen() {
  this.setBackground( new Background( new BackgroundFill( ColorPalette.UI_BACKGROUND.getPaint(),
      null, null ) ) );
  this.goMintLogoView.setFitWidth( 150 );
  this.goMintLogoView.setFitHeight( 150 );
  this.performanceViewerTitle.setFont( Font.font( 20 ) );
  this.performanceViewerTitle.setTextFill( ColorPalette.UI_FOREGROUND.getPaint() );
  this.performanceViewerSubTitle.setTextFill( ColorPalette.UI_SECONDARY_FOREGROUND.getPaint() );
  VBox mainContainer = new VBox();
  HBox secondaryContainer = new HBox();
  VBox textContainer = new VBox();
  Pane separator = new Pane();
  separator.setPrefHeight( 2 );
  separator.setMaxWidth( 500 );
  separator.setBackground( new Background( new BackgroundFill( ColorPalette.UI_BACKGROUND_SECONDARY.getPaint(),
      null, null ) ) );
  mainContainer.setSpacing( 20 );
  mainContainer.setAlignment( Pos.CENTER );
  mainContainer.getChildren().addAll( new UiStatusUpdate( "Current build status | Bloody Edge" ),
      secondaryContainer, separator, new UiButton( "Open performance report" ) );
  secondaryContainer.setSpacing( 20 );
  secondaryContainer.setAlignment( Pos.CENTER );
  secondaryContainer.getChildren().addAll( this.goMintLogoView, textContainer );
  textContainer.setSpacing( 5 );
  textContainer.setAlignment( Pos.CENTER_LEFT );
  textContainer.getChildren().addAll( this.performanceViewerTitle, this.performanceViewerSubTitle );
  this.setAlignment( Pos.CENTER );
  this.getChildren().addAll( mainContainer );
}

相关文章