@Override
 public void start(Stage primaryStage) throws Exception {
   initApplicationDirs();
   File dataDir = new File(applicationDataDir());
   if (dataDir.exists()) {
     LoginWindow loginWindow = new LoginWindow();
     loginWindow.displayLoginAndWait();
     boolean isAuthenticated = SEAGridContext.getInstance().getAuthenticated();
     if (isAuthenticated) {
       HomeWindow homeWindow = new HomeWindow();
       Screen screen = Screen.getPrimary();
       Rectangle2D bounds = screen.getVisualBounds();
       primaryStage.setX(bounds.getMinX());
       primaryStage.setY(bounds.getMinY());
       primaryStage.setWidth(bounds.getWidth());
       primaryStage.setHeight(bounds.getHeight());
       homeWindow.start(primaryStage);
       primaryStage.setOnCloseRequest(
           t -> {
             Platform.exit();
             System.exit(0);
           });
     }
   } else {
     SEAGridDialogHelper.showExceptionDialogAndWait(
         new Exception("Application Data Dir Does Not Exists"),
         "Application Data Dir Does Not Exists",
         null,
         "Application Data Dir Does Not Exists");
     System.exit(0);
   }
 }
 @Override
 public void start(Stage stage) {
   Screen screen = Screen.getPrimary();
   Rectangle2D bounds = screen.getVisualBounds();
   stage.setWidth(bounds.getWidth());
   stage.setHeight(bounds.getHeight());
   stage.setResizable(false);
   new CellSocietyGUI(stage);
 }
  private void setupStageLocation(Stage stage) {
    ObservableList<Screen> screens = Screen.getScreens();
    Screen screen =
        screens.size() <= screenNumber ? Screen.getPrimary() : screens.get(screenNumber);

    Rectangle2D bounds = screen.getBounds();
    boolean primary =
        screen.equals(
            Screen.getPrimary()); // WORKAROUND: this doesn't work nice in combination with full
    // screen, so this hack is used to prevent going fullscreen when
    // screen is not primary

    if (primary) {
      stage.setX(bounds.getMinX());
      stage.setY(bounds.getMinY());
      stage.setWidth(bounds.getWidth());
      stage.setHeight(bounds.getHeight());
      stage.setFullScreen(true);
    } else {
      stage.setX(bounds.getMinX());
      stage.setY(bounds.getMinY());
      stage.setWidth(bounds.getWidth());
      stage.setHeight(bounds.getHeight());
      stage.toFront();
    }
  }
Exemplo n.º 4
0
  @Override
  public void start(Stage ps) throws Exception {
    window = ps;
    control = new WindowControl();

    music = new MediaPlayer(new Media(Util.getResource("music.mp3").toString()));
    breakSound = new MediaPlayer(new Media(Util.getResource("asteroid_break.mp3").toString()));
    explosionSound = new MediaPlayer(new Media(Util.getResource("explosion.mp3").toString()));

    window.setTitle("Asteroids: Space adventure - By macjuul");

    Image icon_128 = Util.getImage("icon_128.png");
    Image icon_32 = Util.getImage("icon_32.png");
    Image icon_16 = Util.getImage("icon_16.png");

    window.getIcons().addAll(icon_128, icon_32, icon_16);

    window.setMinWidth(WIDTH);
    window.setMinHeight(HEIGHT);
    window.setWidth(WIDTH);
    window.setHeight(HEIGHT);

    Parent layout = (Parent) control.loadLayout();

    Scene s = new Scene(layout);

    // Set our stylesheet
    s.getStylesheets().add(Util.getResource("window/style.css").toExternalForm());

    s.setCursor(Cursor.CROSSHAIR);

    window.setScene(s);

    window
        .widthProperty()
        .addListener(
            (ObservableValue<? extends Number> ov, Number oldN, Number newN) -> {
              WIDTH = newN.intValue();

              updateDimensions(true);
            });

    window
        .heightProperty()
        .addListener(
            (ObservableValue<? extends Number> ov, Number oldN, Number newN) -> {
              HEIGHT = (int) newN.intValue();

              updateDimensions(true);
            });

    // Open the window
    window.show();

    window.setOnCloseRequest(
        e -> {
          Platform.exit();
          System.exit(0);
        });
  }
Exemplo n.º 5
0
  @Override
  public void start(Stage primaryStage) throws IOException {

    Parent root = FXMLLoader.load(getClass().getResource("FXML.fxml"));
    scene = new Scene(root);
    primaryStage.setScene(scene);
    Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds();
    primaryStage.setWidth(720);
    primaryStage.setHeight(576);
    primaryStage.show();

    /** Keycode handler reader for barcode reader */
    scene.setOnKeyPressed(
        new EventHandler<javafx.scene.input.KeyEvent>() {
          @Override
          public void handle(javafx.scene.input.KeyEvent event) {
            if (event.getCode().equals(KeyCode.ENTER)) {
              System.out.println("ENTER + " + terminal.getBarcodeReader());
              String code = "" + (Long.valueOf(terminal.getBarcodeReader()));
              if (terminal.isBarcodeNew()) {
                udp.sendCard(code, terminal.getbReaderID());
                terminal.setBarcodeNew(false);
              }

              terminal.setBarcodeReader("");
            } else {
              terminal.setBarcodeReader(terminal.getBarcodeReader() + event.getText());
              System.out.println(terminal.getBarcodeReader());
            }
          }
        });
  }
Exemplo n.º 6
0
  public void storeEntry() {
    Stage window = new Stage();
    Button button;

    Label label = new Label("Please enter the item UPC");
    Label label2 = new Label("Please enter the item's location");

    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Save an item");
    window.setWidth(300);
    window.setHeight(400);

    final TextField upcInput = new TextField();
    final TextField locationInput = new TextField();
    button = new Button("Save");
    button.setOnAction(
        e -> {
          try {
            itemUPC = Double.parseDouble(upcInput.getText());
            itemLOC = locationInput.getText();
          } catch (Exception f) {
            displaySimple("Bad input", "Please enter valid inputs");
            status = false;
          }
          window.close();
        });

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, upcInput, label2, locationInput, button);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();
  }
Exemplo n.º 7
0
  public void customerEntry() {
    Stage window = new Stage();
    Button button;

    Label label = new Label("Please enter the item you are searching for");
    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Find an item");
    window.setWidth(400);
    window.setHeight(400);

    final TextField nameInput = new TextField();
    button = new Button("Find");
    button.setOnAction(
        e -> {
          try {
            userEntry = nameInput.getText();
          } catch (Exception f) {
            displaySimple("Bad input", "Please enter valid inputs");
            status = false;
          }
          window.close();
        });

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, nameInput, button);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();
  }
Exemplo n.º 8
0
  public void storeLogin() {
    Stage window = new Stage();
    Button button;
    String password = "******";

    Label label = new Label("Please enter the store password");

    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Store Login");
    window.setWidth(300);
    window.setHeight(200);

    final TextField passWordInput = new TextField();
    button = new Button("Enter");
    button.setOnAction(
        e -> {
          String entry = passWordInput.getText();
          if (entry.equalsIgnoreCase(password)) {
            answer = true;
            window.close();
          } else {
            answer = false;
            window.close();
          }
        });

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, passWordInput, button);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();
  }
Exemplo n.º 9
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    primaryStage.setTitle(Msg.get(this, "title"));

    primaryStage.setOpacity(Msg.get(this, "stage.opacity", Double::parseDouble, 1.0));

    Group root = new Group();
    Button btnHello = new Button(Msg.get(this, "btnHello.text"));
    root.getChildren().add(btnHello);

    Scene scene =
        new Scene(
            root,
            Msg.get(this, "scene.width", Integer::parseInt, 300),
            Msg.get(this, "scene.height", Integer::parseInt, 300));
    primaryStage.setScene(scene);
    //		primaryStage.sizeToScene();
    primaryStage.setWidth(Msg.get(this, "stage.width", Integer::parseInt, 300));
    primaryStage.setHeight(Msg.get(this, "stage.height", Integer::parseInt, 300));
    primaryStage.show();

    // Center the stage to window only after the stage has been shown
    Rectangle2D bounds = Screen.getPrimary().getVisualBounds();
    double x = bounds.getMinX() + (bounds.getWidth() - primaryStage.getWidth()) / 2;
    double y = bounds.getMinY() + (bounds.getHeight() - primaryStage.getHeight()) / 2;

    //
    primaryStage.setX(x);
    primaryStage.setY(y);
  }
  @Test
  public void testConceptNewJump() {
    // given
    Set<Node> newButtons = conceptMapView.lookupAll(".newBtnTop");
    Node firstNewButton = newButtons.iterator().next();

    moveTo(firstNewButton).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY);
    Node concept = conceptMapView.lookup(".concept");

    double expectedX = concept.getLayoutX() + concept.getTranslateX();
    double expectedY = concept.getLayoutY() + concept.getTranslateY();

    // when

    super.interact(
        () -> {
          stage.setFullScreen(false);
          stage.setWidth(stage.getWidth() - 40);
          stage.setHeight(stage.getHeight() - 40);
        });

    // then

    double actualX = concept.getLayoutX() + concept.getTranslateX();
    double actualY = concept.getLayoutY() + concept.getTranslateY();

    assertEquals(expectedX, actualX, 50);
    assertEquals(expectedY, actualY, 50);
  }
Exemplo n.º 11
0
 private void update() {
     stage.setX(display.getX());
     stage.setY(display.getY());
     stage.setWidth(display.getWidth());
     stage.setHeight(display.getHeight());
     currentLayout.update();
     lastUpdate = Calendar.getInstance().getTimeInMillis();
 }
Exemplo n.º 12
0
  /**
   * maximized the given stage
   *
   * @param primaryStage
   */
  public static void maximize(Stage primaryStage) {
    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();

    primaryStage.setX(bounds.getMinX());
    primaryStage.setY(bounds.getMinY());
    primaryStage.setWidth(bounds.getWidth());
    primaryStage.setHeight(bounds.getHeight());
  }
Exemplo n.º 13
0
 @Override
 public void start(Stage stage) throws Exception {
   StackPane root = new StackPane();
   Scene scene = new Scene(root, Color.LINEN);
   stage.setWidth(300);
   stage.setHeight(300);
   stage.setScene(scene);
   stage.show();
   configureForm(root);
 }
Exemplo n.º 14
0
  @Override
  public void showGui(Stage stage, int width, int height) {
    this.width = width;
    this.height = height;
    this.stage = stage;
    this.jobsManager = JobsManager.create();
    final FXMLLoader loader = new FXMLLoader();
    try {
      root = loader.load(GuiAgentImpl.class.getResourceAsStream(GUI_AGENT_FXML));
      ctrl = loader.getController();
    } catch (IOException e) {
      LOGGER.severe("Cannot load " + GUI_AGENT_FXML + " !");
      System.exit(0);
    }

    scene = new Scene(root, this.width, this.height, Color.ALICEBLUE);
    this.loadCss(scene);

    dockManager.init(root, scene, height, width);
    dockManager.makeDock();

    createMOBWidget(scene);

    // Place scene components
    ctrl.leftBorderPane.setCenter(layerTreeServices.getDisplayService().getDisplayable());
    ctrl.centerStackPane.getChildren().add(geoViewServices.getDisplayService().getDisplayable());
    ctrl.statusBorderPane.setRight(jobsManager.getDisplay().getDisplayable());

    // Initialize menu
    // this.menuServices.setMenuComponent(ctrl.menuBar);
    // this.initializeMenuItems(this.menuServices);
    stage.setTitle(TITLE);
    stage.setOnCloseRequest(
        e -> {
          LOGGER.info("Stop Application");
          ComponentManager.componentManager.stopApplication();
          System.exit(0);
        });
    stage.setScene(scene);
    // stage.setFullScreen(true);
    stage.show();

    // Deuxieme stage pour le sonar, pour qu'il reste au dessus, bug sur l'api ?
    stage1 = new Stage();
    stage1.setOpacity(.0);
    stage1.setHeight(400);
    stage1.setWidth(400);
    stage1.setX(600);
    stage1.setY(200);
    stage1.initStyle(StageStyle.UNDECORATED);

    // test Slider pour layers
    //   SliderController sliderController = new SliderController();
    //   root.getChildren().add(sliderController);
  }
 public void showWindow() {
   // resize primary stage to full screen
   Screen primaryScreen = Screen.getPrimary();
   Rectangle2D bounds = primaryScreen.getVisualBounds();
   Stage mainWindowStage = (Stage) mainWindowRoot.getScene().getWindow();
   mainWindowStage.setX(bounds.getMinX());
   mainWindowStage.setY(bounds.getMinY() + 98);
   mainWindowStage.setWidth(bounds.getWidth());
   mainWindowStage.setHeight(1080); // bounds.getHeight()
   mainWindowStage.setOnCloseRequest(event -> quit());
 }
Exemplo n.º 16
0
 /** 最大化、最大化解除を行う */
 public void toogleMaximized() {
   final Screen screen = Screen.getScreensForRectangle(stage.getX(), stage.getY(), 1, 1).get(0);
   if (maximized) {
     maximized = false;
     if (backupWindowBounds != null) {
       stage.setX(backupWindowBounds.getMinX());
       stage.setY(backupWindowBounds.getMinY());
       stage.setWidth(backupWindowBounds.getWidth());
       stage.setHeight(backupWindowBounds.getHeight());
     }
   } else {
     maximized = true;
     backupWindowBounds =
         new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight());
     stage.setX(screen.getVisualBounds().getMinX());
     stage.setY(screen.getVisualBounds().getMinY());
     stage.setWidth(screen.getVisualBounds().getWidth());
     stage.setHeight(screen.getVisualBounds().getHeight());
   }
 }
Exemplo n.º 17
0
  public static void subWindow(String title, Parent parentControl) {
    Stage stage = new Stage();
    Scene scene = new Scene(parentControl);

    CloseWindowOnEscape.apply(scene, stage);

    stage.setScene(scene);
    stage.setWidth(800);
    stage.setHeight(600);
    stage.setTitle(title);

    stage.show();
  }
Exemplo n.º 18
0
  @Override
  public void start(Stage primaryStage) {
    System.out.println("GUI.start()");
    EnumPolicy.load();
    EnumRegion.loadIcons();
    // TODO: THIS WILL BE REMOVED WHEN PHASE HANDLING IS FULLY IMPLEMENTED
    MapController.setCurrentController(GamePhaseMapController.class);
    this.primaryStage = primaryStage;
    primaryStage.setTitle("Starvation Evasion");

    // fills a list of all the product types

    // primaryStage.setMaxHeight(maxHeight);
    // primaryStage.setMinHeight(maxHeight);
    primaryStage.setResizable(true);

    Screen screen = Screen.getPrimary();
    Rectangle2D bounds = screen.getVisualBounds();

    primaryStage.setX(bounds.getMinX());
    primaryStage.setY(bounds.getMinY());
    primaryStage.setWidth(bounds.getWidth());
    primaryStage.setHeight(bounds.getHeight());

    boxHeight = primaryStage.getWidth() / DraftLayout.ROWS;
    boxWidth = primaryStage.getWidth() / DraftLayout.COLS;

    // instantiate helper classes
    imageGetter = new ImageGetter();
    popupManager = new PopupManager(this);
    graphManager = new GraphManager(this);

    // instantiate the DraftLayout
    draftLayout = new DraftLayout(this);
    votingLayout = new VotingLayout(this);
    // make a scene for displaying the game
    gameScene = new Scene(draftLayout);
    currentRoot = draftLayout;
    primaryStage.setScene(gameScene);

    primaryStage.show();

    primaryStage.setOnCloseRequest(
        arg0 -> {
          if (client != null) client.shutdown();
          Platform.exit();
        });

    initGame();
  }
Exemplo n.º 19
0
  @Override
  public void start(Stage stage) throws Exception {
    // TODO Auto-generated method stub
    primaryStage = stage;

    primaryStage.setResizable(true);
    primaryStage.setHeight(600);
    primaryStage.setWidth(600);
    primaryStage.setTitle("Jeet Test tool");

    mainView = new ProfessorMainViewUI(600, 600);
    mainView.performFinalSetup("loginView", 0);

    primaryStage.setScene(mainView);
    primaryStage.show();
  }
Exemplo n.º 20
0
  @Override
  public void start(Stage stage) throws Exception {

    Group group = new Group();
    Scene scene = new Scene(group);
    scene.setFill(Color.GREY);
    for (int i = 0; i <= 27; i++) {
      Sector sector = new Sector(20 * i, 20 * i, 10 * i, 20 * i);
      group.getChildren().add(sector);
    }

    stage.setTitle("Hello, SectorApplication!");
    stage.setScene(scene);
    stage.setWidth(600);
    stage.setHeight(620);
    stage.show();
  }
Exemplo n.º 21
0
  @Override
  public void start(Stage primaryStage) throws Exception {

    root = new Pane((Pane) createContent());
    // from game menu
    root.setPrefSize(windowWidth, windowHeight);

    gameMenu = new BlackjackMain.GameMenu();
    gameMenu.setVisible(true);

    root.getChildren().addAll(gameMenu);

    // root.setStyle("-fx-background-image: url('res/images/casino.jpg')");
    Scene scene = new Scene(root);
    scene.setOnKeyPressed(
        event -> {
          if (event.getCode() == KeyCode.ESCAPE) {
            if (!gameMenu.isVisible()) {
              FadeTransition ft = new FadeTransition(Duration.seconds(0.5), gameMenu);
              ft.setFromValue(0);
              ft.setToValue(1);

              gameMenu.setVisible(true);
              ft.play();
            } else {
              FadeTransition ft = new FadeTransition(Duration.seconds(0.5), gameMenu);
              ft.setFromValue(1);
              ft.setToValue(0);
              ft.setOnFinished(evt -> gameMenu.setVisible(false));
              ft.play();
            }
          }
        });

    // resize(primaryStage);
    primaryStage.setScene(scene);
    primaryStage.show();

    // primaryStage.setScene(new Scene(createContent()));
    primaryStage.setWidth(800);
    primaryStage.setHeight(600);
    primaryStage.setResizable(false);
    primaryStage.setTitle("BlackJack");
    primaryStage.show();
  }
    @Override
    public void start(Stage t) {
      primaryStage = t;
      t.setScene(new Scene(new Group()));
      t.setWidth(100);
      t.setHeight(100);
      t.show();

      Thread.currentThread()
          .setUncaughtExceptionHandler(
              (t2, e) -> {
                System.out.println("Exception caught: " + e);
                System.out.flush();
                exception = e;
              });

      startupLatch.countDown();
    }
Exemplo n.º 23
0
 @InvokableAction(
     name = "Resize window",
     category = "general",
     description = "Resize the screen to 1x/1.5x/2x/3x video size",
     alternatives =
         "Adjust screen;Adjust window size;Adjust aspect ratio;Fix screen;Fix window size;Fix aspect ratio;Correct aspect ratio;",
     defaultKeyMapping = {"ctrl+shift+a"})
 public static void scaleIntegerRatio() {
   Platform.runLater(
       () -> {
         JaceApplication.getApplication().primaryStage.setFullScreen(false);
         size++;
         if (size > 3) {
           size = 0;
         }
         int width = 0, height = 0;
         switch (size) {
           case 0: // 1x
             width = 560;
             height = 384;
             break;
           case 1: // 1.5x
             width = 840;
             height = 576;
             break;
           case 2: // 2x
             width = 560 * 2;
             height = 384 * 2;
             break;
           case 3: // 3x (retina) 2880x1800
             width = 560 * 3;
             height = 384 * 3;
             break;
           default: // 2x
             width = 560 * 2;
             height = 384 * 2;
         }
         Stage stage = JaceApplication.getApplication().primaryStage;
         double vgap = stage.getScene().getY();
         double hgap = stage.getScene().getX();
         stage.setWidth(hgap * 2 + width);
         stage.setHeight(vgap + height);
       });
 }
Exemplo n.º 24
0
 /** 設定値からウインドウの状態を復元する。 */
 public void loadWindowState() {
   IrisPreferences preferences = new IrisPreferences();
   stage.setHeight(preferences.getDouble(IrisPreferences.WINDOW_HEIGHT, 600f));
   stage.setWidth(preferences.getDouble(IrisPreferences.WINDOW_WIDTH, 900f));
   double[] div1 = new double[1];
   div1[0] = preferences.getDouble(IrisPreferences.WINDOW_DIVIDER_POSITION1, 0.3f);
   leftSplitPane.setDividerPositions(div1);
   double[] div2 = new double[1];
   div2[0] = preferences.getDouble(IrisPreferences.WINDOW_DIVIDER_POSITION2, 0.5f);
   rightSplitPane.setDividerPositions(div2);
   log.debug(
       "ウインドウサイズ復元 width="
           + preferences.getDouble(IrisPreferences.WINDOW_WIDTH, 600f)
           + " height="
           + preferences.getDouble(IrisPreferences.WINDOW_HEIGHT, 900f)
           + " split1="
           + preferences.getDouble(IrisPreferences.WINDOW_DIVIDER_POSITION1, 0.3f)
           + " split2="
           + preferences.getDouble(IrisPreferences.WINDOW_DIVIDER_POSITION2, 0.5f));
 }
Exemplo n.º 25
0
 private void stateLoop() {
   switch (currentState) {
     case MainMenu:
       // adds a new menu and initializes its components
       mainState = new MainMenu(this);
       mainState.start();
       break;
     default:
       break;
   }
   // set Stage attributes
   stage.setTitle("Finding Ataraxy");
   stage.setWidth(Screen_Width);
   stage.setHeight(Screen_Height);
   stage.setScene(scene);
   // stage.getStyle();
   stage.sizeToScene();
   stage.show();
   createKeyInputHandling();
   createMouseInputHandling();
 }
Exemplo n.º 26
0
  @Override
  public void start(final Stage stage) {
    try {
      palco = stage;
      page = FXMLLoader.load(Login.class.getResource("../view/login/login.fxml"));
      cena = new Scene(page);

      stage.initStyle(StageStyle.UNDECORATED);

      stage.setX(windows.getMinX());
      stage.setY(windows.getMinY());
      stage.setWidth(windows.getWidth());
      stage.setHeight(windows.getHeight());

      stage.getIcons().addAll(new Image(Login.class.getResourceAsStream("icone.png")));

      stage.setScene(cena);
      stage.show();

    } catch (Exception ex) {
      System.out.println("Erro ao inicializar aplicação!" + ex);
    }
  }
Exemplo n.º 27
0
  public static void displaySimple(String title, String message) {
    Stage window = new Stage();

    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle(title);
    window.setWidth(450);
    window.setHeight(200);

    Label label = new Label();
    label.setWrapText(true);
    label.setText(message);
    label.setTextAlignment(TextAlignment.CENTER);
    Button closeButton = new Button("Close");
    closeButton.setOnAction(e -> window.close());

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, closeButton);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();
  }
Exemplo n.º 28
0
  public static boolean displayConfirmation() {

    Stage window = new Stage();

    window.initModality(Modality.APPLICATION_MODAL);
    window.setTitle("Exit?");
    window.setWidth(300);
    window.setHeight(250);

    Label label = new Label();
    label.setWrapText(true);
    label.setText("Are you sure you want to quit?");
    label.setTextAlignment(TextAlignment.CENTER);
    label.setPadding(new Insets(20, 20, 20, 20));
    Button yesButton = new Button("Yes");
    yesButton.setOnAction(
        e -> {
          yesNo = true;
          window.close();
        });
    Button noButton = new Button("No");
    noButton.setOnAction(
        e -> {
          yesNo = false;
          window.close();
        });

    VBox layout = new VBox(20);
    layout.getChildren().addAll(label, yesButton, noButton);
    layout.setAlignment(Pos.CENTER);

    Scene scene = new Scene(layout);
    window.setScene(scene);
    window.showAndWait();

    return yesNo;
  }
Exemplo n.º 29
0
  /** Nastaví výšku okna. */
  public ScreenBuilder setHeight(double height) {
    stage.setHeight(height);

    return this;
  }
Exemplo n.º 30
0
  public void start(final Stage stage) {
    for (ConditionalFeature f : EnumSet.allOf(ConditionalFeature.class)) {
      System.err.println(f + ": " + Platform.isSupported(f));
    }
    Rectangle2D screen = Screen.getPrimary().getVisualBounds();
    final Random rand = new Random();

    /*
    final Group starfield = new Group();
    for(int i=0;i<66;i++) {
        int size = rand.nextInt(3)+1;
        if(size==3) {
            size = rand.nextInt(3)+1;
        }
        Circle circ = new Circle(rand.nextInt((int)screen.getWidth()), rand.nextInt(200+(int)screen.getHeight())-200,
            size);
        circ.setFill(Color.rgb(200,200,200+rand.nextInt(56)));
        circ.setTranslateZ(1+rand.nextInt(40));
        starfield.getChildren().add(circ);
    }
    */
    final List<Starfield> stars = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
      int sw = (int) screen.getWidth(), sh = (int) screen.getHeight();
      Starfield sf = new Starfield(rand, -sw, -sh, 2 * sw, 2 * sh, rand.nextInt(30) + 10);
      sf.setTranslateZ(rand.nextInt(2000) + 50);
      stars.add(sf);
    }
    // final Starfield starfield2 = new Starfield(rand, -200, -200, (int)screen.getWidth(),
    // (int)screen.getHeight()+200, 40);

    final Ruleset1D rules =
        new Ruleset1D(new int[] {Colors.randomColor(rand), Colors.randomColor(rand)});
    final Ruleset rules2 = new Rulespace1D(rules);
    // Rule rule = rules.random(rand).next();
    Iterator<Rule> it = rules.iterator();
    GridPane gridp = new GridPane();
    int i = 0, j = 0;
    while (it.hasNext()) {
      Rule rule = it.next();
      CA ca = new CA(rule, new RandomInitializer(), rand, 42, 100, 100);
      Plane plane = ca.createPlane();
      ImageView imview = new ImageView(plane.toImage());
      imview.setSmooth(true);
      imview.setFitWidth(30);
      imview.setPreserveRatio(true);
      gridp.add(imview, i, j);
      if (++i == 16) {
        i = 0;
        j++;
      }
    }
    // gridp.setScaleX(0.3);
    // gridp.setScaleY(0.3);
    // gridp.setPrefSize(100*3/3, 100*3/3);
    // gridp.setMaxSize(100*3/3, 100*3/3);

    final double XTRANS = screen.getWidth() / 2 - 30 * 16 / 2;
    final double YTRANS = screen.getHeight() / 2 - 30 * 16 / 2;
    // gridp.setTranslateX((screen.getWidth()/2+100*16/2)*0.3);
    // gridp.setTranslateX(0);
    gridp.setTranslateX(XTRANS);
    gridp.setTranslateY(YTRANS);
    // gridp.setAlignment(Pos.CENTER);
    Group grid = new Group(gridp);
    // grid.setTranslateX(0);
    // grid.setTranslateY(0);

    // gridp.relocate(-400, -400);
    // gridp.setTranslateX(-300);
    // gridp.setTranslateY(-150);

    /*
    final RotateTransition rt = new RotateTransition(Duration.millis(3000), gridp);
    rt.setByAngle(180);
    rt.setCycleCount(4);
    rt.setAutoReverse(true);
    */
    // rt.setAutoReverse(false);

    /*`
    final BorderPane border = new BorderPane();
    */
    // Label title = new Label("EXPLORATIONS IN CELLULAR SPACES");
    Label title = new Label("E  X  P  L  O  R  A  T  I  O  N  S");
    title.setFont(new Font("Helvetica Neue Condensed Bold", 36));
    title.setTextFill(Color.WHITE);
    // Label title2 = new Label("IN CELLULAR SPACES");
    Label title2 = new Label("EXPLORATIONS IN CELLULAR SPACES");
    title2.setFont(new Font("Helvetica Neue Condensed Bold", 28));
    title2.setTextFill(Color.WHITE);
    /*`
    title.setAlignment(Pos.CENTER);
    title.setContentDisplay(ContentDisplay.CENTER);
    title.setTextAlignment(TextAlignment.CENTER);
    */
    final HBox toptitle = new HBox();
    toptitle.setAlignment(Pos.CENTER);
    toptitle.getChildren().add(title);
    toptitle.setTranslateX(XTRANS);
    toptitle.setTranslateY(YTRANS - 36);

    final HBox btitle = new HBox();
    btitle.setAlignment(Pos.CENTER);
    title2.setAlignment(Pos.CENTER);
    btitle.getChildren().add(title2);
    btitle.setTranslateX(XTRANS);
    // btitle.setTranslateX(screen.getWidth()/2-title2.getPrefWidth()/2);
    btitle.setTranslateY(YTRANS + 30 * 16);

    Group border = new Group();
    // border.getChildren().add(toptitle);
    for (Starfield st : stars) {
      border.getChildren().add(st);
    }
    // border.getChildren().add(starfield2);
    border.getChildren().add(btitle);
    border.getChildren().add(grid);

    final List<TranslateTransition> tts = new ArrayList<>();
    final TranslateTransition tt = new TranslateTransition(Duration.millis(6000), grid);
    tt.setByY(2000);
    tts.add(tt);
    for (Starfield sf : stars) {
      TranslateTransition st = new TranslateTransition(Duration.millis(6000), sf);
      st.setByY(200);
      st.setByZ(100 + rand.nextInt(100));
      tts.add(st);
    }
    /*
    final TranslateTransition tt2 = new TranslateTransition(Duration.millis(6000), starfield1);
    tt2.setByY(200);
    tt2.setByZ(200);
    final TranslateTransition tt3 = new TranslateTransition(Duration.millis(6000), starfield2);
    tt3.setByY(300);
    tt3.setByZ(200);
    */
    // final ParallelTransition infinite = new ParallelTransition(tt, tt2, tt3);
    final ParallelTransition infinite =
        new ParallelTransition(tts.toArray(new TranslateTransition[0]));

    final BorderPane ctrl = new BorderPane();
    // ctrl.setPrefSize(200, 100);
    // ctrl.setMaxSize(200, 100);
    Label start = new Label("Start");
    start.setTextFill(Color.WHITE);
    start.setFont(new Font("Helvetica", 28));
    start.setAlignment(Pos.CENTER_LEFT);
    start.setContentDisplay(ContentDisplay.CENTER);
    start.setTranslateX(XTRANS + 30 * 16 + 100);
    start.setTranslateY(screen.getHeight() / 2);
    // start.setTranslateX(-400);
    Circle ico = new Circle(15);
    ico.setOnMouseClicked(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent e) {
            FadeTransition ft = new FadeTransition(Duration.millis(500), ctrl);
            ft.setFromValue(1.0);
            ft.setToValue(0.0);
            FadeTransition tft = new FadeTransition(Duration.millis(500), btitle);
            tft.setFromValue(1.0);
            tft.setToValue(0.0);
            ParallelTransition pt = new ParallelTransition(ft, tft);
            // TranslateTransition fft = new TranslateTransition(Duration.millis(3000), border);
            // tt.setByY(2000);
            SequentialTransition st = new SequentialTransition(pt, infinite);
            st.setOnFinished(
                new EventHandler<ActionEvent>() {
                  public void handle(ActionEvent e) {
                    State state = State.state().rules(rules2).random(new Rand()).size(400);
                    Iterator<Rule> it = state.rules().random(state.random().create());
                    CA ca =
                        new CA(
                            it.next(),
                            new RandomInitializer(),
                            state.random().create(),
                            0,
                            state.size(),
                            state.size());
                    state.ca(ca);
                    // final Futures futures = new Futures(rules2, new Rand());
                    final Controls controls = new Controls(state);
                    // controls.setTranslateX(screen.getWidth()/2 -
                    // futures.getPossibilityWidth()/2);
                    // controls.setTranslateY(screen.getHeight()/2 -
                    // futures.getPossiblityHeight()/2-20);

                    // controls.setTranslateX(screen.getWidth()/2 - (3*200+2*10)/2);
                    // controls.setTranslateY(screen.getHeight()/2 - (3*200+2*10)/2-20);

                    for (Starfield sf : stars) {
                      state.addListener(sf);
                      // futures.addFutureListener(sf);
                    }
                    // futures.addFutureListener(starfield1);
                    // futures.addFutureListener(starfield2);
                    border.getChildren().remove(grid);
                    border.getChildren().remove(btitle);
                    // border.getChildren().add(futures);
                    border.getChildren().add(controls);
                    // futures.setTranslateX(screen.getWidth()/2 - futures.getPossibilityWidth()/2);
                    // futures.setTranslateY(screen.getHeight()/2 -
                    // futures.getPossiblityHeight()/2);
                    // border.setCenter(futures);
                    // border.setAlignment(futures, Pos.CENTER);
                  }
                });
            st.play();
          }
        });
    // Sphere ico = new Sphere(15);
    // ico.setDrawMode(DrawMode.LINE);
    ico.setFill(Color.rgb(10, 10, 10));
    ico.setStroke(Color.WHITE);
    ico.setStrokeWidth(3);
    ico.setTranslateX(XTRANS + 30 * 16 + 100);
    ico.setTranslateY(screen.getHeight() / 2);
    // ctrl.setTop(ico);
    ctrl.setCenter(ico);
    /*
    border.setRight(ctrl);

    border.setMaxSize(800,600);
    border.setPrefSize(800,600);
    */
    border.getChildren().add(ctrl);
    Group root = new Group();
    root.getChildren().add(border);
    // root.setAutoSizeChildren(false);
    // root.setLayoutX(-400);
    // root.setLayoutY(-400);
    // Scene scene = new Scene(root, 1200, 1000);
    Scene scene = new Scene(root, 1280, 1024, true, SceneAntialiasing.DISABLED);
    scene.setFill(Color.BLACK);
    scene.setCamera(new PerspectiveCamera());

    // set Stage boundaries to visible bounds of the main screen
    stage.setX(screen.getMinX());
    stage.setY(screen.getMinY());
    stage.setWidth(screen.getWidth());
    stage.setHeight(screen.getHeight());

    stage.setTitle("Explorations in Cellular Spaces");
    stage.setScene(scene);
    stage.setResizable(false);
    // root.autosize();
    // stage.sizeToScene();
    stage.show();
  }