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

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

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

ImageView.getImage介绍

暂无

代码示例

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

0,
0,
imageView.getImage().getWidth(),
imageView.getImage().getHeight(),
Color.RED

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

if (node instanceof ImageView) {
 ImageView imageView = (ImageView) node;
 String url = imageView.getImage().impl_getUrl();
 if (url != null && imageNamePattern.matcher(url).matches()) {
  Node button = imageView.getParent().getParent();

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

ImageView image = ...
ImageView src   = ...
image.setImage(src.getImage());

代码示例来源:origin: com.github.almasb/fxgl-effects

public Node getView() {
  return imageView.getImage() != null ? imageView : view;
}

代码示例来源:origin: com.github.almasb/fxgl-base

public Node getView() {
  return imageView.getImage() != null ? imageView : view;
}

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

box.setButtonCell(new ListCell<ImageView>() 
     {
         @Override protected void updateItem(ImageView item, boolean empty) 
         {
          super.updateItem(item, empty);
          if (item == null || empty) {
           setGraphic(null);
          } else {
           setGraphic(new ImageView(item.getImage()));
          }
         }
      });

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

@FXML
ImageView imageView;
double getScaleXRatio()
{ 
  return imageView.getBoundsInParent().getWidth()/imageView.getImage().getWidth();
}

double getScaleYRatio()
{ 
  return imageView.getBoundsInParent().getHeight()/imageView.getImage().getHeight();
}

代码示例来源:origin: org.refcodes/refcodes-graphical-ext-javafx

/**
 * {@inheritDoc}
 */
@Override
public Image getImage() {
  if ( _content instanceof ImageView ) {
    return ((ImageView) _content).getImage();
  }
  else if ( _content instanceof FxLabelDecorator ) {
    return ((FxLabelDecorator) _content).getImage();
  }
  return null;
}

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

EventHandler mouseHandler = new EventHandler<MouseEvent>() {
  @Override
  public void handle(MouseEvent t) {
    ImageView imageView = (ImageView) t.getSource();
    System.out.println("You clicked " + imageView.getImage());
  }
};

for (int i = 0; i < 8; i++) {
  ImageView imageView = new ImageView(im[i]);
  imageView.setOnMouseClicked(mouseHandler);
  flowpane.getChildren().add(imageView);
}

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

private void resetClipXPosition(double x) {
  if (x < 0) {
    x = 0;
  }
  if (x > imgView.getImage().getWidth()) {
    x = imgView.getImage().getWidth();
  }
  imgView.setLayoutX(-x);
  shipCanvas.setLayoutX(-x);
  clip.setX(x);
  logger.trace("Set clip position={}, view and ship canvas layout: {}", x, -x);
}

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

/**
 * Create an element that will layout the <code>childNode</code>
 * horizontally centered within a Dialog.
 * @param childNode that should be centered
 * @return wrapping Pane
 */
public Pane center(ImageView childNode) {
  final int width = IDialog.WRAPPING_WIDTH - 24;
  Pane g = new Pane(childNode);
  double in = (width - childNode.getImage().getWidth())/2;
  g.setLayoutX(in);
  childNode.getImage().widthProperty().addListener((observable, oldValue, newValue) -> {
    double inset = (width - childNode.getImage().getWidth())/2;
    g.setLayoutX(inset);
  });
  return g;
}
/**

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

private boolean scrolledAllToTheRight() {
  return clip.getX() >= imgView.getImage().getWidth() - clip.getWidth();
}

代码示例来源:origin: de.roskenet/springboot-javafx-support

/**
 * Override this to create your own splash pane parent node.
 *
 * @return A standard image
 */
public Parent getParent() {
  final ImageView imageView = new ImageView(getClass().getResource(getImagePath()).toExternalForm());
  final ProgressBar splashProgressBar = new ProgressBar();
  splashProgressBar.setPrefWidth(imageView.getImage().getWidth());
  final VBox vbox = new VBox();
  vbox.getChildren().addAll(imageView, splashProgressBar);
  return vbox;
}

代码示例来源:origin: net.sf.dcutils/dcutils

public void setCenter(Point2D center) {
 this.center = center;
 this.sprite.translateXProperty().set(this.center.getX() - this.sprite.getImage().getWidth() / 2d);
 this.sprite.translateYProperty().set(this.center.getY() - this.sprite.getImage().getHeight() / 2d);
} // END setCenter

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

private void focusOnPoint(Point2D focus) {
  double totalwidth = imgView.getImage().getWidth();
  double focusX = focus.getX();
  double clipX = clip.getX();
  double clipWidth = clip.getWidth();
  double centerX = clipX + clipWidth/2;
  if (clipX == 0.0 && focusX < centerX) {
    // we are all to the left
  } else if (clipX + clipWidth >= totalwidth) {
    // we are all to the right
  } else {
    double x = Math.min(focusX - clipWidth/2, totalwidth - clipWidth);
    resetClipXPosition(x);
  }
}

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

/**
 * set the color of the graphic of the given tab
 *
 * @param tab
 *          - the tab to change
 * @param oldColor
 *          - the old color
 * @param newColor
 *          - the new color
 */
protected void setColor(Tab tab, Color oldColor, Color newColor) {
 if (debug)
  LOGGER.log(Level.INFO, "changing  tab color for " + tab.getId() + " from "
    + oldColor + " to " + newColor);
 Node graphic = tab.getGraphic();
 if (graphic instanceof Glyph) {
  Glyph glyph = (Glyph) graphic;
  glyph.setColor(newColor);
 } else if (graphic instanceof ImageView) {
  // https://docs.oracle.com/javafx/2/image_ops/jfxpub-image_ops.htm
  ImageView imageView = (ImageView) graphic;
  imageView.setImage(reColor(imageView.getImage(), oldColor, newColor));
 }
}

代码示例来源: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: com.jfoenix/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();
}

相关文章