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


Java ImageView.setFitHeight方法代码示例

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


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

示例1: createIcon

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
/**
 * Creates the left side Icon
 * @return Returns a StackPane
 */
public StackPane createIcon(){
    StackPane layout = new StackPane();
    layout.setAlignment(Pos.CENTER);

    final ImageView imageView = new ImageView(
            sample.Main.class.getResource(ICONS_PATH + content.getIconPath() + ICONS_EXT).toString() );

    imageView.setPreserveRatio(true);
    imageView.setSmooth(true);
    imageView.setFitHeight(25.0f);
    imageView.setFitWidth(25.0f);

    layout.getChildren().add(imageView);

    return layout;
}
 
开发者ID:Theldus,项目名称:PSE,代码行数:21,代码来源:ItemView.java

示例2: redrawGrid

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private void redrawGrid() {
	Map<SpriteMakerModel, Boolean> onScreenOrNot = myModel.getIfTileOnScreen();
	for (SpriteMakerModel sprite : onScreenOrNot.keySet()) {
		if (onScreenOrNot.get(sprite) == false) {
			onScreenOrNot.put(sprite, true);
			for (Component c : sprite.getDeprecatedComponents().values()) {
				if (c.getType().equals(Images.TYPE)) {
					Images imageComponent = (Images) c;
					ImageView imageView = new ImageView(imageComponent.image().getFXImage());
					imageView.setFitHeight(myGrid.getHeight() / myModel.getNumRows());
					imageView.setFitWidth(myGrid.getWidth() / myModel.getNumCols());
					Component possiblePosition = sprite.getComponentByType(Position.TYPE);
					if (possiblePosition != null) {
						Position pos = (Position) possiblePosition;
						GamePoint percentPoint = pos.pos();
						GamePoint gridCoords = getCoordOfMouseHover(percentPoint.x()*getScreenWidth(), percentPoint.y()*getScreenHeight());
						Integer xPos = (int) gridCoords.x();
						Integer yPos = (int) gridCoords.y();
						myGrid.add(imageView, xPos, yPos);
					}
				}
			}
		}			
	}
}
 
开发者ID:LtubSalad,项目名称:voogasalad-ltub,代码行数:26,代码来源:ScreenMap.java

示例3: load

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private void load(String fxml, String buttonName, Image background, boolean showDefault) {
    Parent parent = null;
    try {
        parent = FXMLLoader.load(Main.class.getResource("/fxml/" + fxml + ".fxml"));
        panes.put(fxml, parent);
        ImageView imageView = new ImageView(background);
        imageView.setFitHeight(30);
        imageView.setFitWidth(30);
        Button button = new Button(buttonName, imageView);
        button.setAlignment(Pos.BASELINE_LEFT);
        button.setPrefSize(200, 50);
        button.setStyle("-fx-border-width: 0;");
        InterfaceManager.addInterface(Container.create(fxml, button));
        if (showDefault) FrameController.instance.pane.getChildren().add(getInstance(fxml));
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:IzzelAliz,项目名称:LCL,代码行数:19,代码来源:Main.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: newDir

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public void newDir() {
    tilePane.getChildren().clear();
    Stage stage = new Stage();
    if (textAreaPth != "")
        directory = new File(textAreaPth);
    else {
        directory = folderChooser.showDialog(stage);
        if (directory != null) {
            System.out.println("Directory: " + directory);
         }
    }

    fileList = directory.listFiles();
    txtDirPath.setText("" + directory);
    for (int i=0; i<fileList.length; i++) {
    					imgView = new ImageView();
		       imgView.setFitWidth(300); // Need these here to get grid properly.
		       imgView.setFitHeight(200);
	 		     tilePane.getChildren().add(imgView);
    }

    Task getDir = new Task<Void>() {
        @Override public Void call() {
          newDir2();
          return null;
        }};
    new Thread(getDir).start();
}
 
开发者ID:maximstewart,项目名称:UDE,代码行数:29,代码来源:BackgroundMngrController.java

示例6: loadIcon

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private void loadIcon(Consumer<ImageView> iconConsumer, String path) {
    final Image icon = new Image(getClass().getResourceAsStream("/" + path));
    final ImageView iconView = new ImageView(icon);
    iconView.setFitWidth(22);
    iconView.setFitHeight(22);
    iconConsumer.accept(iconView);
}
 
开发者ID:LanternPowered,项目名称:LanternNBT,代码行数:8,代码来源:NbtEditor.java

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

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

示例9: limitImageHeight

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public ImageView limitImageHeight(ImageView imageView, double limit) {

        double height = imageView.getImage().getHeight();

        if(height > limit) {
            imageView.setFitHeight(limit);
        } else {
            imageView.setFitHeight(height);
        }

        return imageView;
    }
 
开发者ID:AntonioGabrielAndrade,项目名称:LIRE-Lab,代码行数:13,代码来源:ImageViewConfig.java

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

示例11: createFailureBox

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
private StackPane createFailureBox( ) {
    final StackPane pane = new StackPane( );
    final ImageView background = new ImageView( UIUtils.createImage( "icons/square-red.png" ) );
    background.setPreserveRatio( true );
    background.setFitHeight( 70 );

    final Label label = new Label( );
    label.setFont( UIUtils.font( 32, FontWeight.BOLD ) );
    label.setTextFill( Color.WHITE );
    label.setEffect( UIUtils.shadowEffect( ) );
    label.textProperty( ).bind( _model.failureCountProperty( ).asString( ) );
    pane.getChildren( ).addAll( background, label );
    return pane;
}
 
开发者ID:u2032,项目名称:wall-t,代码行数:15,代码来源:ProjectTileView.java

示例12: constructContentPane

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
@Override
public JFXMasonryPane constructContentPane()
{
    JFXMasonryPane pane = new JFXMasonryPane();

    for (Profile fav : curProfile.getAllFavourites())
    {
        BorderPane tile = new BorderPane();
        tile.setStyle("-fx-background-color: #d3ecff;");

        ImageView profilePicView = new ImageView(fav.getProfileImg());
        profilePicView.setFitHeight(GUIConstants.PROFILE_HEIGHT / 1.5);
        profilePicView.setFitWidth(GUIConstants.PROFILE_WIDTH / 1.5);

        Label label  = new Label(fav.getUsername());
        label.setStyle("-fx-font-weight: bold; -fx-font-size: 16pt;");

        tile.setCenter(profilePicView);
        tile.setBottom(new StackPane(label));

        tile.setOnMouseClicked( e -> {
            GUIController.getPrimaryStage().setScene(new Scene(new ProfileScene(dc,fav,curProfile).getPane(),
                    GUIConstants.SCENE_WIDTH, GUIConstants.SCENE_HEIGHT));
        });

        pane.getChildren().add(tile);
    }

    return pane;
}
 
开发者ID:hadalhw17,项目名称:Artatawe,代码行数:31,代码来源:FavouriteProfileScene.java

示例13: getAssetView

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public static ImageView getAssetView(String filename, int w, int h) {
	if (assets == null)
		loadAssets();
	
	Image asset = getAsset(filename);
	
	if (asset == null)
		return null;
	
	ImageView result = new ImageView(asset);
	
	result.setFitWidth(w);
	result.setFitHeight(h);
	
	return result;
}
 
开发者ID:ScreachFr,项目名称:titanium,代码行数:17,代码来源:AssetsLoader.java

示例14: Splash

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
Splash() {
    state = STATE_SHOW_TITLE;
    stateArg = 0;
    initTimeline();
    background = new ImageView();
    background.setFocusTraversable(true);
    background.setImage(Config.getImages().get(Config.IMAGE_BACKGROUND));
    background.setFitWidth(Config.SCREEN_WIDTH);
    background.setFitHeight(Config.SCREEN_HEIGHT);
    background.setOnMousePressed(new EventHandler<MouseEvent>() {
        public void handle(MouseEvent me) {
            Main.getMainFrame().startGame();
        }
    });
    background.setOnKeyPressed(new EventHandler<KeyEvent>() {
        public void handle(KeyEvent ke) {
            Main.getMainFrame().startGame();
        }
    });
    brick = new ImageView();
    brick.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BRICK));
    brick.setTranslateX(-1000);
    brick.setTranslateY(brick.getImage().getHeight());
    brickShadow = new ImageView();
    brickShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BRICKSHADOW));
    brickShadow.setTranslateX(-1000);
    breaker = new ImageView();
    breaker.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BREAKER));
    breaker.setTranslateX(-1000);
    breaker.setTranslateY(brick.getTranslateY() + brick.getImage().getHeight() * 5 / 4);
    breakerShadow = new ImageView();
    breakerShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_BREAKERSHADOW));
    breakerShadow.setTranslateX(-1000);
    strike = new ImageView();
    strike.setImage(Config.getImages().get(Config.IMAGE_SPLASH_STRIKE));
    strike.setTranslateY(brick.getTranslateY() -
        (strike.getImage().getHeight() - brick.getImage().getHeight()) / 2);
    strike.setVisible(false);
    pressanykey = new ImageView();
    pressanykey.setImage(Config.getImages().get(Config.IMAGE_SPLASH_PRESSANYKEY));
    pressanykey.setTranslateX((Config.SCREEN_WIDTH - pressanykey.getImage().getWidth()) / 2);
    double y = breaker.getTranslateY() + breaker.getImage().getHeight();
    pressanykey.setTranslateY(y + (Config.SCREEN_HEIGHT - y) / 2);
    pressanykey.setOpacity(0);
    strikeShadow = new ImageView();
    strikeShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_STRIKESHADOW));
    strikeShadow.setTranslateX(-1000);
    pressanykeyShadow = new ImageView();
    pressanykeyShadow.setImage(Config.getImages().get(Config.IMAGE_SPLASH_PRESSANYKEYSHADOW));
    pressanykeyShadow.setTranslateX(-1000);
    sun = new ImageView();
    sun.setImage(Config.getImages().get(Config.IMAGE_SPLASH_SUN));
    sun.setTranslateX(-1000);
    NODES = new ImageView[] {brick, breaker, strike, pressanykey};
    NODES_SHADOWS = new ImageView[] {brickShadow, breakerShadow, strikeShadow, pressanykeyShadow};
    Group group = new Group();
    group.getChildren().add(background);
    group.getChildren().addAll(NODES_SHADOWS);
    group.getChildren().addAll(NODES);
    group.getChildren().add(sun);
    getChildren().add(group);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:63,代码来源:Splash.java

示例15: ChangeInstru

import javafx.scene.image.ImageView; //导入方法依赖的package包/类
public ChangeInstru(Instru instru) {

        this.instru = instru;
        GridPane gridpane = new GridPane();

        // création des images des 3 instruments
        ImageView piano = new ImageView(new Image(ChangeInstru.class.getResourceAsStream("images/piano.png")));
        piano.setFitHeight(50);
        piano.setPreserveRatio(true);
        ImageView guitare = new ImageView(new Image(ChangeInstru.class.getResourceAsStream("images/guitare.png")));
        guitare.setFitHeight(50);
        guitare.setPreserveRatio(true);
        ImageView orgue = new ImageView(new Image(ChangeInstru.class.getResourceAsStream("images/orgue.png")));
        orgue.setFitHeight(50);
        orgue.setPreserveRatio(true);

        // on ajoute nos images à notre layout
        gridpane.add(piano, 1, 0);
        gridpane.add(guitare, 1, 1);
        gridpane.add(orgue, 1, 2);
        gridpane.setVgap(15);

        // création des boutons radio
        ToggleGroup groupe = new ToggleGroup();
        rb_piano = new RadioButton();
        rb_guitare = new RadioButton();
        rb_orgue = new RadioButton();
        rb_piano.setToggleGroup(groupe);
        rb_guitare.setToggleGroup(groupe);
        rb_orgue.setToggleGroup(groupe);
        rb_piano.setFocusTraversable(false);
        rb_guitare.setFocusTraversable(false);
        rb_orgue.setFocusTraversable(false);
        rb_piano.setSelected(true);// le piano est l'instrument sélectionné par défaut

        // ajout d'un ChangeListener au groupe de boutons radio
        groupe.selectedToggleProperty().addListener(new ChangeListener() {
            public void changed(ObservableValue observable, Object oldValue, Object newValue) {
                if (newValue.equals(rb_piano))
                    instru.set_instrument(0);// numéro MIDI du piano = 0
                else if (newValue.equals(rb_guitare))
                    instru.set_instrument(26);// numéro MIDI de la guitare = 26
                else
                    instru.set_instrument(16);// numéro MIDI de l'orgue = 16
            }
        });

        // on ajoute les boutons radio au layout
        gridpane.add(rb_piano, 0, 0);
        gridpane.add(rb_guitare, 0, 1);
        gridpane.add(rb_orgue, 0, 2);
        gridpane.setHgap(20);

        this.getChildren().add(gridpane);

        this.setTranslateX(100);
        this.setTranslateY(30);

    }
 
开发者ID:schwabdidier,项目名称:GazePlay,代码行数:60,代码来源:ChangeInstru.java


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