Example #1
1
  private static void layoutizeLabelCreator(
      ICreatorCustomLabel myLabel, double r, double g, double b) {
    Color color = Color.color(r, g, b);
    ((Label) myLabel)
        .setBackground(
            new Background(new BackgroundFill(color, new CornerRadii(3), new Insets(0))));
    ((Label) myLabel).setStyle("-fx-border-color: white;");
    ((Label) myLabel).setMinSize(400, 35);
    ((Label) myLabel).setTextAlignment(TextAlignment.CENTER);
    ((Label) myLabel).setFont(Font.font(20));
    ((Label) myLabel)
        .setOnDragDetected(
            new EventHandler<MouseEvent>() {
              @Override
              public void handle(MouseEvent event) {
                Dragboard db = ((Label) event.getSource()).startDragAndDrop(TransferMode.ANY);

                ClipboardContent content = new ClipboardContent();
                content.putString("clipboardString");
                db.setContent(content);

                event.consume();
              }
            });
    ((Label) myLabel).setVisible(true);
  }
  public void showEDResult(List<String> path) {
    // intialize alert/dialog to display edit distance result
    Alert alert = new Alert(AlertType.INFORMATION);
    alert.setTitle("Result");
    alert.setHeaderText("Word Path : ");
    alert.initModality(Modality.NONE);
    alert.setResizable(true);

    // create layout for content
    VBox box = new VBox();
    HBox midBox = new HBox();
    box.setPadding(new Insets(35, 0, 35, 0));
    box.setSpacing(35);
    midBox.setSpacing(15);

    Label pathLabel = new Label();
    Label numStepsLabel = new Label("Number of steps : ");
    Label numSteps = new Label();
    Font font = new Font(14);
    pathLabel.setFont(font);
    numStepsLabel.setFont(font);
    numSteps.setFont(Font.font(font.getFamily(), FontWeight.BOLD, 14));

    midBox.getChildren().add(numStepsLabel);
    midBox.getChildren().add(numSteps);
    midBox.setAlignment(Pos.CENTER);

    box.getChildren().add(pathLabel);
    box.getChildren().add(midBox);
    box.setAlignment(Pos.CENTER);
    alert.getDialogPane().setPrefWidth(300);

    // check for path
    if (path != null) {
      numSteps.setText(Integer.toString(path.size() - 1));
      pathLabel.setText(String.join(" -> ", path));

      Text text = new Text(pathLabel.getText());
      text.setFont(font);
      if (text.getLayoutBounds().getWidth() > 200) {
        alert.getDialogPane().setPrefWidth(text.getLayoutBounds().getWidth() + 100);
      }

    }
    // no path found
    else {
      pathLabel.setText("No Path Found.");
      numSteps.setText("N/A");
    }

    // set content and styling
    alert.getDialogPane().setContent(box);
    alert
        .getDialogPane()
        .getStylesheets()
        .add(getClass().getResource("application.css").toExternalForm());
    alert.getDialogPane().getStyleClass().add("myDialog");
    alert.showAndWait();
  }
  public void initContent(GridPane pane) {
    // pane.setGridLinesVisible(true);
    pane.setPadding(new Insets(20));
    pane.setHgap(10);
    pane.setVgap(20);

    // header label
    Label lblHeader = new Label("Alert Dialogs");
    pane.add(lblHeader, 1, 0);
    lblHeader.setTextFill(Color.DARKBLUE);
    lblHeader.setFont(Font.font("Calibri", FontWeight.BOLD, 36));

    // label for input text field
    Label lblInput = new Label("A Text field:");
    pane.add(lblInput, 0, 1);
    lblInput.setFont(Font.font("Calibri", FontWeight.NORMAL, 20));

    // input text field
    this.txfInput = new TextField();
    pane.add(txfInput, 1, 1);
    this.txfInput.setMinHeight(30.0);
    this.txfInput.setPromptText("Enter some text and save.");

    // horizontal box for buttons
    HBox hbox = new HBox(20);
    pane.add(hbox, 1, 2);
    hbox.setAlignment(Pos.CENTER);

    // info button
    Button btnInfo = new Button("Info");
    btnInfo.setOnAction(event -> this.infoAction());
    hbox.getChildren().add(btnInfo);

    // save button
    Button btnSave = new Button("Save");
    btnSave.setOnAction(event -> this.saveAction());
    hbox.getChildren().add(btnSave);

    // clear button
    Button btnClear = new Button("Clear");
    btnClear.setOnAction(event -> this.clearAction());
    hbox.getChildren().add(btnClear);

    // status text
    this.txtStatus = new Text();
    pane.add(txtStatus, 0, 4, 3, 1);
    this.txtStatus.setFont(Font.font("Calibri", FontWeight.NORMAL, 20));
    this.txtStatus.setFill(Color.FIREBRICK);
    this.txtStatus.setText("An example of Alert Dialogs. Enter some text and save.");

    btnInfo.requestFocus();
  }
 public void setResults(BenchmarkResult results) {
   double p = (double) results.score / 100;
   double marginalError = (1.96 * Math.sqrt((p * (1 - p)) / results.signatures.size())) * 100;
   pctLabel.setText(
       results.score
           + "% \u00B1 "
           + Math.round(marginalError)
           + "% ("
           + results.matched
           + "/"
           + results.signatures.size()
           + ")");
   for (SignatureResult result : results.signatures) {
     if (result.matched) {
       Label lbl =
           new Label(
               ""
                   + String.format(
                       "0x%06X -> 0x%06X", result.sourcePosition, result.matchedPosition)
                   + result.toString());
       lbl.setFont(Font.font("monospace"));
       resultList.getItems().add(lbl);
     }
   }
 }
Example #5
0
  public TelaAux(String mensagem) {
    this.mensagem = mensagem;

    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 450, 80, Color.LIGHTGRAY);

    VBox boxtexto = new VBox(10);

    Label texto = new Label(getMensagem());
    Button ok = new Button("OK");
    ok.setStyle("-fx-cursor: hand;");

    boxtexto.getChildren().addAll(texto, ok);
    boxtexto.setAlignment(Pos.CENTER);

    root.setCenter(boxtexto);
    texto.setFont(new Font(15));
    setScene(scene);
    setOpacity(0.9);
    initModality(
        Modality.APPLICATION_MODAL); // Responsável por só ser possível voltar ao sg ong se fechar a
    // janela.
    show();

    ok.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent arg0) {
            close();
          }
        });
  }
Example #6
0
  /** Constructor to create to access the GridPane created for adding organizations. */
  public QuestionnaireAdd() {

    // PaneController.addMap(TITLE, this);

    // GridPane gp = new GridPane();

    label = new Label("Create a New Questionnaire");
    label.setFont(Font.font("Verdana", FontWeight.BOLD, 18));
  }
 public Church(Main.Location loc) {
   super(CHURCH, loc);
   Label label = new Label();
   label.textProperty().bind(mealsServed.asString());
   label.setFont(Font.font("Impact", 12 * Main.SCALE));
   label.setTranslateX(-8 * Main.SCALE);
   label.setTranslateY(3 * Main.SCALE);
   getChildren().add(label);
 }
Example #8
0
  private Pane buildUpperArea() {

    Pane up = new Pane();
    up.prefHeightProperty().bind(this.heightProperty());
    up.prefWidthProperty().bind(this.widthProperty());

    TableView<DebateDetails> table = new TableView<DebateDetails>();
    table.prefHeightProperty().bind(up.heightProperty());
    table.prefWidthProperty().bind(up.widthProperty());

    final Label label = new Label("Debate Tournament");
    label.setFont(new Font("Arial", 20));

    table.setEditable(false);

    table.getChildrenUnmodifiable().clear();
    table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);

    TableColumn<DebateDetails, String> divCol = new TableColumn<DebateDetails, String>("Division");
    divCol.setCellValueFactory(new PropertyValueFactory<>("division"));

    TableColumn<DebateDetails, String> teamCountCol =
        new TableColumn<DebateDetails, String>("Team Count");
    teamCountCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("teamCount")));

    TableColumn<DebateDetails, String> debCountCol =
        new TableColumn<DebateDetails, String>("Debate Count");
    debCountCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("totalMatch")));

    TableColumn<DebateDetails, String> debCompCol =
        new TableColumn<DebateDetails, String>("Debates Completed ");
    debCompCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("matchCompleted")));

    TableColumn<DebateDetails, String> debRemCol =
        new TableColumn<DebateDetails, String>("Upcoming Debates");
    debRemCol.setCellValueFactory(new PropertyValueFactory<>(String.valueOf("matchRemaining")));

    final ObservableList<DebateDetails> data =
        FXCollections.observableArrayList(TeamManager.getDebateDetails());

    table.setItems(data);
    table.getColumns().add(divCol);
    table.getColumns().add(teamCountCol);
    table.getColumns().add(debCountCol);
    table.getColumns().add(debCompCol);
    table.getColumns().add(debRemCol);

    final VBox vbox = new VBox();
    vbox.setSpacing(5);
    vbox.setPadding(new Insets(10, 0, 0, 10));
    vbox.getChildren().addAll(label, table);
    up.getChildren().add(vbox);

    return up;
  }
  /** Set the Labels */
  protected void setLabels() {
    mLabels = new HashMap<String, Label>();
    mValues = new HashMap<String, Label>();

    for (String name : mLabelNames) {
      Label newLabel1 = new Label(name);
      Label newLabel2 = new Label();
      newLabel1.setFont(new Font("Arial", 20));
      newLabel2.setFont(new Font("Arial", 20));
      mLabels.put(name, newLabel1);
      mValues.put(name, newLabel2);
    }

    Label upgradeLabel = new Label(mUpgradeName);
    upgradeLabel.setFont(new Font("Arial", 25));
    upgradeLabel.setWrapText(true);
    mLabels.put(mUpgradeName, upgradeLabel);

    update();
  }
Example #10
0
 PortPane() {
   label = new Label("Willkommen!\n" + "Bitte Port eingeben:");
   label.setFont(Font.font("Comic sans MS", 20));
   this.add(label, 0, 0, 2, 1);
   Label portLabel = new Label("Port:");
   this.add(portLabel, 0, 1);
   textField = new TextField("24242");
   textField.setPrefColumnCount(5);
   textField
       .lengthProperty()
       .addListener(
           new ChangeListener<Number>() {
             @Override
             public void changed(
                 ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
               if (newValue.intValue() > 5) textField.setText(textField.getText(0, 5));
               else if (newValue.intValue() > oldValue.intValue()) {
                 char ch = textField.getText().charAt(oldValue.intValue());
                 if (!(ch >= '0' && ch <= '9')) {
                   textField.setText(
                       textField.getText().substring(0, textField.getText().length() - 1));
                 }
               }
             }
           });
   this.add(textField, 1, 1);
   final Button button = new Button("Fertig!");
   HBox hBox = new HBox(10);
   hBox.getChildren().add(button);
   hBox.setAlignment(Pos.BOTTOM_RIGHT);
   this.add(hBox, 1, 2);
   this.setHgap(10);
   this.setVgap(10);
   this.setPadding(new Insets(30, 30, 30, 30));
   this.setAlignment(Pos.CENTER);
   textField.setOnAction(
       new EventHandler<ActionEvent>() {
         @Override
         public void handle(ActionEvent actionEvent) {
           button.requestFocus();
         }
       });
   button.setOnAction(
       new EventHandler<ActionEvent>() {
         @Override
         public void handle(ActionEvent actionEvent) {
           if (!Main.createPortListener(Integer.parseInt(textField.getText()))) {
             Main.rootPane.setPorteingabe();
             setFailure(Integer.parseInt(textField.getText()));
           }
         }
       });
 }
  public LoadViewPane() {
    addListeners();

    Reflection reflection = new Reflection();

    text.setStyle("-fx-text-fill: FF8A00;");
    text.setLayoutY(40);
    text.setFont(Font.font("Iowan Old Style", 70));
    text.setEffect(reflection);

    getChildren().add(text);
  }
Example #12
0
 public static void layoutizeLabel(ICustomLabel myLabel, Color color) {
   ((Label) myLabel)
       .setBackground(
           new Background(new BackgroundFill(color, new CornerRadii(3), new Insets(0))));
   ((Label) myLabel).setBorder(Border.EMPTY);
   ((Label) myLabel).setStyle("-fx-border-color: white;");
   ((Label) myLabel).setMinSize(400, 35);
   ((Label) myLabel).setText(myLabel.getName());
   myLabel.setDescription(myLabel.getDescription());
   ((Label) myLabel).setTextAlignment(TextAlignment.CENTER);
   ((Label) myLabel).setFont(Font.font(20));
   ((Label) myLabel).setVisible(true);
 }
  private void setFont() {
    FontWeight weight;
    if (bold.isSelected()) {
      weight = FontWeight.BOLD;
    } else {
      weight = FontWeight.NORMAL;
    }

    FontPosture posture;
    if (italic.isSelected()) {
      posture = FontPosture.ITALIC;
    } else {
      posture = FontPosture.REGULAR;
    }

    newText.setFont(Font.font(fontChoice.getValue(), weight, posture, sizeChoice.getValue()));
  }
Example #14
0
 @Override
 public void handle(MouseEvent event) {
     if (pane.getChildren().isEmpty()) {
         // String tekst = teller++ % 2 == 0 ? "X" : "O";
         String tekst;
         if (teller % 2 == 0) tekst = "X";
         else tekst = "O";
         Label label = new Label(tekst);
         label.setFont(new Font(40));
         pane.getChildren().add(label);
         pane.settTekst(tekst);
         teller++;
     }
     if (sjekkBrett(pane)) {
         System.out.println("YAY");
     }
 }
Example #15
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();
  }
Example #16
0
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("OpenBot");
    primaryStage.setResizable(false);
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER_LEFT);
    grid.setHgap(10);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    Label scenetitle = new Label("Move Joints");
    scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
    grid.add(scenetitle, 2, 0, 5, 1);

    Image imgRight = new Image("images/arrowRight.png");
    Image imgLeft = new Image("images/arrowLeft.png");

    Button baseLeft = new Button();
    baseLeft.setGraphic(new ImageView(imgLeft));
    HBox hbbaseLeft = new HBox(10);
    hbbaseLeft.setAlignment(Pos.CENTER_LEFT);
    hbbaseLeft.getChildren().add(baseLeft);
    grid.add(hbbaseLeft, 0, 1);

    Label baseLabel = new Label("BASE");
    grid.add(baseLabel, 5, 1);

    Button baseRight = new Button();
    baseRight.setGraphic(new ImageView(imgRight));
    HBox hbbaseRight = new HBox(10);
    hbbaseRight.setAlignment(Pos.CENTER_RIGHT);
    hbbaseRight.getChildren().add(baseRight);
    grid.add(hbbaseRight, 7, 1);

    TextField baseText = new TextField();
    baseText.setPromptText("Base angle");
    grid.add(baseText, 8, 1);

    Button shoulderLeft = new Button();
    shoulderLeft.setGraphic(new ImageView(imgLeft));
    HBox hbshoulderLeft = new HBox(10);
    hbshoulderLeft.setAlignment(Pos.CENTER_LEFT);
    hbshoulderLeft.getChildren().add(shoulderLeft);
    grid.add(hbshoulderLeft, 0, 2);

    Label shoulderLabel = new Label("SHOULDER");
    grid.add(shoulderLabel, 5, 2);

    Button shoulderRight = new Button();
    shoulderRight.setGraphic(new ImageView(imgRight));
    HBox hbshoulderRight = new HBox(10);
    hbshoulderRight.setAlignment(Pos.CENTER_RIGHT);
    hbshoulderRight.getChildren().add(shoulderRight);
    grid.add(hbshoulderRight, 7, 2);

    TextField shoulderText = new TextField();
    shoulderText.setPromptText("Shoulder angle");
    grid.add(shoulderText, 8, 2);

    Button elbowLeft = new Button();
    elbowLeft.setGraphic(new ImageView(imgLeft));
    HBox hbelbowLeft = new HBox(10);
    hbelbowLeft.setAlignment(Pos.CENTER_LEFT);
    hbelbowLeft.getChildren().add(elbowLeft);
    grid.add(hbelbowLeft, 0, 3);

    Label elbowLabel = new Label("ELBOW");
    grid.add(elbowLabel, 5, 3);

    Button elbowRight = new Button();
    elbowRight.setGraphic(new ImageView(imgRight));
    HBox hbelbowRight = new HBox(10);
    hbelbowRight.setAlignment(Pos.CENTER_RIGHT);
    hbelbowRight.getChildren().add(elbowRight);
    grid.add(hbelbowRight, 7, 3);

    TextField elbowText = new TextField();
    elbowText.setPromptText("Elbow angle");
    grid.add(elbowText, 8, 3);

    Button wrist1Left = new Button();
    wrist1Left.setGraphic(new ImageView(imgLeft));
    HBox hbwrist1Left = new HBox(10);
    hbwrist1Left.setAlignment(Pos.CENTER_LEFT);
    hbwrist1Left.getChildren().add(wrist1Left);
    grid.add(hbwrist1Left, 0, 4);

    Label wrist1Label = new Label("WRIST 1");
    grid.add(wrist1Label, 5, 4);

    Button wrist1Right = new Button();
    wrist1Right.setGraphic(new ImageView(imgRight));
    HBox hbwrist1Right = new HBox(10);
    hbwrist1Right.setAlignment(Pos.CENTER_RIGHT);
    hbwrist1Right.getChildren().add(wrist1Right);
    grid.add(hbwrist1Right, 7, 4);

    TextField wrist1Text = new TextField();
    wrist1Text.setPromptText("Wrist 1 angle");
    grid.add(wrist1Text, 8, 4);

    Button wrist2Left = new Button();
    wrist2Left.setGraphic(new ImageView(imgLeft));
    HBox hbwrist2Left = new HBox(10);
    hbwrist2Left.setAlignment(Pos.CENTER_LEFT);
    hbwrist2Left.getChildren().add(wrist2Left);
    grid.add(hbwrist2Left, 0, 5);

    Label wrist2Label = new Label("WRIST 2");
    grid.add(wrist2Label, 5, 5);

    Button wrist2Right = new Button();
    wrist2Right.setGraphic(new ImageView(imgRight));
    HBox hbwrist2Right = new HBox(10);
    hbwrist2Right.setAlignment(Pos.CENTER_RIGHT);
    hbwrist2Right.getChildren().add(wrist2Right);
    grid.add(hbwrist2Right, 7, 5);

    TextField wrist2Text = new TextField();
    wrist2Text.setPromptText("Wrist 2 angle");
    grid.add(wrist2Text, 8, 5);

    Button wrist3Left = new Button();
    wrist3Left.setGraphic(new ImageView(imgLeft));
    HBox hbwrist3Left = new HBox(10);
    hbwrist3Left.setAlignment(Pos.CENTER_LEFT);
    hbwrist3Left.getChildren().add(wrist3Left);
    grid.add(hbwrist3Left, 0, 6);

    Label wrist3Label = new Label("WRIST 3");
    grid.add(wrist3Label, 5, 6);

    Button wrist3Right = new Button();
    wrist3Right.setGraphic(new ImageView(imgRight));
    HBox hbwrist3Right = new HBox(10);
    hbwrist3Right.setAlignment(Pos.CENTER_RIGHT);
    hbwrist3Right.getChildren().add(wrist3Right);
    grid.add(hbwrist3Right, 7, 6);

    TextField wrist3Text = new TextField();
    wrist3Text.setPromptText("Wrist 3 angle");
    grid.add(wrist3Text, 8, 6);

    Button sendAllAnglesButton = new Button("Send All Angles");
    grid.add(sendAllAnglesButton, 8, 7);

    sendAllAnglesButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(baseText.getText());
            if (currentValue != -1) {
              client.moveBaseHorizontalTo(currentValue);
            }
            currentValue = parseInt(shoulderText.getText());
            if (currentValue != -1) {
              client.moveShoulderTo(currentValue);
            }
            currentValue = parseInt(elbowText.getText());
            if (currentValue != -1) {
              client.moveElbowTo(currentValue);
            }
            currentValue = parseInt(wrist1Text.getText());
            if (currentValue != -1) {
              client.moveWristOneTo(currentValue);
            }
            currentValue = parseInt(wrist2Text.getText());
            if (currentValue != -1) {
              client.moveWristTwoTo(currentValue);
            }
            currentValue = parseInt(wrist3Text.getText());
            if (currentValue != -1) {
              client.moveWristThreeTo(currentValue);
            }
          }
        });

    baseLeft.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(baseText.getText());
            if (currentValue != -1) {
              int targetValue = currentValue - 1;
              baseText.setText(String.valueOf(targetValue));
              client.moveBaseHorizontalTo(targetValue);
            }
          }
        });

    baseRight.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(baseText.getText());
            if (currentValue != -1) {
              int targetValue = currentValue + 1;
              baseText.setText(String.valueOf(targetValue));
              client.moveBaseHorizontalTo(targetValue);
            }
          }
        });

    shoulderLeft.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(shoulderText.getText());
            if (currentValue != -1) {
              int targetValue = currentValue - 1;
              shoulderText.setText(String.valueOf(targetValue));
              client.moveShoulderTo(targetValue);
            }
          }
        });

    shoulderRight.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(shoulderText.getText());
            if (currentValue != -1) {
              int targetValue = currentValue + 1;
              shoulderText.setText(String.valueOf(targetValue));
              client.moveShoulderTo(targetValue);
            }
          }
        });

    elbowLeft.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(elbowText.getText());
            if (currentValue != -1) {
              int targetValue = currentValue - 1;
              elbowText.setText(String.valueOf(targetValue));
              client.moveElbowTo(targetValue);
            }
          }
        });

    elbowRight.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(elbowText.getText());
            if (currentValue != -1) {
              int targetValue = currentValue + 1;
              elbowText.setText(String.valueOf(targetValue));
              client.moveElbowTo(targetValue);
            }
          }
        });

    wrist1Left.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(wrist1Text.getText());
            if (currentValue != -1) {
              int targetValue = currentValue - 1;
              wrist1Text.setText(String.valueOf(targetValue));
              client.moveWristOneTo(targetValue);
            }
          }
        });

    wrist1Right.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(wrist1Text.getText());
            if (currentValue != -1) {
              int targetValue = currentValue + 1;
              wrist1Text.setText(String.valueOf(targetValue));
              client.moveWristOneTo(targetValue);
            }
          }
        });

    wrist2Left.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(wrist2Text.getText());
            if (currentValue != -1) {
              int targetValue = currentValue - 1;
              wrist2Text.setText(String.valueOf(targetValue));
              client.moveWristTwoTo(targetValue);
            }
          }
        });

    wrist2Right.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(wrist2Text.getText());
            if (currentValue != -1) {
              int targetValue = currentValue + 1;
              wrist2Text.setText(String.valueOf(targetValue));
              client.moveWristTwoTo(targetValue);
            }
          }
        });

    wrist3Left.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(wrist3Text.getText());
            if (currentValue != -1) {
              int targetValue = currentValue - 1;
              wrist3Text.setText(String.valueOf(targetValue));
              client.moveWristThreeTo(targetValue);
            }
          }
        });

    wrist3Right.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int currentValue = parseInt(wrist3Text.getText());
            if (currentValue != -1) {
              int targetValue = currentValue + 1;
              wrist3Text.setText(String.valueOf(targetValue));
              client.moveWristThreeTo(targetValue);
            }
          }
        });

    Label scenetitle2 = new Label("Enter Angle");
    scenetitle2.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
    grid.add(scenetitle2, 8, 0, 5, 1);

    Label scenetitle3 = new Label("Tool Position");
    scenetitle3.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
    grid.add(scenetitle3, 10, 0, 5, 1);

    String xValue = "360.0";
    grid.add(x, 11, 1);
    x.setText("X :  " + xValue);

    String yValue = "360.0";
    grid.add(y, 11, 2);
    y.setText("Y :  " + yValue);

    String zValue = "360.0";
    grid.add(z, 11, 3);
    z.setText("Z :  " + zValue);

    String rxValue = "360.0";
    grid.add(rx, 11, 4);
    rx.setText("RX :  " + rxValue);

    String ryValue = "360.0";
    grid.add(ry, 11, 5);
    ry.setText("RY :  " + ryValue);

    String rzValue = "360.0";
    grid.add(rz, 11, 6);
    rz.setText("RZ :  " + rzValue);

    // Scene
    Scene scene = new Scene(grid, 700, 600);
    primaryStage.setScene(scene);
    primaryStage.show();

    primaryStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          @Override
          public void handle(WindowEvent event) {
            client.killClient();
          }
        });

    Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
    StyleManager.getInstance()
        .addUserAgentStylesheet(
            this.getClass().getResource("/resources/styleSheet.css").toExternalForm());
  }
Example #17
0
  @Override
  public void start(Stage primaryStage) throws Exception {

    GridPane grid = new GridPane();
    // grid.setAlignment(Pos.CENTER);

    Label display = new Label();
    display.setText("Display");
    display.setPrefHeight(50);
    display.setFont(Font.font("Century Gothic", FontWeight.NORMAL, 20));

    Button[] buttons = new Button[16];
    CalculatorButton[] buttonPressed =
        new CalculatorButton[] {
          newButton("7", Element.OPERAND), newButton("8", Element.OPERAND),
              newButton("9", Element.OPERAND), newButton("+", Element.OPERATOR),
          newButton("4", Element.OPERAND), newButton("5", Element.OPERAND),
              newButton("6", Element.OPERAND), newButton("-", Element.OPERATOR),
          newButton("1", Element.OPERAND), newButton("2", Element.OPERAND),
              newButton("3", Element.OPERAND), newButton("*", Element.OPERATOR),
          newButton("DEL", Element.CLEANER), newButton("0", Element.OPERAND),
              newButton("=", Element.OPERATOR), newButton("/", Element.OPERATOR),
        };

    for (int i = 0; i < buttons.length; i++) {

      if (i % 4 == 0) rows++;

      buttons[i] = new Button();
      buttons[i].setPrefSize(50, 50);
      buttons[i].setText(buttonPressed[i].getButtonValue());
      final int finalI = i;
      buttons[i].setOnMouseClicked(
          new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {

              switch (buttonPressed[finalI].getElementType()) {
                case CLEANER:
                  display.setText("0");
                  firstValue = "";
                  secondValue = "";
                  hasOperator = false;
                  operatorString = "";
                  break;

                case OPERAND:
                  if (hasOperator) {

                    secondValue += buttonPressed[finalI].getButtonValue();
                    display.setText(secondValue);

                  } else {
                    firstValue += buttonPressed[finalI].getButtonValue();
                    display.setText(firstValue);
                  }
                  break;

                case OPERATOR:
                  if (hasOperator) {

                    if (firstValue.length() > 0 && secondValue.length() > 0) {

                      display.setText(
                          Integer.toString(
                              brain.operation(firstValue, operatorString, secondValue)));

                      firstValue =
                          Integer.toString(
                              brain.operation(firstValue, operatorString, secondValue));

                      operatorString = buttonPressed[finalI].getButtonValue();

                      secondValue = "";
                    } else {
                      operatorString = buttonPressed[finalI].getButtonValue();
                    }

                    System.out.println("has operator");

                  } else {
                    if (firstValue.length() > 0) {

                      operatorString = buttonPressed[finalI].getButtonValue();
                      hasOperator = true;
                      display.setText(operatorString);
                      System.out.println("first operator");
                    } else {

                      preOperator = buttonPressed[finalI].getButtonValue();
                    }
                  }
                  break;
              }

              System.out.println(
                  "first value: "
                      + firstValue
                      + " operator: "
                      + operatorString
                      + " second value: "
                      + secondValue);
            }
          });
      grid.add(buttons[i], i % 4, rows);
    }

    grid.add(display, 0, 0, 4, 1);

    Scene scene = new Scene(grid);

    primaryStage.setTitle("Calculator");
    primaryStage.setScene(scene);
    primaryStage.show();
  }
Example #18
0
  public TelaAux(final Object o, String confirmacao, final TableView tabela) {
    this.mensagem = confirmacao;
    final Banco banco = Main.getBanco();

    BorderPane root = new BorderPane();
    Scene scene = new Scene(root, 450, 60, Color.LIGHTGRAY);

    Label texto = new Label(getMensagem());
    Button sim = new Button("Sim");
    Button nao = new Button("Não");

    VBox boxtexto = new VBox(10);
    HBox opcoes = new HBox(10);

    opcoes.getChildren().addAll(sim, nao);
    boxtexto.getChildren().addAll(texto, opcoes);

    boxtexto.setAlignment(Pos.CENTER);
    opcoes.setAlignment(Pos.CENTER);

    root.setCenter(boxtexto);
    texto.setFont(new Font(15));
    setScene(scene);
    setOpacity(0.9);
    initModality(
        Modality.APPLICATION_MODAL); // Responsável por só ser possível voltar ao sg ong se fechar a
    // janela.
    show();

    nao.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent arg0) {
            close();
          }
        });

    sim.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent arg0) {
            close();
            banco.excluirObjeto(o);

            String classe = o.getClass().toString();

            if (classe.equals("class model.Paciente")) {
              ObservableList<Paciente> listaPacientesRefresh =
                  FXCollections.observableArrayList(banco.listarPacientes());
              tabela.setItems(listaPacientesRefresh);
            } else if (classe.equals("class model.Socio")) {
              ObservableList<Socio> listaSociosRefresh =
                  FXCollections.observableArrayList(banco.listarSocios());
              tabela.setItems(listaSociosRefresh);
            } else if (classe.equals("class model.Doacao")) {
              ObservableList<Doacao> listaDoacoesRefresh =
                  FXCollections.observableArrayList(banco.listarDoacoes());
              tabela.setItems(listaDoacoesRefresh);
            } else if (classe.equals("class model.Despesa")) {
              ObservableList<Despesa> listaDespesasRefresh =
                  FXCollections.observableArrayList(banco.listarDespesas());
              tabela.setItems(listaDespesasRefresh);
            }
          }
        });
  }
  @FXML
  private void ratingButtonClicked(ActionEvent event) throws SQLException {
    configureButtons();
    ratingButton.setGraphic(ratingSelectedIMV);

    // clear old content
    contentPane.getChildren().clear();

    // set up
    titleLabel.setText("Rating and Feedback");

    // rating box
    HBox ratingBox = new HBox();
    ratingBox.setAlignment(Pos.CENTER);
    ratingBox.setSpacing(20);
    ratingBox.setPadding(new Insets(10, 0, 10, 0));

    // Rating label
    Label ratingTitle = new Label("Average Rating: ");
    ratingTitle.setFont(new Font("System", 24));

    // 5 stars
    String yellowStarURL = "Graphics/StarYellow.png";
    String blankStarURL = "Graphics/StarBlank.png";

    ImageView starBlank1 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank2 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank3 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank4 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));
    ImageView starBlank5 =
        new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png")));

    Button star1 = new Button();
    star1.setGraphic(starBlank1);
    star1.setStyle("-fx-background-color: transparent");
    Button star2 = new Button();
    star2.setGraphic(starBlank2);
    star2.setStyle("-fx-background-color: transparent");
    Button star3 = new Button();
    star3.setGraphic(starBlank3);
    star3.setStyle("-fx-background-color: transparent");
    Button star4 = new Button();
    star4.setGraphic(starBlank4);
    star4.setStyle("-fx-background-color: transparent");
    Button star5 = new Button();
    star5.setGraphic(starBlank5);
    star5.setStyle("-fx-background-color: transparent");

    // get average rating
    double avgRating = 0;
    try {
      avgRating = operation.getAverageRating();
    } catch (SQLException e) {
      e.printStackTrace();
      ratingTitle.setText("Error! Can't get average rating");
    }

    Button[] buttonlist = new Button[5];
    buttonlist[0] = star1;
    buttonlist[1] = star2;
    buttonlist[2] = star3;
    buttonlist[3] = star4;
    buttonlist[4] = star5;

    for (int i = 0; i < Math.floor(avgRating); i++) {
      ImageView image = new ImageView(new Image(getClass().getResourceAsStream(yellowStarURL)));
      buttonlist[i].setGraphic(image);
    }

    // feedback box
    VBox feedBackBox = new VBox();
    feedBackBox.setAlignment(Pos.CENTER);
    feedBackBox.setSpacing(20);

    // Feedback title
    Label feedBackLabel = new Label("Feedback:");
    feedBackLabel.setFont(new Font("System", 24));

    // get feedback string
    String feedback = "";
    ArrayList<Rating> list = operation.getRatingsAndFeedbacks();

    for (Rating r : list) {
      feedback += r.getFeedback() + "\n\n";
    }

    Text feedbackText = new Text(feedback);
    feedbackText.setFont(new Font("System", 14));

    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setContent(feedbackText);

    // Add children nodes to appropriate boxes
    ratingBox.getChildren().addAll(ratingTitle, star1, star2, star3, star4, star5);
    feedBackBox.getChildren().addAll(feedBackLabel, scrollPane);

    // main box
    VBox mainBox = new VBox();
    mainBox.setSpacing(40);
    mainBox.getChildren().addAll(ratingBox, feedBackBox);

    contentPane.getChildren().add(mainBox);
  }
Example #20
0
  public void load() {

    age = 1;
    turn = 1;
    Manager.getKernel().startAge(1);
    boards = Manager.getKernel().getBoards();
    hands = Manager.getKernel().getHands();
    screenX = GUIManager.width; // get the width of the screen
    screenY = GUIManager.height; // get the height of the screen
    // root = new Group();
    scene = new Scene(root, screenX, screenY, GUIManager.bgColor);
    root.setCursor(new ImageCursor(GUIManager.cursor));
    R = screenX / 2.8; //
    r = screenY / 3.1; //
    Ox = screenX / 2 - 140; //
    Oy = screenY / 2 - 98; //
    numOfPlayers = boards.length; // get the amount of players
    moveable = false;
    isDragging = false;
    resList = new SimpleResList[numOfPlayers];
    isIncard = false;
    orListNum = new int[numOfPlayers];
    coins = new int[numOfPlayers];
    for (int i = 0; i < numOfPlayers; i++) coins[i] = 3;
    judgeStateTimeline = new Timeline[numOfPlayers];
    buyStateCircle = new Circle[numOfPlayers];
    // wonderBorderEffect = false;
    // wonderReflectEffect = false;
    if (!GUIManager.enableReflectionEffect) {
      Ox = screenX / 2 - 140; //
      Oy = screenY / 2 - 68;
      r = screenY / 3.5;
    }
    observeIndex = 0;
    isTwice = new boolean[numOfPlayers];
    // primaryStage.setResizable(false);
    for (int i = 0; i < numOfPlayers; i++) isTwice[i] = false;
    handlerEnable = true;
    player = new Circle[numOfPlayers];
    wait = new Circle[numOfPlayers];
    // shop = new Circle[numOfPlayers];
    // look = new Circle[numOfPlayers];
    numOfCardGivenup = new Label();
    numOfCardGivenup.setVisible(true);
    CardsGivenup = 0;
    String s = String.valueOf(CardsGivenup);
    numOfCardGivenup.setText(s);
    numOfCardGivenup.setFont(Font.font("Arial", 45));

    if (GUIManager.enableGlowEffect) numOfCardGivenup.setEffect(new Glow());
    numOfCardGivenup.setTextFill(Color.web("#c88d15"));
    b = new Block(screenX, screenY);
    b.setVisible(false);
    root.getChildren().add(b);
    TPABoard.initialize();
    tpa = new TPABoard[numOfPlayers];

    final Paint[] color = new Paint[7];
    color[0] = Color.RED;
    color[1] = Color.ORANGE;
    color[2] = Color.YELLOW;
    color[3] = Color.YELLOWGREEN;
    color[4] = Color.GREEN;
    color[5] = Color.BLUE;
    color[6] = Color.PURPLE;
    for (int i = 0; i < 7; i++) {
      Paint temp = color[i];
      int newIndex = (int) (Math.random() * 7);
      color[i] = color[newIndex];
      color[newIndex] = temp;
    }

    playerBoard = new Group();
    // primaryStage.setFullScreen(true);
    // primaryStage.initStyle(StageStyle.UNDECORATED);
    Image bg = ResManager.getImage("bg.jpg");
    background = new ImageView(bg);
    if (!GUIManager.isFullScreen && !Manager.isApplet) this.setDragBackground(background);
    xrate = screenX / 1220.0;
    yrate = screenY / 784.0;
    background.setScaleX(xrate);
    background.setScaleY(yrate);
    numOfCardGivenup.setLayoutX(1106 * xrate);
    numOfCardGivenup.setLayoutY(94 * yrate);
    background.setTranslateX((scene.getWidth() - 1220.0) / 2.0);
    background.setTranslateY((scene.getHeight() - 784.0) / 2.0);
    // Rectangle clip = new Rectangle(0,0,1220,784);
    // clip.setArcHeight(50);
    // clip.setArcWidth(50);
    // background.setClip(clip);
    theta = Math.PI / 2;
    root.getChildren().add(background);
    root.getChildren().add(numOfCardGivenup);
    updateAge(1);

    Image im1 = ResManager.getImage("dir0.jpg");
    counterClockwise0 = new ImageView(im1);
    counterClockwise0.setScaleX(xrate);
    counterClockwise0.setScaleY(yrate);
    counterClockwise0.setTranslateX((im1.getWidth() * xrate - 107.0) / 2 + 271.23 * xrate);
    counterClockwise0.setTranslateY((im1.getHeight() * yrate - 86.0) / 2 + 560 * yrate);
    counterClockwise0.setVisible(false);

    Image im2 = ResManager.getImage("dir1.jpg");
    counterClockwise1 = new ImageView(im2);
    counterClockwise1.setScaleX(xrate);
    counterClockwise1.setScaleY(yrate);
    counterClockwise1.setTranslateX((im2.getWidth() * xrate - 112.0) / 2 + 826 * xrate);
    counterClockwise1.setTranslateY((im2.getHeight() * yrate - 86.0) / 2 + 560 * yrate);
    counterClockwise1.setVisible(false);

    Image im3 = ResManager.getImage("dir2.jpg");
    counterClockwise2 = new ImageView(im3);
    counterClockwise2.setScaleX(xrate);
    counterClockwise2.setScaleY(yrate);
    counterClockwise2.setTranslateX((im3.getWidth() * xrate - 52.0) / 2 + 846.4 * xrate);
    counterClockwise2.setTranslateY((im3.getHeight() * yrate - 39.0) / 2 + 223 * yrate);
    counterClockwise2.setVisible(false);

    Image im4 = ResManager.getImage("dir3.jpg");
    counterClockwise3 = new ImageView(im4);
    counterClockwise3.setScaleX(xrate);
    counterClockwise3.setScaleY(yrate);
    counterClockwise3.setTranslateX((im4.getWidth() * xrate - 52.0) / 2 + 302.6 * xrate);
    counterClockwise3.setTranslateY((im4.getHeight() * yrate - 39.0) / 2 + 222.8 * yrate);
    counterClockwise3.setVisible(false);
    root.getChildren().add(counterClockwise0);
    root.getChildren().add(counterClockwise1);
    root.getChildren().add(counterClockwise2);
    root.getChildren().add(counterClockwise3);

    Image[] image = new Image[numOfPlayers];
    wonder = new Wonders[numOfPlayers];
    Rectangle[] rec = new Rectangle[numOfPlayers];

    TreeMap<String, Integer> boardNameMap = new TreeMap<String, Integer>();
    boardNameMap.put("Rhodes", 0);
    boardNameMap.put("Alexandria", 1);
    boardNameMap.put("Ephesus", 2);
    boardNameMap.put("Babylon", 3);
    boardNameMap.put("Olympia", 4);
    boardNameMap.put("Halicarnassus", 5);
    boardNameMap.put("Giza", 6);

    TreeMap<String, Integer> resNameMap = new TreeMap<String, Integer>();
    // resNameMap.put("", value)

    for (int i = 0; i < numOfPlayers; i++) {
      // Manager.debug(boards[i].getResourceList());
      int ii = boardNameMap.get(boards[i].getName());
      if (boards[i].isBSide()) ii += 7;
      // Manager.debug("" + ii + boards[i].isBSide());
      image[i] = ResManager.getImage("board" + ii + ".jpg");
      // }
      rec[i] = new Rectangle(image[i].getWidth(), image[i].getHeight(), Color.TRANSPARENT);
      rec[i].setX(0);
      rec[i].setY(0);
      rec[i].setArcWidth(20);
      rec[i].setArcHeight(20);
      // if (i > 0) {
      rec[i].setStroke(color[i]);
      rec[i].setStrokeWidth(8);
      // } else {
      // MovingStroke.set(rec[i], (Color) color[i], 8.0, 20.0, 15.0, 0);
      // rec[i].setStroke(color[i]);
      // rec[i].setStrokeWidth(14);
      // }
      // tpa[i] = new TPABoard();
      if (GUIManager.enableLightingEffect) rec[i].setEffect(new Lighting());
      tpa[i] = new TPABoard();
      wonder[i] =
          new Wonders(
              image[i], screenX, screenY, GUIManager.enableReflectionEffect, ii, tpa[i], root);

      SimpleResList list = boards[i].getResourceList();
      for (int index = 1; index <= 7; index++) {
        for (int am = 0; am < list.numAt(index); am++) wonder[i].addResource(index);
        // Manager.debug(i + "Adding Res..." +
        // SimpleResList.resourceAt(index).toString());
      }
      wonder[i].addGoldSign(3);
      double percent = (workoutY1(Ox, Oy + r, i, numOfPlayers) - Oy + r) / (2 * r);
      wonder[i].setLayoutX(workoutX1(Ox, Oy + r, i, numOfPlayers) - (0.6 * percent + 0.4) * 160);
      wonder[i].setLayoutY(workoutY1(Ox, Oy + r, i, numOfPlayers) - (0.6 * percent + 0.4) * 90);
      wonder[i].setScaleX(0.6 * percent + 0.4);
      wonder[i].setScaleY(0.6 * percent + 0.4);
      wonder[i].getChildren().add(rec[i]);
      final int index = i;
      wonder[i].addEventHandler(
          MouseEvent.MOUSE_ENTERED,
          new EventHandler<MouseEvent>() {
            public void handle(MouseEvent event) {
              moveable = true;
              targetWonderIndex = index;
              for (int i = 0; i < numOfPlayers; i++) {
                Timeline tl =
                    new Timeline(
                        new KeyFrame(
                            Duration.seconds(0.3), new KeyValue(wonder[i].opacityProperty(), 1)));
                tl.play();
              }
            }
          });
      wonder[i].addEventHandler(
          MouseEvent.MOUSE_EXITED,
          new EventHandler<MouseEvent>() {
            public void handle(MouseEvent event) {
              if (!isDragging) moveable = false;
            }
          });

      wonder[i].getChildren().add(tpa[i]);
      tpa[i].setLayoutY(-80);
      tpa[i].setLayoutX(65);
      tpa[i].setScaleX(1 / (0.6 * percent + 0.4));
      tpa[i].setScaleY(1 / (0.6 * percent + 0.4));
    }

    dicClockwise();
    bigCircle = new Group();
    bigCircle
        .getChildren()
        .add(
            MovingStroke.set(
                new Circle(29, Color.web("white", 0)),
                Color.web("white", 0.7),
                6,
                5,
                10,
                0.3 * (age != 2 ? -1 : 1)));

    // bigCircle.setStroke(Color.web("white", 0.3));
    if (GUIManager.enableLightingEffect) bigCircle.setEffect(new Lighting());
    // bigCircle.setStrokeWidth(4);
    playerBoard.getChildren().add(bigCircle);

    for (int i = 0; i < numOfPlayers; i++) {
      wait[i] = new Circle(8);
      wait[i].setFill(color[i]);
      // look[i] = new Circle(4);
      // look[i].setFill(color[i]);
      // shop[i] = new Circle(5, Color.web("white", 0));
      // shop[i].setStroke(color[i]);
      // shop[i].setStrokeWidth(4);
      player[i] = wait[i];
      player[i].setVisible(true);
      if (GUIManager.enableLightingEffect) player[i].setEffect(new Lighting());
      player[i].setLayoutX(xForPlayer(i));
      player[i].setLayoutY(yForPlayer(i));
      player[i].addEventHandler(
          MouseEvent.MOUSE_ENTERED,
          new EventHandler<MouseEvent>() {
            public void handle(MouseEvent e) {
              // show the information of the players
            }
          });
      final int i1 = i;
      player[i].addEventHandler(
          MouseEvent.MOUSE_CLICKED,
          new EventHandler<MouseEvent>() {
            public void handle(MouseEvent e) {
              if (!isTwice[i1]) {
                if (remable) {
                  remable = false;
                }
                isTwice[i1] = true;
                for (int i = 0; i < numOfPlayers; i++) if (i != i1) isTwice[i] = false;
                handlerEnable = true;
                EventHandler<ActionEvent> act1 =
                    new EventHandler<ActionEvent>() {
                      public void handle(ActionEvent event) {
                        wonder[signrec].hideInfo();
                      }
                    };
                EventHandler<ActionEvent> act2 =
                    new EventHandler<ActionEvent>() {
                      public void handle(ActionEvent event) {
                        b.setVisible(false);
                        // cardBoard.toFront();
                        player[i1].setDisable(false);
                      }
                    };
                Timeline pre_tl =
                    new Timeline(
                        new KeyFrame(Duration.ZERO, act1),
                        new KeyFrame(
                            Duration.seconds(0.3),
                            new KeyValue(b.opacityProperty(), 0.7),
                            new KeyValue(cardBoard.layoutYProperty(), screenY - 105)),
                        new KeyFrame(Duration.seconds(0.6), new KeyValue(b.opacityProperty(), 0)),
                        new KeyFrame(Duration.seconds(0.6), act2));
                if (b.isVisible()) {
                  player[i1].setDisable(true);
                  pre_tl.play();
                }
                double[] forsort = new double[numOfPlayers];
                int[] sign = new int[numOfPlayers];
                for (int j = 0; j < numOfPlayers; j++) {
                  double percent = (workoutY1(Ox, Oy + r, j - i1, numOfPlayers) - Oy + r) / (2 * r);
                  Timeline tl =
                      new Timeline(
                          new KeyFrame(
                              Duration.seconds(0.3),
                              new KeyValue(
                                  wonder[j].layoutXProperty(),
                                  workoutX1(Ox, Oy + r, j - i1, numOfPlayers)
                                      - (0.6 * percent + 0.4) * 160),
                              new KeyValue(
                                  wonder[j].layoutYProperty(),
                                  workoutY1(Ox, Oy + r, j - i1, numOfPlayers)
                                      - (0.6 * percent + 0.4) * 90),
                              new KeyValue(tpa[j].scaleXProperty(), 1 / (0.6 * percent + 0.4)),
                              new KeyValue(tpa[j].scaleYProperty(), 1 / (0.6 * percent + 0.4)),
                              new KeyValue(wonder[j].scaleXProperty(), (0.6 * percent + 0.4)),
                              new KeyValue(wonder[j].scaleYProperty(), (0.6 * percent + 0.4))));
                  // wonder[j].setLayoutX();
                  // wonder[j].setLayoutY();
                  // tpa[j].setScaleX();
                  // tpa[j].setScaleY();
                  // wonder[j].setScaleX();
                  // wonder[j].setScaleY();
                  // Path path = new Path();
                  // Manager.debug(wonder[j].getLayoutX() +
                  // ":" +
                  // wonder[j].getLayoutY() + " " +
                  // wonder[j].getTranslateX() + ":" +
                  // wonder[j].getTranslateY());
                  // double x = wonder[j].getLayoutX();
                  // double y = wonder[j].getLayoutY();
                  // path.getElements().addAll(new
                  // MoveTo(screenX/2,screenY/2),
                  // new ArcTo(R/2,r/2,0,workoutX1(Ox, Oy + r,
                  // j - i1,
                  // numOfPlayers) - x, workoutY1(Ox, Oy + r,
                  // j - i1,
                  // numOfPlayers) - y,true,true)
                  // );
                  // path.setStroke(color[j]);
                  // path.setStrokeWidth(10);
                  // root.getChildren().add(path);
                  // PathTransition pt = new
                  // PathTransition(Duration.seconds(8),path,wonder[j]);
                  //
                  // pt.setCycleCount(PathTransition.INDEFINITE);
                  // pt.setAutoReverse(true);
                  // pt.play();

                  tl.play();
                  forsort[j] = wonder[j].getLayoutY();
                  sign[j] = j;
                }
                // wonder[i1].toFront();
                for (int i = 0; i < numOfPlayers - 1; i++) {
                  for (int j = 0; j < numOfPlayers - i - 1; j++) {
                    if (forsort[j] > forsort[j + 1]) {
                      double temp = forsort[j + 1];
                      forsort[j + 1] = forsort[j];
                      forsort[j] = temp;
                      int temp1 = sign[j + 1];
                      sign[j + 1] = sign[j];
                      sign[j] = temp1;
                    }
                  }
                }
                for (int i = 0; i < numOfPlayers; i++) {
                  if (sign[i] == i1) {

                    b.toFront();
                  }
                  wonder[sign[i]].toFront();
                }
                // if(!b.isVisible())
                cardBoard.toFront();
                playerBoard.toFront();
                // turn the wonderBoard
                if (Manager.getKernel().isReplayMode()) {
                  int index = 0;
                  if (age == 2) index = (2 * numOfPlayers - turn + i1 + 1) % numOfPlayers;
                  else index = (turn + i1 - 1) % numOfPlayers;
                  handCard.changeRole(boards[i1], hands[index]);
                  observeIndex = i1;
                }
              } else {
                EventHandler<ActionEvent> act =
                    new EventHandler<ActionEvent>() {
                      public void handle(ActionEvent event) {
                        wonder[i1].showInfo();
                        remable = true;
                        signrec = i1;
                        playerBoard.toFront();
                        // show the game information of player
                      }
                    };
                for (int i = 0; i < numOfPlayers; i++) isTwice[i] = false;
                b.setOpacity(0);
                b.toFront();
                playerBoard.toFront();
                wonder[i1].toFront();
                b.setVisible(true);

                handlerEnable = false;
                Timeline tl =
                    new Timeline(
                        new KeyFrame(
                            Duration.seconds(0.3),
                            new KeyValue(b.opacityProperty(), 0.7),
                            new KeyValue(cardBoard.layoutYProperty(), screenY)),
                        new KeyFrame(Duration.seconds(0.3), act));
                tl.play();
              }
              theta = Math.PI / 2 - 2 * Math.PI / numOfPlayers * i1;
            }
          });
      playerBoard.getChildren().add(player[i]);
      judgeStateTimeline[i] =
          new Timeline(
              new KeyFrame(Duration.seconds(0.3), new KeyValue(player[i].opacityProperty(), 0)));
      judgeStateTimeline[i].setCycleCount(Timeline.INDEFINITE);
      judgeStateTimeline[i].setAutoReverse(true);
      buyStateCircle[i] =
          (Circle)
              MovingStroke.set(
                  new Circle(xForPlayer(i), yForPlayer(i), 11, Color.TRANSPARENT),
                  Color.GOLDENROD,
                  3,
                  3,
                  4,
                  0.3);
      playerBoard.getChildren().add(buyStateCircle[i]);
      buyStateCircle[i].setVisible(false);
    }
    buy = new BuyBoard();
    buy.setScaleX(0.7);
    buy.setScaleY(0.7);
    buy.setLayoutY(0);
    buy.setVisible(false);
    root.getChildren().add(buy);
    CardGroup.initializeData(screenX, buy, boards[0]);
    handCard = new CardGroup();
    handCard.setplayer(wonder[0]);
    for (int i = 0; i < numOfPlayers; i++) {
      resList[i] = new SimpleResList(boards[i].getResourceList());
    }
    /*
     * primaryStage.addEventHandler(WindowEvent.RESIZE, new
     * EventHandler<MouseEvent>(){
     *
     * @Override public void handle(MouseEvent event) {
     * System.out.println("OK");
     *
     * }
     *
     * }); primaryStage.
     */

    scene.addEventHandler(
        MouseEvent.MOUSE_PRESSED,
        new EventHandler<MouseEvent>() {
          public void handle(MouseEvent e) {
            if (handlerEnable && moveable) {
              double x = e.getX(), y = e.getY();
              double tana = (y - Oy) / (x - Ox) * R / r;
              beta = Math.atan(tana);
              if (x <= Ox) beta = beta + Math.PI;
            }
          }
        });

    scene.addEventHandler(
        MouseEvent.MOUSE_RELEASED,
        new EventHandler<MouseEvent>() {
          public void handle(MouseEvent e) {
            isDragging = false;
            if (handlerEnable && moveable) theta = alpha - beta + theta;
          }
        });

    scene.addEventHandler(
        MouseEvent.MOUSE_DRAGGED,
        new EventHandler<MouseEvent>() {
          public void handle(MouseEvent e) {
            isDragging = true;
            if (handlerEnable && moveable) {
              for (int i = 0; i < numOfPlayers; i++) isTwice[i] = false;
              double x = e.getX() - 70, y = e.getY();
              double[] forsort = new double[numOfPlayers];
              int[] sign = new int[numOfPlayers];
              for (int i = 0; i < numOfPlayers; i++) {
                // int index = (i +
                // numOfPlayers+targetWonderIndex+1) %
                // numOfPlayers;
                int index = i;
                double percent = (workoutY(x, y, i, numOfPlayers) - Oy + r) / (2 * r);
                tpa[index].setScaleX(1 / (0.6 * percent + 0.4));
                tpa[index].setScaleY(1 / (0.6 * percent + 0.4));
                wonder[index].setScaleX((0.6 * percent + 0.4));
                wonder[index].setScaleY((0.6 * percent + 0.4));
                wonder[index].setLayoutX(
                    workoutX(x, y, i, numOfPlayers) - (0.6 * percent + 0.4) * 160);
                wonder[index].setLayoutY(
                    workoutY(x, y, i, numOfPlayers) - (0.6 * percent + 0.4) * 90);
                forsort[i] = wonder[i].getLayoutY();
                sign[i] = i;
              }
              for (int i = 0; i < numOfPlayers - 1; i++) {
                for (int j = 0; j < numOfPlayers - i - 1; j++) {
                  if (forsort[j] > forsort[j + 1]) {
                    double temp = forsort[j + 1];
                    forsort[j + 1] = forsort[j];
                    forsort[j] = temp;
                    int temp1 = sign[j + 1];
                    sign[j + 1] = sign[j];
                    sign[j] = temp1;
                  }
                }
              }
              for (int i = 0; i < numOfPlayers; i++) wonder[sign[i]].toFront();
              playerBoard.toFront();
              cardBoard.toFront();
            }
          }
        });

    scene.addEventHandler(
        MouseEvent.MOUSE_ENTERED,
        new EventHandler<MouseEvent>() {
          public void handle(MouseEvent e) {
            if (handlerEnable) {
              double y = e.getX();
              // if( y > screenY - 牌宽)
              // 牌.show();
            }
          }
        });
    switch (numOfPlayers) {
      case 3:
        root.getChildren().add(wonder[2]);
        break;
      case 4:
        root.getChildren().add(wonder[3]);
        root.getChildren().add(wonder[2]);
        break;
      case 5:
        root.getChildren().add(wonder[3]);
        root.getChildren().add(wonder[2]);
        root.getChildren().add(wonder[4]);
        break;
      case 6:
        root.getChildren().add(wonder[3]);
        root.getChildren().add(wonder[2]);
        root.getChildren().add(wonder[4]);
        root.getChildren().add(wonder[5]);
        break;
      case 7:
        root.getChildren().add(wonder[3]);
        root.getChildren().add(wonder[2]);
        root.getChildren().add(wonder[4]);
        root.getChildren().add(wonder[5]);
        root.getChildren().add(wonder[6]);
    }

    root.getChildren().add(wonder[1]);
    root.getChildren().add(wonder[0]);

    playerBoard.setLayoutX(scene.getWidth() - 60);
    playerBoard.setLayoutY(50);
    root.getChildren().add(playerBoard);
    handCard.nextHand(hands[0], true);
    cardBoard = new Group();
    cardBoard.getChildren().add(handCard);
    root.getChildren().add(cardBoard);
    cardBoard.setLayoutX(0);
    cardBoard.setLayoutY(screenY - 105);
    cardBoard.addEventHandler(
        MouseEvent.MOUSE_ENTERED,
        new EventHandler<MouseEvent>() {

          public void handle(MouseEvent e) {
            if (wonderFadeTimeline != null)
              for (Timeline tl : wonderFadeTimeline) if (tl != null) tl.stop();
            wonderFadeTimeline = new Timeline[numOfPlayers];
            wonderFadeTimeline[observeIndex] =
                new Timeline(
                    new KeyFrame(
                        Duration.seconds(0.1),
                        new KeyValue(cardBoard.layoutYProperty(), screenY - 270)));
            for (int i = 0; i < numOfPlayers; i++) {
              if (i == observeIndex) continue;
              if (wonder[i].getOpacity() > 0.99)
                wonderFadeTimeline[i] =
                    new Timeline(
                        new KeyFrame(
                            Duration.seconds(0), new KeyValue(wonder[i].opacityProperty(), 1)),
                        new KeyFrame(
                            Duration.seconds(1.5), new KeyValue(wonder[i].opacityProperty(), 1)),
                        new KeyFrame(
                            Duration.seconds(2),
                            new KeyValue(
                                wonder[i].opacityProperty(),
                                i == (1 + observeIndex) % numOfPlayers
                                        || i == (numOfPlayers - 1 + observeIndex) % numOfPlayers
                                    ? 0.65
                                    : 0.35,
                                Interpolator.EASE_IN)));
            }
            for (Timeline tl : wonderFadeTimeline) if (tl != null) tl.play();

            cardBoard.toFront();
            isIncard = true;
          }
        });
    cardBoard.addEventHandler(
        MouseEvent.MOUSE_EXITED,
        new EventHandler<MouseEvent>() {
          public void handle(MouseEvent e) {
            if (wonderFadeTimeline != null)
              for (Timeline tl : wonderFadeTimeline) if (tl != null) tl.stop();
            wonderFadeTimeline = new Timeline[numOfPlayers];
            wonderFadeTimeline[0] =
                new Timeline(
                    new KeyFrame(
                        Duration.seconds(0.15),
                        new KeyValue(cardBoard.layoutYProperty(), screenY - 105)));
            for (int i = 1; i < numOfPlayers; i++) {
              if (wonder[i].getOpacity() < 0.99)
                wonderFadeTimeline[i] =
                    new Timeline(
                        new KeyFrame(
                            Duration.seconds(0), new KeyValue(wonder[i].opacityProperty(), 0.5)),
                        new KeyFrame(
                            Duration.seconds(0.3), new KeyValue(wonder[i].opacityProperty(), 1)));
            }
            for (Timeline tl : wonderFadeTimeline) if (tl != null) tl.play();
            isIncard = true;
          }
        });
    this.exitDialog = Index.loadExitGameDialog(root);
    root.getChildren().add(new GameMenu());

    // For Test
    for (int i = 0; i < numOfPlayers; i++) {
      updatePlayerState(i, 1);
    }
    // ScoreBoard sb = new ScoreBoard(boards);
    // root.getChildren().add(sb);
    // JOptionPane.showMessageDialog(null,
    // boards[0].getLeftNeighbor().getName() + ""
    // +boards[0].getRightNeighbor().getName());
    if (Manager.getKernel().isReplayMode()) {
      // Button nextBtn = new Button("Next!");
      // nextBtn.setOnMouseClicked(new EventHandler<MouseEvent>() {
      // @Override
      // public void handle(MouseEvent event) {
      // nextTurn();
      // }
      // });
      // root.getChildren().add(nextBtn);
      root.getChildren().add(replayControl = new ReplayControl());
    }
  }
Example #21
0
  public void handle(ActionEvent event) {
    BorderPane pane = new BorderPane();
    Scene scene = new Scene(pane, 550, 300, Color.WHITE);
    Stage stage = new Stage();
    stage.setTitle("Zathura Enterprise ™");
    pane.setPadding(new Insets(20, 20, 20, 20));

    ContaCorrenteController cc = new ContaCorrenteController();
    PessoaFisicaController pfc = new PessoaFisicaController();
    PessoaFisica pf = new PessoaFisica();

    List<String> pfN = new ArrayList<String>();
    List<String> pfC = new ArrayList<String>();
    List<String> lc = new ArrayList<String>();

    try {
      for (int i = 0; i < cc.listarContas().size(); i++) {
        if ('1' == cc.listarContas().get(i).getAtivo()) {
          lc.add(MascaraDeFormatacao.formatar("#####-#", cc.listarContas().get(i).getNumero()));
          pf = pfc.exibir(cc.listarContas().get(i).getCpfCliente());
          pfN.add(pf.getNome());
          pfC.add(MascaraDeFormatacao.formatar("###.###.###-##", pf.getCpf()));
        }
      }

    } catch (ConexaoException e) {
      Erro erro = new Erro(e.getMessage());
      erro.handle(null);
    } catch (PessoaFisicaNullPointerException e) {
      Erro erro = new Erro(e.getMessage());
      erro.handle(null);
    } catch (EnderecoNullPointerException e) {
      Erro erro = new Erro(e.getMessage());
      erro.handle(null);
    }

    ObservableList<String> data = FXCollections.observableArrayList();
    ListView<String> listN = new ListView<String>(data); // LISTA NOME
    listN.setPrefSize(200, 250);
    data.addAll(pfN);
    listN.setItems(data);

    ObservableList<String> data1 = FXCollections.observableArrayList();
    ListView<String> listCPF = new ListView<String>(data); // LISTA CPF
    listCPF.setPrefSize(100, 250);
    data1.addAll(pfC);
    listCPF.setItems(data1);

    ObservableList<String> data2 = FXCollections.observableArrayList();
    ListView<String> listC = new ListView<String>(data); // LISTA CONTA
    listC.setPrefSize(100, 250);
    data2.addAll(lc);
    listC.setItems(data2);

    VBox vbC = new VBox(10);
    Label nome = new Label("Conta");
    nome.setFont(Font.font("Courier New", FontWeight.THIN, 14));
    vbC.getChildren().addAll(nome, listC);

    VBox vbN = new VBox(10);
    Label nome2 = new Label("Nome Completo");
    nome2.setFont(Font.font("Courier New", FontWeight.THIN, 14));
    vbN.getChildren().addAll(nome2, listN);

    VBox vbCPF = new VBox(10);
    Label nome3 = new Label("CPF");
    nome3.setFont(Font.font("Courier New", FontWeight.THIN, 14));
    vbCPF.getChildren().addAll(nome3, listCPF);

    pane.setLeft(vbC); // CONTA
    pane.setCenter(vbN); // NOME
    pane.setRight(vbCPF); // CPF
    stage.setScene(scene);
    stage.showAndWait();
  }
Example #22
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    window = primaryStage;
    window.setTitle("Organiseerija");
    final javafx.scene.control.Label label = new javafx.scene.control.Label("Ajaplaneerija");
    label.setFont(new Font("Arial", 20));

    // Aine veerg
    TableColumn<Kodut66.Input, String> aineColumn = new TableColumn<>("Aine");
    aineColumn.setMinWidth(150);
    aineColumn.setCellValueFactory(new PropertyValueFactory<>("aine"));

    // Ruum veerg
    TableColumn<Kodut66.Input, String> ruumColumn = new TableColumn<>("Ruum");
    ruumColumn.setMinWidth(100);
    ruumColumn.setCellValueFactory(new PropertyValueFactory<>("ruum"));

    // Kuupäeva veerg
    TableColumn<Kodut66.Input, String> dateColumn = new TableColumn<>("Kuupäev");
    dateColumn.setMinWidth(150);
    dateColumn.setCellValueFactory(new PropertyValueFactory<>("kuupäev"));

    // Sisestab aine
    aineInput = new TextField();
    aineInput.setPromptText("Aine");
    aineInput.setMinWidth(100);

    // Sisestab ruumi
    ruumInput = new TextField();
    ruumInput.setPromptText("Ruum");
    ruumInput.setMinWidth(100);

    // Sisestab kuupäeva
    dateInput = new TextField();
    dateInput.setPromptText("dd/mm/yyyy");
    dateInput.setMinWidth(100);

    // Lisa juurde töid ja kustuta tehtud tööd
    Button lisaButton = new Button("Lisa juurde");
    lisaButton.setOnAction(e -> lisaButtonVajutatud());
    Button kustutaButton = new Button("Tehtud!");
    kustutaButton.setOnAction(e -> kustutaButtonVajutatud());

    // Tabel
    table = new TableView<>();
    table.setItems(getInput());
    table.getColumns().addAll(aineColumn, ruumColumn, dateColumn);

    // Horisontaalne
    HBox hBox = new HBox();
    hBox.setPadding(new Insets(10, 10, 10, 10));
    hBox.setSpacing(10);
    hBox.getChildren().addAll(aineInput, ruumInput, dateInput, lisaButton, kustutaButton);

    // Vertikaalne
    VBox vBox = new VBox();
    vBox.getChildren().addAll(label, table, hBox);

    Scene scene = new Scene(vBox);
    window.setScene(scene);
    window.show();
  }
Example #23
0
  @Override
  public void start(Stage primaryStage) {

    primaryStage.setTitle("PolyStar 1.0 ");

    GridPane grid = new GridPane();
    // grid.setAlignment(Pos.CENTER);
    grid.setHgap(6);
    grid.setVgap(6);
    grid.setPadding(new Insets(15, 15, 15, 15));
    // grid.setAlignment(Pos.TOP_RIGHT);

    Text scenetitle = new Text("PolyStar 1.0 (Hover for tool tips)");
    scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 16));
    grid.add(scenetitle, 0, 0, 2, 1);

    Label mainLbl = new Label("PolyStar polytropic stellar interior structure modeling");
    mainLbl.setFont(Font.font("Tahoma", FontWeight.NORMAL, 11));
    grid.add(mainLbl, 2, 0);

    ImageView imageLogo;
    imageLogo =
        new ImageView(new Image(PolyStar.class.getResourceAsStream("graphics/SMULOGO2.png")));
    grid.add(imageLogo, 4, 0, 2, 1);

    // Model atmosphere parameters:
    Label atmosLbl = new Label("Model star parameters:");
    atmosLbl.setFont(Font.font("Tahoma", FontWeight.NORMAL, 12));
    grid.add(atmosLbl, 0, 1);
    Tooltip atmosTip = new Tooltip();
    atmosTip.setText(
        "Default parameters are for the Sun's central density, \r\n"
            + " rho_c = 162 g/cm^3, n=1.5");
    atmosLbl.setTooltip(atmosTip);

    // central density input - solar units
    Label rhoCLbl = new Label("rho_c (0.1 - 10.0 x rho_C_Sun)");
    grid.add(rhoCLbl, 0, 2);
    Tooltip rhoCTip = new Tooltip();
    rhoCTip.setText(
        "Central mass density relative to that of Sun \r\n" + " rho_C_Sun = 162 g cm^-3");
    rhoCLbl.setTooltip(rhoCTip);

    TextField rhoCSolIn = new TextField("1.0");
    grid.add(rhoCSolIn, 1, 2);

    Label trialLbl = new Label(" ");
    trialLbl.setFont(Font.font("Tahoma", FontWeight.NORMAL, 12));
    grid.add(trialLbl, 2, 1);

    // Polytropic index, n - dimensionless:
    Label indexLbl = new Label("n (1.0 - 3.5)");
    grid.add(indexLbl, 0, 3);
    Tooltip indexTip = new Tooltip();
    indexTip.setText(
        "Dimensionless polytropic index.  \r\n"
            + " = Adiabatic gamma = (n+1)/n \r\n"
            + " n=1.5 for ideal monatomic gas (best for Sun) \r\n"
            + " n=3.0 for photon gas - Eddington standard model");
    indexLbl.setTooltip(indexTip);

    TextField indexIn = new TextField("1.5");
    grid.add(indexIn, 1, 3);
    /*
    // Radiation pressure fraction, beta:
    Label betaLbl = new Label("Beta (0 - 1)");
    grid.add(betaLbl, 0, 4);
    Tooltip betaTip = new Tooltip();
    betaTip.setText(
    "Fractional contribution of gas pressure, P_Gas\r\n"
    + "to total pressure (ie. P_Gas = Beta * P = P - P_Rad)"
    );
    betaLbl.setTooltip(betaTip);

    TextField betaIn = new TextField("0.0");
    grid.add(betaIn, 1, 4);
    */

    // He mass fraction (Y)
    Label yFracLbl = new Label("He mass fraction, Y (0.2 - 0.5)");
    grid.add(yFracLbl, 2, 2);
    Tooltip yFracTip = new Tooltip();
    yFracTip.setText("Helium mass fraction, Y (0.2 - 0.5)");
    yFracLbl.setTooltip(yFracTip);

    TextField yFracIn = new TextField("0.28");
    grid.add(yFracIn, 3, 2);

    // metal mass fraction (Z)
    Label zFracLbl = new Label("Metal mass fraction, Z (0.0001 - 0.05)");
    grid.add(zFracLbl, 2, 3);
    Tooltip zFracTip = new Tooltip();
    zFracTip.setText("Mass fraction of elements of z > 2, Z (0.0001 - 0.05)");
    zFracLbl.setTooltip(zFracTip);

    TextField zFracIn = new TextField("0.02");
    grid.add(zFracIn, 3, 3);

    //
    //
    Button btn = new Button("Model");
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);
    grid.add(hbBtn, 3, 5);

    final Text actiontarget = new Text();
    grid.add(actiontarget, 0, 8);

    btn.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            actiontarget.setFill(Color.FIREBRICK);
            // actiontarget.setText("Output here");
            actiontarget.setFont(Font.font("Tahoma", FontWeight.NORMAL, 14));

            String rhoCSolStr = rhoCSolIn.getText();
            String indexStr = indexIn.getText();
            // String betaStr = betaIn.getText();
            String yFracStr = yFracIn.getText();
            String zFracStr = zFracIn.getText();

            // If *any* model atmosphere input string is empty, set rhoCSolStr to empty to simplify
            // conditional logic below.
            if (indexStr == null || indexStr.isEmpty()) {
              rhoCSolStr = null;
            }
            // if (betaStr == null || betaStr.isEmpty()) {
            //    rhoCSolStr = null;
            // }
            if (yFracStr == null || yFracStr.isEmpty()) {
              rhoCSolStr = null;
            }
            if (zFracStr == null || zFracStr.isEmpty()) {
              rhoCSolStr = null;
            }

            if ((rhoCSolStr != null && !rhoCSolStr.isEmpty())) {

              // Argument 1: Stellar mass, M, in solar masses
              double rhoCSol = (Double.valueOf(rhoCSolStr)).doubleValue();

              // Argument 2: He mass fraftion, Y
              double yFrac = (Double.valueOf(yFracStr)).doubleValue();

              // Argument 3: Metal mass fraftion, Z
              double zFrac = (Double.valueOf(zFracStr)).doubleValue();

              // Argument 4: Effective temperature, Teff, in K:
              double index = (Double.valueOf(indexStr)).doubleValue();

              //// Argument 5: Logarithmic surface gravity, g, in cm/s/s:
              // double beta = (Double.valueOf(betaStr)).doubleValue();
              // Sanity checks:
              if (rhoCSol < 0.1) {
                rhoCSol = 0.1;
                rhoCSolStr = "0.1";
              }
              if (rhoCSol > 10.0) {
                rhoCSol = 10.0;
                rhoCSolStr = "10.0";
              }

              if (yFrac < 0.1) {
                yFrac = 0.1;
                yFracStr = "0.1";
              }
              if (yFrac > 0.5) {
                yFrac = 0.5;
                yFracStr = "0.5";
              }

              if (zFrac < 0.0002) {
                zFrac = 0.0002;
                zFracStr = "0.0002";
              }
              if (zFrac > 0.05) {
                zFrac = 0.05;
                zFracStr = "0.05";
              }

              if (index < 1.0) {
                index = 1.0;
                indexStr = "1.0";
              }
              if (index > 3.5) {
                index = 3.5;
                indexStr = "3.5";
              }

              // if (beta < 0.0) {
              //    beta = 0.0;
              //    betaStr = "0.0";
              // }
              // if (beta > 1.0) {
              //    beta = 1.0;
              //    betaStr = "1.0";
              // }
              // All code after this line
              // Solar parameters:
              double teffSun = 5778.0;
              double log10gSun = 4.44;
              double gravSun = Math.pow(10.0, log10gSun);
              // Solar units:
              double massSun = 1.0;
              double radiusSun = 1.0;
              double rhoCSun = 162.2; // g cm^-3
              // double massStar = 1.0; //solar masses // test

              // Composition by mass fraction - needed for opacity approximations
              //   and interior structure
              double massXSun = 0.70; // Hydrogen
              double massYSun = 0.28; // Helium
              double massZSun = 0.02; // "metals"
              // log_10 num density H in surface layer:
              double log10NH = 17.0;

              double log10E = Math.log10(Math.E); // convert log_e to log_10
              double logE10 = Math.log(10.0); // convert log_10 to log_e

              double xFrac = 1.0 - yFrac - zFrac;
              double logXFrac = Math.log(xFrac);
              double logYFrac = Math.log(yFrac);

              double rhoC = rhoCSol * rhoCSun; // Sun's central mass density in cgs units

              // Set up all the special Lane-Emden equation variables:
              // Adiabatic gamma consistent with input polytropic index
              double gammaPoly = (index + 1.0) / index;
              // For convection criterion:
              double gamThing = PhysData.gammaMono / (PhysData.gammaMono - 1.0);

              // Initial Kay and lambda parameters from Lame-Embden equations:
              /* Doesn't work
              double Kay, KayTerm1, KayTerm2;
              KayTerm1 = 3.0 * (1.0 - beta) / Useful.aStef();
              KayTerm2 = Useful.k / beta / PhysData.muI(xFrac, yFrac, zFrac) / Useful.amu;
              Kay = Math.pow(KayTerm1, 0.3333) * Math.pow(KayTerm2, 4.0 / 3.0);
              */
              double Kay = 5.0e13; // hard wire to value at centre of Sun

              double lambda, lamTerm, indxExp;
              indxExp = (1.0 - index) / index;
              lamTerm =
                  (index + 1.0) * Kay * Math.pow(rhoC, indxExp) / 4.0 / Math.PI / Useful.GConst;
              lambda = Math.pow(lamTerm, 0.5);

              System.out.println("Kay " + Kay + " lambda " + lambda);

              // Dimensionless Lane-Emden Equation variables, xi and D_n(xi)
              // xi is the independenet variable
              // y(xi) is a helper function to separate the 2nd order Lane-Emden equation
              // into two coupled 1st order equations
              int maxNumDeps = 1000;
              double[] xi = new double[maxNumDeps];
              double[] DFunc = new double[maxNumDeps];
              double[] yFunc = new double[maxNumDeps];
              double deltaXi, deltaDFunc, deltaY, deltaYMag;
              // double logDeltaXi, logDeltaD, logDeltaY, logDeltaYMag;

              // Physical variables:
              double[] radShell = new double[maxNumDeps]; // shell radial width
              double[] tempShell = new double[maxNumDeps]; // kinetic temperature
              double[] pressShell = new double[maxNumDeps]; // total pressure
              double[] pGasShell = new double[maxNumDeps]; // gas pressure
              double[] pRadShell = new double[maxNumDeps]; // radiation pressure
              double[] rhoShell = new double[maxNumDeps]; // total fluid density
              double[] massShell = new double[maxNumDeps]; // shell mass
              double[] lumShell = new double[maxNumDeps]; // shell luminosity
              double[] lumPpShell = new double[maxNumDeps]; // shell luminosity
              double[] lumCnoShell = new double[maxNumDeps]; // shell luminosity

              double[] epsShell = new double[maxNumDeps]; // total nuclear energy generation rate
              double[] epsPpShell =
                  new double[maxNumDeps]; // nuclear p-p chain energy generation rate
              double[] epsCnoShell =
                  new double[maxNumDeps]; // nuclear cno cycle energy generation rate

              double[] kapShell = new double[maxNumDeps]; // mean opacity
              double[] kapBfShell = new double[maxNumDeps]; // mean b-f opacity
              double[] kapFfShell = new double[maxNumDeps]; // mean f-f opacity
              double[] kapEsShell = new double[maxNumDeps]; // mean e^- scattering opacity
              double[] kapHminShell = new double[maxNumDeps]; // mean H^- opacity

              // cumulative quantities
              double[] radInt = new double[maxNumDeps]; // interior radius
              // double[] logRadInt = new double[maxNumDeps];
              double[] massInt = new double[maxNumDeps]; // interior mass
              double[] lumInt = new double[maxNumDeps]; // interior luminosity
              double[] lumPpInt = new double[maxNumDeps]; // interior luminosity
              double[] lumCnoInt = new double[maxNumDeps]; // interior luminosity
              double[] gravInt = new double[maxNumDeps]; // acceleration of gravity

              // Convection:
              double[] dLnPdLnT = new double[maxNumDeps];
              boolean[] convFlag = new boolean[maxNumDeps];

              double RHS, logRHS, logRHSMag; // , logLastXi;
              double xiSquare; // useful

              // Try uniform spacing for now...
              // We know that at surface, xi >~ 3.0
              // guess at a good spacing for now...
              // Surface value of dimensionless xi parameter is in
              //   range 3 to 7 for polytropic index 1.5 to 3.0
              deltaXi = 10.0 / maxNumDeps;
              // deltaXi = 0.04;  //debug mode
              // logDeltaXi = Math.log(deltaXi);

              // For Newton-Raphson temperature recovery:
              double firstTemp = 0.0;

              // central bounday (initial) values:
              // NOTE: we cannot set xi=0 - singularity
              // We know that at surface, xi >~ 3.0
              // guess at a good initial abscissa and spacing for now...
              int j = 0;
              xi[j] = 0.001;
              yFunc[j] = 0.0;
              DFunc[j] = 1.0;
              // The stuff that follows...
              radInt[j] = lambda * xi[j];
              radShell[j] = radInt[j];
              rhoShell[j] = rhoC * Math.pow(DFunc[j], index);
              pressShell[j] = Kay * Math.pow(rhoShell[j], gammaPoly);
              tempShell[j] =
                  NRtemp.getTemp(pressShell[j], rhoShell[j], xFrac, yFrac, zFrac, firstTemp);
              // pGasShell[j] = beta * pressShell[j];
              // pRadShell[j] = (1.0 - beta) * pressShell[j];
              pGasShell[j] =
                  Useful.k
                      * rhoShell[j]
                      * tempShell[j]
                      / PhysData.muI(xFrac, yFrac, zFrac)
                      / Useful.amu;
              pRadShell[j] = Useful.aStef() * Math.pow(tempShell[j], 4.0) / 3.0;
              // tempShell[i] = pressShell[i] * PhysData.muI(xFrac, yFrac, zFrac) * Useful.amu /
              // Useful.k / rhoShell[i];
              massInt[j] = rhoC * 4.0 * Math.PI * Math.pow(radInt[j], 3) / 3.0;
              massShell[j] = massInt[j];

              if (tempShell[j] >= PhysData.fusionPPTemp) {
                epsPpShell[j] =
                    Power.ppChain(tempShell[j], rhoShell[j], xFrac, zFrac); // H fusion p-p chain
                epsCnoShell[j] =
                    Power.cnoCycle(tempShell[j], rhoShell[j], xFrac, zFrac); // H fusion CNO cycle
                epsShell[j] = epsPpShell[j] + epsCnoShell[j];
                // lumInt[j] = rhoC * 4.0 * Math.PI * Math.pow(radInt[j], 3) * epsShell[j] / 3.0;
                lumPpInt[j] = rhoC * 4.0 * Math.PI * Math.pow(radInt[j], 3) * epsPpShell[j] / 3.0;
                lumCnoInt[j] = rhoC * 4.0 * Math.PI * Math.pow(radInt[j], 3) * epsCnoShell[j] / 3.0;
                lumPpShell[j] = lumPpInt[j];
                lumCnoShell[j] = lumCnoInt[j];
                lumInt[j] = lumPpInt[j] + lumCnoInt[j];
                lumShell[j] = lumPpShell[j] + lumCnoShell[j];
              } else {
                epsPpShell[j] = 0.0; // H fusion p-p chain
                epsCnoShell[j] = 0.0; // H fusion CNO cycle
                epsShell[j] = 0.0;
                // lumInt[j] = rhoC * 4.0 * Math.PI * Math.pow(radInt[j], 3) * epsShell[j] / 3.0;
                lumPpInt[j] = 0.0;
                lumCnoInt[j] = 0.0;
                lumPpShell[j] = 0.0;
                lumCnoShell[j] = 0.0;
                lumInt[j] = 0.0;
                lumShell[j] = 0.0;
              }

              kapBfShell[j] =
                  Kappa.kappaBfFn(tempShell[j], rhoShell[j], xFrac, zFrac); // b-f photo-ionization
              kapFfShell[j] =
                  Kappa.kappaFfFn(tempShell[j], rhoShell[j], xFrac, zFrac); // f-f Bremsstrahlung
              kapEsShell[j] =
                  Kappa.kappaEsFn(
                      tempShell[j], rhoShell[j], xFrac, zFrac); // Thomson e^- scattering
              kapHminShell[j] =
                  Kappa.kappaHminFn(tempShell[j], rhoShell[j], xFrac, zFrac); // H^- b-f
              kapShell[j] = kapBfShell[j] + kapFfShell[j] + kapEsShell[j] + kapHminShell[j];

              gravInt[j] = Useful.GConst * massInt[j] / Math.pow(radInt[j], 2);

              dLnPdLnT[j] = 0.0;

              // 4th order Runge-Kutta (RK4) helper variables
              double k1y, k2y, k3y, k4y;
              double k1D, k2D, k3D, k4D;
              double hHalf = deltaXi / 2.0;
              double yHalf, DHalf, xiHalf;
              double yFull, DFull, xiFull;

              // System.out.println("    i     " + "   radius   " + "   massIn    " + "   lumInt   "
              // + "   temp   " + "   press   "
              //        + "   rh    " + "   kappa   " + "   epsilon   " + "   dLnPdLnT    " + "
              // gravInt   " + "   pGas/PTot    "
              //        + "   convection? ");
              // System.out.println("      i       " + "    radius    " + "    press    " + "    rho
              //    ");
              // Master numerical integration loop:
              // Loop exits when surface is found
              // Try Euler's method for now...
              // System.out.println("i    xi[i]    yFunc[i]    DFunc[i] ");
              int iSurf = 0;
              int iCore = 0;
              for (int i = 1; i < maxNumDeps; i++) {

                xi[i] = xi[i - 1] + deltaXi;

                /* Logarithmic - difficult due to signs
                logLastXi = Math.log(xi[i - 1]);

                //Start by advanceing helper function, y(xi):
                logRHSMag = index * Math.log(DFunc[i - 1]) + 2.0 * logLastXi;
                //RHS = -1.0 * Math.exp(logRHSMag);
                logDeltaYMag = logRHSMag + logDeltaXi;
                deltaYMag = Math.exp(logDeltaYMag);
                deltaY = -1.0 * deltaYMag;
                yFunc[i] = yFunc[i - 1] + deltaY;

                //Now use the updated value of y to update D_n
                logRHS = Math.log(yFunc[i]) - 2.0 * logLastXi;
                logDeltaD = logRHS + logDeltaXi;
                deltaDFunc = Math.exp(logDeltaD);
                DFunc[i] = DFunc[i - 1] + deltaDFunc;
                */
                //
                xiSquare = Math.pow(xi[i - 1], 2);
                xiHalf = Math.pow((xi[i - 1] + hHalf), 2);
                xiFull = Math.pow(xi[i], 2);
                //

                /*
                //Euler's method
                //Start by advanceing helper function, y(xi):
                RHS = -1.0 * Math.pow(DFunc[i - 1], index) * xiSquare;
                deltaY = RHS * deltaXi;
                yFunc[i] = yFunc[i - 1] + deltaY;

                //Now use the updated value of y to update D_n
                RHS = yFunc[i] / xiSquare;
                deltaDFunc = RHS * deltaXi;
                DFunc[i] = DFunc[i - 1] + deltaDFunc;

                System.out.format("Euler: %03d   %15.10f   %15.10f   %15.10f%n", i, xi[i], yFunc[i], DFunc[i]);
                */
                // 4th order Runge-Kutta (RK4):
                k1y = -1.0 * Math.pow(DFunc[i - 1], index) * xiSquare;
                k1D = yFunc[i - 1] / xiSquare;

                DHalf = DFunc[i - 1] + hHalf * k1D;
                yHalf = yFunc[i - 1] + hHalf * k1y;
                k2y = -1.0 * Math.pow(DHalf, index) * xiHalf;
                k2D = yHalf / xiHalf;

                DHalf = DFunc[i - 1] + hHalf * k2D;
                yHalf = yFunc[i - 1] + hHalf * k2y;
                k3y = -1.0 * Math.pow(DHalf, index) * xiHalf;
                k3D = yHalf / xiHalf;

                DFull = DFunc[i - 1] + deltaXi * k3D;
                yFull = yFunc[i - 1] + deltaXi * k3y;
                k4y = -1.0 * Math.pow(DFull, index) * xiFull;
                k4D = yFull / xiFull;

                deltaY = deltaXi * (k1y + 2.0 * k2y + 2.0 * k3y + k4y) / 6.0;
                deltaDFunc = deltaXi * (k1D + 2.0 * k2D + 2.0 * k3D + k4D) / 6.0;
                yFunc[i] = yFunc[i - 1] + deltaY;
                DFunc[i] = DFunc[i - 1] + deltaDFunc;

                // Are we there yet?
                if ((DFunc[i] <= 0)
                    || (Double.isNaN(DFunc[i]) == true)
                    || (Double.isInfinite(DFunc[i]) == true)) {
                  break;
                }

                // System.out.format("RK4: %03d   %15.10f   %15.10f   %15.10f%n", i, xi[i],
                // yFunc[i], DFunc[i]);
                radInt[i] = lambda * xi[i];
                radShell[i] = radInt[i] - radInt[i - 1];
                rhoShell[i] = rhoC * Math.pow(DFunc[i], index);
                pressShell[i] = Kay * Math.pow(rhoShell[i], gammaPoly);
                tempShell[i] =
                    NRtemp.getTemp(
                        pressShell[i], rhoShell[i], xFrac, yFrac, zFrac, tempShell[i - 1]);
                // pGasShell[i] = beta * pressShell[i];
                // pRadShell[i] = (1.0 - beta) * pressShell[i];
                pGasShell[i] =
                    Useful.k
                        * rhoShell[i]
                        * tempShell[i]
                        / PhysData.muI(xFrac, yFrac, zFrac)
                        / Useful.amu;
                pRadShell[i] = Useful.aStef() * Math.pow(tempShell[i], 4.0) / 3.0;
                // tempShell[i] = pressShell[i] * PhysData.muI(xFrac, yFrac, zFrac) * Useful.amu /
                // Useful.k / rhoShell[i];
                massShell[i] = 4.0 * Math.PI * Math.pow(radInt[i], 2) * rhoShell[i] * radShell[i];
                massInt[i] = massInt[i - 1] + massShell[i];
                // epsShell[i] = Power.nuclear(tempShell[i], rhoShell[i], xFrac, zFrac);

                if (tempShell[i] >= PhysData.fusionPPTemp) {
                  iCore = i;
                  epsPpShell[i] =
                      Power.ppChain(tempShell[i], rhoShell[i], xFrac, zFrac); // H fusion p-p chain
                  epsCnoShell[i] =
                      Power.cnoCycle(tempShell[i], rhoShell[i], xFrac, zFrac); // H fusion CNO cycle
                  epsShell[i] = epsPpShell[i] + epsCnoShell[i];
                  // lumShell[i] = 4.0 * Math.PI * Math.pow(radInt[i], 2) * rhoShell[i] *
                  // epsShell[i] * radShell[i];
                  lumPpShell[i] =
                      4.0
                          * Math.PI
                          * Math.pow(radInt[i], 2)
                          * rhoShell[i]
                          * epsPpShell[i]
                          * radShell[i];
                  lumCnoShell[i] =
                      4.0
                          * Math.PI
                          * Math.pow(radInt[i], 2)
                          * rhoShell[i]
                          * epsCnoShell[i]
                          * radShell[i];
                  lumShell[i] = lumPpShell[i] + lumCnoShell[i];
                  lumPpInt[i] = lumPpInt[i - 1] + lumPpShell[i];
                  lumCnoInt[i] = lumCnoInt[i - 1] + lumCnoShell[i];
                  lumInt[i] = lumInt[i - 1] + lumShell[i];
                } else {
                  epsPpShell[i] = 0.0; // H fusion p-p chain
                  epsCnoShell[i] = 0.0; // H fusion CNO cycle
                  epsShell[i] = 0.0;
                  // lumShell[i] = 4.0 * Math.PI * Math.pow(radInt[i], 2) * rhoShell[i] *
                  // epsShell[i] * radShell[i];
                  lumPpShell[i] = 0.0;
                  lumCnoShell[i] =
                      4.0
                          * Math.PI
                          * Math.pow(radInt[i], 2)
                          * rhoShell[i]
                          * epsCnoShell[i]
                          * radShell[i];
                  lumShell[i] = 0.0;
                  lumPpInt[i] = lumPpInt[i - 1];
                  lumCnoInt[i] = lumCnoInt[i - 1];
                  lumInt[i] = lumInt[i - 1];
                }

                // kapShell[i] = Kappa.kappaFn(tempShell[i], rhoShell[i], xFrac, zFrac);
                kapBfShell[i] =
                    Kappa.kappaBfFn(
                        tempShell[i], rhoShell[i], xFrac, zFrac); // b-f photo-ionization
                kapFfShell[i] =
                    Kappa.kappaFfFn(tempShell[i], rhoShell[i], xFrac, zFrac); // f-f Bremsstrahlung
                kapEsShell[i] =
                    Kappa.kappaEsFn(
                        tempShell[i], rhoShell[i], xFrac, zFrac); // Thomson e^- scattering
                kapHminShell[i] =
                    Kappa.kappaHminFn(tempShell[i], rhoShell[i], xFrac, zFrac); // H^- b-f
                kapShell[i] = kapBfShell[i] + kapFfShell[i] + kapEsShell[i] + kapHminShell[i];

                gravInt[i] = Useful.GConst * massInt[i] / Math.pow(radInt[i], 2);

                dLnPdLnT[i] =
                    (Math.log(pGasShell[i]) - Math.log(pGasShell[i - 1]))
                        / (Math.log(tempShell[i]) - Math.log(tempShell[i - 1]));
                if ((dLnPdLnT[i] >= gamThing)) {
                  // Radiative transport
                  convFlag[i] = false;
                } else {
                  // Convective transport
                  convFlag[i] = true;
                }

                // Dynamically update Kay and lambda:
                // Hmmm... these never seem to change, but let's update them anyway...
                Kay = pressShell[i] / Math.pow(rhoShell[i], gammaPoly);
                lamTerm =
                    (index + 1.0) * Kay * Math.pow(rhoC, indxExp) / 4.0 / Math.PI / Useful.GConst;
                lambda = Math.pow(lamTerm, 0.5);
                // System.out.println("Kay " + Kay + " lambda " + lambda);

                // System.out.println("    i     " + "     radius     " + "     massInt     " + "
                //  lumInt     " + "     temp     " + "     press     "
                //         + "     rho     " + "     kappa     " + "     epsilon     " + "
                // dLnPdLnT     " + "     gravInt     " + "     pGas/PTot     "
                //         + "     convection? ");
                // System.out.println("      i       " + "    radius    " + "    press    " + "
                // rho    ");
                // System.out.format("%03d  %10.6f   %10.6f   %10.6f   %10.6f   %10.6f   %10.6f
                // %10.6f   %10.6f   %10.6f   %10.6f   %10.6f   %b%n",
                //        i, log10E * Math.log(radInt[i]), log10E * Math.log(massInt[i]), log10E *
                // Math.log(lumInt[i]), log10E * Math.log(tempShell[i]),
                //        log10E * Math.log(pressShell[i]), log10E * Math.log(rhoShell[i]),
                // kapShell[i], log10E * Math.log(epsShell[i]),
                //        dLnPdLnT[i], log10E * Math.log(gravInt[i]), pGasShell[i] / pressShell[i],
                // convFlag[i]);
                // System.out.format("   %03d     %15.11f      %15.11f      %15.11f      %15.11f
                //  %n",
                //        i, log10E * Math.log(radInt[i]), log10E * Math.log(pressShell[i]), log10E
                // * Math.log(rhoShell[i]), log10E * Math.log(tempShell[i]));
                // Surface boundary condition:
                iSurf++;
              }

              int numDeps = iSurf;
              System.out.println("Actual number of depths = " + numDeps);
              // Independent total mass calculation:
              // First derivative, dD_n/dXi at surface:
              double dDFuncdXi = (DFunc[iSurf] - DFunc[iSurf - 1]) / (xi[iSurf] - xi[iSurf - 1]);
              double totMass =
                  -4.0
                      * Math.PI
                      * Math.pow(lambda, 3.0)
                      * rhoC
                      * Math.pow(xi[iSurf], 2.0)
                      * dDFuncdXi;
              System.out.println("Total analytic mass " + totMass);

              // Results:
              // cgs units:
              double mass = massInt[numDeps];
              double radius = radInt[numDeps];
              double luminosity = lumInt[numDeps];
              double surfTemp = tempShell[numDeps];

              // Compute the effective temperature of the model:
              double teff4 = luminosity / 4.0 / Math.PI / Math.pow(radius, 2.0) / Useful.sigma;
              double teff = Math.pow(teff4, 0.25);

              // solar units:
              double massSol = mass / Useful.mSun;
              double radiusSol = radius / Useful.rSun;
              double lumSol = luminosity / Useful.lSun;

              // Run the loop inward to build the optical depth scasle, tauIn:
              //// No!While we're at it - find the nuclear burning core
              double[] tauIn = new double[numDeps];
              tauIn[numDeps - 1] = 0.0;
              // int iCore = numDeps - 1;
              for (int i = numDeps - 2; i == 0; i--) {
                tauIn[i] = tauIn[i - 1] + rhoShell[i] * kapShell[i] * radShell[i];
                // if (lumInt[i] > 0.99 * luminosity) {
                //    iCore--;
                // }
              }

              // Report:
              System.out.println("cgs units:");
              System.out.println(
                  "Radius: "
                      + log10E * Math.log(radius)
                      + " Mass: "
                      + log10E * Math.log(mass)
                      + " Bol Luminosity: "
                      + log10E * Math.log(luminosity));
              System.out.println("Teff: " + teff + " TSurf: " + surfTemp);
              System.out.println("Solar units:");
              System.out.println(
                  "Radius: " + radiusSol + " Mass: " + massSol + " Bol Luminosity: " + lumSol);
              System.out.println(
                  "Nuclear burning core fractional radius: " + (radInt[iCore] / radius));

              // Compute spectral energy distribution (SED):
              // wavelength grid (cm):
              double[] waveSetup = new double[3];
              waveSetup[0] = 100.0 * 1.0e-7; // test Start wavelength, cm
              waveSetup[1] = 2000.0 * 1.0e-7; // test End wavelength, cm
              waveSetup[2] = 100; // test number of lambda
              int numWaves = (int) waveSetup[2];

              double[] SED = new double[numWaves];
              double[] waveGrid = new double[numWaves];
              double thisWave, thisLogWave, logWave0, logWave1;
              logWave0 = Math.log(waveSetup[0]);
              logWave1 = Math.log(waveSetup[1]);
              double deltaLogWave = (logWave1 - logWave0) / numWaves;
              for (int i = 0; i < numWaves; i++) {
                thisLogWave = logWave0 + ((double) i) * deltaLogWave;
                thisWave = Math.exp(thisLogWave);
                waveGrid[i] = thisWave;
                SED[i] = Planck.planck(teff, thisWave);
                // System.out.println(" " + waveGrid[i] + " " + SED[i]);
              }

              //
              // double colors[] = new double[5];
              double colors[] = Photometry.UBVRI(waveGrid, SED);

              // All code before this line
              String patternCol = "0.00";
              // String pattern = "#####.##";
              DecimalFormat colFormatter = new DecimalFormat(patternCol);
              // // String patternWl = "0.00";
              //  //String pattern = "#####.##";
              // DecimalFormat WlFormatter = new DecimalFormat(patternWl);

              actiontarget.setText(
                  "Photometric color indices: "
                      + "U-B: "
                      + colFormatter.format(colors[0])
                      + " B-V: "
                      + colFormatter.format(colors[1])
                      + " V-R: "
                      + colFormatter.format(colors[2])
                      + " V-I: "
                      + colFormatter.format(colors[3])
                      + " R-I: "
                      + colFormatter.format(colors[4])
                      + "\r\n");

              // No! //grid.getChildren().add(r);
              // Graphical output section:
              /*
              // Plot 1: T_Kin(radius):
              LineChart<Number, Number> lineChartT2 = LineCharts.t2Plot(numDeps, radInt, tempShell);
              grid.add(lineChartT2, 0, 9);
              // Plot 2: log(P(radius):
              LineChart<Number, Number> lineChartP = LineCharts.pressPlot(numDeps, radInt, pressShell, pGasShell, pRadShell);
              grid.add(lineChartP, 2, 9);
              // Plot 3: log rho:
              LineChart<Number, Number> lineChartRho = LineCharts.rhoPlot(numDeps, radInt, rhoShell);
              grid.add(lineChartRho, 2, 11);

              // Plot 4: log cumulative L_Bol
              LineChart<Number, Number> lineChartLum = LineCharts.lumPlot(numDeps, radInt, lumInt, lumPpInt, lumCnoInt);
              grid.add(lineChartLum, 0, 10);

              // Plot 5: log cumulative mass
              LineChart<Number, Number> lineChartMass = LineCharts.massPlot(numDeps, radInt, massInt);
              grid.add(lineChartMass, 2, 10);
              // Plot 6: log epsilon (nuc power generation)
              LineChart<Number, Number> lineChartEps = LineCharts.epsPlot(numDeps, radInt, epsShell, epsPpShell, epsCnoShell);
              grid.add(lineChartEps, 0, 11);
              // Plot 7: log kappa (mass extinction)
              LineChart<Number, Number> lineChartKap = LineCharts.kapPlot(numDeps, radInt, kapShell, kapBfShell, kapFfShell, kapEsShell, kapHminShell);
              grid.add(lineChartKap, 4, 10);
              // Plot 8: log flux(lambda) (SED)
              LineChart<Number, Number> lineChartSED = LineCharts.sedPlot(numWaves, waveGrid, SED);
              grid.add(lineChartSED, 4, 11);
              */

              // Graphical output section:
              // Plot 1: T_Kin(radius):
              LineChart<Number, Number> lineChartT2 = LineCharts.t2Plot(numDeps, radInt, tempShell);
              grid.add(lineChartT2, 0, 9);
              // Plot 2: log(P(radius):
              LineChart<Number, Number> lineChartP =
                  LineCharts.pressPlot(numDeps, radInt, pressShell, pGasShell, pRadShell);
              grid.add(lineChartP, 2, 9);
              // Plot 3: log rho:
              LineChart<Number, Number> lineChartRho =
                  LineCharts.rhoPlot(numDeps, radInt, rhoShell);
              grid.add(lineChartRho, 2, 13);

              // Plot 4: log cumulative L_Bol
              LineChart<Number, Number> lineChartLum =
                  LineCharts.lumPlot(numDeps, iCore, radInt, lumInt, lumPpInt, lumCnoInt);
              grid.add(lineChartLum, 0, 11);

              // Plot 5: log cumulative mass
              LineChart<Number, Number> lineChartMass =
                  LineCharts.massPlot(numDeps, radInt, massInt);
              grid.add(lineChartMass, 2, 11);
              // Plot 6: log epsilon (nuc power generation)
              LineChart<Number, Number> lineChartEps =
                  LineCharts.epsPlot(numDeps, radInt, epsShell, epsPpShell, epsCnoShell);
              grid.add(lineChartEps, 0, 13);
              // Plot 7: log kappa (mass extinction)
              LineChart<Number, Number> lineChartKap =
                  LineCharts.kapPlot(
                      numDeps, radInt, kapShell, kapBfShell, kapFfShell, kapEsShell, kapHminShell);
              grid.add(lineChartKap, 4, 11);
              // Plot 8: log flux(lambda) (SED)
              LineChart<Number, Number> lineChartSED = LineCharts.sedPlot(numWaves, waveGrid, SED);
              grid.add(lineChartSED, 4, 13);

              //                   LineChart<Number, Number> lineChartSpec =
              // LineCharts.specPlot(numMaster, masterLams, cosTheta, masterIntens, masterFlux);
              //                   grid.add(lineChartSpec, 2, 10);
              //// LineChart<Number, Number> lineChartLine = LineCharts.linePlot(numPoints,
              // lineLambdas, cosTheta, lineProf, lam0);
              //                   grid.add(lineChartLine, 4, 10);
              // Debug versions of the function with parameters for plotting up quqntities used in
              // line profile
              // calculation:
              // LineChart<Number, Number> lineChartLine = LineCharts.linePlot(numPoints,
              // lineLambdas, cosTheta, logKappaL, lam0, kappa);
              // grid.add(lineChartLine, 4, 10);
              // LineChart<Number, Number> lineChartLine = LineCharts.linePlot(numPoints,
              // lineLambdas, cosTheta, logTauL, lam0);
              // grid.add(lineChartLine, 4, 10);
              // Final scene / stage stuff:
              // Scene scene = new Scene(grid, 1600, 900);
              // scene.getStylesheets().add("../../GrayCascadeStyleSheet.css");
              //
              // primaryStage.setScene(scene);
              //
              // primaryStage.show();
            } else {
              actiontarget.setText("All fields must have values");
            }
          }
        });

    // Final scene / stage stuff:
    Scene scene = new Scene(grid, 1600, 900);

    // Stylesheet.css must go in /src/ directory
    scene.getStylesheets().add("GrayCascadeStyleSheet.css");

    primaryStage.setScene(scene);
    primaryStage.show();
  }
  @Override
  public void start(Stage stage) {

    // create temporary file outside of application

    // create the scene

    stage.setTitle("CSV visualization");
    Browser b = new Browser();
    BorderPane sp = new BorderPane();
    VBox bottomStack = new VBox();

    FileChooser csvfinder = new FileChooser();
    ExtensionFilter filter = new ExtensionFilter("csv only", "*.csv");
    csvfinder.getExtensionFilters().add(filter);
    csvfinder.setTitle("Find CSV File");

    // initializing bounds and panes
    VBox topStack = new VBox(); // Creates a container to hold all Menu Objects.
    MenuBar mainMenu = new MenuBar(); // Creates our main menu to hold our Sub-Menus.
    ToolBar toolBar = new ToolBar(); // Creates our tool-bar to hold the buttons.
    topStack.getChildren().add(mainMenu);
    topStack.getChildren().add(toolBar);

    Menu file = new Menu("File");
    MenuItem openFile = new MenuItem("Open CSV File");
    MenuItem exitApp = new MenuItem("Exit");
    file.getItems().addAll(openFile, exitApp);

    // Create and add the "Edit" sub-menu options.
    Menu edit = new Menu("Edit");
    MenuItem properties = new MenuItem("Save Frame Image");
    edit.getItems().add(properties);

    // Create and add the "Help" sub-menu options.
    Menu help = new Menu("Help");
    MenuItem visitWebsite = new MenuItem("About");
    help.getItems().add(visitWebsite);
    mainMenu.getMenus().addAll(file, edit, help);

    Options rightStack = new Options(b);
    Label file_notif = new Label();
    file_notif.setText("No file");
    file_notif.setFont(Font.font("Tahoma", FontWeight.NORMAL, 15));
    topStack.setAlignment(Pos.CENTER_LEFT);
    bottomStack.getChildren().add(file_notif);

    // aligning boxes
    b.refresh();
    sp.setCenter(b);

    sp.setTop(topStack);
    sp.setRight(rightStack);
    sp.setBottom(bottomStack);
    properties.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            WritableImage image = b.snapshot(new SnapshotParameters(), null);
            FileChooser chooser = new FileChooser();
            // TODO: probably use a file chooser here
            File file = chooser.showSaveDialog(stage);

            try {
              ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", file);
            } catch (IOException e) {
              // TODO: handle exception here
            }
          }
        });

    visitWebsite.setOnAction(
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            Stage stage = new Stage();
            // Fill stage with content
            StackPane sp = new StackPane();
            Label ta = new Label();
            ta.minHeight(400);
            ta.minWidth(400);

            ta.setText(
                "This is a tool that was developed by PowerAmerica to help "
                    + "visualize multidimensional CSV files on a 2D graph. It's "
                    + "initial use was visualization of the relationships between "
                    + "the specifications of different electrical components as shown"
                    + " by the sample data. Use the file menu option to upload any CSV file and use"
                    + " the option bars on the right pane to control the dimensions "
                    + "that you want to put on the graph.");
            ta.setWrapText(true);
            ta.setPadding(new Insets(10, 10, 10, 10));
            sp.setAlignment(Pos.TOP_LEFT);
            sp.getChildren().add(ta);

            Scene s = new Scene(sp, 400, 400);
            stage.setScene(s);

            stage.show();
          }
        });

    exitApp.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            System.exit(0);
          }
        });

    // button event handlers
    openFile.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            File file = csvfinder.showOpenDialog(stage);
            System.out.println(file.getName());

            file_notif.setText(file.getName());
            // write name to file for javascript to use

            FTPClient client = new FTPClient();
            FileInputStream fis = null;

            try {
              client.connect("ftp.enloecompsci.com");
              client.login("southpawac", "**********");
              client.changeWorkingDirectory("/public_html/PowerAmerica/CSV_FILES");
              System.out.print(client.getReplyString());
              fis = new FileInputStream(file.getPath());
              client.storeFile(file.getName(), fis);
              b.fileName = file.getName();
              client.logout();
            } catch (IOException e) {
              e.printStackTrace();
            } finally {
              try {
                if (fis != null) {
                  fis.close();
                }
                client.disconnect();
              } catch (IOException e) {
                e.printStackTrace();
              }
            }

            BufferedReader br;
            try {
              br = new BufferedReader(new FileReader(new File(file.getPath())));
              String options;
              if ((options = br.readLine()) != null) {
                rightStack.resetOptions(options.split(","));
                rightStack.setSizes();
              }

            } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });

    scene = new Scene(sp, 1000, 850, Color.web("#666970"));
    stage.setScene(scene);
    stage.show();
  }
Example #25
0
  @Override
  public void start(Stage primaryStage) throws IOException { // тут прорисовка поля
    primaryStage.setTitle("Dots game"); // заголовок
    // Parent root = FXMLLoader.load(getClass().getResource("sample.fxml")); //это для Scene
    // Builder! но пользоваться им для этой игры было не удобно. так что здесь ничего

    for (int i = 0; i < 10; i++) { // тут создается поле

      for (int j = 0; j < 10; j++) {
        PaintGrid(i, j); // а здесь прорисовывается
        layout.getChildren().add(FieldRect[i][j]); // добавляем на экран
      }
      X += 1; // это для создания линий между rectangle
      Y = 0;
    }
    Button button = new Button("GO!"); // кнопка, при помощи которой игрок подтверждает ход

    pane.setTop(layout); // в верхнюю часть экрана помещаем поле

    HBox box = new HBox(); // layout для расположений внижу экрана
    box.setSpacing(30); // устранавливаем промежуток между элементами
    box.getChildren().add(button); // добавляем кнопку Go, она нужна двоим игрокам

    text = new TextField();
    box.getChildren().add(text);

    button.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) { // добавляем слушателя кнопки
            try {
              DataOutputStream output1 = new DataOutputStream(clientSocket.getOutputStream());
              output1.writeInt(y3); // отправляем на сервер
              // System.out.println("Input column!"); //вводим колонку

              output1.writeInt(x3); // отправляем на сервер
              output1.flush(); // заставляем поток закончить передачу данных.
              getFromServer(in);

              PaintCircle1();
            } catch (IOException e) {
              System.out.println("IOException in sending data to server!");
            }
          }
        });

    if (Number
        == 2) { // если играет игрок 2, то создаем дополнительную кнопку - Get field! В начале игры
      // после 1го ода игрока надо нажать ее, чтобы получать ходы игрока1
      Button button1 = new Button("Get Field!");
      button1.setOnAction(
          new EventHandler<ActionEvent>() {
            @Override
            public void handle(ActionEvent event) {
              try {
                getFromServer(in);
                PaintCircle1();
              } catch (IOException e) {
              }
            }
          });
      box.getChildren().add(button1);
    }

    Label label = new Label("Dots Game"); // сщздаем label
    label.setFont(new Font("Algerian", 18)); // устанавливаем шрифт

    box.getChildren().add(label); // добавляем label на экран
    pane.setBottom(box); // + в нижнюю часть экрана
    Scene scene = new Scene(pane, 500, 500, Color.YELLOW); // устанавливаем параметры scene
    primaryStage.setScene(scene); // устанавливаем эту сцену как текущую

    primaryStage.show(); // показываем окно
  }
Example #26
0
  public static Group createPane() {
    Group group = new Group();
    VBox vbox = new VBox();
    Label label = new Label("List of contructors");
    label.setFont(new Font("Arial", 20));
    label.setPadding(new Insets(50, 0, 0, 100));
    // Create TableView
    TableView<ContructorViewer> table = new TableView<ContructorViewer>();
    table.setEditable(true);
    table.setMinWidth(800);
    table.setMaxHeight(500);
    TableColumn<ContructorViewer, Integer> firstNameCol =
        new TableColumn<ContructorViewer, Integer>("id");
    TableColumn<ContructorViewer, String> secondNameCol =
        new TableColumn<ContructorViewer, String>("name");
    firstNameCol.setCellValueFactory(new PropertyValueFactory<ContructorViewer, Integer>("id"));
    firstNameCol.setMinWidth(100);
    secondNameCol.setCellValueFactory(new PropertyValueFactory<ContructorViewer, String>("name"));
    secondNameCol.setMinWidth(400);

    // Добавление колонок в таблицу
    list = getList();
    table.setItems(list);
    table.getColumns().addAll(firstNameCol, secondNameCol);
    // Панель для дополнительных операций
    HBox hb = new HBox();
    hb.setPadding(new Insets(40, 0, 20, 300));
    hb.setSpacing(10);
    TextField nameContructor = new TextField();
    nameContructor.setPromptText("new name of contructor");
    Button add = new Button("Add");
    Button close = new Button("Close");
    Text textEdit = new Text("Edit operation is open");
    textEdit.setFont(new Font(15));

    // Создание кнопок
    HBox btns = new HBox();
    btns.setStyle("-fx-background-color:#E6EFF5");
    btns.setMinHeight(60);
    Button[] buttons = new Button[12];
    String[] commands =
        new String[] {
          "HELP", "SAVE", "", "EDIT", "", "", "ADD", "DELETE", "REFRESH", "EXIT", "IMPORT", "EXPORT"
        };
    for (int i = 0; i < buttons.length; i++) {
      buttons[i] = new Button("F" + Integer.toString(i + 1) + "\n" + commands[i]);
      buttons[i].setTooltip(new Tooltip(commands[i]));
      buttons[i].setStyle("-fx-background-color:#C2CCCF");
      buttons[i].setMaxSize(70, 60);
      buttons[i].setMinSize(70, 60);
    }
    btns.getChildren().addAll(buttons);
    btns.setSpacing(15);
    btns.setPadding(new Insets(10, 0, 0, 0));
    btns.setAlignment(Pos.CENTER);

    //		Добавления таблицы и кнопок на панель
    vbox.getChildren().setAll(table, btns);
    vbox.setMinWidth(800);
    vbox.setMaxHeight(500);
    //		vbox.setAlignment(Pos.CENTER);
    vbox.setPadding(new Insets(100, 20, 20, 20));

    // ==========EDIT============================
    buttons[3].setOnAction(
        new EventHandler<ActionEvent>() {
          int i = 0;

          @Override
          public void handle(ActionEvent event) {
            if (i == 0) vbox.getChildren().add(textEdit);
            // TODO Auto-generated method stub
            // Редактирование колонок
            // Открытие на редактирование колонка NAME
            secondNameCol.setCellFactory(TextFieldTableCell.forTableColumn());
            // Cобытие на изменение ячейки
            secondNameCol.setOnEditCommit(
                new EventHandler<CellEditEvent<ContructorViewer, String>>() {
                  @Override
                  public void handle(CellEditEvent<ContructorViewer, String> value) {
                    int activeRow = value.getTablePosition().getRow();
                    if (value.getNewValue().isEmpty()) {
                      MyAlert er =
                          new MyAlert(
                              "ERROR! Please try again." + "\n" + "Input name of contructor");
                      Stage primaryStage = new Stage();
                      try {
                        er.start(primaryStage);
                      } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                      }
                    } else {
                      value.getTableView().getItems().get(activeRow).setName(value.getNewValue());
                    }
                  }
                });
            i++;
          }
        });
    // ==========ADD POSITION============================
    buttons[6].setOnAction(
        new EventHandler<ActionEvent>() {
          int i = 0;

          @Override
          public void handle(ActionEvent event) {
            // TODO Auto-generated method stub
            if (i == 0) hb.getChildren().addAll(nameContructor, add, close);

            add.setOnAction(
                new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent event) {
                    // TODO Auto-generated method stub
                    if (nameContructor.getText().isEmpty()) {
                      MyAlert er =
                          new MyAlert("ERROR! Please try again." + "\n" + "Input name of product");
                      Stage primaryStage = new Stage();
                      try {
                        er.start(primaryStage);
                      } catch (Exception e1) {
                        // TODO Auto-generated catch block
                        e1.printStackTrace();
                      }
                    } else {
                      list.add(new ContructorViewer(list.size() + 1, nameContructor.getText()));
                      nameContructor.clear();
                    }
                  }
                });
            i++;
            close.setOnAction(
                new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent event) {
                    // TODO Auto-generated method stub
                    hb.getChildren().removeAll(nameContructor, add, close);
                    i = 0;
                  }
                });
          }
        });
    // ==========DELETE POSITION============================
    buttons[7].setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            int selectedInd = table.getSelectionModel().getSelectedIndex();
            if (selectedInd >= 0) {
              table.getItems().remove(selectedInd);
            } else {
              // Nothing selected
              Stage st = new Stage();
              MyAlert er = new MyAlert("Please select row for delete");
              try {
                er.start(st);
              } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
              }
            }
          }
        });
    // ==========REFRESH============================
    buttons[8].setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            // TODO Auto-generated method stub
            list = getList();
            table.setItems(list);
          }
        });
    // ==========SAVE=============================================
    list = table.getItems();
    buttons[1].setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            // TODO Auto-generated method stub
            setList(list);
            Stage st = new Stage();
            MyAlert er = new MyAlert("Executed store successfully");
            try {
              er.start(st);
            } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        });
    // ==========EXIT=====================================================
    buttons[9].setOnAction(eventExit -> TabPanelJFX.primaryStage.close());

    //		Добавление панели в группу
    group.getChildren().addAll(label, vbox, hb);

    return group;
  }
  @FXML
  private void archiveButtonClicked(ActionEvent event) {
    configureButtons();
    archiveButton.setGraphic(archiveSelectedIMV);

    // clear old content
    contentPane.getChildren().clear();

    // ask for archive date
    titleLabel.setText("Archiving");

    // create text and textfield
    VBox mainBox = new VBox();
    mainBox.setSpacing(20);
    mainBox.setAlignment(Pos.CENTER);

    HBox box = new HBox();
    contentPane.getChildren().add(mainBox);

    box.setSpacing(5);
    box.setAlignment(Pos.CENTER);

    Label dateLabel = new Label("Cut Off Date:");
    dateLabel.setFont(new Font("System", 24));

    TextField dateTF = new TextField();
    dateTF.setPromptText("YYYY-MM-DD");

    Label errorLabel = new Label();
    errorLabel.setTextFill(Paint.valueOf("#f5515f"));
    errorLabel.setFont(new Font("System", 14));

    Button confirmButton = new Button("Confirm");
    confirmButton.setStyle(
        "-fx-background-color: #e63347;" + "-fx-background-radius: 7;" + "-fx-text-fill: white");
    confirmButton.setPrefSize(130, 40);

    confirmButton.setOnAction(
        e -> {
          if (dateTF.getText() != null) {
            String cutoffDate = dateTF.getText().trim();
            if (cutoffDate.length() > 10) {
              errorLabel.setText("Too long");
              return;
            } else if (!isDate(cutoffDate)) {
              errorLabel.setText("Wrong date format");
              return;
            }

            boolean success = operation.archive(cutoffDate);
            if (success) {
              // set up content
              contentPane.getChildren().clear();

              TableView table = new TableView();
              TableColumn fnCol = new TableColumn("First Name");
              fnCol.setCellValueFactory(new PropertyValueFactory<>("firstName"));
              TableColumn lnCol = new TableColumn("Last Name");
              lnCol.setCellValueFactory(new PropertyValueFactory<>("lastName"));
              TableColumn emailCol = new TableColumn("Email");
              emailCol.setCellValueFactory(new PropertyValueFactory<>("email"));
              TableColumn lvCol = new TableColumn("Updated At");
              lvCol.setCellValueFactory(new PropertyValueFactory<>("updatedAt"));
              TableColumn discountCol = new TableColumn("Discount");
              discountCol.setCellValueFactory(new PropertyValueFactory<>("discount"));

              table.getColumns().addAll(fnCol, lnCol, emailCol, lvCol, discountCol);
              ObservableList<Customer> data =
                  FXCollections.observableArrayList(operation.getArchivedCustomers());
              table.setItems(data);

              contentPane.getChildren().add(table);

              titleLabel.setText("Archived Customers");

            } else {
              titleLabel.setText("Can't archive");
              return;
            }

          } else {
            errorLabel.setText("Please enter a date");
            return;
          }
        });

    box.getChildren().addAll(dateLabel, dateTF, errorLabel);
    mainBox.getChildren().addAll(box, confirmButton);
  }
Example #28
0
  public void initialize() {

    //        if (Objects.equals(System.getProperty("os.name"), "Mac OS X")){
    //
    //        }

    JSON json = new JSON();
    String[] result = json.returner();
    String name1 = result[3].replace(".zip", "");

    JCalPropertiesReader jCalPropertiesReader = new JCalPropertiesReader();
    String[] strings = jCalPropertiesReader.reader();

    new PropertiesWriter(name1, strings[5], result[1], result[2]);

    Text text1 = new Text(result[2]);
    text1.setFont(Font.font("Courier New", FontWeight.BOLD, 15));

    name.setFont(Font.font("", FontWeight.BOLD, 12));
    name.setText(name1);

    newVersion.setFont(Font.font("", FontWeight.BOLD, 12));
    newVersion.setText(result[1]);

    PropertiesReader propertiesReader = new PropertiesReader();
    String[] tempString = propertiesReader.reader();
    currentVersion.setText(tempString[1]);

    if (Objects.equals(result[1], tempString[1])) {
      Alert alert = new Alert(Alert.AlertType.INFORMATION);
      alert.setTitle("GUpdater");
      alert.setHeaderText("JCal up to date");
      alert.setContentText("Looks like your software is up to date");

      Optional<ButtonType> result1 = alert.showAndWait();
      if (result1.get() == ButtonType.OK) {
        Platform.exit();
      }
    }

    summary.getChildren().add(text1);

    close.setOnAction(event -> Platform.exit());

    update.setOnAction(
        event -> {
          Window ownerWindow = ((Node) event.getTarget()).getScene().getWindow();
          Stage stage = new Stage();
          stage.initStyle(StageStyle.UNDECORATED);
          stage.initModality(Modality.APPLICATION_MODAL);
          stage.initOwner(ownerWindow);
          Parent parent = null;
          try {
            parent = FXMLLoader.load(getClass().getResource("/resource/GUpdater-progress.fxml"));
          } catch (IOException e) {
            e.printStackTrace();
          }
          assert parent != null;
          Scene scene = new Scene(parent, 600, 148);
          stage.setResizable(false);
          stage.getIcons().add(new Image("/resource/g-4.png"));
          stage.setTitle("GUpdater");
          stage.setScene(scene);
          stage.show();
        });

    cancel.setOnAction(event -> Platform.exit());
  }
Example #29
0
  public SerieInfo(final Serie serie) {
    // TODO Auto-generated constructor stub

    GridPane grid = new GridPane();
    FlowPane flow = new FlowPane(Orientation.HORIZONTAL);
    flow.setAlignment(Pos.TOP_LEFT);
    flow.setHgap(40);

    DropShadow dropShadow = new DropShadow();
    dropShadow.setOffsetX(10);
    dropShadow.setOffsetY(10);
    dropShadow.setColor(Color.rgb(50, 50, 50, 0.7));

    Label poster = new Label();
    String style_inner =
        "-fx-font: Gill Sans;"
            + "-fx-font-family: Gill Sans;"
            + "-fx-effect: dropshadow(one-pass-box, black, 8, 0, 4, 4);";
    poster.setStyle(style_inner);

    final Label star = new Label();
    Image stella = new Image("img/greentick.png", 35, 35, true, true, true);
    star.setGraphic(new ImageView(stella));
    star.setVisible(false);

    ImageView image = new ImageView(serie.getPoster());
    poster.setGraphic(image);

    TextArea text = new TextArea();

    text.setPrefSize(600, 160);
    text.setText(serie.getOverview());
    text.setWrapText(true);
    text.setEditable(false);
    /*
     * text.setStyle("-fx-text-fill: black;"+ "-fx-font: Gill Sans;"+
     * "-fx-font-size: 13;" + "-fx-height:400");
     */

    text.setStyle(LABEL_STYLE);
    String name = null;
    if (serie.getNome().length() > 16) {
      name = serie.getNome().substring(0, 15);
      name = name.concat("...");
    } else {

      name = serie.getNome();
    }

    Label nome = new Label(name);
    nome.setTextFill(Color.BLACK);
    nome.setFont(Font.font("Helvetica", 28));

    final Button btn = new Button("  Add   ");
    ImageView imageview = new ImageView(new Image("img/add.png", 12, 12, true, true, true));
    btn.setGraphic(imageview);
    btn.setContentDisplay(ContentDisplay.LEFT);
    /*
     * String buttonCss = SerieInfo.class.getResource("CustomButton.css")
     * .toExternalForm(); btn.getStylesheets().add(buttonCss);
     */
    btn.getStyleClass().add("custom-browse");
    btn.setCursor(Cursor.HAND);
    btn.setTextFill(Color.WHITE);

    btn.addEventHandler(
        MouseEvent.MOUSE_CLICKED,
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent e) {

            star.setVisible(true);

            if (Preferiti.getInstance().addToPreferiti(serie) == false) {

              /*
               * new MyDialog(Guiseries2.stage,
               * Modality.APPLICATION_MODAL, "Warning!", serie);
               */

            } else {

              btn.setDisable(true);
              btn.setText("  Added  ");
              btn.setGraphic(null);
              // torrent...
              DaemonManager manager = new DaemonManager();
              Search search =
                  new Search(
                      serie,
                      manager,
                      "ENG",
                      new SearchListener() {

                        @Override
                        public void SearchListener() {
                          Platform.runLater(
                              new Runnable() {

                                @Override
                                public void run() {

                                  boolean compare = false;
                                  for (int i = 0; i < serie.getStagioni().size(); i++) {

                                    for (int j = 0;
                                        j < serie.getStagioni().get(i).getEpisodiStagione().size();
                                        j++) {

                                      compare = false;

                                      if ((serie
                                              .getStagioni()
                                              .get(i)
                                              .getEpisodiStagione()
                                              .get(j)
                                              .getTorrent()
                                          != null)) {
                                        for (int k = (1 + j);
                                            k
                                                < serie
                                                    .getStagioni()
                                                    .get(i)
                                                    .getEpisodiStagione()
                                                    .size();
                                            k++) {

                                          if (serie
                                                  .getStagioni()
                                                  .get(i)
                                                  .getEpisodiStagione()
                                                  .get(k)
                                                  .getTorrent()
                                              != null) {
                                            if (serie
                                                .getStagioni()
                                                .get(i)
                                                .getEpisodiStagione()
                                                .get(j)
                                                .getTorrent()
                                                .getName()
                                                .equals(
                                                    serie
                                                        .getStagioni()
                                                        .get(i)
                                                        .getEpisodiStagione()
                                                        .get(k)
                                                        .getTorrent()
                                                        .getName())) {

                                              compare = true;
                                            }
                                          }
                                        }

                                        if (compare == false) {

                                          TorrentSeriesElement.getInstance()
                                              .addToTorrents(
                                                  serie
                                                      .getStagioni()
                                                      .get(i)
                                                      .getEpisodiStagione()
                                                      .get(j)
                                                      .getTorrent());
                                          if ((TorrentSeriesElement.getInstance()
                                                      .torrents
                                                      .indexOf(
                                                          serie
                                                              .getStagioni()
                                                              .get(i)
                                                              .getEpisodiStagione()
                                                              .get(j)
                                                              .getTorrent())
                                                  % 2)
                                              == 0) {

                                            TabDownload.mainDownload
                                                .getChildren()
                                                .add(
                                                    TabDownload.addTorrentEvenToDownloadTab(
                                                        serie
                                                            .getStagioni()
                                                            .get(i)
                                                            .getEpisodiStagione()
                                                            .get(j)
                                                            .getTorrent()));

                                          } else {

                                            TabDownload.mainDownload
                                                .getChildren()
                                                .add(
                                                    TabDownload.addTorrentOddToDownloadTab(
                                                        serie
                                                            .getStagioni()
                                                            .get(i)
                                                            .getEpisodiStagione()
                                                            .get(j)
                                                            .getTorrent()));
                                          }

                                          System.out.println(
                                              serie
                                                  .getStagioni()
                                                  .get(i)
                                                  .getEpisodiStagione()
                                                  .get(j)
                                                  .getTorrent()
                                                  .getName());
                                        }
                                      }
                                    }
                                  }

                                  try {

                                    FilmistaDb.getInstance().addSeriesToFilmistaDb(serie);
                                  } catch (ClassNotFoundException e1) {
                                    // TODO Auto-generated
                                    // catch
                                    // block
                                    e1.printStackTrace();
                                  } catch (IOException e1) {
                                    // TODO Auto-generated
                                    // catch
                                    // block
                                    e1.printStackTrace();
                                  } catch (SQLException e1) {
                                    // TODO Auto-generated
                                    // catch
                                    // block
                                    e1.printStackTrace();
                                  }

                                  TabPreferiti.updateTab();
                                }
                              });
                        }
                      });
            }
          }
        });

    flow.getChildren().add(btn);
    flow.getChildren().add(nome);

    if (Preferiti.getInstance().series.contains(serie) == true) {

      btn.setText("  Added  ");
      btn.setDisable(true);
      star.setVisible(true);
      btn.setGraphic(null);
    }

    grid.setHgap(25);
    grid.setVgap(15);
    grid.add(poster, 0, 0, 1, 2);
    grid.add(flow, 1, 0);
    FlowPane paneStar = new FlowPane(Orientation.HORIZONTAL);
    paneStar.setAlignment(Pos.TOP_RIGHT);
    paneStar.getChildren().add(star);
    grid.add(paneStar, 2, 0, 1, 1);
    grid.add(text, 1, 1, 2, 1);

    grid.getColumnConstraints().add(0, new ColumnConstraints());
    grid.getColumnConstraints().add(1, new ColumnConstraints());
    grid.getColumnConstraints().add(2, new ColumnConstraints(150));

    // grid.setGridLinesVisible(true);
    grid.setHgrow(text, Priority.ALWAYS);
    grid.setVgrow(poster, Priority.ALWAYS);

    grid.setPadding(new Insets(25, 25, 25, 25));
    this.setCenter(grid);

    String customCss = SerieInfo.class.getResource("CustomBorder.css").toExternalForm();
    this.getStylesheets().add(customCss);
    this.getStyleClass().add("custom-border");
  }
 protected Label getBoldLabel(String text) {
   Label label = new Label(text);
   label.setFont(
       Font.font(Font.getDefault().getFamily(), FontWeight.BOLD, Font.getDefault().getSize()));
   return label;
 }