当前位置: 首页>>代码示例>>Java>>正文


Java Image.getWidth方法代码示例

本文整理汇总了Java中javafx.scene.image.Image.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Image.getWidth方法的具体用法?Java Image.getWidth怎么用?Java Image.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.image.Image的用法示例。


在下文中一共展示了Image.getWidth方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: adaptMapPaneToImage

import javafx.scene.image.Image; //导入方法依赖的package包/类
private void adaptMapPaneToImage(Image image) {
    mapPane.getChildren().remove(importMapText);

    if(image.getWidth() < mapViewPort.getWidth())
        mapViewPort.setMaxWidth(image.getWidth());

    if(image.getHeight() < mapViewPort.getHeight())
        mapViewPort.setMaxHeight(image.getHeight());

    mapPane.setPrefWidth(image.getWidth());
    mapPane.setMinWidth(image.getWidth());
    mapPane.setPrefHeight(image.getHeight());
    mapPane.setMinHeight(image.getHeight());

    mapPane.setAlignment(Pos.TOP_LEFT);
    mapPane.getChildren().add(new ImageView(image));
}
 
开发者ID:Moccko,项目名称:campingsimulator2017,代码行数:18,代码来源:MapCreatorView.java

示例2: resetState

import javafx.scene.image.Image; //导入方法依赖的package包/类
private void resetState(Scene scene) {
    Image image = new Image(pictureResourceLocation);

    double imageWidth = image.getWidth();
    double imageHeight = image.getHeight();
    double imageHeightToWidthRatio = imageHeight / imageWidth;

    double initialHeight = scene.getHeight() * pictureInitialHeightToSceneHeightRatio;
    double initialWidth = initialHeight / imageHeightToWidthRatio;

    double positionX = (scene.getWidth() - initialWidth) / 2;
    double positionY = (scene.getHeight() - initialHeight) / 2;

    setFill(new ImagePattern(image));

    setX(positionX);
    setY(positionY);
    setWidth(initialWidth);
    setHeight(initialHeight);

    setTranslateX(0);
    setScaleX(1);
    setScaleY(1);
    setScaleZ(1);

    setOpacity(0);

    toFront(); // bug when it is uncommented (with bloc at least).
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:30,代码来源:Bravo.java

示例3: setFillImageKeepingAspectRatio

import javafx.scene.image.Image; //导入方法依赖的package包/类
public void setFillImageKeepingAspectRatio(Rectangle rectangle, Image image, Dimension2D gamingContextDimension2D) {
    double imageWidth = image.getWidth();
    double imageHeight = image.getHeight();
    double imageHeightToWidthRatio = imageHeight / imageWidth;

    double initialHeight = rectangle.getHeight();
    double initialWidth = initialHeight / imageHeightToWidthRatio;

    double positionX = (gamingContextDimension2D.getWidth() - initialWidth) / 2;
    double positionY = (gamingContextDimension2D.getHeight() - initialHeight) / 2;

    rectangle.setFill(new ImagePattern(image));

    rectangle.setX(positionX);
    rectangle.setY(positionY);
    rectangle.setWidth(initialWidth);
    rectangle.setHeight(initialHeight);

    rectangle.setTranslateX(0);
    rectangle.setScaleX(1);
    rectangle.setScaleY(1);
    rectangle.setScaleZ(1);
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:24,代码来源:AspectRatioImageRectangleUtil.java

示例4: createErrorImageRectangle

import javafx.scene.image.Image; //导入方法依赖的package包/类
private Rectangle createErrorImageRectangle() {
    final Image image = new Image("data/common/images/error.png");

    double imageWidth = image.getWidth();
    double imageHeight = image.getHeight();
    double imageHeightToWidthRatio = imageHeight / imageWidth;

    double rectangleWidth = imageRectangle.getFitWidth() / 3;
    double rectangleHeight = imageHeightToWidthRatio * rectangleWidth;

    double positionX = imageRectangle.getX() + (imageRectangle.getFitWidth() - rectangleWidth) / 2;
    double positionY = imageRectangle.getY() + (imageRectangle.getFitHeight() - rectangleHeight) / 2;

    Rectangle errorImageRectangle = new Rectangle(rectangleWidth, rectangleHeight);
    errorImageRectangle.setFill(new ImagePattern(image));
    errorImageRectangle.setX(positionX);
    errorImageRectangle.setY(positionY);
    errorImageRectangle.setOpacity(0);
    errorImageRectangle.setVisible(false);
    return errorImageRectangle;
}
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:22,代码来源:WhereIsIt.java

示例5: drawShuffledPieces

import javafx.scene.image.Image; //导入方法依赖的package包/类
public void drawShuffledPieces() {
    fillBackgroundWithColor(Color.BLACK);

    if (shuffledPieces.isEmpty()) {
        return;
    }

    Image originalImage = shuffledPieces.get(0).getOriginalImage();
    Iterator<Piece> iterator = shuffledPieces.iterator();
    for (int h = 0; h < AppConstants.NUM_HORIZONTAL_SLICES; h++) {
        int originalXPos = (int) ((originalImage.getWidth() / AppConstants.NUM_HORIZONTAL_SLICES) * h);

        for (int v = 0; v < AppConstants.NUM_VERTICAL_SLICES; v++) {
            int originalYPos = (int) ((originalImage.getHeight() / AppConstants.NUM_VERTICAL_SLICES) * v);
            Piece piece = iterator.hasNext() ? iterator.next() : null;
            if (piece != null) {
                graphicsContext.getPixelWriter().setPixels(
                        originalXPos, originalYPos,
                        piece.getWidth(), piece.getHeight(),
                        piece.getOriginalImage().getPixelReader(),
                        piece.getXPos(), piece.getYPos());
            }
        }
    }
}
 
开发者ID:luxmeter,项目名称:puzzlefx,代码行数:26,代码来源:Controller.java

示例6: centerImage

import javafx.scene.image.Image; //导入方法依赖的package包/类
private void centerImage() {
    Image img = showImage.getImage();
    if (img != null) {
        double w = 0;
        double h = 0;

        double ratioX = showImage.getFitWidth() / img.getWidth();
        double ratioY = showImage.getFitHeight() / img.getHeight();

        double reducCoeff = 0;
        if(ratioX >= ratioY) {
            reducCoeff = ratioY;
        } else {
            reducCoeff = ratioX;
        }

        w = img.getWidth() * reducCoeff;
        h = img.getHeight() * reducCoeff;

        showImage.setX((showImage.getFitWidth() - w) / 2);
        showImage.setY((showImage.getFitHeight() - h) / 2);

    }
}
 
开发者ID:symphonicon,项目名称:Fav-Track,代码行数:25,代码来源:mainController.java

示例7: getMask

import javafx.scene.image.Image; //导入方法依赖的package包/类
@Override
public Set<Point2D> getMask(Image image, Color color) {
	PixelReader pixelReader = image.getPixelReader();
	Set<Point2D> mask = new HashSet<>();
	int pixel;
	boolean isTransparent, isBackgroundColor;
	for(int i =0; i < image.getWidth(); i++){
		for(int j = 0; j < image.getHeight(); j++){
			pixel = pixelReader.getArgb(i, j);
			//check the transparency of the pixel at (i,j)
			isTransparent = (pixel >> 24) == 0x00;				
			Color backgroundColor = pixelReader.getColor(i, j);
			isBackgroundColor = (color.equals(backgroundColor));
			if(!isTransparent && !isBackgroundColor){
				Point2D p = new Point2D(i,j);
				mask.add(p);
			}
		}
	}
	return mask;
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:22,代码来源:ImageTransformation.java

示例8: Bonus

import javafx.scene.image.Image; //导入方法依赖的package包/类
public Bonus(int type) {
    content = new ImageView();
    getChildren().add(content);
    this.type = type;
    Image image = Config.getBonusesImages().get(type);
    width = (int)image.getWidth() - Config.SHADOW_WIDTH;
    height = (int)image.getHeight() - Config.SHADOW_HEIGHT;
    content.setImage(image);
    setMouseTransparent(true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:Bonus.java

示例9: prefWidth

import javafx.scene.image.Image; //导入方法依赖的package包/类
@Override
public double prefWidth(double height) {
  Image image = getImage();
  if (image == null) {
    return minWidth(height);
  }
  return image.getWidth();
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:9,代码来源:ResizableImageView.java

示例10: Photo

import javafx.scene.image.Image; //导入方法依赖的package包/类
/**
 * Constructor
 *
 * @param photoURI the URI of the photo file.
 */
public Photo(URI photoURI) throws FileNotFoundException {
    file = new File(photoURI);
    String filePath = file.getAbsolutePath();
    Image img = buildImage();

    baseName = FilenameUtils.getBaseName(filePath);
    format = FilenameUtils.getExtension(filePath);
    height = img.getHeight();
    width = img.getWidth();
}
 
开发者ID:polimi-mt-acg,项目名称:course-examples,代码行数:16,代码来源:Photo.java

示例11: computeActualScale

import javafx.scene.image.Image; //导入方法依赖的package包/类
/**
 * Computes the actual scaling of an Image in an ImageView. If the preserveRatio
 * property on the ImageView is false the scaling has no meaning so NaN is
 * returned.
 *
 * @return The scale factor of the image in relation to display coordinates
 */
public double computeActualScale() {

    if (!imageView.isPreserveRatio()) {
        actualScale = Double.NaN;
    }
    else if (doScaleRecompute) {
        Image localImage = imageView.getImage();
        Rectangle2D localViewport = imageView.getViewport();

        double w = 0;
        double h = 0;
        if (localViewport != null && localViewport.getWidth() > 0 && localViewport.getHeight() > 0) {
            w = localViewport.getWidth();
            h = localViewport.getHeight();
        } else if (localImage != null) {
            w = localImage.getWidth();
            h = localImage.getHeight();
        }

        double localFitWidth = imageView.getFitWidth();
        double localFitHeight = imageView.getFitHeight();

        if (w > 0 && h > 0 && (localFitWidth > 0 || localFitHeight > 0)) {
            if (localFitWidth <= 0 || (localFitHeight > 0 && localFitWidth * h > localFitHeight * w)) {
                w = w * localFitHeight / h;
            } else {
                w = localFitWidth;
            }

            actualScale = w / localImage.getWidth();
        }

        doScaleRecompute = false;

    }

    return actualScale;
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:46,代码来源:ImageViewExt.java

示例12: createPieces

import javafx.scene.image.Image; //导入方法依赖的package包/类
public static List<Piece> createPieces(Image originalImage, int numHorizontalSlices, int numVerticalSlices) {
    List<Piece> pieces = new ArrayList();
    for (int h = 0; h < numHorizontalSlices; h++) {
        int originalXPos = (int) ((originalImage.getWidth() / numHorizontalSlices) * h);
        int width = (int) (originalImage.getWidth() / numHorizontalSlices);

        for (int v = 0; v < numVerticalSlices; v++) {
            int originalYPos = (int) ((originalImage.getHeight() / numVerticalSlices) * v);
            int height = (int) (originalImage.getHeight() / numVerticalSlices);
            pieces.add(new Piece(originalImage, originalXPos, originalYPos, width, height));
        }
    }
    return Collections.unmodifiableList(pieces);
}
 
开发者ID:luxmeter,项目名称:puzzlefx,代码行数:15,代码来源:Piece.java

示例13: width

import javafx.scene.image.Image; //导入方法依赖的package包/类
public double width() {
	Image image = getFXImage();
	if (image != null) {
		return (image.getWidth() >= 100) ? 100 : image.getWidth();
	}
	else {
		return 0;
	}
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:10,代码来源:LtubImage.java

示例14: mkRoot

import javafx.scene.image.Image; //导入方法依赖的package包/类
@Override
public Node mkRoot() {


	Image image = new Image(LenaSample.LENA);

	GesturePane gesturePane = new GesturePane(new ImageView(image));
	gesturePane.setMaxSize(image.getWidth(), image.getHeight());

	ImageView background = new ImageView(LenaSample.LENA);
	background.setFitWidth(image.getWidth());
	background.setFitHeight(image.getHeight());

	Rectangle shade = new Rectangle(image.getWidth(),
			                               image.getHeight(),
			                               Color.grayRgb(0, 0.5));
	Rectangle viewRect = new Rectangle();
	viewRect.setStroke(Color.WHITE);
	viewRect.setStrokeWidth(2);
	viewRect.setFill(Color.WHITE);
	// shade * rect
	Group group = new Group(shade, viewRect);
	group.setBlendMode(BlendMode.MULTIPLY);
	Pane viewportSim = new Pane(background, group);
	viewportSim.maxWidthProperty().bind(background.fitWidthProperty());
	viewportSim.maxHeightProperty().bind(background.fitHeightProperty());

	gesturePane.targetViewportProperty().addListener((o, p, n) -> {
		viewRect.setTranslateX(n.getMinX());
		viewRect.setTranslateY(n.getMinY());
		viewRect.setWidth(n.getWidth());
		viewRect.setHeight(n.getHeight());
	});

	HBox box = new HBox(gesturePane, viewportSim);
	box.setAlignment(Pos.CENTER);
	VBox.setVgrow(box, Priority.ALWAYS);
	Label description = new Label("Zoom and scroll on the left image(wrapped in a GesturePane)" +
			                              "; the right image will reflect the actual viewport " +
			                              "of the current transformation");
	description.setWrapText(true);
	description.setPadding(new Insets(16));
	return new VBox(description, box);
}
 
开发者ID:tom91136,项目名称:GestureFX,代码行数:45,代码来源:ViewportRectSample.java


注:本文中的javafx.scene.image.Image.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。