@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);
   }
 }
  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();
    }
  }
  @Override
  public void start(Stage primaryStage) {
    Pane p = new Pane();
    for (int i = 0; i < 5; i++) {
      Button b = new Button("pm" + i);
      b.setLayoutX(i * 40);
      b.setLayoutY(i * 20);
      p.getChildren().add(b);
    }
    Scene s = new Scene(p);
    primaryStage.setScene(s);
    primaryStage.setTitle("Gauche à droite");
    primaryStage.setX(0);
    primaryStage.setY(0);
    primaryStage.show();

    Stage st = new Stage();
    Pane pt = new Pane();
    for (int i = 0; i < 5; i++) {
      Button b = new Button("s" + i);
      b.setLayoutX((4 - i) * 40);
      b.setLayoutY(i * 20);
      pt.getChildren().add(b);
    }
    Scene t = new Scene(pt);
    st.setScene(t);
    st.setTitle("Droite à gauche");
    st.setX(400);
    st.setY(400);

    st.show();
  }
Esempio n. 4
0
  private void showSplash(
      final Stage initStage, Task<?> task, InitCompletionHandler initCompletionHandler) {
    progressText.textProperty().bind(task.messageProperty());
    loadProgress.progressProperty().bind(task.progressProperty());
    task.stateProperty()
        .addListener(
            (observableValue, oldState, newState) -> {
              if (newState == Worker.State.SUCCEEDED) {
                loadProgress.progressProperty().unbind();
                loadProgress.setProgress(1);
                initStage.toFront();
                FadeTransition fadeSplash = new FadeTransition(Duration.seconds(1.2), splashLayout);
                fadeSplash.setFromValue(1.0);
                fadeSplash.setToValue(0.0);
                fadeSplash.setOnFinished(actionEvent -> initStage.hide());
                fadeSplash.play();

                initCompletionHandler.complete();
              } // todo add code to gracefully handle other task states.
            });

    Scene splashScene = new Scene(splashLayout);
    initStage.initStyle(StageStyle.UNDECORATED);
    final Rectangle2D bounds = Screen.getPrimary().getBounds();
    initStage.setScene(splashScene);
    initStage.setX(bounds.getMinX() + bounds.getWidth() / 2 - SPLASH_WIDTH / 2);
    initStage.setY(bounds.getMinY() + bounds.getHeight() / 2 - SPLASH_HEIGHT / 2);
    initStage.show();
  }
Esempio n. 5
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);
  }
 private void onShownHandler(WindowEvent windowEvent) {
   dialogStage.sizeToScene();
   Window parent = dialogStage.getOwner();
   dialogStage.setX(parent.getX() + parent.getWidth() / 2 - dialogStage.getWidth() / 2);
   dialogStage.setY(parent.getY() + parent.getHeight() / 2 - dialogStage.getHeight() / 2);
   dialogStage.requestFocus();
 }
Esempio n. 7
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();
 }
Esempio n. 8
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());
  }
Esempio n. 9
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);
  }
Esempio n. 10
0
  @Override
  public void start(Stage stage) {
    stage.initStyle(StageStyle.TRANSPARENT);
    stage.setAlwaysOnTop(true);
    VBox box = new VBox();
    imageView = new ImageView(sprites[currentFrame]);

    box.getChildren().add(imageView);
    final Scene scene = new Scene(box, 0, 0);
    Rectangle2D screenBounds = Screen.getPrimary().getVisualBounds();
    stage.setX(currentX);
    stage.setY(currentY);
    scene.setFill(null);
    stage.setScene(scene);
    mainLoop = new Timeline();
    mainLoop.setCycleCount(Animation.INDEFINITE);
    renderFrame =
        new KeyFrame(
            frameDuration,
            new EventHandler<ActionEvent>() {
              public void handle(ActionEvent event) {
                Double currentFrameWidth = sprites[currentFrame].getWidth();
                Double currentFrameHeight = sprites[currentFrame].getHeight();
                stage.setWidth(currentFrameWidth);
                stage.setHeight(currentFrameHeight);
                currentY = screenBounds.getMinY() + screenBounds.getHeight() - currentFrameHeight;

                Double minLimitX = 0.0;
                Double maxLimitX =
                    screenBounds.getMinX() + screenBounds.getWidth() - currentFrameWidth;
                if (currentX >= maxLimitX || currentX <= minLimitX) {
                  velocity = -1 * velocity;
                  currentX = currentX >= maxLimitX ? maxLimitX - 1 : minLimitX + 1;
                  currentWalkingFrame = 0;
                } else {
                  currentX += velocity;
                }

                if (velocity > 0) {
                  currentFrame = walking_right_indexes[currentWalkingFrame];
                } else {
                  currentFrame = walking_left_indexes[currentWalkingFrame];
                }

                stage.setX(currentX);
                stage.setY(currentY);
                imageView.setImage(sprites[currentFrame]);
                currentWalkingFrame = (++currentWalkingFrame) % walking_right_indexes.length;
              }
            });
    mainLoop.getKeyFrames().add(renderFrame);
    stage.show();
    mainLoop.play();
  }
Esempio n. 11
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());
   }
 }
 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());
 }
Esempio n. 13
0
  @FXML
  private void handleAction(ActionEvent event) {
    TextArea textarea = (TextArea) menuBar.getScene().lookup("#textarea");

    if (event.getSource() == chmiWordWrap) {
      wordWrapOn = chmiWordWrap.isSelected();
      textarea.setWrapText(wordWrapOn);

    } else if (event.getSource() == miChangeCase) {
      try {
        if (changeCaseDialog == null) {
          FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("ChangeCaseDialog.fxml"));
          Parent root = fxmlLoader.load();
          controller = fxmlLoader.getController();
          controller.setSelectedCase(prefs.get(strSelectedCase, "UPPERCASE"));
          changeCaseDialog = new Stage();
          changeCaseDialog.setResizable(false);
          changeCaseDialog.initStyle(StageStyle.UTILITY);
          changeCaseDialog.setAlwaysOnTop(true);
          changeCaseDialog.setX(prefs.getDouble(strChangeCaseX, changeCaseDialog.getX()));
          changeCaseDialog.setY(prefs.getDouble(strChangeCaseY, changeCaseDialog.getY()));
          Scene scene = new Scene(root);
          changeCaseDialog.setScene(scene);
          changeCaseDialog.setTitle("Change Case");
        }

        changeCaseDialog.toFront();
        changeCaseDialog.show();
      } catch (Exception e) {

      }
    } else if (event.getSource() == miRemoveLineBreaks) {
      if (textarea.getSelectedText().length() == 0) {
        textarea.selectAll();

        if (textarea.getSelectedText().length() == 0) {
          return;
        }
      }

      String result = TextUtilities.removeLineBreaks(textarea.getSelectedText());

      int start = textarea.getSelection().getStart();
      textarea.replaceSelection(result);
      textarea.selectRange(start, start + result.length());
    } else if (event.getSource() == miFont) {
      Font font = textarea.getFont();
      FontSelectorDialog dialog = new FontSelectorDialog(font);
      Optional<Font> op = dialog.showAndWait();
      if (op.isPresent()) {
        textarea.setFont(op.get());
      }
    }
  }
 @Override
 public void start(Stage stage) {
   for (int i = 0; i < 10; i++) {
     Stage s = new Stage();
     Scene t = new Scene(new Button("Button: " + i));
     s.setScene(t);
     s.setTitle("Stage " + i);
     s.setX(i * 130);
     s.setY(200);
     s.show();
   }
   System.out.println("Sort de la méthode start");
 }
Esempio n. 15
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();
  }
Esempio n. 16
0
  @Override
  public void start(Stage stage) throws Exception {
    Application.Parameters params = getParameters();
    List<String> paramList = params.getUnnamed();

    // Check for the existence of a proper API Key
    if (paramList.size() < 1 || !paramList.get(0).startsWith("-K")) {
      throw new IllegalStateException("Demo must be started with arguments [-K]<your-api-key>");
    }

    PAFoxEatsDemoView view = new PAFoxEatsDemoView(this, params);
    Scene scene = new Scene(view, 900, 600, Color.WHITE);
    stage.setScene(scene);
    stage.show();

    Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds();
    stage.setX((primScreenBounds.getWidth() - stage.getWidth()) / 2);
    stage.setY((primScreenBounds.getHeight() - stage.getHeight()) / 4);
  }
Esempio n. 17
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);
    }
  }
Esempio n. 18
0
  public void readLyrics() throws IOException {

    String filename = songName + ".txt";

    lyrStage = new Stage();
    lyrStage.setTitle("Lyrics");
    lyrStage.setHeight(420);
    AnchorPane root = new AnchorPane();
    root.setStyle(
        "-fx-border-color: black, transparent; -fx-border-width: 1px, 5px; -fx-border-insets: 0px, 1px");

    root.setOnMouseDragged(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent me) {
            lyrStage.setX(me.getScreenX());
            lyrStage.setY(me.getScreenY());
          }
        });

    lyrStage.initStyle(StageStyle.UNDECORATED);
    Scene scene = new Scene(root);

    lyrStage.setScene(scene);

    Boolean songTitle = true;
    final Label label = new Label();

    ScrollBar sc = new ScrollBar();
    sc.setMin(0);
    sc.setValue(0);
    sc.setPrefWidth(3);
    sc.setPrefHeight(140);
    sc.setVisibleAmount(10);
    sc.setOrientation(Orientation.VERTICAL);

    sc.valueProperty()
        .addListener(
            new ChangeListener<Number>() {
              @Override
              public void changed(
                  ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
                label.setLayoutY(-new_val.doubleValue());
              }
            });

    int row = 0;
    try (FileReader re = new FileReader(filename)) {
      BufferedReader br = new BufferedReader(re);
      String content;
      while ((content = br.readLine()) != null) {
        if (songTitle == true) {
          content = content.toUpperCase();
          content = content.substring(0, content.length() - 4);
          songText = "    ";
          songTitle = false;
        }
        songText += (content + "\n    ");
        row++;
      }
    } catch (IOException ex) {
      System.out.println("Cant read but why?!!!");
    }

    sc.setMax(row * 10);

    label.setAlignment(Pos.CENTER_RIGHT);
    label.setMinSize(50, 80);
    label.setText(songText);
    // label.boundsInParentProperty();
    root.getChildren().addAll(label, sc);

    lyrStage.setX(50);
    lyrStage.setY(50);

    lyrStage.show();
  }
Esempio n. 19
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();
  }
Esempio n. 20
0
 private void restoreLocation() {
   dialogStage.setX(savedX);
   dialogStage.setY(savedY);
   dialogStage.setWidth(savedWidth);
   dialogStage.setHeight(savedHeight);
 }
Esempio n. 21
0
  private void shiftDock() {
    long now = System.currentTimeMillis();
    Rectangle2D cfgBounds = Client.getConfiguredBounds();

    // The bounds to work in
    int boundsSize = cfg.isVertical() ? (int) cfgBounds.getHeight() : (int) cfgBounds.getWidth();

    // Total amount to slide
    int value = cfg.sizeProperty().get() - AUTOHIDE_TAB_OPPOSITE_SIZE;

    // How far along the timeline?
    float fac = Math.min(1f, 1f - ((float) (yEnd - now) / (float) AUTOHIDE_DURATION));

    // The amount of movement so far
    float amt = fac * (float) value;

    // The amount to shrink the width (or height when vertical) of the
    // visible 'bar'
    float barSize = (float) boundsSize * fac;

    // If showing, reverse
    final boolean fhidden = hidden;

    if (!hidden) {
      amt = value - amt;
      barSize = (float) boundsSize - barSize;
      if (!pull.isVisible()) pull.setVisible(true);
    }

    // Reveal or hide the pull tab
    dockContent.setOpacity(hidden ? 1f - fac : fac);
    pull.setOpacity((hidden ? fac : 1f - fac) * 0.5f);

    Stage stage = getStage();
    if (stage != null) {
      if (cfg.topProperty().get()) {
        getScene().getRoot().translateYProperty().set(-amt);
        stage.setHeight(cfg.sizeProperty().get() - amt + Client.DROP_SHADOW_SIZE);
        stage.setWidth(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getWidth() - barSize));
        stage.setX(cfgBounds.getMinX() + ((cfgBounds.getWidth() - stage.getWidth()) / 2f));
      } else if (cfg.bottomProperty().get()) {
        stage.setY(cfgBounds.getMaxY() + amt);
        stage.setHeight(cfg.sizeProperty().get() - amt + Client.DROP_SHADOW_SIZE);
        stage.setWidth(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getWidth() - barSize));
        stage.setX(cfgBounds.getMinX() + ((cfgBounds.getWidth() - stage.getWidth()) / 2f));
      } else if (cfg.leftProperty().get()) {
        getScene().getRoot().translateXProperty().set(-amt);
        stage.setWidth(cfg.sizeProperty().get() - amt);
        stage.setHeight(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getHeight() - barSize));
        stage.setY(cfgBounds.getMinY() + ((cfgBounds.getHeight() - stage.getHeight()) / 2f));
      } else if (cfg.rightProperty().get()) {
        stage.setX(cfgBounds.getMaxX() + amt - cfg.sizeProperty().get());
        stage.setWidth(cfg.sizeProperty().get() - amt);
        stage.setHeight(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getHeight() - barSize));
        stage.setY(cfgBounds.getMinY() + ((cfgBounds.getHeight() - stage.getHeight()) / 2f));
      } else {
        throw new UnsupportedOperationException();
      }
    }

    // The update or the sign in dialog may have been popped, so make sure
    // it is position correctly
    if (signInPopup != null && signInPopup.isShowing()) {
      signInPopup.sizeToScene();
    }

    // If not fully hidden / revealed, play again
    if (now < yEnd) {
      dockHider.playFromStart();
    } else {
      // Defer this as events may still be coming in
      Platform.runLater(
          new Runnable() {
            @Override
            public void run() {
              if (!fhidden && stage != null) {
                stage.requestFocus();
                pull.setVisible(false);
              }
              hiding = false;
            }
          });
    }
  }
Esempio n. 22
0
  public void setLyrics() throws IOException {

    lyrStage = new Stage();
    lyrStage.setTitle("Lyrics setting");
    lyrStage.setHeight(420);
    AnchorPane root = new AnchorPane();
    root.setStyle(
        "-fx-border-color: black, transparent; -fx-border-width: 1px, 5px; -fx-border-insets: 0px, 1px");

    root.setOnMouseDragged(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent me) {
            lyrStage.setX(me.getScreenX());
            lyrStage.setY(me.getScreenY());
          }
        });

    lyrStage.initStyle(StageStyle.UNDECORATED);
    Scene scene = new Scene(root);

    final TextArea lyricArea = new TextArea();

    lyrStage.setScene(scene);

    lyricArea.setPrefHeight(100);
    lyricArea.setPrefWidth(190);
    lyricArea.setMinHeight(100);
    lyricArea.setLayoutY(315);
    lyricArea.setLayoutX(7);
    lyricArea.setMaxWidth(TextField.USE_PREF_SIZE);

    final Label label = new Label();
    /*
            final ScrollPane sp = new ScrollPane();
            sp.setPrefSize(200, 200);
            sp.setHbarPolicy(ScrollBarPolicy.AS_NEEDED);
            sp.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
            sp.setPannable(true);
            sp.setContent(label);
            sp.vvalueProperty().addListener(new ChangeListener<Number>() {
                @Override
                public void changed(ObservableValue<? extends Number> ov,
                    Number old_val, Number new_val) {
                        label.setLayoutY(-new_val.doubleValue());
                        label.setLayoutX(-new_val.doubleValue());
                }
            });
    */

    label
        .textProperty()
        .bind(
            new StringBinding() {
              {
                bind(lyricArea.textProperty());
              }

              @Override
              protected String computeValue() {

                String text = lyricArea.getText();

                return "Lyric preview: \n\n " + songName + "\n\n" + text;
              }
            });

    final VBox vBox = new VBox();
    vBox.setPrefHeight(800); // ////////////////////////////////////////
    vBox.setPrefWidth(240);
    vBox.setPadding(new Insets(18));
    vBox.getChildren().addAll(label);

    final VBox vBox2 = new VBox();
    vBox2.setPrefHeight(340);
    vBox2.setPrefWidth(240);
    vBox2.setAlignment(Pos.BOTTOM_RIGHT);

    Button btnText = new Button();
    btnText.setText("Ok");
    btnText.setStyle("-fx-base: white;");
    btnText.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            String txt = lyricArea.getText();
            textSet(txt);
            lyrStage.close();
          }
        });

    vBox2.getChildren().add(btnText);

    ScrollBar sc = new ScrollBar();
    sc.setMin(0);
    sc.setMax(500);
    sc.setValue(30);
    sc.setPrefWidth(3);
    sc.setPrefHeight(160);
    sc.setVisibleAmount(10);
    sc.setOrientation(Orientation.VERTICAL);

    sc.valueProperty()
        .addListener(
            new ChangeListener<Number>() {
              @Override
              public void changed(
                  ObservableValue<? extends Number> ov, Number old_val, Number new_val) {
                label.setLayoutY(-new_val.doubleValue());
              }
            });

    root.getChildren().addAll(vBox, lyricArea, vBox2, sc);

    lyrStage.setX(50);
    lyrStage.setY(50);

    lyrStage.show();
  }
Esempio n. 23
0
  @Override
  public void handle(MouseEvent event) {
    if (event.getEventType() == MouseEvent.MOUSE_PRESSED) {
      if (dockNode.isFloating()
          && event.getClickCount() == 2
          && event.getButton() == MouseButton.PRIMARY) {
        dockNode.setMaximized(!dockNode.isMaximized());
      } else {
        // drag detected is used in place of mouse pressed so there is some threshold for the
        // dragging which is determined by the default drag detection threshold
        dragStart = new Point2D(event.getX(), event.getY());
      }
    } else if (event.getEventType() == MouseEvent.DRAG_DETECTED) {
      if (!dockNode.isFloating()) {
        // if we are not using a custom title bar and the user
        // is not forcing the default one for floating and
        // the dock node does have native window decorations
        // then we need to offset the stage position by
        // the height of this title bar
        if (!dockNode.isCustomTitleBar() && dockNode.isDecorated()) {
          dockNode.setFloating(true, new Point2D(0, DockTitleBar.this.getHeight()));
        } else {
          dockNode.setFloating(true);
        }

        // TODO: Find a better solution.
        // Temporary work around for nodes losing the drag event when removed from
        // the scene graph.
        // A possible alternative is to use "ghost" panes in the DockPane layout
        // while making DockNode simply an overlay stage that is always shown.
        // However since flickering when popping out was already eliminated that would
        // be overkill and is not a suitable solution for native decorations.
        // Bug report open: https://bugs.openjdk.java.net/browse/JDK-8133335
        DockPane dockPane = this.getDockNode().getDockPane();
        if (dockPane != null) {
          dockPane.addEventFilter(MouseEvent.MOUSE_DRAGGED, this);
          dockPane.addEventFilter(MouseEvent.MOUSE_RELEASED, this);
        }
      } else if (dockNode.isMaximized()) {
        double ratioX = event.getX() / this.getDockNode().getWidth();
        double ratioY = event.getY() / this.getDockNode().getHeight();

        // Please note that setMaximized is ruined by width and height changes occurring on the
        // stage and there is currently a bug report filed for this though I did not give them an
        // accurate test case which I should and wish I would have. This was causing issues in the
        // original release requiring maximized behavior to be implemented manually by saving the
        // restored bounds. The problem was that the resize functionality in DockNode.java was
        // executing at the same time canceling the maximized change.
        // https://bugs.openjdk.java.net/browse/JDK-8133334

        // restore/minimize the window after we have obtained its dimensions
        dockNode.setMaximized(false);

        // scale the drag start location by our restored dimensions
        dragStart = new Point2D(ratioX * dockNode.getWidth(), ratioY * dockNode.getHeight());
      }
      dragging = true;
      event.consume();
    } else if (event.getEventType() == MouseEvent.MOUSE_DRAGGED) {
      if (dockNode.isFloating()
          && event.getClickCount() == 2
          && event.getButton() == MouseButton.PRIMARY) {
        event.setDragDetect(false);
        event.consume();
        return;
      }

      if (!dragging) return;

      Stage stage = dockNode.getStage();
      Insets insetsDelta = this.getDockNode().getBorderPane().getInsets();

      // dragging this way makes the interface more responsive in the event
      // the system is lagging as is the case with most current JavaFX
      // implementations on Linux
      stage.setX(event.getScreenX() - dragStart.getX() - insetsDelta.getLeft());
      stage.setY(event.getScreenY() - dragStart.getY() - insetsDelta.getTop());

      // TODO: change the pick result by adding a copyForPick()
      DockEvent dockEnterEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_ENTER,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null);
      DockEvent dockOverEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_OVER,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null);
      DockEvent dockExitEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_EXIT,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null);

      EventTask eventTask =
          new EventTask() {
            @Override
            public void run(Node node, Node dragNode) {
              executions++;

              if (dragNode != node) {
                Event.fireEvent(node, dockEnterEvent.copyFor(DockTitleBar.this, node));

                if (dragNode != null) {
                  // fire the dock exit first so listeners
                  // can actually keep track of the node we
                  // are currently over and know when we
                  // aren't over any which DOCK_OVER
                  // does not provide
                  Event.fireEvent(dragNode, dockExitEvent.copyFor(DockTitleBar.this, dragNode));
                }

                dragNodes.put(node.getScene().getWindow(), node);
              }
              Event.fireEvent(node, dockOverEvent.copyFor(DockTitleBar.this, node));
            }
          };

      this.pickEventTarget(
          new Point2D(event.getScreenX(), event.getScreenY()), eventTask, dockExitEvent);
    } else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) {
      dragging = false;

      DockEvent dockReleasedEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_RELEASED,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null,
              this.getDockNode());

      EventTask eventTask =
          new EventTask() {
            @Override
            public void run(Node node, Node dragNode) {
              executions++;
              if (dragNode != node) {
                Event.fireEvent(node, dockReleasedEvent.copyFor(DockTitleBar.this, node));
              }
              Event.fireEvent(node, dockReleasedEvent.copyFor(DockTitleBar.this, node));
            }
          };

      this.pickEventTarget(new Point2D(event.getScreenX(), event.getScreenY()), eventTask, null);

      dragNodes.clear();

      // Remove temporary event handler for bug mentioned above.
      DockPane dockPane = this.getDockNode().getDockPane();
      if (dockPane != null) {
        dockPane.removeEventFilter(MouseEvent.MOUSE_DRAGGED, this);
        dockPane.removeEventFilter(MouseEvent.MOUSE_RELEASED, this);
      }
    }
  }