Package com.vengo.test.ui

Source Code of com.vengo.test.ui.UserInterface

package com.vengo.test.ui;
import java.awt.Color;

import java.awt.Dimension;
import javafx.application.Platform;
import javafx.embed.swing.JFXPanel;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;

public class UserInterface
{
  static JPanel root=new JPanel();
  static JPanel cards;
  static JPanel jpanel=new JPanel();
  static JPanel jpanel2=new JPanel();
  static final JFXPanel jfxpanel=new JFXPanel();
  static final JFXPanel jfxpanel2=new JFXPanel();
  static final JFXPanel jfxpanel3=new JFXPanel();//make animation2
 
  static final JFXPanel jfxpanel4=new JFXPanel();//
  static final JFXPanel jfxpanel5=new JFXPanel();
  static final SelectionPanel selectionpanel = new SelectionPanel();
  static final waitvendingpanel processing=new waitvendingpanel();
  static final Media media=new Media("file:///C:/assets/movies/swiping2.mp4");
  static final MediaPlayer mediaPlayer = new MediaPlayer(media);
  static final Media media2=new Media("file:///C:/assets/movies/vending.mp4");
  static final MediaPlayer mediaPlayer2 = new MediaPlayer(media2);
  private static Model model;
  static JFrame frame;
  static ImageView iv1;
  static StartPanel startpanel=new StartPanel( );
  /**
   * @param args
   */
  public static void main(String[] args)
  {
    SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
            initAndShowGUI();
            }
        });
    }
 
  public  static void initAndShowGUI()
  {  
    frame = new JFrame();
    frame.setUndecorated(true);
    frame.setResizable(false);
      frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
     
      jpanel.setBackground(Color.gray)
      jpanel2.setBackground(Color.gray)
      jfxpanel.setBackground(Color.gray)
      jfxpanel2.setBackground(Color.gray);
      jfxpanel3.setBackground(Color.gray);
      jfxpanel4.setBackground(Color.gray);
      jfxpanel5.setBackground(Color.gray);
        
        jfxpanel3.add(startpanel)
    frame.getContentPane().add(jfxpanel3);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocation(0,0);
      frame.setPreferredSize(new Dimension(1280, 800));
    frame.pack();
    frame.setVisible(true);

    Platform.runLater(new Runnable(){
      @Override
      public void run()
      {
        initFX(jfxpanel);
        initFX2(jfxpanel2);
        initFX4(jfxpanel4);
        initFX5(jfxpanel5);
          //initFX3(jfxpanel3);
       
      }
    });
   
   
    System.out.println("Free memory: " +
          ((double)Runtime.getRuntime().freeMemory()/1024/1024 + "/" + (double)Runtime.getRuntime().totalMemory()/1024/1024) + "MB");
  }
 
 
  private static void initFX(JFXPanel fxPanel) {
        // This method is invoked on JavaFX thread
        Scene scene = createScene();
        fxPanel.setScene(scene);
    }
 
  private static void initFX2(JFXPanel fxPanel) {
        // This method is invoked on JavaFX thread
        Scene scene = createScene2();
        fxPanel.setScene(scene);
    }
 
  private static void initFX4(JFXPanel fxPanel) {
        // This method is invoked on JavaFX thread
        Scene scene = swipScene();
       
        fxPanel.setScene(scene);
    }
 
 
  private static void initFX5(JFXPanel fxPanel) {
        // This method is invoked on JavaFX thread
        Scene scene = ProcessingScene();
        fxPanel.setScene(scene);
    }
 
  private static Scene createScene()//Fading in and Fading out Animation
    {
      Group root = new Group();
        Scene scene = new Scene(root);
        model = new Model(root);
        root.getChildren().setAll(model.ivScene[0], model.ivScene[1]);
        model.play();
          return scene;
    }
 
   private static Scene createScene2() //Fading in and Fading out Animation for return
     {
      Group root = new Group();
        Scene scene = new Scene(root);
        model = new Model(root);
        root.getChildren().setAll(model.ivScene[0], model.ivScene[1]);
        model.play();
        return scene;      
     }
        
    private static Scene swipScene() //swiping card animation
      {
     
      Image image=new Image("file:///C:/vengo/images/receipt.png");
      iv1=new ImageView();
        iv1.setImage(image)
      Group  root  =  new  Group();
          Label label1=new Label("Test label");
          Scene  scene  =  new  Scene(root);
          Text  text  =  new  Text();
          Text  text2  =  new  Text();
          text2.setText("Jafar\nAzad\nAdam\nSteve\nMr.B\nDavid\nArthur\nWEILONG");
          text2.setFont(Font.font ("Verdana", 40));
          //text.setLayoutX(10);
          //text.setLayoutY(10);
          text.setFont(Font.font ("Verdana", 40));
          text.setText("Brain");
          Label label = new Label("Test Label:");
          TextField tb = new TextField();
          Button button = new Button("Button...");
          // HBox with spacing = 5
          HBox hbox=new HBox(120);
          hbox.getChildren().addAll(text, text2);
          VBox vbox=new VBox();
      hbox.setStyle("-fx-padding:300 150 100 50");
          //hbox.setAlignment(Pos.CENTER);
      mediaPlayer.setAutoPlay(true);
      mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);   
      MediaView mediaView = new MediaView(mediaPlayer);
      StackPane.setAlignment(iv1, Pos.CENTER_LEFT);
      StackPane stack=new StackPane();
        StackPane stack2=new StackPane();
        //stack2.getChildren().addAll(iv1,vbox);
      stack2.getChildren().addAll(iv1,hbox);
      stack.getChildren().addAll(mediaView,stack2);
      ((Group)scene.getRoot()).getChildren().addAll(stack, stack2);
          return scene;    
      }
   
    private static Scene ProcessingScene()// Vending processing animation
      {
      Group root = new Group();
      Scene scene = new Scene(root,500,500 )
      mediaPlayer2.setAutoPlay(true);
      mediaPlayer2.setCycleCount(MediaPlayer.INDEFINITE);     
      MediaView mediaView = new MediaView(mediaPlayer2);
      ((Group)scene.getRoot()).getChildren().add(mediaView);
            return scene;
      }
   
    /*jfxpanel3.addMouseListener(new MouseListener()
    {
     
      @Override
      public void mouseClicked(java.awt.event.MouseEvent arg0) {
        // TODO Auto-generated method stub
        Transitionpanel.transitiion(UserInterface.startpanel);
      }

      @Override
      public void mouseEntered(java.awt.event.MouseEvent arg0) {
        // TODO Auto-generated method stub
       
      }

      @Override
      public void mouseExited(java.awt.event.MouseEvent arg0) {
        // TODO Auto-generated method stub
       
      }

      @Override
      public void mousePressed(java.awt.event.MouseEvent arg0) {
        // TODO Auto-generated method stub
       
      }

      @Override
      public void mouseReleased(java.awt.event.MouseEvent arg0) {
        // TODO Auto-generated method stub
      }
    });
     */ 
   
    /*private static void initFX3(JFXPanel fxPanel) {//Setting the scene for animation2
        // This method is invoked on JavaFX thread
        Scene scene = createScene3();
        fxPanel.setScene(scene);
    }*/
   
    /*private static Scene createScene3()// Animation2
      {
      Group root = new Group();
      Scene scene = new Scene(root,500,500 );
      Media media=new Media("file:///C:/Users/Weilong-Wang/workspace/EmbeddedMediaPlayer/src/animation2.mp4");
      mediaPlayer = new MediaPlayer(media);
      mediaPlayer.setAutoPlay(true);
      mediaPlayer.setCycleCount(MediaPlayer.INDEFINITE);   
      MediaView mediaView = new MediaView(mediaPlayer);
      ((Group)scene.getRoot()).getChildren().add(mediaView);
                  return scene;
      }*/
    
}
TOP

Related Classes of com.vengo.test.ui.UserInterface

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.