コード例 #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);
  }
コード例 #2
0
 private void assignColor(Color color) {
   if (color != null) {
     usernameLabel.setStyle(String.format("-fx-text-fill: %s", JavaFxUtil.toRgbCode(color)));
     clanLabel.setStyle(String.format("-fx-text-fill: %s", JavaFxUtil.toRgbCode(color)));
   } else {
     usernameLabel.setStyle("");
     clanLabel.setStyle("");
   }
 }
コード例 #3
0
ファイル: Home.java プロジェクト: josh-marasigan/DocketDoctor
  /* Place relevant data findings to screen */
  private static void addScrollData() {

    scrollSocial.setMaxSize(370, 100);
    scrollMedical.setMaxSize(370, 100);
    scrollHistory.setMaxSize(370, 100);

    Label mh = new Label("MEDICAL HISTORY BY RECENT: ");
    mh.setStyle("-fx-font: 15px Futura;" + "-fx-text-fill: #ff0080;" + "-fx-font-weight: bold;");

    // Social histories input
    Text medText = new Text();
    medText.setStyle("-fx-font: 12px Futura;" + "-fx-text-fill: #ff0080;");
    medText.setText(
        "\t- "
            + "9/17/2015 | Emergency | Northern Hospital  | Peterson MD, Marc\n"
            + "\t- "
            + "5/21/2015 | Emergency | Western Hospital  | Bermann MD, Jason\n"
            + "\t- "
            + "11/4/2014 | Emergency | Northern Hospital | Middleton MD, Lisa\n"
            + "\t- "
            + "7/19/2014 | Emergency | Southern Hospital | Johnson MD, Alex\n"
            + "\t- "
            + "3/9/2014 | Emergency | Western Hospital  | Walton MD, Jonathan\n"
            + "\t- "
            + "10/18/2013 | Emergency | Eastern Hospital | Campbell MD, Ivan\n"
            + "\t- "
            + "4/5/2013 | Emergency | Southern Hospital  | Thomas MD, Judy \n"
            + "\t- "
            + "12/23/2012 | Emergency | Western Hospital  | Johnson MD, Alex\n");
    medScroll.getChildren().addAll(medText);

    Label sh = new Label("SOCIAL HISTORY: ");
    sh.setStyle("-fx-font: 15px Futura;" + "-fx-text-fill: #ff0080;" + "-fx-font-weight: bold;");

    // Social histories input
    Text socialText = new Text();
    socialText.setStyle("-fx-font: 12px Futura;" + "-fx-text-fill: #ff0080;");
    socialText.setText(
        "\t- "
            + "Eats in fast food outlets\n"
            + "\t- "
            + "Ex-smoker\n"
            + "\t- "
            + "Uninsured medical expenses\n"
            + "\t- "
            + "Independent housing, lives alone\n"
            + "\t- "
            + "Does not drive a car\n"
            + "\t- "
            + "Employed in paid casual work\n"
            + "\t- "
            + "Widower\n");

    soScroll.getChildren().addAll(socialText);
  }
コード例 #4
0
  @FXML
  private void handleInsertNewOneClick() {
    DatabaseConnection db = new DatabaseConnection();
    boolean result = db.dodajNowy_Dokument(dokumentyController.getDokumentByFields());

    if (result) {
      statusLabel.setText("Dodano nowy dokument!");
      statusLabel.setStyle("-fx-text-fill: rgb(49, 89, 23);");
    } else {
      statusLabel.setText("Wystąpił błąd przy próbie dodania dokumentu!");
      statusLabel.setStyle("-fx-text-fill: rgb(255, 0, 0);");
    }

    refreshList();
  }
コード例 #5
0
ファイル: Home.java プロジェクト: josh-marasigan/DocketDoctor
  /* Place relevant data findings to screen */
  private static void initScrollData() {

    scrollSocial.setMaxSize(370, 100);
    scrollMedical.setMaxSize(370, 100);
    scrollHistory.setMaxSize(370, 100);

    Label mh = new Label("MEDICAL HISTORY BY RECENT: ");
    mh.setStyle("-fx-font: 15px Futura;" + "-fx-text-fill: #ff0080;" + "-fx-font-weight: bold;");

    medScroll.getChildren().addAll(mh);

    Label sh = new Label("SOCIAL HISTORY: ");
    sh.setStyle("-fx-font: 15px Futura;" + "-fx-text-fill: #ff0080;" + "-fx-font-weight: bold;");

    soScroll.getChildren().addAll(sh);
  }
コード例 #6
0
  @Override
  void setUpScene() {
    Line baseline = new Line(0, getMyHeight() * 2 / 3, getMyWidth(), getMyHeight() * 2 / 3);
    baseline.setStrokeWidth(8);
    baseline.setFill(Color.ROSYBROWN);
    Line midline =
        new Line(getMyWidth() * .55, getMyHeight() * 2 / 3, getMyWidth() * .45, getMyHeight());
    midline.setStrokeWidth(8);
    Circle midCirc = new Circle(getMyWidth() / 2, getMyHeight() * 5 / 6, 15);
    midCirc.setStrokeWidth(6);
    Label timerLabel = new Label(Double.toString(getTimeRemaining()));
    timerLabel.setTextFill(Color.BLACK);
    timerLabel.setStyle("-fx-font-size: 4em;");
    timerLabel.setLayoutX(getMyWidth() / 2 - getMyWidth() * .05);
    timerLabel.setLayoutY(getMyHeight() * .2);
    setTimerLabel(timerLabel);
    setThrowBalllbl(new Label("'Space' -> Throw Ball"));
    getThrowBalllbl().visibleProperty().set(false);
    getThrowBalllbl().setStyle("-fx-font-size: 3em;");
    getThrowBalllbl().setLayoutY(getMyHeight() - 50);

    getMyRoot()
        .getChildren()
        .addAll(
            getTimerLabel(),
            getTimerButtonVBox(),
            getThrowBalllbl(),
            baseline,
            midline,
            midCirc,
            getMyPlayerIV(),
            villainPlayerIV,
            getMyLivesHBox(),
            getEnemyLivesHBox());
  }
コード例 #7
0
  @Override
  public void start(Stage primaryStage) {
    ImageView us = new ImageView(new Image("File:C:/Java/site/image/us.gif"));
    Label lb1 = new Label("US\n50 States", us);
    lb1.setStyle("-fx-border-color: green; -fx-border-width: 2");
    lb1.setContentDisplay(ContentDisplay.BOTTOM);
    lb1.setTextFill(Color.RED);

    Label lb2 = new Label("Circle", new Circle(50, 50, 25));
    lb2.setContentDisplay(ContentDisplay.TOP);
    lb2.setTextFill(Color.ORANGE);

    Label lb3 = new Label("Rectangle", new Rectangle(10, 10, 50, 25));
    lb3.setContentDisplay(ContentDisplay.RIGHT);

    Label lb4 = new Label("Ellipse", new Ellipse(50, 50, 50, 25));
    lb4.setContentDisplay(ContentDisplay.LEFT);

    Ellipse ellipse = new Ellipse(50, 50, 50, 25);
    ellipse.setStroke(Color.GREEN);
    ellipse.setFill(Color.WHITE);
    StackPane stackPane = new StackPane();

    stackPane.getChildren().addAll(ellipse, new Label("JavaFX"));
    Label lb5 = new Label("A pane inside a label", stackPane);
    lb5.setContentDisplay(ContentDisplay.BOTTOM);

    HBox pane = new HBox(20);
    pane.getChildren().addAll(lb1, lb2, lb3, lb4, lb5);

    Scene scene = new Scene(pane, 700, 150);
    primaryStage.setTitle("LabelWithGraphic");
    primaryStage.setScene(scene);
    primaryStage.show();
  }
コード例 #8
0
  private static Label createLabel(String pText, String pColor) {
    Label label = new Label(pText);
    label.setAlignment(Pos.CENTER);
    label.setTextAlignment(TextAlignment.CENTER);
    label.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    label.setStyle("-fx-background-color: #" + pColor + ";");

    return label;
  }
コード例 #9
0
  /**
   * Update background, tick and gridline colors
   *
   * @param cfg cfg[0] Background, cfg[1] Chart background, cfg[2] y cfg[3] gridline
   */
  public void updateChartColors(String[] cfg) {
    strBackgroundColor = cfg[0];
    for (Node le : legendFrame.getChildren()) {
      if (le instanceof LegendAxis) {
        le.setStyle("-fx-background-color:" + strBackgroundColor);
        ((LegendAxis) le).selected = false;
      }
    }
    chart.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor)));
    chartPanel.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(
                scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor)))));
    chartPanel.setBackground(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor)));

    legendFrame.setStyle("marco: " + strBackgroundColor + ";-fx-background-color: marco;");

    strChartBackgroundColor = cfg[1];
    ;
    plot.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strChartBackgroundColor)));

    for (Node le : legendFrame.getChildren()) {
      if (le instanceof LegendAxis) {
        le.setStyle("-fx-background-color:" + strBackgroundColor);
        ((LegendAxis) le).selected = false;
        for (Node nn : ((LegendAxis) le).getChildren()) {
          if (nn instanceof Label) {
            ((Label) nn)
                .setStyle(
                    "fondo: "
                        + strChartBackgroundColor
                        + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                        + String.valueOf(fontSize)
                        + "px");
          }
        }
      }
    }

    strGridlineColor = cfg[2];
    ;
    plot.setDomainGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor)));
    plot.setRangeGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor)));

    strTickColor = cfg[3];
    ;
    abcissaAxis.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
    abcissaAxis.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
    for (NumberAxis ejeOrdenada : AxesList) {
      ejeOrdenada.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
      ejeOrdenada.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor)));
    }
  }
コード例 #10
0
  @FXML
  private void handleWriteChangesClick() {
    Dokument d = lista.getSelectionModel().getSelectedItem();

    if (d != null) {
      DatabaseConnection db = new DatabaseConnection();
      boolean result = db.zapiszZmiany_Dokument(dokumentyController.getDokumentByFields());

      if (result) {
        statusLabel.setText("Zmieniono dokument");
        statusLabel.setStyle("-fx-text-fill: rgb(49, 89, 23);");
      } else {
        statusLabel.setText("Wystąpił błąd przy próbie zmiany dokumentu!");
        statusLabel.setStyle("-fx-text-fill: rgb(255, 0, 0);");
      }
      refreshList();
    } else {
      statusLabel.setText("Nie wybrano żadnego dokumentu!");
      statusLabel.setStyle("-fx-text-fill: yellow;");
    }
  }
コード例 #11
0
  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);
  }
コード例 #12
0
  public void change(String userinput, Scene s) {
    String colorName = userinput.substring(userinput.indexOf(" ") + 1);
    if (!ApplicationColor.hasColor(colorName)) return;

    ApplicationColor selectedColor = ApplicationColor.valueOf(colorName.toUpperCase());
    JFXDecorator decorator = (JFXDecorator) s.lookup(".jfx-decorator");
    JFXToolbar toolbar = (JFXToolbar) s.lookup(".jfx-tool-bar");
    Label label = (Label) s.lookup(".icons-badge Label");
    label.setStyle("-fx-text-fill:" + selectedColor.getColorValue() + ";");
    decorator.setStyle("-fx-decorator-color: derive(" + selectedColor.getColorValue() + ",-20%);");
    toolbar.setStyle("-fx-background-color: " + selectedColor.getColorValue() + ";");
  }
コード例 #13
0
 public void endGame() {
   if (playerScore > enemyScore) {
     message.setText("Sinu võit!");
   } else if (playerScore < enemyScore) {
     message.setText("Oi oi, kaotasid!");
   } else {
     message.setText("Viik!");
   }
   message.setStyle("-fx-font-size: 150%; -fx-text-fill: red");
   // lülita nupud välja
   playerBoard.disableButtons();
   enemyBoard.disableButtons();
 }
コード例 #14
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);
 }
コード例 #15
0
ファイル: ReportView.java プロジェクト: reyho/rs_project
  public ReportView() {
    this.setPadding(new Insets(15));
    Label help =
        new Label(
            "Here you can generate the report for your monthly activities. The report is generated as an HTML file in the app root directory.");
    help.setStyle(" -fx-text-fill: black; -fx-font: 14px 'Helvetica'; -fx-padding:4;");

    generateReportButton.setOnAction(
        e -> {
          rc.generateReport();
        });

    this.getChildren().addAll(help, generateReportButton);
  }
コード例 #16
0
  public static void rightVisuaalid() {
    rightVbox = new VBox();
    rightVbox.setSpacing(5);
    rightVbox.setPadding(new Insets(15, 0, 0, 10));

    jaatmejaamadeVastuvottLabel1 = new Label("Jäätmejaamades võetakse elanikelt tasuta vastu:");
    jaatmejaamadeVastuvottLabel1.setStyle("-fx-font: 12 helvetica;-fx-font-weight: bold");
    Label jaatmejaamadeVastuvottLabel2 =
        new Label(
            "* pakendeid "
                + "\n"
                + "* plaste"
                + "\n"
                + "* paberit ja pappi"
                + "\n"
                + "* immutamata/töötlemata puitu"
                + "\n"
                + "* betooni ja telliseid (va Rahumäe jäätmejaam, kus kehtib eraldi hinnakiri)"
                + "\n"
                + "* vanametalli"
                + "\n"
                + "* toiduõli"
                + "\n"
                + "* kasutuskõlblikku vanamööblit"
                + "\n"
                + "* sõiduauto rehve"
                + "\n"
                + "* elektri- ja elektroonikajäätmeid"
                + "\n"
                + "* klaasi"
                + "\n"
                + "* kasutatud riideid"
                + "\n"
                + "* biolagunevaid aia- ja haljastusjäätmeid"
                + "\n"
                + "* koduseid ohtlikke jäätmeid"
                + "\n");
    jaatmejaamadeVastuvottLabel2.setMaxWidth(250);
    jaatmejaamadeVastuvottLabel2.setWrapText(true);

    kaardiNupp = new Button("Jäätmejaamade kaart");
    nupuvajutus();

    rightVbox
        .getChildren()
        .addAll(jaatmejaamadeVastuvottLabel1, jaatmejaamadeVastuvottLabel2, kaardiNupp);
    Java_fx.border.setRight(rightVbox);
  }
コード例 #17
0
ファイル: InventoryView.java プロジェクト: rwcarlsen/cyclist2
    public AgentEntry(final AgentInfo info) {
      super();
      this.info = info;

      getStyleClass().add("agent");
      Label text = new Label(info.value);
      text.setStyle("-fx-background-color:" + ColorUtil.toString(info.color));

      Node button = GlyphRegistry.get(AwesomeIcon.TIMES, "10px");
      button.setVisible(false);

      _status = new Status();
      getChildren().addAll(text, new Spring(), _status, button);

      info.taskProperty.addListener(o -> _status.setTask(info.getTask()));
      setOnMouseEntered(
          e -> {
            button.setVisible(true);
            getStyleClass().add("hover");
          });

      setOnMouseExited(
          e -> {
            button.setVisible(false);
            getStyleClass().remove("hover");
          });

      setOnMouseClicked(
          e -> {
            info.active = !info.active;
            text.setDisable(!info.active);
            if (info.active) {
              _chart.add(info);
            } else {
              _chart.remove(info);
            }
          });

      button.setOnMouseClicked(
          e -> {
            if (_onClose != null) {
              _onClose.accept(this);
            }
            e.consume();
          });

      HBox.setHgrow(text, Priority.ALWAYS);
    }
コード例 #18
0
  public CrashReportView() {
    VBox.setVgrow(termTreeView, Priority.ALWAYS);

    Label label;
    label = new Label("Stack Trace");
    label.setStyle("-fx-padding: 5; -fx-font-size: 14;");

    Tab stackTraceTab, argsTermsTab, termsTab;
    termsTab = new Tab("Crash Report Terms");
    termsTab.setContent(termTreeView);
    argsTermsTab = new Tab("Call Args");
    argsTermsTab.setContent(argsTreeView);
    stackTraceTab = new Tab("Stack Trace");
    stackTraceTab.setContent(new VBox(crashInfoTable, label, stackTraceView));

    getTabs().addAll(stackTraceTab, argsTermsTab, termsTab);
  }
コード例 #19
0
 @Override
 public void initialize(URL url, ResourceBundle rb) {
   initButtons();
   try {
     player = FileManager.loadPlayer();
     playerLabel.setText(player.getName());
     playerLabel.setStyle("-fx-border-color:#00FF69;-fx-border-width:1;");
     loadLevel();
     loadGame();
     instructions();
     updateScores();
     gamePicture();
     instructions.setDisable(false);
     start.setDisable(false);
     updateGameLabel();
   } catch (Exception ex) {
     System.out.println("file error");
   }
 }
コード例 #20
0
  public ImageLoadingProgressBar(double parentWidth, double parentHeight) {
    super();

    this.setWidth(parentWidth); // this.maxWidthProperty().doubleValue());
    this.setHeight(parentHeight); // this.maxHeightProperty().doubleValue());

    ProgressBar pb = new ProgressBar();
    pb.setProgress(-1);
    setHalignment(pb, HPos.CENTER);

    Label progressLabel = new Label("Loading Image...");
    progressLabel.setStyle(
        "-fx-text-fill: old-pink-light;" + "-fx-font-family: 'Helvetica', Arial, sans-serif;");
    setHalignment(progressLabel, HPos.CENTER);

    this.add(progressLabel, 0, 0);
    this.add(pb, 0, 1);

    double translateX = (parentWidth / 2) - 70;
    this.setStyle("-fx-column-halignment: center; " + "-fx-padding: 200 0 0 " + translateX + ";");
  }
コード例 #21
0
  private HBox initGUIcenterRechtsDatenbank() {
    HBox zeile = new HBox(20);
    zeile.setPadding(new Insets(5, 5, 5, 5));
    zeile.setStyle(Css.boxhellblaugrau());

    TextArea antwortDatenbank = new TextArea();
    antwortDatenbank.getStyleClass().add("textareaFlat");
    antwortDatenbank.setStyle(Css.focusrahmenWeg());
    antwortDatenbank.setEditable(false);
    antwortDatenbank.setPrefRowCount(3);
    antwortDatenbank.setPrefColumnCount(25);
    antwortDatenbank.setWrapText(true);
    RahmenTitelWeiss rahmenAntwortDatenbank =
        new RahmenTitelWeiss("Antwort Datenbank", antwortDatenbank);

    VBox senkrecht = new VBox(5);
    Label schildchenAktion = new Label("Aktion");
    schildchenAktion.setStyle(CssExtras.titel());

    ToggleGroup gruppe = new ToggleGroup();

    RadioButton knopfArchivieren = new RadioButton("aktivieren");
    knopfArchivieren.setToggleGroup(gruppe);

    RadioButton knopfLöschen = new RadioButton("löschen");
    knopfLöschen.setToggleGroup(gruppe);

    senkrecht.getChildren().add(schildchenAktion);
    senkrecht.getChildren().add(knopfArchivieren);
    senkrecht.getChildren().add(knopfLöschen);

    Button knopfSenden = new Button("senden");

    zeile.getChildren().add(rahmenAntwortDatenbank);
    zeile.getChildren().add(senkrecht);
    zeile.getChildren().add(knopfSenden);
    return zeile;
  }
コード例 #22
0
ファイル: TableTabController.java プロジェクト: Gikkman/CluIt
  /**
   * Creates labels with the squared error sums for the different clusters, as well as creates one
   * total squared error, which is the sum of the squared error from the different clusters
   *
   * @param r
   * @return
   */
  private ArrayList<Label> getSquaredErrors(Results r) {
    ArrayList<Label> errorLabels = new ArrayList<>();
    double[] errors = r.getSquaredErrors();
    double totalErrors = 0;
    errorLabels.add(new Label(" ")); // Adds an empty row

    // Calculate the number of digits in the largest error.
    // This'll be used to place the numbers in the labels correctly
    double largestNr = 0;
    for (double d : errors) {
      if (Math.abs(d) > largestNr) largestNr = Math.abs(d);
    }
    int offset = (int) (Math.log10(largestNr) + 6);

    for (int i = 0; i < errors.length; i++) {
      Label label = new Label(String.format("SSE Clu" + i + ": %" + offset + ".4f", errors[i]));
      DataTable.skinDataLabel(label);

      totalErrors += errors[i];

      errorLabels.add(label);
    }

    Label blank = new Label(" ");
    Label total = new Label("Total SSE");
    Label val = new Label(String.format("%.4f", totalErrors));

    total.setStyle("-fx-underline: true;");
    DataTable.skinDataLabel(blank);
    DataTable.skinDataLabel(total);
    DataTable.skinDataLabel(val);

    errorLabels.add(blank);
    errorLabels.add(total);
    errorLabels.add(val);
    return errorLabels;
  }
コード例 #23
0
  public Veld1RijtechniekKijktechniek(
      SchermController schermCtrl, EvaController evaCtrl, LeerlingController llnCtrl) {
    evaController = evaCtrl;
    schermController = schermCtrl;
    llnController = llnCtrl;

    this.llnController.getLeerling().addView(this);

    aandachtBtn = new Button("Aandachtspunt");
    aandachtBtn.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            aandacht();
          }
        });

    commentaarCol = new TableColumn("Commentaar");
    commentaarCol.setCellValueFactory(new PropertyValueFactory<Rijtechniek, String>("commentaar"));
    commentaarCol.setCellFactory(TextFieldTableCell.forTableColumn());
    commentaarCol.setOnEditCommit(
        new EventHandler<CellEditEvent<Rijtechniek, String>>() {
          @Override
          public void handle(CellEditEvent<Rijtechniek, String> t) {
            ((Rijtechniek) t.getTableView().getItems().get(t.getTablePosition().getRow()))
                .setCommentaar(t.getNewValue());
          }
        });

    table.setItems(data);
    table.getColumns().addAll(commentaarCol);

    commentaarFld = new TextField();
    commentaarFld.setPromptText("Commentaar");

    addButton = new Button("Voeg toe");
    addButton.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            resetAandachtBtn();
            if (!"".equals(commentaarFld.getText())) {
              data.add(new Rijtechniek(commentaarFld.getText()));
              commentaarFld.clear();
            }
          }
        });
    table.setItems(data);
    table.setOnMouseClicked(
        new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent e) {
            resetAandachtBtn();
          }
        });
    table.setEditable(true);

    vBox2.getChildren().addAll(table, commentaarFld);
    exit = new Button("Ga terug");

    exit.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            evaController.saveListDataRijtechniek("Stuurtechniek", data);
            Veld1RijtechniekKijktechniek.this.schermController.setScherm(MainApp.RIJTECHNIEK_ID);
            resetAandachtBtn();
          }
        });
    delBtn = new Button("Verwijder");
    delBtn.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent e) {
            resetAandachtBtn();

            table.getItems().remove(table.getSelectionModel().getSelectedItem());
          }
        });
    delBtn.setMinHeight(30);
    delBtn.setMaxHeight(30);
    delBtn.setMinWidth(125);
    delBtn.setMaxWidth(125);
    delBtn.setAlignment(Pos.CENTER);
    delBtn.setTranslateX(-47);
    delBtn.setStyle("-fx-background-color: #5F6A95; -fx-text-fill:white");
    table.getStylesheets().add("resource/tableView.css");
    commentaarFld.setStyle("-fx-background-color:#789EBF; -fx-text-fill:white");
    commentaarCol.setMaxWidth(496);
    commentaarCol.setMinWidth(496);
    hBox1.getChildren().addAll(titelAfb, titel);
    hBox1.setMinHeight(50);
    hBox1.setMaxHeight(50);
    hBox1.setMinWidth(600);
    hBox1.setMaxWidth(600);
    hBox1.setSpacing(15);
    hBox1.setAlignment(Pos.CENTER);
    titelAfb.setFitHeight(50);
    titelAfb.setFitWidth(50);
    titel.setStyle("-fx-font: 40px Tahoma; -fx-text-fill:white");

    table.setMinWidth(500);
    table.setMaxWidth(500);
    table.setMinHeight(400);
    table.setMaxHeight(400);
    addButton.setMinHeight(30);
    addButton.setMaxHeight(30);
    addButton.setMinWidth(150);
    addButton.setMaxWidth(150);
    addButton.setAlignment(Pos.CENTER);
    aandachtBtn.setMinHeight(30);
    aandachtBtn.setMaxHeight(30);
    aandachtBtn.setMinWidth(150);
    aandachtBtn.setMaxWidth(150);
    aandachtBtn.setAlignment(Pos.CENTER);
    exit.setMinHeight(30);
    exit.setMaxHeight(30);
    exit.setMinWidth(150);
    exit.setMaxWidth(150);
    exit.setAlignment(Pos.CENTER);
    commentaarFld.setMinHeight(30);
    commentaarFld.setMaxHeight(30);
    commentaarFld.setMinWidth(250);
    commentaarFld.setMaxWidth(250);
    commentaarFld.setAlignment(Pos.CENTER);
    table.setTranslateX(70);
    commentaarFld.setTranslateX(90);
    addButton.setTranslateX(90);
    aandachtBtn.setTranslateX(90);
    exit.setTranslateX(90);

    addButton.setStyle("-fx-background-color: #5F6A95; -fx-text-fill:white");
    exit.setStyle("-fx-background-color: #5F6A95; -fx-text-fill:white");
    aandachtBtn.setStyle("-fx-background-color: #5F6A95; -fx-text-fill:white");

    gp.setStyle(
        "-fx-border-color: #282E54; -fx-border-radius:10 10 10 10;"
            + "-fx-effect: dropshadow(three-pass-box, rgba(0,0,0,0.8), 10, 0, 0, 0);"
            + "-fx-background-color: #282B3A;"
            + "-fx-background-radius: 5;");
    gp.setMaxWidth(900);
    gp.setMinWidth(900);
    gp.setMinHeight(600);
    gp.setMaxHeight(600);
    gp.setHgap(50);
    gp.setVgap(20);
    gp.setAlignment(Pos.CENTER);
    gp.add(hBox1, 0, 0, 2, 1);
    gp.add(table, 0, 1, 2, 1);
    gp.add(commentaarFld, 0, 2);
    gp.add(addButton, 1, 2);
    gp.add(aandachtBtn, 0, 3);
    gp.add(exit, 1, 3);
    gp.add(delBtn, 1, 3);

    this.setAlignment(Pos.CENTER);
    this.getChildren().add(gp);
    this.setStyle("-fx-background-image: url('resource/achtergrondStandaard.png')");

    update();
  }
コード例 #24
0
ファイル: GUI.java プロジェクト: ChrisDaBang/Ball-of-Duty
  @Override
  public void start(Stage theStage) {
    this.tStage = theStage;
    theStage.setTitle("Ball of Duty");
    theStage.setHeight(WINDOW_START_HEIGHT);
    theStage.setWidth(WINDOW_START_WIDTH);
    theStage.centerOnScreen();
    theStage.setResizable(false);
    theStage.setOnCloseRequest(
        new EventHandler<WindowEvent>() {
          public void handle(WindowEvent we) {
            gameManager.quitGame();
            System.exit(0);
          }
        });

    BorderPane startMenuRoot = new BorderPane();
    startMenu = new Scene(startMenuRoot);

    gameBox = new BorderPane();
    Scene gameScene = new Scene(gameBox);

    BorderPane createAccountRoot = new BorderPane();
    BorderPane lohInRoot = new BorderPane();

    theStage.setScene(startMenu);

    gameManager = new GameClient(getRelativeSceneLocation(theStage));

    scale = new Scale();
    scale.xProperty().bind(gameScene.widthProperty().divide(WINDOW_START_WIDTH));
    scale.yProperty().bind(gameScene.heightProperty().divide(WINDOW_START_HEIGHT));
    scale.setPivotX(0);
    scale.setPivotY(0);
    // gameBox.getTransforms().add(scale);
    // gameBox.setBackground(null);
    // TODO scaling

    theStage
        .heightProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage)); // This
              // only
              // happens
              // once
              // for
              // some
              // reason.
            });
    theStage
        .widthProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    theStage
        .xProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    theStage
        .yProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    gameScene
        .xProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    gameScene
        .yProperty()
        .addListener(
            e -> {
              gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
            });
    Image image = new Image("images/frontpage.png");
    BackgroundSize backgroundSize = new BackgroundSize(100, 100, true, true, true, false);
    // new BackgroundImage(image, repeatX, repeatY, position, size)
    BackgroundImage backgroundImage =
        new BackgroundImage(
            image,
            BackgroundRepeat.REPEAT,
            BackgroundRepeat.NO_REPEAT,
            BackgroundPosition.CENTER,
            backgroundSize);
    // new Background(images...)
    Background background = new Background(backgroundImage);
    startMenuRoot.setBackground(background);

    RadioButton chooseBlaster = new RadioButton("Blaster");
    RadioButton chooseRoller = new RadioButton("Roller");
    RadioButton chooseHeavy = new RadioButton("Heavy");

    final ToggleGroup specializationGroup = new ToggleGroup();

    chooseBlaster.setToggleGroup(specializationGroup);
    chooseRoller.setToggleGroup(specializationGroup);
    chooseHeavy.setToggleGroup(specializationGroup);

    chooseBlaster.setSelected(true);

    HBox specializationBox = new HBox();
    specializationBox.setSpacing(9);
    specializationBox.getChildren().add(chooseBlaster);
    specializationBox.getChildren().add(chooseRoller);
    specializationBox.getChildren().add(chooseHeavy);

    Label lblNickname = new Label("Nickname:");
    TextField tfNickname = new TextField();
    Button loginStart = new Button("Log in");
    Button createStart = new Button("Create Account");
    theStage.getIcons().add(new Image("images/ball_red.png"));
    VBox mainButtonBox = new VBox();
    mainButtonBox.setSpacing(5);
    Button joinBtn = new Button("Join game");

    Button viewLB = new Button("Leaderboard");
    viewLB.setPrefSize(150, 50);
    viewLB.setId("viewLB");
    viewLB.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

    BorderPane lbBorder = new BorderPane();
    VBox lbBox = new VBox();
    Scene lbScene = new Scene(lbBorder);

    Button lbBack = new Button("Start menu");
    lbBox.getChildren().add(lbBack);
    lbBorder.setLeft(lbBox);
    lbBack.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

    Label topText = new Label("Only shows scores higher than 100!");
    topText.setStyle("-fx-font-size: 20pt;-fx-font-family: Segoe UI Semibold;");

    viewLB.setOnAction(
        ActionEvent -> {
          HighscoreLeaderboard hBoard = gameManager.getHighscoreLeaderboard();
          hBoard.setFocusTraversable(false);
          lbBorder.setCenter(hBoard);
          if (gameManager.getPlayer() != null) {
            Player client = gameManager.getPlayer();
            Label you =
                new Label(
                    "YOU:    "
                        + client.getNickname()
                        + " ["
                        + client.getId()
                        + "]    | Score: "
                        + client.getHighscore());

            you.setStyle("-fx-font-size: 15pt;-fx-font-family: Segoe UI Semibold;");
            lbBorder.setBottom(you);
          }

          BorderPane.setMargin(hBoard, new Insets(12, 12, 12, 12));

          lbBorder.setTop(topText);
          theStage.setScene(lbScene);

          lbBack.setOnAction(
              ActionEvent1 -> {
                theStage.setScene(startMenu);
                startMenuRoot.setLeft(mainButtonBox);

                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });
        });

    joinBtn.setPrefSize(150, 50);
    tfNickname.setPrefSize(150, 20);
    joinBtn.setId("joinBtn");
    joinBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
    lblNickname.setId("lblNickname");
    lblNickname.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
    createStart.setId("CreateStart");
    createStart.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
    loginStart.setId("loginStart");
    loginStart.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

    joinBtn.setOnAction(
        ActionEvent -> {
          Specializations spec;
          if (chooseRoller.isSelected()) {
            spec = Specializations.ROLLER;
          } else if (chooseHeavy.isSelected()) {
            spec = Specializations.HEAVY;
          } else // Blaster is default, if something goes wrong with radio
          // buttons
          {
            spec = Specializations.BLASTER;
          }

          theStage.setScene(gameScene);
          gameManager.joinAsGuest(gameBox, tfNickname.getText(), spec);
          gameManager.getMap().addObserver(this);
          gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
          gameBox.requestFocus();
        });
    tfNickname.setOnAction(
        ActionEvent -> {
          Specializations spec;
          if (chooseRoller.isSelected()) {
            spec = Specializations.ROLLER;
          } else if (chooseHeavy.isSelected()) {
            spec = Specializations.HEAVY;
          } else // Blaster is default, if something goes wrong with radio
          // buttons
          {
            spec = Specializations.BLASTER;
          }
          theStage.setScene(gameScene);
          gameManager.joinAsGuest(gameBox, tfNickname.getText(), spec);
          gameManager.setSceneRelativeLocation(getRelativeSceneLocation(theStage));
          gameBox.requestFocus();
        });

    mainButtonBox.getChildren().add(lblNickname);
    mainButtonBox.getChildren().add(tfNickname);
    mainButtonBox.getChildren().add(specializationBox);
    mainButtonBox.getChildren().add(joinBtn);
    mainButtonBox.getChildren().add(loginStart);
    mainButtonBox.getChildren().add(createStart);
    mainButtonBox.getChildren().add(viewLB);
    startMenuRoot.setLeft(mainButtonBox);

    createStart.setOnAction(
        ActionEvent -> {
          VBox createAccountButtonBox = new VBox();
          Label lblNickname2 = new Label("Nickname:");
          TextField tfNickname2 = new TextField();
          Label lblUserName = new Label("Name:");
          TextField tfUserName = new TextField();
          Label lblPassword = new Label("Password:"******"Repeat password:"******"Create account");
          Button back = new Button("Start menu");

          createBtn.setId("join-yyyyy");
          createBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          lblUserName.setId("join-game");
          lblUserName.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          lblPassword.setId("join-game");
          lblPassword.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          lblPassword2.setId("join-game");
          lblPassword2.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          back.setId("join-game");
          back.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

          createAccountButtonBox.getChildren().add(lblNickname2);
          createAccountButtonBox.getChildren().add(tfNickname2);
          createAccountButtonBox.getChildren().add(lblUserName);
          createAccountButtonBox.getChildren().add(tfUserName);
          createAccountButtonBox.getChildren().add(lblPassword);
          createAccountButtonBox.getChildren().add(pf);
          createAccountButtonBox.getChildren().add(lblPassword2);
          createAccountButtonBox.getChildren().add(pf2);
          createAccountButtonBox.getChildren().add(createBtn);
          createAccountButtonBox.getChildren().add(back);

          startMenuRoot.setLeft(createAccountButtonBox);
          BorderPane.setMargin(createAccountButtonBox, new Insets(350, 0, 0, 150));

          createBtn.setOnAction(
              ActionEvent1 -> {
                gameManager.createAccount(
                    tfUserName.getText(),
                    tfNickname2.getText(),
                    pf.getText().toCharArray(),
                    pf2.getText().toCharArray());
                startMenuRoot.setLeft(mainButtonBox);
                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });

          back.setOnAction(
              ActionEvent1 -> {
                startMenuRoot.setLeft(mainButtonBox);
                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });
        });

    loginStart.setOnAction(
        ActionEvent -> {
          VBox loginButtonBox = new VBox();
          Button logInBtn = new Button("Log in");
          Label lblUserName2 = new Label("Name:");
          TextField tfUserName2 = new TextField();
          Label lblPassword2 = new Label("Password:"******"Start Menu");

          logInBtn.setId("join-game");
          logInBtn.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");
          back2.setId("join-game");
          back2.setStyle("-fx-font: 20 arial; -fx-base: #ff0717;");

          loginButtonBox.getChildren().add(lblUserName2);
          loginButtonBox.getChildren().add(tfUserName2);
          loginButtonBox.getChildren().add(lblPassword2);
          loginButtonBox.getChildren().add(pf3);
          loginButtonBox.getChildren().add(logInBtn);
          loginButtonBox.getChildren().add(back2);

          startMenuRoot.setLeft(loginButtonBox);
          BorderPane.setMargin(loginButtonBox, new Insets(350, 0, 0, 150));

          logInBtn.setOnAction(
              ActionEvent1 -> {
                // TODO login
              });

          back2.setOnAction(
              ActionEvent1 -> {
                startMenuRoot.setLeft(mainButtonBox);
                BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));
              });
        });

    BorderPane.setMargin(mainButtonBox, new Insets(350, 0, 0, 150));

    Button quitBtn = new Button("Quit game");
    quitBtn.setPrefSize(80, 40);
    quitBtn.setId("quit-game");

    quitBtn.setOnAction(
        ActionEvent -> {
          gameManager.quitGame();
          theStage.setScene(startMenu);
        });

    canvas = new Canvas(CANVAS_START_WIDTH, CANVAS_START_HEIGHT);
    gameBox.setCenter(canvas);
    BorderPane.setAlignment(canvas, Pos.TOP_LEFT);

    gameBox.setBottom(quitBtn);
    BorderPane.setAlignment(quitBtn, Pos.TOP_LEFT);
    theStage.show();
  }
コード例 #25
0
  private Tuple2<TableView<Offer>, VBox> getOfferTable(Offer.Direction direction) {
    TableView<Offer> tableView = new TableView();

    // price
    TableColumn<Offer, Offer> priceColumn = new TableColumn<>();
    priceColumn.textProperty().bind(priceColumnLabel);
    priceColumn.setMinWidth(120);
    priceColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    priceColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatFiat(item.getPrice()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(priceColumn);

    // amount
    TableColumn<Offer, Offer> amountColumn = new TableColumn<>("Amount (BTC)");
    amountColumn.setText("Amount (BTC)");
    amountColumn.setMinWidth(120);
    amountColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    amountColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatCoin(item.getAmount()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(amountColumn);

    // volume
    TableColumn<Offer, Offer> volumeColumn = new TableColumn<>("Amount (BTC)");
    volumeColumn.setMinWidth(120);
    volumeColumn.textProperty().bind(volumeColumnLabel);
    volumeColumn.setCellValueFactory((offer) -> new ReadOnlyObjectWrapper<>(offer.getValue()));
    volumeColumn.setCellFactory(
        new Callback<TableColumn<Offer, Offer>, TableCell<Offer, Offer>>() {
          @Override
          public TableCell<Offer, Offer> call(TableColumn<Offer, Offer> column) {
            return new TableCell<Offer, Offer>() {
              @Override
              public void updateItem(final Offer item, boolean empty) {
                super.updateItem(item, empty);
                if (item != null && !empty) setText(formatter.formatFiat(item.getOfferVolume()));
                else setText("");
              }
            };
          }
        });
    tableView.getColumns().add(volumeColumn);

    tableView.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new Label("Currently there are no offers available");
    placeholder.setWrapText(true);
    tableView.setPlaceholder(placeholder);

    Label titleLabel =
        new Label(
            direction.equals(Offer.Direction.BUY)
                ? "Offers for buy bitcoin (bid)"
                : "Offers for sell bitcoin (ask)");
    titleLabel.setStyle("-fx-font-weight: bold; -fx-font-size: 16; -fx-alignment: center");
    UserThread.execute(() -> titleLabel.prefWidthProperty().bind(tableView.widthProperty()));

    VBox vBox = new VBox();
    vBox.setSpacing(10);
    vBox.setFillWidth(true);
    vBox.setMinHeight(150);
    vBox.getChildren().addAll(titleLabel, tableView);
    return new Tuple2<>(tableView, vBox);
  }
コード例 #26
0
  @Override
  public void handleKeyInput(KeyCode code) {
    double xLoc = getMyPlayerIV().getBoundsInParent().getMinX();
    double yLoc = getMyPlayerIV().getY();
    double yLocBottom = yLoc + getMyPlayerIV().getBoundsInParent().getHeight() / 2;
    double moveSpeed = getMyPlayer().getMyMoveSpeed();
    switch (code) {
      case RIGHT:
        // Check to see if crossed half court or ducking
        if (xLoc + getMyPlayerIV().getBoundsInLocal().getWidth() + moveSpeed < getMyWidth() / 2
            && !isDucking()) {
          getMyPlayerIV().setX(xLoc + moveSpeed);
        }
        // Check to see if player picks up ball
        if (myDodgeball != null) {
          if (getMyPlayerIV().getBoundsInParent().intersects(myDodgeball.getBoundsInParent())) {
            getMyRoot().getChildren().remove(getMyDodgeball());
            getMyPlayer().setHoldingBall(true);
            getMyRoot().getChildren().get(0).setVisible(true);
          }
        }

        break;
      case LEFT:
        // Make sure not too far out of window or ducking
        if (xLoc - moveSpeed > 0 && !isDucking()) {
          getMyPlayerIV().setX(xLoc - moveSpeed);
        }
        break;
      case UP:
        // Joe Jumps, prevents jump if already in the middle of one
        if (getJumpTransition() == null
            || getJumpTransition().getStatus() == Animation.Status.STOPPED) {
          setJumpTransition(new TranslateTransition(Duration.millis(300), getMyPlayerIV()));
          getJumpTransition().interpolatorProperty().set(Interpolator.SPLINE(.1, .1, .7, .7));
          getJumpTransition().setByY(-getMyPlayerIV().getY());
          getJumpTransition().setAutoReverse(true);
          getJumpTransition().setCycleCount(2);
          getJumpTransition().play();
        }
        break;
      case DOWN:
        // Prevents "duck" if already ducking
        if (!isDucking()) {
          Boolean wasHoldingBall = getMyPlayer().isHoldingBall();
          getMyRoot().getChildren().removeAll(getMyPlayerIV());
          Image duck =
              new Image(
                  getClass()
                      .getClassLoader()
                      .getResourceAsStream("main/resources/images/duck.png"));
          setMyPlayer(new MyDodgeballer(getMyStartLives(), getMyMoveSpeed(), new ImageView(duck)));
          getMyPlayer().setHoldingBall(wasHoldingBall);
          setMyPlayerIV(getMyPlayer().getMyImageView());
          getMyPlayer().getMyImageView().setX(xLoc);
          getMyPlayer().getMyImageView().setY(yLocBottom);
          getMyRoot().getChildren().add(getMyPlayerIV());
          setDucking(true);
        }
        break;
      case SPACE:
        if (getMyPlayer().isHoldingBall()) {
          setMyDodgeball(
              new Dodgeball(
                  getMyPlayerIV().getX(),
                  getMyPlayerIV().getY(),
                  villainPlayerIV.getX(),
                  villainPlayerIV.getY(),
                  20,
                  Color.RED,
                  false,
                  true));
          getMyPlayer().setHoldingBall(false);
          getBallsInFlightList().add(getMyDodgeball());
          getThrowBalllbl().setVisible(false);
          getMyRoot().getChildren().add(getMyDodgeball());
        }
        break;
      case L:
        if (getGameStarted() == false) {
          setMyStartLives(getMyStartLives() + 1);
          getMyRoot().getChildren().remove(getMyLivesHBox());
          setMyLivesHBox(getMyStartLives());
          getMyRoot().getChildren().add(getMyLivesHBox());
        }
        break;
      case D:
        if (getGameStarted() == false && getMyStartLives() > 1) {
          setMyStartLives(getMyStartLives() - 1);
          getMyRoot().getChildren().remove(getMyLivesHBox());
          setMyLivesHBox(getMyStartLives());
          getMyRoot().getChildren().add(getMyLivesHBox());
        }
        break;
      case T:
        if (getGameStarted() == false) {
          setMyStartTime(getMyStartTime() + 5);
          setTimeRemaining(getMyStartTime());
          getTimerButtonVBox();
          getMyRoot().getChildren().remove(getTimerLabel());

          Label timerLabel = new Label(Double.toString(getTimeRemaining()));
          timerLabel.setTextFill(Color.BLACK);
          timerLabel.setStyle("-fx-font-size: 4em;");
          timerLabel.setLayoutX(getMyWidth() / 2 - getMyWidth() * .05);
          timerLabel.setLayoutY(getMyHeight() * .2);
          setTimerLabel(timerLabel);
          getMyRoot().getChildren().add(getTimerLabel());
        }
        break;
      case Y:
        if (getGameStarted() == false && getMyStartTime() > 5) {
          setMyStartTime(getMyStartTime() - 5);
          setTimeRemaining(getMyStartTime());
          getTimerButtonVBox();
          getMyRoot().getChildren().remove(getTimerLabel());

          Label timerLabel = new Label(Double.toString(getTimeRemaining()));
          timerLabel.setTextFill(Color.BLACK);
          timerLabel.setStyle("-fx-font-size: 4em;");
          timerLabel.setLayoutX(getMyWidth() / 2 - getMyWidth() * .05);
          timerLabel.setLayoutY(getMyHeight() * .2);
          setTimerLabel(timerLabel);
          getMyRoot().getChildren().add(getTimerLabel());
        }
        break;
      default:
    }
  }
コード例 #27
0
  /**
   * @param axis Axis name to wich the new series belongs
   * @param cs Series Coinfiguration
   */
  @Override
  public final void addSeries(String axis, SimpleSeriesConfiguration cs) {
    for (int i = 0; i < axes.size(); i++) {
      if (axes.get(i).getName().equals(axis)) {
        String strColor;
        javafx.scene.paint.Color color;
        int indice = seriesList.size();
        if (cs.getColor() == null) {
          color = getColor(indice);
        } else {
          color = cs.getColor();
        }
        strColor = color.toString();

        XYSeriesCollection dataset = datasetList.get(i);
        Series series =
            new Series(
                cs.getName(),
                "color: "
                    + strColor
                    + ";width: "
                    + String.valueOf(cs.getLineWidth())
                    + ";shape: "
                    + cs.getShapeName()
                    + ";",
                i,
                dataset.getSeriesCount());
        dataset.addSeries(series);

        XYItemRenderer renderer = plot.getRenderer(i);
        renderer.setSeriesPaint(dataset.getSeriesCount() - 1, scene2awtColor(color));

        SeriesShape simb =
            new SeriesShape(
                cs.getShapeName(), javafx.scene.paint.Color.web(strColor.replace("#", "0x")));

        if (cs.getLineWidth() > 0) {
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesLinesVisible(dataset.getSeriesCount() - 1, true);
          renderer.setSeriesStroke(
              dataset.getSeriesCount() - 1, new BasicStroke(cs.getLineWidth()));
        } else {
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesLinesVisible(dataset.getSeriesCount() - 1, false);
        }

        if (cs.getShapeName().equals("null")) {
          renderer.setSeriesShape(dataset.getSeriesCount() - 1, null);
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesShapesVisible(dataset.getSeriesCount() - 1, false);
        } else {
          renderer.setSeriesShape(dataset.getSeriesCount() - 1, simb.getShapeAWT());
          ((XYLineAndShapeRenderer) renderer)
              .setSeriesShapesVisible(dataset.getSeriesCount() - 1, true);
          if (cs.getShapeName().contains("empty")) {
            ((XYLineAndShapeRenderer) renderer)
                .setSeriesShapesFilled(dataset.getSeriesCount() - 1, false);
          } else {
            ((XYLineAndShapeRenderer) renderer)
                .setSeriesShapesFilled(dataset.getSeriesCount() - 1, true);
          }
        }

        if (i == 0) {
          plot.setRenderer(renderer);
        } else {
          plot.setRenderer(i, renderer);
        }

        seriesList.add(series);

        final LegendAxis le = getLegendAxis(axis);
        final Label label = new Label(cs.toString());
        Platform.runLater(
            () -> {
              label.setStyle(
                  "fondo: "
                      + strChartBackgroundColor
                      + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                      + String.valueOf(fontSize)
                      + "px");
            });

        label.setOnMouseClicked(
            (MouseEvent t) -> {
              if (t.getClickCount() == 2) {
                for (int i1 = 0; i1 < seriesList.size(); i1++) {
                  if (seriesList.get(i1).getKey().toString().equals(label.getText())) {
                    editSeries(seriesList.get(i1));
                    break;
                  }
                }
              }
            });
        label.setOnMouseExited(
            (MouseEvent t) -> {
              label.setStyle(
                  label
                      .getStyle()
                      .replace("-fx-background-color: blue", "-fx-background-color: fondo"));
            });
        label.setOnMouseEntered(
            (MouseEvent t) -> {
              label.setStyle(
                  label
                      .getStyle()
                      .replace("-fx-background-color: fondo", "-fx-background-color: blue"));
              for (Node le1 : legendFrame.getChildren()) {
                if (le1 instanceof LegendAxis) {
                  le1.setStyle("-fx-background-color:" + strBackgroundColor);
                  ((LegendAxis) le1).selected = false;
                }
              }
            });
        label.setStyle(
            "fondo: "
                + strChartBackgroundColor
                + ";-fx-text-fill: white;-fx-background-color: fondo;-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: "
                + String.valueOf(fontSize)
                + "px");

        le.getChildren().add(label);
        label.setGraphic(simb.getShapeGraphic());

        break;
      }
    }
  }
コード例 #28
0
  @Override
  public void step(double elapsedTime) {
    Random rand = new Random();
    if (getTimeRemaining() < 0 && getGameStarted()) {
      exitLevel("You got beat, you didn't defeat Goodman!!");
    }
    if (getGameStarted()) {
      getMyRoot().getChildren().remove(getTimerLabel());
      setTimeRemaining(getTimeRemaining() - elapsedTime);
      Label timerLabel = new Label(Long.toString(Math.round(getTimeRemaining() - elapsedTime)));
      timerLabel.setTextFill(Color.BLACK);
      timerLabel.setStyle("-fx-font-size: 4em;");
      timerLabel.setLayoutX(getMyWidth() / 2 - getMyWidth() * .04);
      timerLabel.setLayoutY(getMyHeight() * .15);
      setTimerLabel(timerLabel);
      getMyRoot().getChildren().add(getTimerLabel());
      if (myDodgeball == null && rand.nextInt(100) == 0) {

        myDodgeball =
            new Dodgeball(
                getMyWidth() * .45,
                getMyHeight() * 2 / 3,
                villainPlayerIV.getX(),
                villainPlayerIV.getY(),
                20,
                Color.RED,
                false,
                false);

        getBallsInFlightList().add(myDodgeball);
        getMyRoot().getChildren().add(myDodgeball);
      }
      if (tossBall()) {
        int highOrLow = rand.nextInt(3) * 20;
        Dodgeball newEnemyBall =
            new Dodgeball(
                villainPlayerIV.getX(),
                villainPlayerIV.getY(),
                getMyPlayerIV().getX(),
                getMyPlayerIV().getY() + highOrLow,
                20,
                Color.PURPLE,
                true,
                true);

        getBallsInFlightList().add(newEnemyBall);
        getMyRoot().getChildren().add(newEnemyBall);
      }
      Iterator<Dodgeball> iter = getBallsInFlightList().iterator();
      while (iter.hasNext()) {
        Dodgeball currBall = iter.next();

        if (currBall.isBeingThrown()) {
          if (!currBall.isEnemyBall()) {
            currBall.setCenterX(currBall.getCenterX() + villainPlayer.getMyTossSpeed());
            currBall.setCenterY(
                currBall.getCenterX() * currBall.getTrajectorySlope()
                    + currBall.getTrajectoryYIntercept());
            // check for collisions
            if (villainPlayerIV.getBoundsInParent().intersects(currBall.getBoundsInParent())) {
              int currLives = enemyLivesHBox.getChildren().size();
              getMyRoot().getChildren().removeAll(currBall, enemyLivesHBox);
              setEnemyLivesHBox(currLives - 1);
              getMyRoot().getChildren().add(getEnemyLivesHBox());
              iter.remove();
              myDodgeball = null;
              if (enemyLivesHBox.getChildren().size() == 0) {
                exitLevel("You won!!");
              }
            }
          } else {
            currBall.setCenterX(currBall.getCenterX() - villainPlayer.getMyTossSpeed());
            currBall.setCenterY(
                currBall.getCenterX() * currBall.getTrajectorySlope()
                    + currBall.getTrajectoryYIntercept());
            //                     check for collisions
            if (getMyPlayerIV().getBoundsInParent().intersects(currBall.getBoundsInParent())) {
              iter.remove();
              getMyRoot().getChildren().removeAll(currBall, getMyLivesHBox());

              setMyLivesHBox(getMyLivesHBox().getChildren().size() - 1);
              getMyRoot().getChildren().add(getMyLivesHBox());
              if (getMyLivesHBox().getChildren().size() == 0) {
                exitLevel("You got beat!!");
              }
            }
          }
          double currX = currBall.getCenterX();
          if (currX < 0) {
            iter.remove();
            getMyRoot().getChildren().remove(currBall);
          }
        }
      }
    }
  }
コード例 #29
0
ファイル: Home.java プロジェクト: josh-marasigan/DocketDoctor
  public static void establishScene() {
    initScrollData();
    Main.hLeft = new VBox(20);
    Main.hLeft.setEffect(new DropShadow());
    Main.hLeft.setAlignment(Pos.CENTER);
    Main.hLeft.setBackground(new Background(Main.myBG));
    Main.hLeft.setMinHeight(Main.height);
    Main.hLeft.setMinWidth(Main.width / 2 - 100);

    Main.hRight = new VBox(18);
    Main.hRight.setAlignment(Pos.TOP_CENTER);
    Main.hRight.setMinHeight(Main.height);
    Main.hRight.setMinWidth(Main.width / 2 + 100);
    Main.hRight.setPadding(new Insets(20, 0, 0, 20));

    // Create Dividers
    VBox stats = new VBox(10);
    stats.setAlignment(Pos.CENTER);

    // Patient Portal
    Image pp = new Image("file:src/docketdoc/res/PD_Logo.png");
    ImageView pap = new ImageView(pp);
    VBox patientPortal = new VBox();
    patientPortal.setAlignment(Pos.CENTER);
    patientPortal.setPadding(new Insets(10, 10, 10, 10));

    // Label
    Label lp = new Label("Patient Portal");
    lp.setStyle("-fx-font: 25px Futura;" + "-fx-text-fill: #66CDAA;");

    patientPortal.getChildren().addAll(pap, lp);

    // Search Patient
    TextField searchTF = new TextField();
    searchTF.setStyle(
        "-fx-max-height: 50px;"
            + "-fx-max-width: 200px;"
            + "-fx-text-fill: #505050;"
            + "-fx-font: 12px Futura;"
            + "-fx-prompt-text-fill: #505050;");
    searchTF.setPromptText("First Name");

    TextField searchTFlast = new TextField();
    searchTFlast.setStyle(
        "-fx-max-height: 50px;"
            + "-fx-max-width: 200px;"
            + "-fx-text-fill: #505050;"
            + "-fx-font: 12px Futura;"
            + "-fx-prompt-text-fill: #505050;");
    searchTFlast.setPromptText("Last Name");

    // Interact Button
    Button searchName = new Button("Search Name");
    searchName.setStyle(
        "-fx-background-radius: 0;"
            + "-fx-font: 16px Futura;"
            + "-fx-font-weight: bold;"
            + "-fx-text-fill: white;"
            + "-fx-background-color: #FF7F50;");

    // Hover animation.
    searchName.setOnMouseEntered(
        e -> {
          searchName.setOpacity(.5);
        });
    searchName.setOnMouseExited(
        e -> {
          searchName.setOpacity(2);
        });

    // Button Search for Name
    searchName.setOnAction(
        e -> {
          /* ------------------------------------ */
          /* Search patiend directory by FHIR API */
          /* ------------------------------------ */
          new FhirContext();
          // Create a client (only needed once)
          FhirContext ctx = FhirContext.forDstu2();
          IGenericClient client =
              ctx.newRestfulGenericClient("http://fhir2.healthintersections.com.au/open");

          String search = new String(searchTF.getText() + " " + searchTFlast.getText());

          // Invoke the client
          Bundle bundle =
              client
                  .search()
                  .forResource(Patient.class)
                  .where(Patient.NAME.matchesExactly().value(search))
                  .encodedJson()
                  .execute();

          System.out.println("patients count=" + bundle.size());
          List<Patient> list = bundle.getResources(Patient.class);
          for (Patient p : list) {
            namess = p.getNameFirstRep().getText();
            agess = p.getBirthDateElement().toHumanDisplay();
            sexess = p.getGender();
          }
          // Add to grid then display

          // Update Name
          nameShow = new Label(namess.toUpperCase());
          namePat.getChildren().remove(nameShow);
          patientData.getChildren().remove(namePat);
          nameShow.setStyle("-fx-font: 15px Futura;" + "-fx-text-fill: #ff0080;");
          namePat.getChildren().addAll(nameShow);
          patientData.getChildren().add(namePat);

          // Update Age
          ageShow = new Label(agess.toUpperCase());
          agePat.getChildren().remove(ageShow);
          patientData.getChildren().remove(agePat);
          ageShow.setStyle("-fx-font: 15px Futura;" + "-fx-text-fill: #ff0080;");
          agePat.getChildren().addAll(ageShow);
          patientData.getChildren().add(agePat);

          // Update Sex
          sexShow = new Label(sexess.toUpperCase());
          sexPat.getChildren().remove(sexShow);
          patientData.getChildren().remove(sexPat);
          sexShow.setStyle("-fx-font: 15px Futura;" + "-fx-text-fill: #ff0080;");
          sexPat.getChildren().addAll(sexShow);
          patientData.getChildren().add(sexPat);

          addScrollData();
          searchTF.setText(null);
          searchTFlast.setText(null);
        });

    /* ----------------------------------------- */
    /* Right Side contained within a scroll Pane */
    /* ----------------------------------------- */
    patientData = new VBox(10);

    // Name Divisors
    pname = new Label("NAME:\t");
    pname.setStyle("-fx-font: 15px Futura;" + "-fx-text-fill: #66CDAA;" + "-fx-font-weight: bold;");
    namePat = new HBox(10);
    namePat.getChildren().addAll(pname, nameShow);

    // Age Divisors
    page = new Label("DOB:\t");
    page.setStyle("-fx-font: 15px Futura;" + "-fx-text-fill: #66CDAA;" + "-fx-font-weight: bold;");
    agePat = new HBox(10);
    agePat.getChildren().addAll(page, ageShow);

    // Gender Divisors
    psex = new Label("SEX:\t\t");
    psex.setStyle("-fx-font: 15px Futura;" + "-fx-text-fill: #66CDAA;" + "-fx-font-weight: bold;");
    sexPat = new HBox(10);
    sexPat.getChildren().addAll(psex, sexShow);

    patientData.getChildren().addAll(namePat, agePat, sexPat);

    // Scrolls
    scrollSocial.setContent(soScroll);
    scrollMedical.setContent(medScroll);
    scrollHistory.setContent(hisScroll);

    // Add search results to right side
    Main.hRight.getChildren().addAll(patientData, scrollMedical, scrollSocial, hisScroll);

    // Add elements to Left Side
    stats.getChildren().addAll(patientPortal, searchTF, searchTFlast, searchName);

    // Set Main stage to home scene

    Main.hLeft.getChildren().addAll(stats);
    Main.containHome = new HBox();
    Main.containHome.getChildren().addAll(Main.hLeft, Main.hRight);
    Main.homeScene = new Scene(Main.containHome);
  }
コード例 #30
0
ファイル: SerieInfo.java プロジェクト: lelmarir/Filmista
  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");
  }