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


Java ImageView.setViewport方法代码示例

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


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

示例1: ImagePropertiesSample

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public ImagePropertiesSample() {
    //we can set image properties directly during creation
    ImageView sample1 = new ImageView(new Image(url, 30, 70, false, true));

    ImageView sample2 = new ImageView(new Image(url));
    //image can be resized to preferred width
    sample2.setFitWidth(200);
    sample2.setPreserveRatio(true);
    
    ImageView sample3 = new ImageView(new Image(url));
    //image can be resized to preferred height
    sample3.setFitHeight(20);
    sample3.setPreserveRatio(true);
    
    ImageView sample4 = new ImageView(new Image(url));
    //one can resize image without preserving ratio between height and width
    sample4.setFitWidth(40);
    sample4.setFitHeight(80);
    sample4.setPreserveRatio(false);
    sample4.setSmooth(true); //the usage of the better filter

    ImageView sample5 = new ImageView(new Image(url));
    sample5.setFitHeight(60);
    sample5.setPreserveRatio(true);
    //viewport is used for displaying the part of image
    Rectangle2D rectangle2D = new Rectangle2D(50, 200, 120, 60);
    sample5.setViewport(rectangle2D);

    //add the imageviews to layout
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(sample1, sample3, sample4, sample5);

    //show the layout
    VBox vb = new VBox(10);
    vb.getChildren().addAll(hBox, sample2);
    getChildren().add(vb);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:39,代码来源:ImagePropertiesSample.java

示例2: createIconContent

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public static Node createIconContent() {
    //TODO better icon?
    ImageView iv = new ImageView(BRIDGE);
    iv.setFitWidth(80);
    iv.setFitHeight(80);
    iv.setViewport(new Rectangle2D(0, 85, 330, 330));
    return iv;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:ImagePropertiesSample.java

示例3: createIconContent

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public static Node createIconContent() {
    ImageView iv = new ImageView(BOAT);
    iv.setFitWidth(80);
    iv.setFitHeight(80);
    iv.setViewport(new Rectangle2D(90,0,332,332));
    final SepiaTone SepiaTone = new SepiaTone();
    SepiaTone.setLevel(1);
    iv.setEffect(SepiaTone);
    return iv;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:11,代码来源:SepiaToneSample.java

示例4: updateItem

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
@Override
protected void updateItem(Object item, boolean empty) {
	super.updateItem(item, empty);

	this.setAlignment(Pos.CENTER);

	if (item != null) {
		if (item instanceof String) {
			setText((String) item);
			setGraphic(null);
		} else if (item instanceof Image) {
			setText(null);
			ImageView imageView = new ImageView((Image) item);

			double width = ((Image) item).getWidth();
			double height = ((Image) item).getHeight();
			double x = 0;
			double y = height / 4;

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

			imageView.setViewport(croppedPortion);
			imageView.setFitWidth(180);
			imageView.setFitHeight(50);
			imageView.setSmooth(true);
			setGraphic(imageView);
		} else {
			setText(null);
			setGraphic(null);
		}
	}
}
 
开发者ID:Team-Sprout,项目名称:Clipcon-Client,代码行数:34,代码来源:MainScene.java


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