Java Code Examples for javafx.scene.image.ImageView#setLayoutY()

The following examples show how to use javafx.scene.image.ImageView#setLayoutY() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FxmlControl.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public static void paneSize(ScrollPane sPane, ImageView iView) {
        try {
            if (iView == null || iView.getImage() == null
                    || sPane == null) {
                return;
            }
            iView.setFitWidth(sPane.getWidth() - 20);
            iView.setFitHeight(sPane.getHeight() - 20);
            FxmlControl.moveXCenter(sPane, iView);
            iView.setLayoutY(10);
        } catch (Exception e) {
//            logger.error(e.toString());
        }
    }
 
Example 2
Source File: FxmlControl.java    From MyBox with Apache License 2.0 5 votes vote down vote up
public static void imageSize(ScrollPane sPane, ImageView iView) {
        try {
            if (iView == null || iView.getImage() == null
                    || sPane == null) {
                return;
            }
            iView.setFitWidth(iView.getImage().getWidth());
            iView.setFitHeight(iView.getImage().getHeight());
            FxmlControl.moveXCenter(sPane, iView);
            iView.setLayoutY(10);
        } catch (Exception e) {
//            logger.error(e.toString());
        }
    }
 
Example 3
Source File: OverView.java    From CrazyAlpha with GNU General Public License v2.0 4 votes vote down vote up
public OverView() {
    root = new Pane();
    Game.getInstance().resetMedia();

    GameMap map = Game.getInstance().getMapManager().getCurrentMap();
    ImageView mapIv = new ImageView(map.getMapImage());
    mapIv.setFitWidth(Game.getInstance().getWidth());
    mapIv.setFitHeight(Game.getInstance().getHeight());

    Label nameLbl = new Label("Game Over!");
    nameLbl.setTextFill(Color.WHITESMOKE);
    nameLbl.setFont(Game.getInstance().getResouceManager().getFont("Starcraft", 80));
    nameLbl.setLayoutX(50);
    nameLbl.setLayoutY(50);


    Label scoreLbl = new Label();
    scoreLbl.setTextFill(Color.WHITESMOKE);
    scoreLbl.setFont(Game.getInstance().getResouceManager().getFont("Starcraft", 60));
    scoreLbl.setLayoutX(50);
    scoreLbl.setLayoutY(map.getHeight() - scoreLbl.getHeight() - 140);
    if (Game.getInstance().getScore() > Game.getInstance().getDataManager().getHighestScore()) {
        // 刷新高分记录!
        scoreLbl.setText("New Record: " + Game.getInstance().getScore());
        Game.getInstance().getDataManager().setHighestScore(Game.getInstance().getScore());
    } else
        scoreLbl.setText("Score: " + Game.getInstance().getScore());

    Reflection reflection = new Reflection();
    reflection.setFraction(1.0);
    nameLbl.setEffect(reflection);

    ImageView homeBtn = new ImageView(Game.getInstance().getResouceManager().getControl("btn_home"));
    homeBtn.setFitWidth(165 * 1.5);
    homeBtn.setFitHeight(65 * 1.5);

    homeBtn.setLayoutX(map.getWidth() - homeBtn.getFitWidth() - 20);
    homeBtn.setLayoutY(map.getHeight() - homeBtn.getFitHeight() - 60);
    homeBtn.setEffect(reflection);
    homeBtn.setOnMouseEntered(event -> {
        homeBtn.setEffect(new Glow(0.8));
        Game.getInstance().getButtonOverMusic().play();
    });
    homeBtn.setOnMouseExited(event -> {
        homeBtn.setEffect(reflection);
        Game.getInstance().getButtonOverMusic().stop();
    });
    homeBtn.setOnMousePressed(event -> {
        homeBtn.setEffect(new GaussianBlur());
        Game.getInstance().getButtonClickMusic().play();
    });
    homeBtn.setOnMouseReleased(event -> {
        homeBtn.setEffect(new Glow(0.8));
        Game.getInstance().home();
    });

    root.getChildren().add(mapIv);
    root.getChildren().add(nameLbl);
    root.getChildren().add(scoreLbl);
    root.getChildren().add(homeBtn);

    makeFadeTransition(homeBtn, 2000, 1, 0.7);
    makeFadeTransition(mapIv, 3000, 1, 0.8);
    makeScaleTransition(mapIv, 10000, 0.25, 0.25);
}
 
Example 4
Source File: PauseView.java    From CrazyAlpha with GNU General Public License v2.0 4 votes vote down vote up
public PauseView() {
    root = new Pane();
    Game.getInstance().resetMedia();

    map = Game.getInstance().getMapManager().getCurrentMap();
    mapIv = new ImageView(map.getMapImage());
    mapIv.setFitWidth(Game.getInstance().getWidth());
    mapIv.setFitHeight(Game.getInstance().getHeight());

    nameLbl = new Label("CrazyAlpha!");
    nameLbl.setTextFill(Color.WHITESMOKE);
    nameLbl.setFont(Game.getInstance().getResouceManager().getFont("Starcraft", 120));
    nameLbl.setLayoutX(50);
    nameLbl.setLayoutY(50);

    Reflection reflection1 = new Reflection();
    reflection1.setFraction(1.0);
    nameLbl.setEffect(reflection1);

    Reflection reflection02 = new Reflection();
    reflection02.setFraction(0.4);

    resumeBtn = new ImageView(Game.getInstance().getResouceManager().getControl("btn_resume"));
    resumeBtn.setFitWidth(165 * 1.5);
    resumeBtn.setFitHeight(65 * 1.5);
    exitBtn = new ImageView(Game.getInstance().getResouceManager().getControl("btn_exit"));
    exitBtn.setFitWidth(165 * 1.5);
    exitBtn.setFitHeight(65 * 1.5);

    resumeBtn.setLayoutX(map.getWidth() - resumeBtn.getFitWidth() - 20);
    resumeBtn.setLayoutY(map.getHeight() - resumeBtn.getFitHeight() - exitBtn.getFitHeight() - 120);
    resumeBtn.setEffect(reflection02);
    resumeBtn.setOnMouseEntered(event -> {
        resumeBtn.setEffect(new Glow(0.8));
        Game.getInstance().getButtonOverMusic().play();
    });
    resumeBtn.setOnMouseExited(event -> {
        resumeBtn.setEffect(reflection02);
        Game.getInstance().getButtonClickMusic().stop();
    });
    resumeBtn.setOnMousePressed(event -> {
        resumeBtn.setEffect(new GaussianBlur());
        Game.getInstance().getButtonClickMusic().play();
        Game.getInstance().resume();
    });
    resumeBtn.setOnMouseReleased(event -> {
        resumeBtn.setEffect(new Glow(0.8));
    });

    exitBtn.setLayoutX(map.getWidth() - exitBtn.getFitWidth() - 20);
    exitBtn.setLayoutY(map.getHeight() - exitBtn.getFitHeight() - 60);
    exitBtn.setEffect(reflection02);
    exitBtn.setOnMouseEntered(event -> {
        exitBtn.setEffect(new Glow(0.8));
        Game.getInstance().getButtonOverMusic().play();
    });
    exitBtn.setOnMouseExited(event -> {
        exitBtn.setEffect(reflection02);
        Game.getInstance().getButtonOverMusic().stop();
    });
    exitBtn.setOnMousePressed(event -> {
        exitBtn.setEffect(new GaussianBlur());
        Game.getInstance().getButtonClickMusic().play();
    });
    exitBtn.setOnMouseReleased(event -> {
        exitBtn.setEffect(new Glow(0.8));
        Game.getInstance().exit();
    });


    root.getChildren().add(mapIv);
    root.getChildren().add(nameLbl);
    root.getChildren().add(resumeBtn);
    root.getChildren().add(exitBtn);

    makeFadeTransition(resumeBtn, 2000, 1, 0.7);
    makeFadeTransition(exitBtn, 2000, 1, 0.7);
    makeFadeTransition(mapIv, 3000, 1, 0.8);
    makeScaleTransition(mapIv, 10000, 0.25, 0.25);
}
 
Example 5
Source File: LedView.java    From ARMStrong with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * Creates a new instance of Node
 * @param simulator the arm simulator
 */
public LedView(ArmSimulator simulator){

    this.simulator = simulator;

    this.mainPane = new ScrollPane();
    
    ledOff = new Image(getClass().getResource("/resources/ledOff.png").toExternalForm());
    ledOn = new Image(getClass().getResource("/resources/ledOn.png").toExternalForm());
    leverOff = new Image(getClass().getResource("/resources/leverOff.png").toExternalForm());
    leverOn = new Image(getClass().getResource("/resources/leverOn.png").toExternalForm()); 
      
    gameContainer = new HBox();
    ledContainer = new VBox();
    buttonContainer = new VBox();
            
    for(int i=0 ; i < 8 ; i++) { //creating 8 leds at the start of the view
    	IOLed led = simulator.newIOLed();
    	
    	AnchorPane newLedAddress = new AnchorPane();
        ImageView newLedImage = new ImageView();
        
        ledArray.add(led);
    	ledImageArrayList.add(newLedImage);
    	
    	if(led.isOn()) {
        	newLedImage.setImage(ledOn);
        }else {
        	newLedImage.setImage(ledOff);
        }       	

        newLedImage.setLayoutX(0);
        newLedImage.setLayoutY(0);
        Text newAddress = new Text();
        newAddress.setText("0x" + Long.toHexString(led.getPortAddress()) + " Bit N°" + led.shift);
        newAddress.setLayoutX(95);
        newAddress.setLayoutY(55);
        
        newLedAddress.getChildren().addAll(newLedImage, newAddress);
        ledContainer.getChildren().add(newLedAddress);
    }
    
    for(int i=0 ; i < 2 ; i++) { //creating 3 buttons at the start of the view
    	IOButton IOpressButton = simulator.newIOButton();
    	IOSwitch IOleverButton = simulator.newIOSwitch();
    	AnchorPane buttonAndTextAndLeverAndTextAnchorPane = new AnchorPane();
    	       	
    	Text leverText = new Text();
    	leverText.setText("0x" + Long.toHexString(IOpressButton.getPortAddress()) + " Bit N°" + IOpressButton.shift);
    	leverText.setLayoutX(30);
        leverText.setLayoutY(100);

        Text pushingText = new Text();
        pushingText.setText("0x" + Long.toHexString(IOleverButton.getPortAddress()) + " Bit N°" + IOleverButton.shift);
        pushingText.setLayoutX(30);
        pushingText.setLayoutY(190);
        
        ImageView lever = new ImageView(leverOff);            
    	Button leverButton =  new Button("", lever);
    	Button pushingButton = new Button("", new ImageView(new Image(getClass().getResource("/resources/pushingButton.png").toExternalForm())));

    	leverButton.setOnAction(ActionEvent -> {
    		IOleverButton.flip();       
    		refresh();
        });
    	
    	pushingButton.setOnAction(ActionEvent -> {
    		IOpressButton.push();     
    		refresh();
        });


    	leverButton.setLayoutX(70);
        leverButton.setLayoutY(25);
    	pushingButton.setLayoutX(70);
        pushingButton.setLayoutY(115);        
        
    	leverButtonArray.add(IOleverButton);
    	pressButtonArray.add(IOpressButton);
    	leverImageArrayList.add(lever);
    	
    	buttonAndTextAndLeverAndTextAnchorPane.getChildren().addAll(leverButton, leverText, pushingButton, pushingText);
    	buttonContainer.getChildren().add(buttonAndTextAndLeverAndTextAnchorPane);
    }
    
    gameContainer.getChildren().addAll(ledContainer, buttonContainer);
    
    this.dockNode = new DockNode(mainPane, "Led Game", new ImageView(dockImage));
    
    dockNode.setPrefSize(300,666);
    
    this.mainPane.setContent(gameContainer);  
    this.mainPane.setFitToWidth(true);
    this.mainPane.setFitToHeight(true);  
    this.mainPane.setHmin(dockNode.getHeight());
}