コード例 #1
0
  @Override
  public void start(Stage stage) {
    stage.setTitle("URL Lister");
    Scene scene = new Scene(new Group(), 1250, 700);

    GridPane grid = new GridPane();
    grid.setVgap(4);
    grid.setHgap(10);
    grid.setPadding(new Insets(5, 5, 5, 5));
    grid.add(new Label("Server: "), 0, 0);
    grid.add(new Label("URL: "), 0, 1);
    grid.add(subject, 1, 1, 3, 1);
    grid.add(text, 1, 60, 2, 10);
    grid.add(text2, 10, 60, 2, 10);
    grid.add(text3, 10, 20, 2, 5);
    grid.add(button, 0, 3);
    grid.add(button2, 5, 60);
    grid.add(button3, 5, 65);
    grid.add(notification, 1, 3, 3, 1);

    Group root = (Group) scene.getRoot();
    root.getChildren().add(grid);
    stage.setScene(scene);
    stage.show();
  }
コード例 #2
0
ファイル: Main.java プロジェクト: senderboard/matrix
  @Override
  public void start(Stage stage) throws Exception {
    this.primaryStage = stage;
    primaryStage.setTitle("Matrix Digital Rain");

    Group root = new Group();
    Scene scene = new Scene(root, 1024, 768);
    scene.addEventHandler(
        KeyEvent.KEY_PRESSED,
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent keyEvent) {
            if (keyEvent.getCode() == KeyCode.F) {
              primaryStage.setFullScreen(!primaryStage.isFullScreen());
            }
            if (keyEvent.isControlDown() && keyEvent.getCode() == KeyCode.Q) {
              primaryStage.close();
            }
          }
        });

    Canvas canvas = new Canvas();
    canvas.widthProperty().bind(primaryStage.widthProperty());
    canvas.heightProperty().bind(primaryStage.heightProperty());

    final GraphicsContext gc = canvas.getGraphicsContext2D();
    gc.setFont(font);

    setupSimulation();

    new AnimationTimer() {
      @Override
      public void handle(long now) {
        update(now);

        gc.clearRect(0, 0, primaryStage.getWidth(), primaryStage.getHeight());
        gc.setFill(Color.rgb(0, 0, 1));
        gc.fillRect(0, 0, primaryStage.getWidth(), primaryStage.getHeight());

        int y = 0;
        int nbGlyphsPerRow = getNbGlyphsPerRow();
        int nbGlyphsPerColumn = getNbGlyphsPerColumn();

        for (int i = 0; i < nbGlyphsPerRow * nbGlyphsPerColumn; ++i) {
          gc.setFill(Color.rgb(0, path[i], 0));
          String text = String.valueOf(data[i]);
          gc.fillText(text, (i % nbGlyphsPerRow) * 12 + 1, y + 13);

          if (i % nbGlyphsPerRow == nbGlyphsPerRow - 1) {
            y += 12;
          }
        }
      }
    }.start();

    root.getChildren().add(canvas);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
コード例 #3
0
  private static SubScene createSubScene(
      String title, Node node, Paint fillPaint, Camera camera, boolean msaa) {
    Group root = new Group();

    PointLight light = new PointLight(Color.WHITE);
    light.setTranslateX(50);
    light.setTranslateY(-300);
    light.setTranslateZ(-400);
    PointLight light2 = new PointLight(Color.color(0.6, 0.3, 0.4));
    light2.setTranslateX(400);
    light2.setTranslateY(0);
    light2.setTranslateZ(-400);

    AmbientLight ambientLight = new AmbientLight(Color.color(0.2, 0.2, 0.2));
    node.setRotationAxis(new Point3D(2, 1, 0).normalize());
    node.setTranslateX(180);
    node.setTranslateY(180);
    root.getChildren().addAll(setTitle(title), ambientLight, light, light2, node);

    SubScene subScene =
        new SubScene(
            root, 500, 400, true, msaa ? SceneAntialiasing.BALANCED : SceneAntialiasing.DISABLED);
    subScene.setFill(fillPaint);
    subScene.setCamera(camera);

    return subScene;
  }
コード例 #4
0
  private Scene createMainTetrisScene() {
    mainPane = new BorderPane();

    VBox mainBox = new VBox();
    mainBox.setPadding(new Insets(200, 0, 0, 20));
    mainBox.getChildren().add(mainGrid);
    mainGrid.setOnKeyPressed(new KeyboardHandler());

    mainPane.setBottom(mainBox);
    mainPane.setTop(createActionPane());
    mainPane.setRight(createStatePane());

    Group group = new Group();
    for (int i = 19; i >= 0; i--) {
      for (int j = 0; j < 10; j++) {
        Image img;
        if (mainGrid.getColor(i, j) != Color.DARKGRAY) {
          img = new Image(getClass().getResourceAsStream("RED.png"));
        } else {
          img = new Image(getClass().getResourceAsStream("EMPTY.png"));
        }
        ImageView iView = new ImageView(img);
        iView.setX(j * 17);
        iView.setY(i * 16);
        iView.setOpacity(1);
        iView.setPreserveRatio(true);
        group.getChildren().addAll(iView);
      }
    }
    Scene scene = new Scene(group, 600, 600);
    mainPane.setCenter(group);

    return new Scene(mainPane, 380, 540); // 540
  }
コード例 #5
0
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("CoAP Explorer");
    Group root = new Group();
    Scene scene = new Scene(root, 800, 600);

    TextArea hexArea = new TextArea();
    TextArea binArea = new TextArea();

    CoapPacket packet = new CoapPacket();
    packet.setPayload("PAYLOAD");
    packetProp.setValue(packet);

    binArea.textProperty().bindBidirectional(packetProp, new AsciiConverter());

    hexArea.textProperty().bindBidirectional(packetProp, new HexConverter());
    hexArea.setEditable(false);
    hexArea.setFont(javafx.scene.text.Font.font(Font.MONOSPACED));

    VBox vbox = new VBox();
    vbox.setPadding(new Insets(10));
    vbox.setSpacing(8);

    VBox.setMargin(hexArea, new Insets(0, 0, 0, 8));
    vbox.getChildren().add(hexArea);
    VBox.setMargin(binArea, new Insets(0, 0, 0, 8));
    vbox.getChildren().add(binArea);

    root.getChildren().add(vbox);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
コード例 #6
0
ファイル: VisualiseFX.java プロジェクト: kcleungam/SLT
  /*
   * initialize the spheres
   */
  public void initializeParam() {
    lightSetting();

    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 5; j++) {
        for (int k = 0; k < 5; k++) {
          fingerCoor[i][j][k] = new Point3D(0, 0, -100);
          fingerNode[i][j][k] = new VisSphere(fingerSize);
          root.getChildren().add(fingerNode[i][j][k]);
        }
        fingerLine[i][j] = new PolyCylinder3D(getPoint3DArray(i, j), 5, Color.WHITE);
        root.getChildren().addAll(fingerLine[i][j].getLine());
      }
      palmCoor[i] = new Point3D(0, 0, -100);
      palmNode[i] = new VisSphere(palmSize);
      palmLine[i] = new PolyCylinder3D(getPoint3DArray(i), 7, Color.WHITE);
      root.getChildren().addAll(palmLine[i].getLine());
      root.getChildren().add(palmNode[i]);
    }
    // for better appearance, some nodes are hidden
    fingerNode[0][1][4].setVisible(false);
    fingerNode[0][2][4].setVisible(false);
    fingerNode[0][3][4].setVisible(false);
    fingerNode[1][1][4].setVisible(false);
    fingerNode[1][2][4].setVisible(false);
    fingerNode[1][3][4].setVisible(false);
  }
コード例 #7
0
  public Scene initialize(Stage s) {
    stage = s;
    Group root = new Group();
    Text t =
        new Text(
            260,
            100,
            " Escape From New Pangea                               The Survival of Humankind");
    t.setWrappingWidth(500);
    t.setFont(Font.font("Verdana", 20));
    t.setFill(Color.AZURE);
    Button b = new Button("Click to start");
    ImageView im = new ImageView(new Image("images/Gobi_Desert.jpg"));
    b.setLayoutX(300);
    b.setLayoutY(275);
    b.setMinWidth(200);
    b.setMinHeight(50);
    b.setOnMouseClicked(e -> startGame(e));
    root.getChildren().add(im);
    root.getChildren().add(t);
    root.getChildren().add(b);

    Scene scene = new Scene(root, 800, 600, Color.WHITE);
    return scene;
  }
コード例 #8
0
ファイル: Main.java プロジェクト: kofer99/testcode
  @Override
  public void start(Stage primaryStage) {
    try {
      Group root = new Group();
      Scene scene = new Scene(root, 400, 400);
      scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
      primaryStage.setScene(scene);
      primaryStage.show();

      final Rectangle rectBasicTimeline = new Rectangle();
      rectBasicTimeline.setX(0);
      rectBasicTimeline.setY(0);
      rectBasicTimeline.widthProperty().bind(scene.widthProperty());
      rectBasicTimeline.heightProperty().bind(scene.heightProperty());
      rectBasicTimeline.setFill(Color.RED);
      root.getChildren().add(rectBasicTimeline);
      final Timeline timeline = new Timeline();
      timeline.setCycleCount(Timeline.INDEFINITE);
      timeline.setAutoReverse(true);
      final KeyValue kv1 = new KeyValue(rectBasicTimeline.fillProperty(), Color.YELLOW);
      final KeyValue kv2 = new KeyValue(rectBasicTimeline.fillProperty(), Color.GREEN);
      final KeyValue kv3 = new KeyValue(rectBasicTimeline.fillProperty(), Color.BLUE);
      final KeyFrame kf1 = new KeyFrame(Duration.millis(5000), kv1);
      final KeyFrame kf2 = new KeyFrame(Duration.millis(10000), kv2);
      final KeyFrame kf3 = new KeyFrame(Duration.millis(15000), kv3);
      timeline.getKeyFrames().add(kf1);
      timeline.getKeyFrames().add(kf2);
      timeline.getKeyFrames().add(kf3);
      timeline.play();

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
コード例 #9
0
ファイル: StopWatch.java プロジェクト: ch25061/AnagramGame
 private void init(Stage primaryStage) {
   Group root = new Group();
   primaryStage.setScene(new Scene(root, 310, 320));
   watch = new Watch();
   myLayout();
   root.getChildren().add(watch);
 }
コード例 #10
0
  @Override
  public void start(Stage primaryStage) throws Exception {

    Button okBtn = new Button(Msg.get(this, "ok"));
    Button cancelBtn = new Button(Msg.get(this, "cancel"));

    // Set the location of the OK button
    okBtn.setLayoutX(10);
    cancelBtn.setLayoutY(10);

    // Set the location of the Cancel button relative to the OK button
    NumberBinding layoutXBinding = okBtn.layoutXProperty().add(okBtn.widthProperty().add(10));
    cancelBtn.layoutXProperty().bind(layoutXBinding);

    //
    cancelBtn.layoutYProperty().bind(okBtn.layoutYProperty());

    //
    Group root = new Group();
    root.getChildren().addAll(okBtn, cancelBtn);

    //
    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.setTitle(Msg.get(this, "title"));
    primaryStage.show();
  }
コード例 #11
0
ファイル: TableTabController.java プロジェクト: Gikkman/CluIt
  @FXML
  protected void clear_tab(ActionEvent ae) {
    group.getChildren().clear();

    wrap_pane.getChildren().clear();
    label_box.getChildren().clear();

    wrap_pane = new HBox();
    label_box = new VBox();

    group.getChildren().add(wrap_pane);
    group.getChildren().add(label_box);

    mDataLabelToRow.clear();
    mRefLabelToRow.clear();

    mDataTables.clear();
    mRefDataTables.clear();

    mNextLabelIndex = 0;
    mNextRefLabelIndex = 0;
    mNextRun = 1;

    mLabelTable = null;
    mRefLabelTable = null;

    first = true;
  }
コード例 #12
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    Group root = new Group();
    primaryStage.setScene(new Scene(root));

    MoltenToggleButtonBar moltenToggleButtonBar = new MoltenToggleButtonBar();
    moltenToggleButtonBar.addToggleButton("Left Button");
    moltenToggleButtonBar.addToggleButton("Center Button");
    moltenToggleButtonBar.addToggleButton("another");
    moltenToggleButtonBar.addToggleButton("one");
    moltenToggleButtonBar.addToggleButton("Right Button");
    moltenToggleButtonBar.each(
        new Callback<ToggleButton, Void>() {
          @Override
          public Void call(final ToggleButton toggleButton) {
            toggleButton.setOnAction(
                new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent actionEvent) {
                    System.out.println(toggleButton.getText());
                  }
                });
            return null;
          }
        });

    HBox hBox = new HBox();
    moltenToggleButtonBar.addButtonsTo(hBox);

    hBox.getChildren().add(new ToggleButton("default size"));

    root.getChildren().addAll(hBox);
    primaryStage.show();
  }
コード例 #13
0
ファイル: FlightCubeViewer.java プロジェクト: ecmnet/MAVGCL
  public void remove(int k) {
    try {
      zAxisData.remove(k);
      xAxisData.remove(k);
      yAxisData.remove(k);
    } catch (Exception e) {
      e.printStackTrace();
    }

    Platform.runLater(
        () -> {
          scatterDataGroup.getChildren().clear();
          for (int i = 0; i < zAxisData.size(); i++) {
            final Sphere dataSphere = new Sphere(scatterRadius);
            double translateX = 0.0;
            double translateY = 0.0;
            if (!xAxisData.isEmpty() && xAxisData.size() > i) translateX = xAxisData.get(i);
            if (!yAxisData.isEmpty() && yAxisData.size() > i) translateY = yAxisData.get(i);
            dataSphere.setTranslateX(translateX);
            dataSphere.setTranslateY(translateY);
            dataSphere.setTranslateZ(zAxisData.get(i));
            scatterDataGroup.getChildren().add(dataSphere);
          }
        });
  }
コード例 #14
0
ファイル: HelloStage.java プロジェクト: mectest1/HelloGUI
  @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);
  }
コード例 #15
0
ファイル: Clock.java プロジェクト: ArfaaShariff/javafx-gradle
 public Clock(Color onColor, Color offColor) {
   // create effect for on LEDs
   Glow onEffect = new Glow(1.7f);
   onEffect.setInput(new InnerShadow());
   // create effect for on dot LEDs
   Glow onDotEffect = new Glow(1.7f);
   onDotEffect.setInput(new InnerShadow(5, Color.BLACK));
   // create effect for off LEDs
   InnerShadow offEffect = new InnerShadow();
   // create digits
   digits = new Digit[7];
   for (int i = 0; i < 6; i++) {
     Digit digit = new Digit(onColor, offColor, onEffect, offEffect);
     digit.setLayoutX(i * 80 + ((i + 1) % 2) * 20);
     digits[i] = digit;
     getChildren().add(digit);
   }
   // create dots
   Group dots =
       new Group(
           new Circle(80 + 54 + 20, 44, 6, onColor),
           new Circle(80 + 54 + 17, 64, 6, onColor),
           new Circle((80 * 3) + 54 + 20, 44, 6, onColor),
           new Circle((80 * 3) + 54 + 17, 64, 6, onColor));
   dots.setEffect(onDotEffect);
   getChildren().add(dots);
   // update digits to current time and start timer to update every second
   refreshClocks();
 }
コード例 #16
0
ファイル: Snake.java プロジェクト: szamani20/Snake
  private void doesEatRegime() {
    if (isEnd) return;

    if (Math.abs(blocks.peekFirst().getX() - regimeRectangle.getX()) < 10
        && Math.abs(blocks.peekFirst().getY() - regimeRectangle.getY()) < 10
        && System.currentTimeMillis() - currentTime <= 10000) {

      regimeRectangle.setX(1200);
      isRegime = false;
      ++score;
      scoreLabel.setText(String.valueOf(score));

      blocks.pollLast();
      blocks.pollLast();
      blocks.pollLast();

      group.getChildren().remove(rectangles.peekLast());
      rectangles.pollLast();
      group.getChildren().remove(rectangles.peekLast());
      rectangles.pollLast();
      group.getChildren().remove(rectangles.peekLast());
      rectangles.pollLast();
    }

    if (System.currentTimeMillis() - currentTime > 10000) {
      regimeRectangle.setX(1200);
      isRegime = false;
    }
  }
コード例 #17
0
ファイル: PlayingVideo.java プロジェクト: weijiancai/reserve
  private Group createButtonArea(final Scene scene) {
    // create button area
    final Group buttonGroup = new Group();
    // rounded rect
    Rectangle buttonArea =
        RectangleBuilder.create()
            .arcWidth(15)
            .arcHeight(20)
            .fill(new Color(0, 0, 0, .55))
            .x(0)
            .y(0)
            .width(60)
            .height(30)
            .stroke(Color.rgb(255, 255, 255, .70))
            .build();
    buttonGroup.getChildren().add(buttonArea);

    // move button group when scene is resized
    buttonGroup
        .translateXProperty()
        .bind(scene.widthProperty().subtract(buttonArea.getWidth() + 6));
    buttonGroup
        .translateYProperty()
        .bind(scene.heightProperty().subtract(buttonArea.getHeight() + 6));
    return buttonGroup;
  }
コード例 #18
0
  public InputDialog(final String title, final Object[] data) {
    initOwner(null);

    setTitle(title);

    if (0 != data.length % 2) {
      throw new IllegalArgumentException("Object data must be even!");
    }

    final Group root = new Group();
    final Scene scene = new Scene(root);
    setScene(scene);

    final GridPane gridpane = new GridPane();
    gridpane.setPadding(new Insets(5));
    gridpane.setHgap(5);
    gridpane.setVgap(5);

    for (int i = 0; i < data.length; i++) {
      if (0 == i % 2) {
        final Label label = new Label((String) data[i]);
        gridpane.add(label, 0, i / 2);
      } else {
        gridpane.add((Node) data[i], 1, (i - 1) / 2);
      }
    }

    gridpane.add(submit, 1, data.length / 2 + 1);
    GridPane.setHalignment(submit, HPos.RIGHT);
    root.getChildren().add(gridpane);
    sizeToScene();
    show();
  }
コード例 #19
0
ファイル: TetrahedraTest.java プロジェクト: sanke69/fr.xs.jtk
  @Override
  public Group testObject3D() {
    Group group = new Group();

    TetrahedraMesh tetra = new TetrahedraMesh(10, 7, null);
    // cylinder = new PrismMesh(0.2,2,3); //,new Point3D(-5,5,0),new
    // Point3D(0,0,5));
    tetra.setDrawMode(DrawMode.LINE);
    tetra.setCullFace(CullFace.NONE);
    // NONE
    // cylinder.setTextureModeNone(Color.ROYALBLUE);
    // IMAGE
    // tetra.setTextureModeImage(getClass().getResource("res/steel-mesh.jpg").toExternalForm());
    // tetra.setTextureModeVertices1D(6, t->t);
    // cylinder.setColorPalette(ColorPalette.GREEN);
    // DENSITY
    tetra.setTextureModeVertices3D(1530, p -> p.magnitude());
    // cylinder.setTextureModeVertices3D(1530,p->(double)cylinder.unTransform(p).magnitude());
    // FACES
    // tetra.setTextureModeFaces(1530);

    group.getChildren().add(tetra);

    return group;
  }
コード例 #20
0
ファイル: Main.java プロジェクト: chilyashev/ChatClient
  @Override
  public void start(Stage primaryStage) throws Exception {

    ScreenContainer mainScreen = new ScreenContainer();

    // Adding the screens
    mainScreen.loadScreen("login", "/screens/client/login.fxml");
    mainScreen.loadScreen("main", "/screens/client/main.fxml");

    // Showing the main screen
    mainScreen.showScreen("login");
    primaryStage.setOnCloseRequest(
        event -> {
          mainScreen.closeScreen();
        });
    // Displaying the stage
    Group root = new Group();
    root.getChildren().addAll(mainScreen);
    Scene scene =
        new Scene(
            root); // , root.getLayoutBounds().getWidth(), root.getLayoutBounds().getHeight());
    primaryStage.setScene(scene);
    primaryStage.minHeightProperty().bind(mainScreen.heightProperty());
    primaryStage.minWidthProperty().bind(mainScreen.widthProperty());
    primaryStage.setTitle("Chat Client");
    primaryStage.show();
  }
コード例 #21
0
ファイル: MapEditor.java プロジェクト: Alpha2k10/ZGame
  public void loadMapEditor(Group root) {
    Logic.Images.LoadImagesEditor li = new LoadImagesEditor();
    li.loadMapEditor();

    Group meGroup = new Group();
    ivHover = new ImageView(Objekte.getImgMapEditor().getSingleBorderHover());
    ivHover.setVisible(true);

    Gui.Listener.EditorHoverListener eHoverL = new Gui.Listener.EditorHoverListener(ivHover);

    for (int y = 0; y < Objekte.getMapData().getMapSizeY(); y++) {
      for (int x = 0; x < Objekte.getMapData().getMapSizeX(); x++) {

        ImageView iv = new ImageView(Objekte.getImgMapEditor().getSingleBorder());
        iv.setLayoutX(x * 25);
        iv.setLayoutY(y * 25);
        eHoverL.addImageView(iv);
        iv.hoverProperty().addListener(eHoverL);
        meGroup.getChildren().add(iv);
      }
    }

    root.getChildren().add(meGroup);
    root.getChildren().add(ivHover);

    loadEditorPalette(root);
    loadMapUI(root);
    loadEditorButtons(root);
    loadMapNumbers(root);
  }
コード例 #22
0
  private void sceneDidChange() {
    assert this.scrollPane != null;

    if (scrollPane.getScene() != null) {
      assert scalingGroup.isVisible() == false;

      // Here we'd like to layout the user scene graph immediately
      // i.e. invoke:
      //      1) layoutContent()      // to relayout user scene graph
      //      2) adjustWorkspace()    // to size the content workspace
      //
      // However invoking layoutContent() from here (scene change listener)
      // does not work very well (see RT-32326).
      //
      // So we do these two steps in runLater().
      // Until they are done, scalingGroup is kept invisible to avoid
      // visual artifacts. After the two steps are done, we turn the
      // visible by calling revealScalingGroup().

      Platform.runLater(
          () -> {
            layoutContent(true /* applyCSS */);
            adjustWorkspace();
            revealScalingGroup();
          });
    } else {
      assert scalingGroup.isVisible();
      scalingGroup.setVisible(false);
    }
  }
コード例 #23
0
ファイル: Minimal.java プロジェクト: LeiaChen/JavaFX
  @Override
  public void start(Stage primaryStage) throws Exception {
    // creating Layout
    final Group root = new Group();
    Scene scene = new Scene(root, 400, 400);
    primaryStage.setScene(scene);
    primaryStage.setResizable(false);
    StackPane waitingPane = new StackPane();
    final ProgressBar progress = new ProgressBar();
    Label load = new Label("loading things...");
    progress.setTranslateY(-25);
    load.setTranslateY(25);
    waitingPane.getChildren().addAll(new Rectangle(400, 400, Color.WHITE), load, progress);
    root.getChildren().add(waitingPane);

    // Task for computing the Panels:
    Task<Void> task =
        new Task<Void>() {
          @Override
          protected Void call() throws Exception {
            for (int i = 0; i < 20; i++) {
              try {
                Thread.sleep(new Random().nextInt(1000));
              } catch (InterruptedException ex) {
                ex.printStackTrace();
              }
              final double prog = i * 0.05;
              Platform.runLater(
                  new Runnable() {
                    public void run() {
                      progress.setProgress(prog);
                    }
                  });
            }
            return null;
          }
        };

    // stateProperty for Task:
    task.stateProperty()
        .addListener(
            new ChangeListener<Worker.State>() {

              @Override
              public void changed(
                  ObservableValue<? extends State> observable,
                  State oldValue,
                  Worker.State newState) {
                if (newState == Worker.State.SUCCEEDED) {
                  loadPanels(root);
                }
              }
            });

    // start Task
    new Thread(task).start();

    primaryStage.show();
  }
コード例 #24
0
ファイル: Optimizer.java プロジェクト: thiagodemoura/JCSG
 private void removeEmptyGroups() {
   for (Parent p : emptyParents) {
     Parent parent = p.getParent();
     Group g = (Group) parent;
     g.getChildren().addAll(p.getChildrenUnmodifiable());
     g.getChildren().remove(p);
   }
 }
コード例 #25
0
 public List<String> getThemeStyleSheets() {
   final List<String> result;
   if (contentGroup.getStylesheets().isEmpty()) {
     result = null;
   } else {
     result = contentGroup.getStylesheets();
   }
   return result;
 }
コード例 #26
0
ファイル: LabelBox.java プロジェクト: GeePawHill/contentment
 protected void fadeIn(double frac, Context context) {
   if (frac == 0d) {
     group.setOpacity(0d);
     animateDrawText(1d, context);
     animateComputeBox(1d, context);
     animateDrawBox(1d, context);
   }
   group.setOpacity(frac);
 }
コード例 #27
0
 // initializes and returns the Scene for the splash screen, will fail if
 // bg image cannot be found
 public Scene init(Stage stage, Timeline timeline, int width, int height) {
   Group root = new Group();
   mySplash = new Scene(root, width, height, Color.GREEN);
   Image bg = new Image(getClass().getClassLoader().getResourceAsStream("splash.png"));
   myBackground = new ImageView(bg);
   root.getChildren().add(myBackground);
   goToInfo(stage, timeline);
   return mySplash;
 }
コード例 #28
0
  @Override
  public void start(Stage primaryStage) throws MalformedURLException {

    initialize();

    primaryStage.setTitle("Media Player");
    Group root = new Group();
    Scene scene = new Scene(root, 540, 241);

    // create media player
    File file = new File(MEDIA_URL);
    Media media = null;
    try {
      if (file.exists()) {

        System.out.println("FILE EXISTS");
        media = new Media(file.toURI().toURL().toExternalForm());
        MediaPlayer mediaPlayer = new MediaPlayer(media);
        mediaPlayer.setAutoPlay(false);
        MediaControl mediaControl = new MediaControl(mediaPlayer);
        scene.setRoot(mediaControl);

        primaryStage.setScene(scene);
        primaryStage.show();
      } else {
        Dialogs.showErrorDialog(
            null, null, "Instrumental file not found. Please contact the administrator.", "ERROR");
      }
    } catch (Exception e) {
      System.out.println("FILE DOES NOT EXIST");
      // FileChooser fileChooser = new FileChooser();

      // Set extension filter
      // FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("MP3 files
      // (*.mp3)", "*.mp3");
      // fileChooser.getExtensionFilters().add(extFilter);

      // Show open file dialog
      // file = fileChooser.showOpenDialog(null);
      // String url =
      // "http://mp3crow.mobi/dl/aHR0cDovL2FwaS5zb3VuZGNsb3VkLmNvbS90cmFja3MvNjg4ODI2OTUvc3RyZWFtP2NsaWVudF9pZD1mZmEwYzc5YmY4YWVkYzBkOWIwYmIwNzQyNzhjZjI1MQ==yFRzUi1GcmVzaCAmIFNjcmF0Y2gtRCBvZiBEeW5hbWl4IElJIC0gUm9ja2luIHRvIHRoZSBCZWF0IHRoYXQgaXMgc28gRnJlc2hoaGhoaGho.mp3";
      // media = new Media(file.toURI().toURL().toExternalForm());
      // MediaPlayer mediaPlayer = new MediaPlayer(media);
      // mediaPlayer.setAutoPlay(false);
      // MediaControl mediaControl = new MediaControl(mediaPlayer);
      // scene.setRoot(mediaControl);

      String content = open();

      root.getChildren().add(new Button(content));

      primaryStage.setScene(scene);
      primaryStage.show();
      // Dialogs.showErrorDialog(null, null, "Instrumental file not found. Please contact the
      // administrator.", "ERROR");
    }
  }
コード例 #29
0
  @Override
  public Group scene3D() {
    Group group = new Group();

    String[] ac = {
        /* Our star   */
      "Soleil",
      /* Planets    */ "Mercure",
      "Venus",
      "Earth",
      "Mars",
      "Jupiter",
      "Saturne",
      "Uranus",
      "Neptune",
      /* Satellites */ "Moon",
      "Io",
      /* Others     */ "Pluton",
    };

    Planetoid[] astres = new Planetoid[ac.length];

    int i = 0;
    double x = 0.0, dx = 20.0;
    for (String planetoid : ac) {
      System.out.println(planetoid);

      AstralCorpseBean bean = new AstralCorpseBean();
      bean.load(MediaHelper.getURLForFile("/Solar System/" + planetoid + "/" + planetoid + ".ac"));
      bean.setRadius(10 /*bean.getRadius()*/);
      System.out.println(bean);

      final Planetoid corpse = new Planetoid(planetoid, bean.getRadius());
      PlanetoidEnlightment.setTexture(
          corpse, "Solar System/" + planetoid + "/" + planetoid + ".png");
      corpse.setTranslateX(x += dx);
      //			corpse.animate();
      astres[i++] = corpse;
    }

    Pivot p0 = new Pivot(0, 0, 0);
    Pivot p1 = new Pivot(100, 100, 100);

    AmbientLight ambient = new AmbientLight(Color.WHITE);

    //		PointLight light = new PointLight(Color.WHITE);
    //		p1.getChildren().add(light);

    group.getChildren().addAll(ambient);
    group.getChildren().addAll(astres);
    //		group.getChildren().addAll(new UniverseBox("redsky", 1e5));

    group.getChildren().addAll(buildAxes(p0, 10), buildAxes(p1, 50));

    return group;
  }
コード例 #30
0
  private static void updateBoard() {
    for (int ii = 0; ii < numOfPlayers; ii++) {
      SimpleResList list = new SimpleResList(boards[ii].getResourceList());
      list.subtract(resList[ii]);
      for (int i = 1; i < 8; i++) {
        for (int j = 0; j < list.numAt(i); j++) wonder[ii].addResource(i);
      }
      resList[ii] = boards[ii].getResourceList();

      // ArrayList<SimpleResList> or = new
      // ArrayList<SimpleResList>(boards[ii].getOrList());
      // if(orList[ii] != null)
      // or.removeAll(orList[ii]);
      ArrayList<SimpleResList> or = boards[ii].getOrList();
      for (int i = orListNum[ii]; i < or.size(); i++) {
        // JOptionPane.showMessageDialog(null, or.get(i));
        SimpleResList oneOrList = or.get(i);
        int kind;
        if (oneOrList.numAt(1) == 1 && oneOrList.numAt(4) == 1 && oneOrList.numAt(2) == 0) kind = 8;
        else if (oneOrList.numAt(1) == 1 && oneOrList.numAt(3) == 1 && oneOrList.numAt(2) == 0)
          kind = 9;
        else if (oneOrList.numAt(1) == 1 && oneOrList.numAt(2) == 1 && oneOrList.numAt(3) == 0)
          kind = 10;
        else if (oneOrList.numAt(3) == 1 && oneOrList.numAt(4) == 1 && oneOrList.numAt(2) == 0)
          kind = 11;
        else if (oneOrList.numAt(2) == 1 && oneOrList.numAt(4) == 1 && oneOrList.numAt(3) == 0)
          kind = 12;
        else if (oneOrList.numAt(2) == 1 && oneOrList.numAt(3) == 1 && oneOrList.numAt(1) == 0)
          kind = 13;
        else if (oneOrList.numAt(5) == 1 && oneOrList.numAt(6) == 1 && oneOrList.numAt(7) == 1)
          kind = 14;
        else if (oneOrList.numAt(1) == 1
            && oneOrList.numAt(2) == 1
            && oneOrList.numAt(3) == 1
            && oneOrList.numAt(4) == 1) kind = 15;
        else continue;
        wonder[ii].addResource(kind);
        orListNum[ii]++;
      }
      // SimpleResList or = new SimpleResList(sl)
      // if(ii == 0)
      // JOptionPane.showMessageDialog(null,
      // boards[ii].getTotalCoins()+":" + coins[ii]);
      wonder[ii].addGoldSign(boards[ii].getTotalCoins() - coins[ii]);
      coins[ii] = boards[ii].getTotalCoins();

      if (boards[ii].getStagesCompleted() > wonder[ii].getHasbuild()) {
        wonder[ii].stageCompleted(age);
      }

      // wonder[ii].toFront();// Must be wrong, but must be here!
      MainBackGround.order();
    }
    cardBoard.toFront();
    playerBoard.toFront();
  }