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


Java ImageView.setFitWidth方法代码示例

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


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

示例1: createTimeLeftInfoBox

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private HBox createTimeLeftInfoBox( final TileViewModel build ) {
    final HBox lastBuildInfoPart = new HBox( );
    lastBuildInfoPart.setAlignment( Pos.CENTER );

    final ImageView lastBuildIcon = new ImageView( UIUtils.createImage( "icons/timeLeft.png" ) );
    lastBuildIcon.setPreserveRatio( true );
    lastBuildIcon.setFitWidth( 32 );

    final Label timeLeftLabel = new Label( );
    timeLeftLabel.setMinWidth( 110 );
    timeLeftLabel.setTextAlignment( CENTER );
    timeLeftLabel.setAlignment( Pos.CENTER );
    timeLeftLabel.setFont( UIUtils.font( 32, FontWeight.BOLD ) );
    timeLeftLabel.setTextFill( Color.WHITE );
    timeLeftLabel.setWrapText( true );
    timeLeftLabel.setEffect( UIUtils.shadowEffect( ) );
    timeLeftLabel.textProperty( ).bind( createStringBinding( ( ) -> {
        final java.time.Duration timeLeft = build.timeLeftProperty( ).get( );
        return ( timeLeft.isNegative( ) ? "+ " : "" ) + ( abs( timeLeft.toMinutes( ) ) + 1 ) + "\nmin";
    }, build.timeLeftProperty( ) ) );

    lastBuildInfoPart.getChildren( ).addAll( lastBuildIcon, timeLeftLabel );
    return lastBuildInfoPart;
}
 
开发者ID:u2032,项目名称:wall-t,代码行数:25,代码来源:TileView.java

示例2: display

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public static void display(String title, String message)
{
	Stage window= new Stage();
	window.initModality(Modality.APPLICATION_MODAL);
	//window.setAlwaysOnTop(true);
	window.getIcons().add(new Image("/pic/slogo.png"));
	window.setTitle(title);
	Label label= new Label();
	label.setText(message);
	label.setStyle("-fx-font-size:14px;");
	
	ImageView imageView = new ImageView(ICON);
	imageView.setFitWidth(40);
	imageView.setFitHeight(40);
       Label labelimage = new Label("",imageView);
	
	// two buttons
	Button okbtn= new Button("Ok");
	okbtn.setOnAction(e -> {
		answer= false;
		window.close();
	});
	okbtn.setId("red");
	HBox hbox= new HBox(10);
	hbox.setAlignment(Pos.CENTER_LEFT);
	hbox.setPadding(new Insets(10,5,10,5));
	hbox.getChildren().addAll(labelimage,label);
	VBox layout= new VBox(15);
	layout.setAlignment(Pos.CENTER_RIGHT);
	layout.setPadding(new Insets(10,5,10,5));
	layout.getChildren().addAll(hbox,okbtn);
	layout.setStyle("-fx-background-color: linear-gradient(#E4EAA2, #9CD672);");
	Scene scene= new Scene(layout);
	scene.getStylesheets().add(ErrorMessage.class.getResource("confirm.css").toExternalForm());
	window.setScene(scene);
	window.setResizable(false);
	window.showAndWait();
}
 
开发者ID:mikemacharia39,项目名称:gatepass,代码行数:39,代码来源:ErrorMessage.java

示例3: InferenceRuleView

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
/**
 * Adds the content for showing the inference rules to the TabPane in the proof
 * @param tabPane
 *
 */
public InferenceRuleView(TabPane tabPane) {


    //load the image
    Image image = new Image("inferenceRules.png");
    ImageView iv1 = new ImageView();
    iv1.setImage(image);
    iv1.setSmooth(true);
    iv1.setPreserveRatio(true);

    //putting the image on a scrollpane
    ScrollPane sp=new ScrollPane();
    sp.getStyleClass().add("rulesView");
    tab = new ViewTab("Inference Rules",this);
    sp.setContent(iv1);
    tabPane.getTabs().add(tab);
    tab.setContent(sp);
    tabPane.getSelectionModel().select(tab);

    //used for getting screensize
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    //Avoids scaling too much
    double w=primaryScreenBounds.getWidth()/2;
    iv1.setFitWidth(w);
}
 
开发者ID:nonilole,项目名称:Conan,代码行数:31,代码来源:InferenceRuleView.java

示例4: PatientCardPrescription

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public PatientCardPrescription(Patient patient) {
    
    imageView = new ImageView();
    vBox = new VBox();
    label = new Label();
    label0 = new Label();
    label1 = new Label();
    
    setAlignment(javafx.geometry.Pos.CENTER);
    setSpacing(5.0);
    getStylesheets().add("/view/prescription/../../css/main.css");
    
    imageView.setFitHeight(108.0);
    imageView.setFitWidth(93.0);
    imageView.setPickOnBounds(true);
    imageView.setPreserveRatio(true);
    showImage(patient);
    
    vBox.setAlignment(javafx.geometry.Pos.CENTER_LEFT);
    
    label.setText(patient.getName());
    
    label0.setText("Age : " + age(patient) + " Years");
    
    String sex = patient.getSex() == 1 ? "Male" : patient.getSex() == 2 ? "Fe-Male" : "Other";
    
    label1.setText("Sex : " + sex);
    vBox.setPadding(new Insets(0.0, 10.0, 0.0, 5.0));
    
    getChildren().add(imageView);
    vBox.getChildren().add(label);
    vBox.getChildren().add(label0);
    vBox.getChildren().add(label1);
    getChildren().add(vBox);
    
}
 
开发者ID:kmrifat,项目名称:Dr-Assistant,代码行数:37,代码来源:PatientCardPrescription.java

示例5: snapshotNode

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private void snapshotNode(Scene scene, Node node) {
    SnapshotParameters params = new SnapshotParameters();
    Bounds layoutBounds = node.getLayoutBounds();
    Bounds bounds = node.localToScene(layoutBounds);

    if (!(bounds.getWidth() > 0 && bounds.getHeight() > 0)) {
        return;
    }

    params.setViewport(new Rectangle2D(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()));
    WritableImage writable = new WritableImage((int) bounds.getWidth(), (int) bounds.getHeight());
    writable = scene.getRoot().snapshot(params, writable);

    ImageView imageView = new ImageView(writable);
    imageView.getStyleClass().add("snapshot-image");
    imageView.setManaged(false);
    imageView.setLayoutX(bounds.getMinX());
    imageView.setLayoutY(bounds.getMinY());
    imageView.setFitWidth(bounds.getWidth());
    imageView.setFitHeight(bounds.getHeight());

    Region rect = new Region();
    rect.getStyleClass().add("snapshot-background");
    rect.setLayoutX(bounds.getMinX() - 5);
    rect.setLayoutY(bounds.getMinY() - 5);
    rect.resize(bounds.getWidth() + 10, bounds.getHeight() + 10);
    rect.setManaged(false);

    Line line = new Line();
    line.setStartX(bounds.getMaxX() + 4);
    line.setStartY(bounds.getMaxY() + 4);
    line.setEndX(bounds.getMaxX() + 200);
    line.setEndY(bounds.getMaxY() + 200);
    line.setStroke(imagePattern);
    line.setStrokeWidth(5);
    line.setManaged(false);

    getChildren().addAll(rect, imageView); //, line);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:40,代码来源:IntroPaneSkin.java

示例6: formatIcon

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private static ImageView formatIcon(final String path)
{
    final ImageView iv = new ImageView(Util.getResource(path));
    iv.setFitWidth(IconButton.SIZE);
    iv.setFitHeight(IconButton.SIZE);
    return iv;
}
 
开发者ID:Leviathan-Studio,项目名称:MineIDE,代码行数:8,代码来源:IconButton.java

示例7: buildItemCell

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private Node buildItemCell(SocialMediaItem item) {
    HBox hbox = new HBox();
    InputStream resource = item.getClass().getResourceAsStream("icon.png");
    if (resource != null) {
        ImageView sourceImage = new ImageView();
        sourceImage.setFitHeight(18);
        sourceImage.setPreserveRatio(true);
        sourceImage.setSmooth(true);
        sourceImage.setCache(true);
        sourceImage.setImage(new Image(resource));
        hbox.getChildren().add(sourceImage);
    }

    if (item.getImage() != null) {
        HBox picture = new HBox();
        picture.setPadding(new Insets(0, 10, 0, 0));
        ImageView imageView = new ImageView(item.getImage());
        imageView.setPreserveRatio(true);
        imageView.setFitWidth(150);
        picture.getChildren().add(imageView);
        hbox.getChildren().add(picture);
    }

    Label text = new Label(item.getBody());
    text.setFont(Font.font(null, 20));
    text.setWrapText(true);
    hbox.getChildren().add(text);

    return hbox;
}
 
开发者ID:PacktPublishing,项目名称:Java-9-Programming-Blueprints,代码行数:31,代码来源:SocialMediaItemViewCell.java

示例8: 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

示例9: MenuItemIcon

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public MenuItemIcon(final String text, final String iconPath)
{
    super(text);
    String path = iconPath.isEmpty() ? "/mineIDE/img/empty.png" : iconPath;

    final ImageView icon = new ImageView(Util.getResource(path));
    icon.setFitWidth(this.ICON_SIZE);
    icon.setFitHeight(this.ICON_SIZE);

    this.setGraphic(icon);
}
 
开发者ID:Leviathan-Studio,项目名称:MineIDE,代码行数:12,代码来源:MenuItemIcon.java

示例10: createIconContent

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public static Node createIconContent() {
    final WritableImage img = new WritableImage(80, 80);
    renderImage(img, 3.0, 12.0, 240.0);
    ImageView iv = new ImageView(img);
    iv.setFitWidth(80);
    iv.setFitHeight(80);
    return iv;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:ImageOperatorSample.java

示例11: 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

示例12: getVisual

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
@Override
public Node getVisual (ImageGraphic imageGraphic) {
    ImageView imageView = super.getImageView(imageGraphic);
    imageView.setFitWidth(myWidth);
    imageView.setFitHeight(myHeight);
    return imageView;
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:8,代码来源:ScaleFactory.java

示例13: backgroundImage

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private Node backgroundImage() {
	Pane pane = new StackPane();
	ImageView image = new ImageView(backgroundImage);
	image.setPreserveRatio(true);
	image.setFitWidth(300);
	pane.getChildren().add(image);
	pane.getStyleClass().add("ltub-background");
	return pane;
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:10,代码来源:MainMenu.java

示例14: getView

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private Node getView () {
    ImageView view = new ImageView(getImage());
    view.setOnDragDetected(e -> setOnDragDetected(e, view));
    view.setFitWidth(Double.parseDouble(myBundle.getString(IMAGE_SIZE)));
    view.setFitHeight(Double.parseDouble(myBundle.getString(IMAGE_SIZE)));
    return view;
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:8,代码来源:SpawnerView.java

示例15: PlayerView

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public PlayerView(Player player, Server server, Application app) {
	this.player = player;
	this.server = server;
	this.app = app;
	
	ImageView copyImage = new ImageView(AssetsLoader.getAsset("copy.png"));
	copyImage.setFitWidth(16);
	copyImage.setFitHeight(16);
	
	ImageView steamImage = new ImageView(AssetsLoader.getAsset("steam.png"));
	steamImage.setFitWidth(16);
	steamImage.setFitHeight(16);
	
	ImageView banImage = new ImageView(AssetsLoader.getAsset("ban.png"));
	banImage.setFitWidth(16);
	banImage.setFitHeight(16);
	
	ImageView kickImage = new ImageView(AssetsLoader.getAsset("kick.png"));
	kickImage.setFitWidth(16);
	kickImage.setFitHeight(16);
	
	kickButton = new Button("", kickImage);
	banButton = new Button("", banImage);
	
	kickButton.setTooltip(new Tooltip("Kick this player"));
	banButton.setTooltip(new Tooltip("Ban this player"));
	
	actionPane = new HBox(kickButton, banButton);
	kickButton.setOnAction(this::kickPlayerAction);
	banButton.setOnAction(this::banPlayerAction);


	steamIDLabel = new Label(player.getSteamId());
	copyButton = new Button("", copyImage);
	steamProfileButton = new Button("", steamImage);
	
	copyButton.setOnAction(this::copySteamIDToClipboardAction);
	steamProfileButton.setOnAction(this::steamProfileAction);
	
	copyButton.setTooltip(new Tooltip("Copy steamID to clipboard"));

	steamPan = new HBox(steamIDLabel, copyButton, steamProfileButton);
	
	
}
 
开发者ID:ScreachFr,项目名称:titanium,代码行数:46,代码来源:PlayerView.java


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