javafx.scene.image.ImageView类的使用及代码示例

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

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

ImageView介绍

暂无

代码示例

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

@Override
public ImageView view() {
  return new ImageView(load());
}

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

private void updateHSLCircleColor(int x, int y) {
  // transform color to HSL space
  Color color = huesCircleView.getImage().getPixelReader().getColor(x, y);
  double max = Math.max(color.getRed(), Math.max(color.getGreen(), color.getBlue()));
  double min = Math.min(color.getRed(), Math.min(color.getGreen(), color.getBlue()));
  double hue = 0;
  if (max != min) {
    double d = max - min;
    if (max == color.getRed()) {
      hue = (color.getGreen() - color.getBlue()) / d + (color.getGreen() < color.getBlue() ? 6 : 0);
    } else if (max == color.getGreen()) {
      hue = (color.getBlue() - color.getRed()) / d + 2;
    } else if (max == color.getBlue()) {
      hue = (color.getRed() - color.getGreen()) / d + 4;
    }
    hue /= 6;
  }
  currentHue = map(hue, 0, 1, 0, 255);
  // refresh the HSL circle
  refreshHSLCircle();
}

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

@FXML
ImageView image;

@Override
public void initialize(URL url, ResourceBundle rb) {
 image.setImage(new Image ("/about.jpg"));
}

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

setAlignment(Pos.CENTER);
try {
  ImageView imgv = new ImageView(new Image(new FileInputStream(
      "img/Remove.png")));
  imgv.setFitWidth(15);
  imgv.setPreserveRatio(true);
  imgv.setSmooth(true);
  hb.setGraphic(imgv);
  hb.setTooltip(ControlFactory.getTooltip("Klient entfernen"));

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

Button btn2 = new Button("Two");
btn2.setTranslateX(btn.getTranslateX() + 60);
Image img1 = new Image ("https://upload.wikimedia.org/wikipedia/commons/thumb/e/ef/Thumbs_up_font_awesome.svg/512px-Thumbs_up_font_awesome.svg.png");
Image img2 = new Image ("https://cdn2.iconfinder.com/data/icons/windows-8-metro-style/512/thumbs_down.png");
Image loadImg = new Image("http://www.ledr.com/colours/white.jpg");
ImageView imgHolder = new ImageView(loadImg);
imgHolder.setVisible(false);
imgHolder.setFitHeight(100);
imgHolder.setFitWidth(100);
imgHolder.setTranslateY(-80);
imgHolder.setVisible(true);
if(randomNum % 2 == 0){
    imgHolder.setImage(img1);
  imgHolder.setImage(img2);

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

Image img = new Image("Img\\titleSirius.png");
title.setImage(img);
title.setLayoutX(569);
title.setLayoutY(146);
title.fitHeightProperty().add(100);
title.fitWidthProperty().add(100);
title.setVisible(true);

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

@Override
public void start(Stage stage) throws Exception {
  Image image = new Image(
      "http://icons.iconarchive.com/icons/designbolts/smurfs-movie/128/smurfette-icon.png"
  );
  imageView.setClip(new ImageView(image));
          0,
          0,
          imageView.getImage().getWidth(),
          imageView.getImage().getHeight(),
          Color.RED
  imageView.effectProperty().bind(
      Bindings
        .when(imageView.hoverProperty())
          .then((Effect) blush)
          .otherwise((Effect) null)
  );
  imageView.setCache(true);
  imageView.setCacheHint(CacheHint.SPEED);

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

private static final Image ledOff = new Image("/images/led_white.gif");
private static final Image ledOn = new Image("/images/led_blue.gif");

@FXML
private GridPane ledPanel ;

private ImageView[] leds ;

public void initialize() {
  final int numLeds = 64 ;
  final int numLedsPerRow = 8 ;

  leds = new ImageView[numLeds];
  for (int i=0; i<numLeds; i++) {
    ImageView led = new ImageView(ledOff);
    leds[i] = led ;
    ledPanel.add(leds[i], i % numLedsPerRow, i / numLedsPerRow);
    led.setOnMousePressed(event -> {
      if (led.getImage()==ledOff) {
        led.setImage(ledOn);
      } else {
        led.setImage(ledOff);
      }
    });
  }
}

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

int iconNumber = this.getIndex() + 1;
  String iconPath = "MyProject/resources/images/icon_" + iconNumber + ".png";
  icon = new Image(getClass().getClassLoader().getResourceAsStream(iconPath));
} catch(NullPointerException ex) {
  icon = new Image(getClass().getClassLoader().getResourceAsStream(iconPath));
iconImageView.setFitHeight(30);
iconImageView.setPreserveRatio(true);
setGraphic(iconImageView);

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

BorderPane borderPane = new BorderPane();
HBox box = new HBox(10);
ImageView imageView = new ImageView(new Image("file:///home/itachi/Pictures/aaa.png")); // Replace with your image path
Button button1 = new Button("Add");
Button button2 = new Button("Add");
primaryStage.setScene(scene);
primaryStage.show();
System.out.println("Image height : " + imageView.getImage().getHeight());
System.out.println("Hbox height : " + box.getHeight());
System.out.println("BorderPane Height : " + borderPane.getHeight());

代码示例来源:origin: eu.agrosense.client/grid-api

renderImage(img);
final ImageView view = new ImageView(img);
view.setPreserveRatio(true);
view.setFitWidth(scene.getWidth());

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

containerPane.setPrefHeight(EMBEDDED_MEDIA_RECTANGLE_SIDE);
final ImageView imageView = new ImageView();
imageView.setImage(imageResource.getImage());
imageView.setFitWidth(EMBEDDED_MEDIA_RECTANGLE_SIDE);
imageView.setFitHeight(EMBEDDED_MEDIA_RECTANGLE_SIDE);
    EMBEDDED_MEDIA_RECTANGLE_CORNER_RADIUS
);
clipRectangle.layoutXProperty().bind(imageView.layoutXProperty());
clipRectangle.layoutYProperty().bind(imageView.layoutYProperty());
imageView.setClip(clipRectangle);
containerPane.getChildren().setAll(imageView);

代码示例来源: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(
      true
  );
  imageView.setImage(image);
  final Rectangle previewClip = Clipping.getSquareClip(
      MEDIA_PREVIEW_IMAGE_SIZE,
      MEDIA_PREVIEW_IMAGE_SIZE * 0.25
  );
  imageView.setClip(previewClip);
  return imageView;
} catch (final MalformedURLException e) {

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

private static Node copyNode( Node node ) {
  if ( node instanceof ImageView ) {
    return new ImageView( ((ImageView)node).getImage());
  } else if ( node instanceof Duplicatable<?> ) {
    return (Node) ((Duplicatable<?>)node).duplicate();
  } else {
    return null;
  }
}

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

@Override
public void cache(Pane node) {
  if (!cache.containsKey(node)) {
    SnapshotParameters snapShotparams = new SnapshotParameters();
    snapShotparams.setFill(Color.TRANSPARENT);
    WritableImage temp = node.snapshot(snapShotparams,
      new WritableImage((int) node.getLayoutBounds().getWidth(),
        (int) node.getLayoutBounds().getHeight()));
    ImageView tempImage = new ImageView(temp);
    tempImage.setCache(true);
    tempImage.setCacheHint(CacheHint.SPEED);
    cache.put(node, new ArrayList<>(node.getChildren()));
    node.getChildren().setAll(tempImage);
  }
}

相关文章