Beispiel #1
0
  public void introScreen() {
    // Player player = new Player();

    Label Name = new Label("Rapid Memory Test");
    Image img =
        new Image(
            "file:C:\\Users\\emaktse\\Documents\\HITSA\\GIT Repository\\javaProject\\Images library\\mozg2.jpg");
    ImageView imgView = new ImageView(img);
    Label Description =
        new Label(
            "Today we have interesting and very complicated test.\n"
                + "You will be shown pictures. You need to remember it and on the next page \n"
                + "select only those pictures which you have been shown.\n"
                + "This is really complicated. Test has 10 levels, each new is more complex than previous");
    Button startTest = new Button("START TEST");
    startTest.setOnAction(e -> userInputScreen());

    VBox vbox = new VBox(40);
    vbox.getChildren().addAll(Name, Description, imgView, startTest);
    vbox.setAlignment(Pos.CENTER);
    Scene scene = new Scene(vbox, 1000, 800);
    window1.setScene(scene);
    window1.setTitle("MEMORY TEST");
    window1.show();
  }
Beispiel #2
0
  public void selectLevel(int levelCounter) {
    correctImageCounter = 0;
    System.out.println("Level is " + levelCounter);
    VBox layout2 = new VBox(10);
    Label label2 = new Label("RAPID MEMORY TEST");
    layout2.getChildren().addAll(label2);
    Button[] levelButtonArray = new Button[levelCounter];
    for (int i = 0; i < levelCounter; i++) {
      Button button = new Button("Level " + (i + 1));
      button.setOnAction(e -> askImageScreen());
      levelButtonArray[i] = button;
    }

    for (int i = 0; i < levelButtonArray.length; i++) {
      layout2.getChildren().addAll(levelButtonArray[i]);
    }

    layout2.setAlignment(Pos.CENTER);
    scene2 = new Scene(layout2, 1000, 800);

    window1.setScene(scene2);

    window1.setScene(scene2);
    window1.setTitle("Memory Game");
    window1.show();
  }
Beispiel #3
0
  public void userInputScreen() {
    // Scene 1 elements

    Label label1 = new Label("Please enter your name and age");
    TextField nameInput = new TextField();
    TextField ageInput = new TextField();
    nameInput.setPromptText("ENTER YOUR NAME HERE");
    ageInput.setPromptText("ENTER YOUR AGE HERE");
    Button buttonNext = new Button("Next");
    buttonNext.setOnAction(e -> validateName(nameInput, ageInput));
    buttonNext.setOnKeyPressed(
        event -> {
          System.out.println(event.getCode());
          validateName(nameInput, ageInput);
        });

    // Scene 1 layout
    VBox layout1 = new VBox(20);
    layout1.getChildren().addAll(label1, nameInput, ageInput, buttonNext);
    layout1.setAlignment(Pos.CENTER);
    scene1 = new Scene(layout1, 1000, 800);

    window1.setScene(scene1);
    window1.setTitle("Memory test");

    window1.show();
  }
Beispiel #4
0
  private static Object[] iter(List<VBox> lh, double target, int[] histo, int nColors, int niters) {
    VBox vbox;
    while (niters < MAX_ITERATIONS) {
      vbox = lh.get(lh.size() - 1);
      lh.remove(lh.size() - 1);
      if (vbox.count(false) == 0) {
        lh.add(vbox);
        niters++;
        continue;
      }
      VBox[] vboxes = medianCutApply(histo, vbox);

      VBox vbox1 = vboxes[0];
      VBox vbox2 = vboxes[1];

      if (vbox1 == null) return new Object[] {lh, nColors, niters};
      lh.add(vbox1);
      if (vbox2 != null) {
        lh.add(vbox2);
        nColors++;
      }
      if (nColors >= target) return new Object[] {lh, nColors, niters};
      if (niters++ > MAX_ITERATIONS) {
        return new Object[] {lh, nColors, niters};
      }
      Collections.sort(lh);
    }
    return new Object[] {lh, nColors, niters};
  }
Beispiel #5
0
  public static Tuple2<Label, VBox> getTradeInputBox(HBox amountValueBox, String descriptionText) {
    Label descriptionLabel = new Label(descriptionText);
    descriptionLabel.setId("input-description-label");
    descriptionLabel.setPrefWidth(170);

    VBox box = new VBox();
    box.setSpacing(4);
    box.getChildren().addAll(descriptionLabel, amountValueBox);
    return new Tuple2<>(descriptionLabel, box);
  }
    public FileGridCell() {
      Label titleLabel = new Label();
      titleLabel.setPrefWidth(80);
      titleLabel.setWrapText(true);
      titleLabel.setTextAlignment(TextAlignment.CENTER);
      title = titleLabel.textProperty();

      ImageView iconView = new ImageView();
      icon = iconView.imageProperty();

      VBox vbox = new VBox(iconView, titleLabel);
      vbox.setAlignment(Pos.TOP_CENTER);

      setGraphic(vbox);
    }
  private void initPane() {
    //		WebEngine engine = optionView.getEngine();
    try {
      Document document = Jsoup.connect(webView.getEngine().getLocation()).get();
      Element table =
          document.select("#normal_basket_" + document.select("[name=item_id]").val()).first();
      Element td = table.select("td").first();
      Elements spans = td.select("span");
      Elements selects = td.select("select");
      //			System.out.println(spans.size());
      cmb = new ArrayList<ComboBox>();
      for (int i = 0; i < spans.size(); i++) {

        ObservableList<ValuePair> obs = FXCollections.observableArrayList();
        Elements options = selects.get(i).select("option");
        for (int k = 0; k < options.size(); k++) {
          Element option = options.get(k);
          obs.add(new ValuePair("choice", option.text(), option.val()));
        }

        cmb.add(new ComboBox<ValuePair>(obs));
        optionArea.getChildren().addAll(new Text(spans.get(i).text()), cmb.get(i));
      }

    } catch (Exception e) {
      // TODO 自動生成された catch ブロック
      e.printStackTrace();
    }
  }
  @Override
  public void initialize() {
    disputesTable = new TableView<>();
    VBox.setVgrow(disputesTable, Priority.SOMETIMES);
    disputesTable.setMinHeight(150);
    root.getChildren().add(disputesTable);

    TableColumn<Dispute, Dispute> tradeIdColumn = getTradeIdColumn();
    disputesTable.getColumns().add(tradeIdColumn);
    TableColumn<Dispute, Dispute> roleColumn = getRoleColumn();
    disputesTable.getColumns().add(roleColumn);
    TableColumn<Dispute, Dispute> dateColumn = getDateColumn();
    disputesTable.getColumns().add(dateColumn);
    TableColumn<Dispute, Dispute> contractColumn = getContractColumn();
    disputesTable.getColumns().add(contractColumn);
    TableColumn<Dispute, Dispute> stateColumn = getStateColumn();
    disputesTable.getColumns().add(stateColumn);

    disputesTable.getSortOrder().add(dateColumn);
    disputesTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
    Label placeholder = new Label("There are no open tickets");
    placeholder.setWrapText(true);
    disputesTable.setPlaceholder(placeholder);
    disputesTable.getSelectionModel().clearSelection();

    disputeChangeListener = (observableValue, oldValue, newValue) -> onSelectDispute(newValue);
  }
Beispiel #9
0
  public void start(Stage stage) {
    Button yesButton = new Button("Yes");
    Button noButton = new Button("No");
    Button maybeButton = new Button("Maybe");

    final double rem = Font.getDefault().getSize();

    HBox buttons = new HBox(0.8 * rem);
    buttons.getChildren().addAll(yesButton, noButton, maybeButton);

    VBox pane = new VBox(0.8 * rem);
    Label question = new Label("Will you attend?");
    pane.setPadding(new Insets(0.8 * rem));
    pane.getChildren().addAll(question, buttons);
    stage.setScene(new Scene(pane));
    stage.show();
  }
Beispiel #10
0
  public void checkResultScreen(String[] listOfImageAsk) {

    VBox vbox = new VBox(40);
    GridPane grid = new GridPane();
    grid.setGridLinesVisible(false);
    Image imgYes =
        new Image(
            "file:C:\\Users\\emaktse\\Documents\\HITSA\\GIT Repository\\javaProject\\Images library\\yes.gif");
    ImageView imageViewYes = new ImageView(imgYes);
    Image imgNo =
        new Image(
            "file:C:\\Users\\emaktse\\Documents\\HITSA\\GIT Repository\\javaProject\\Images library\\no.gif");
    ImageView imageViewNo = new ImageView(imgNo);

    int i = 0;
    for (int j = 0; j < 7; j++) {
      for (int k = 0; k < 7; k++) {
        Image image = allImages[i];
        ImageView imageCheck = new ImageView(image);
        imageCheck.setId(i + ".gif");
        grid.add(imageCheck, k, j);
        i++;
      }
    }

    grid.setOnMouseClicked(
        e -> {
          ImageView imageViewSourceRef = (ImageView) e.getTarget();
          reactOnMouseClick(grid, listOfImageAsk, imgYes, imgNo, imageViewSourceRef);
        });

    Button tryAgain = new Button("Try again");
    grid.setAlignment(Pos.CENTER);
    vbox.getChildren().addAll(grid, tryAgain);
    vbox.setAlignment(Pos.CENTER);

    scene4 = new Scene(vbox, 1000, 800);
    window1.setScene(scene4);
  }
Beispiel #11
0
  public void gameComplete() {
    System.out.println("level UP!");
    Label label = new Label("RAPID MEMORY TEST");
    Label result =
        new Label(
            "RESULT:\n"
                + "Your memory works on "
                + levelCounter * 10
                + "%. \n"
                + "You are not recommended to engage in intellectual work.\n"
                + "Try to do physical labor. Or train your memory. There are plenty ways to do it.");
    Label amountOfRightImg =
        new Label("You have selected" + correctImageCounter + "pictures correctly!");
    Image imgSimpson =
        new Image(
            "file:C:\\Users\\emaktse\\Documents\\HITSA\\GIT Repository\\javaProject\\Images library\\mozg.jpg");
    ImageView imageViewSimpson = new ImageView(imgSimpson);

    VBox vbox = new VBox(20);
    vbox.setAlignment(Pos.CENTER);
    vbox.getChildren().addAll(label, imageViewSimpson, result, amountOfRightImg);
    scene5 = new Scene(vbox, 1000, 800);
    window1.setScene(scene5);
  }
Beispiel #12
0
  // Creates and returns the top level Widget
  private Widget create() {
    // Name of the file we are sharing
    HBox nameBox = new HBox(false, 6);
    Label name = new Label("Name:");
    name.setJustification(Justification.RIGHT);
    name.setAlignment(0d, 0.5d);
    Label file = new Label(Snark.meta.getName());
    file.setJustification(Justification.LEFT);
    file.setAlignment(0d, 0.5d);
    nameBox.packStart(name);
    nameBox.packEnd(file);

    // Torrent that we are sharing
    HBox torrentBox = new HBox(false, 6);
    Label torrent = new Label("Torrent:");
    torrent.setJustification(Justification.RIGHT);
    torrent.setAlignment(0d, 0.5d);
    Label torrentName = new Label(Snark.torrent);
    torrentName.setJustification(Justification.LEFT);
    torrentName.setAlignment(0d, 0.5d);
    torrentBox.packStart(torrent);
    torrentBox.packEnd(torrentName);

    // Tracker that we are using
    HBox trackerBox = new HBox(false, 6);
    Label tracker = new Label("Tracker:");
    tracker.setJustification(Justification.RIGHT);
    tracker.setAlignment(0d, 0.5d);
    Label trackerName = new Label(Snark.meta.getAnnounce());
    trackerName.setJustification(Justification.LEFT);
    trackerName.setAlignment(0d, 0.5d);
    trackerBox.packStart(tracker);
    trackerBox.packEnd(trackerName);

    // Pieces
    HBox piecesBox = new HBox(false, 6);
    Label pieces = new Label("Pieces:");
    pieces.setJustification(Justification.RIGHT);
    pieces.setAlignment(0d, 0.5d);
    Label piecesTotal = new Label(String.valueOf(Snark.meta.getPieces()));
    piecesTotal.setJustification(Justification.LEFT);
    piecesTotal.setAlignment(0d, 0.5d);
    piecesBox.packStart(pieces);
    piecesBox.packEnd(piecesTotal);

    // Piece size
    HBox sizeBox = new HBox(false, 6);
    Label size = new Label("Piece size:");
    size.setJustification(Justification.RIGHT);
    size.setAlignment(0d, 0.5d);
    String sizeString = Snark.meta.getPieceLength(0) / 1024 + " KB";
    Label psize = new Label(sizeString);
    psize.setJustification(Justification.LEFT);
    psize.setAlignment(0d, 0.5d);
    sizeBox.packStart(size);
    sizeBox.packEnd(psize);

    // Total length
    HBox totalBox = new HBox(false, 6);
    Label length = new Label("Total size:");
    length.setJustification(Justification.RIGHT);
    length.setAlignment(0d, 0.5d);
    String totalString = Snark.meta.getTotalLength() / (1024 * 1024) + " MB";
    Label total = new Label(totalString);
    total.setJustification(Justification.LEFT);
    total.setAlignment(0d, 0.5d);
    totalBox.packStart(length);
    totalBox.packEnd(total);

    // Peers
    HBox peersBox = new HBox(false, 6);
    Label peers = new Label("Peers:");
    peers.setJustification(Justification.RIGHT);
    peers.setAlignment(0d, 0.5d);
    peersLabel = new Label("");
    peersLabel.setJustification(Justification.LEFT);
    peersLabel.setAlignment(0d, 0.5d);
    peersBox.packStart(peers);
    peersBox.packEnd(peersLabel);

    // Buttons
    HBox buttonBox = new HBox(false, 6);
    closeButton = new Button(GtkStockItem.CLOSE);
    closeButton.addListener((ButtonListener) this);
    buttonBox.packEnd(closeButton, false, false, 0);
    peersButton = new Button("Peers...", false);
    peersButton.addListener((ButtonListener) this);
    buttonBox.packStart(peersButton, false, false, 0);

    // Group labels to get the same sizes.
    SizeGroup labelGroup = new SizeGroup(SizeGroupMode.HORIZONTAL);
    labelGroup.addWidget(name);
    labelGroup.addWidget(torrent);
    labelGroup.addWidget(tracker);
    labelGroup.addWidget(pieces);
    labelGroup.addWidget(size);
    labelGroup.addWidget(length);
    labelGroup.addWidget(peers);

    // Group values to get the same sizes.
    SizeGroup valueGroup = new SizeGroup(SizeGroupMode.HORIZONTAL);
    valueGroup.addWidget(file);
    valueGroup.addWidget(torrentName);
    valueGroup.addWidget(trackerName);
    valueGroup.addWidget(psize);
    valueGroup.addWidget(total);
    valueGroup.addWidget(piecesTotal);
    valueGroup.addWidget(peersLabel);

    // Put it all together
    VBox infoBox = new VBox(true, 6);
    infoBox.setBorderWidth(12);
    infoBox.packStart(nameBox, false, false, 0);
    infoBox.packStart(torrentBox, false, false, 0);
    infoBox.packStart(trackerBox, false, false, 0);
    infoBox.packStart(piecesBox, false, false, 0);
    infoBox.packStart(sizeBox, false, false, 0);
    infoBox.packStart(totalBox, false, false, 0);
    infoBox.packStart(peersBox, false, false, 0);
    infoBox.packStart(buttonBox, false, false, 0);

    return infoBox;
  }
  /**
   * Draws the MapMaker screen and displays it to the user
   *
   * @param primaryStage the stage to show it in
   * @throws Exception
   */
  public void drawScreen(Stage primaryStage) throws Exception {
    // Create the base BorderPane for the whole window
    BorderPane borderPane = new BorderPane();
    borderPane.setStyle("-fx-background-color: papayawhip");

    // Add some instructions to the user
    String text =
        "Instructions:\n"
            + "1. Click on the map component that you would like to place in the map\n"
            + "2. Click on the place in the map where you want to place the component\n"
            + "3. Repeat until you built the map you want!\n"
            + "4. Hit the 'Save' button when you are done";
    Label instructions = new Label(text);
    instructions.setFont(Font.font("Arial", FontWeight.BOLD, 12));
    instructions.setPadding(new Insets(5, 5, 5, 5));
    borderPane.setTop(instructions);

    // Create the blank Map
    Pane mapPane = new Pane();
    Map map = new Map(width, height);
    MapGridGUIDecorator mapGridGUIDecorator = new MapGridGUIDecorator(map.getGrid());
    ResizeFactor rf = ResizeFactor.getSuggestedResizeFactor(width, height);
    mapGridGUIDecorator.setResizeFactor(rf);
    GridPane mapGridPane = mapGridGUIDecorator.drawComponents();
    mapGridPane.setPadding(new Insets(0, 0, 5, 5));
    mapPane.getChildren().add(mapGridPane);
    borderPane.setCenter(mapPane);
    MapMakerController.setCurrentFocused(ComponentType.NOTHING);

    VBox sideComponents = new VBox();

    /* Add "Components" label */
    Label componentsLabel = new Label("Components");
    componentsLabel.setFont(Font.font("Arial", FontWeight.EXTRA_BOLD, 14));
    componentsLabel.setPadding(new Insets(15, 5, 0, 20));
    sideComponents.getChildren().add(componentsLabel);

    /* Add Intersection square image */
    VBox intersectionPane = new VBox();
    Label intersectionLabel = new Label("Intersection");
    intersectionLabel.setPadding(new Insets(5, 5, 0, 30));
    intersectionLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12));
    Image intersectionImg = new Image("IntersectionX.png", 60, 60, true, false);
    intersectionImgView = new ImageView(intersectionImg);
    StackPane intersectionStackPane = new StackPane(intersectionImgView);
    intersectionStackPane.setPadding(new Insets(0, 10, 10, 10));
    intersectionPane.getChildren().add(intersectionLabel);
    intersectionPane.getChildren().add(intersectionStackPane);
    sideComponents.getChildren().add(intersectionPane);

    /* Add RoadNS square image */
    VBox roadNSPane = new VBox();
    Label roadNSLabel = new Label("Road (North-South)");
    roadNSLabel.setPadding(new Insets(5, 5, 0, 15));
    roadNSLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12));
    Image roadNSImg = new Image("RoadBackgroundNS.png", 60, 60, true, false);
    roadNSImgView = new ImageView(roadNSImg);
    StackPane roadNSStackPane = new StackPane(roadNSImgView);
    roadNSStackPane.setPadding(new Insets(0, 10, 10, 10));
    roadNSPane.getChildren().add(roadNSLabel);
    roadNSPane.getChildren().add(roadNSStackPane);
    sideComponents.getChildren().add(roadNSPane);

    /* Add RoadEW square image */
    VBox roadEWPane = new VBox();
    Label roadEWLabel = new Label("Road (East-West)");
    roadEWLabel.setPadding(new Insets(5, 5, 0, 15));
    roadEWLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12));
    Image roadEWImg = new Image("RoadBackgroundEW.png", 60, 60, true, false);
    roadEWImgView = new ImageView(roadEWImg);
    StackPane roadEWStackPane = new StackPane(roadEWImgView);
    roadEWStackPane.setPadding(new Insets(0, 10, 10, 10));
    roadEWPane.getChildren().add(roadEWLabel);
    roadEWPane.getChildren().add(roadEWStackPane);
    sideComponents.getChildren().add(roadEWPane);

    /* Add Grass square image to empty out cells */
    VBox grassPane = new VBox();
    Label grassLabel = new Label("Grass (clear square)");
    grassLabel.setPadding(new Insets(5, 5, 0, 15));
    grassLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12));
    Image grassImg = new Image("Grass.png", 60, 60, true, false);
    grassImgView = new ImageView(grassImg);
    StackPane grassStackPane = new StackPane(grassImgView);
    grassStackPane.setPadding(new Insets(0, 10, 10, 10));
    grassPane.getChildren().add(grassLabel);
    grassPane.getChildren().add(grassStackPane);
    sideComponents.getChildren().add(grassPane);

    /* Add Save, Reset buttons */
    VBox buttonsPane = new VBox();
    buttonsPane.setPadding(new Insets(0, 0, 0, 10));
    Label toolsLabel = new Label("Tools");
    toolsLabel.setFont(Font.font("Arial", FontWeight.EXTRA_BOLD, 14));
    toolsLabel.setPadding(new Insets(15, 5, 5, 35));
    buttonsPane.getChildren().add(toolsLabel);
    Insets padding = new Insets(0, 0, 5, 0);
    Button saveButton = new Button("Save Map");
    StackPane saveButtonPane = new StackPane(saveButton);
    saveButtonPane.setPadding(padding);
    saveButton.setStyle("-fx-base:Gold");
    saveButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13));
    buttonsPane.getChildren().add(saveButtonPane);
    Button resetButton = new Button("Reset Map");
    resetButton.setStyle("-fx-base:Gold");
    resetButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13));
    StackPane resetButtonPane = new StackPane(resetButton);
    resetButtonPane.setPadding(padding);
    buttonsPane.getChildren().add(resetButtonPane);
    Button backButton = new Button("Go Back");
    backButton.setStyle("-fx-base:Gold");
    backButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13));
    StackPane backButtonPane = new StackPane(backButton);
    backButtonPane.setPadding(padding);
    buttonsPane.getChildren().add(backButtonPane);

    sideComponents.getChildren().add(buttonsPane);

    Ticker.start();

    /* Add click processing for Map grid squares */
    for (int i = 0; i < height; i++) {
      for (int j = 0; j < width; j++) {
        Node current = getNodeFromIndex(i, j, mapGridPane);
        final int x = j;
        final int y = i;
        current.setOnMouseClicked(
            (MouseEvent click) -> {
              MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
              MapMakerController.setCurrentFocused(ComponentType.MAP_SQUARE);
              current.requestFocus();
            });
        current
            .focusedProperty()
            .addListener(
                (ObservableValue<? extends Boolean> observable,
                    Boolean oldValue,
                    Boolean newValue) -> {
                  ComponentType previous = MapMakerController.getPreviousFocused();
                  if (previous == ComponentType.INTERSECTION) {
                    addIntersection(
                        x, y, map, mapGridGUIDecorator, mapGridPane, intersectionImgView);
                  } else if (previous == ComponentType.ROADNS) {
                    addRoadNS(x, y, map, mapGridGUIDecorator, mapGridPane, roadNSImgView);
                  } else if (previous == ComponentType.ROADEW) {
                    addRoadEW(x, y, map, mapGridGUIDecorator, mapGridPane, roadEWImgView);
                  } else if (previous == ComponentType.GRASS) {
                    addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView);
                  }
                });
      }
    }

    /* Add intersection icon click processing */
    DropShadow ds = new DropShadow(15, Color.BLUE);
    intersectionImgView.setOnMouseClicked(
        click -> {
          MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
          MapMakerController.setCurrentFocused(ComponentType.INTERSECTION);
          intersectionImgView.requestFocus();
        });
    intersectionImgView
        .focusedProperty()
        .addListener(
            (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
              if (newValue) intersectionImgView.setEffect(ds);
              else intersectionImgView.setEffect(null);
            });

    /* Add roadNS icon click processing */
    roadNSImgView.setOnMouseClicked(
        click -> {
          MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
          MapMakerController.setCurrentFocused(ComponentType.ROADNS);
          roadNSImgView.requestFocus();
        });
    roadNSImgView
        .focusedProperty()
        .addListener(
            (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
              if (newValue) roadNSImgView.setEffect(ds);
              else roadNSImgView.setEffect(null);
            });

    /* Add roadEW icon click processing */
    roadEWImgView.setOnMouseClicked(
        click -> {
          MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
          MapMakerController.setCurrentFocused(ComponentType.ROADEW);
          roadEWImgView.requestFocus();
        });
    roadEWImgView
        .focusedProperty()
        .addListener(
            (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
              if (newValue) roadEWImgView.setEffect(ds);
              else roadEWImgView.setEffect(null);
            });

    /* Add grass icon click processing */
    grassImgView.setOnMouseClicked(
        click -> {
          MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused());
          MapMakerController.setCurrentFocused(ComponentType.GRASS);
          grassImgView.requestFocus();
        });
    grassImgView
        .focusedProperty()
        .addListener(
            (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
              if (newValue) grassImgView.setEffect(ds);
              else grassImgView.setEffect(null);
            });

    /* Add save button functionality */
    saveButton.setOnMouseClicked(
        click -> {
          TextInputDialog nameDialog = new TextInputDialog();
          nameDialog.setTitle("Save Map");
          nameDialog.setHeaderText(
              "Please provide a name for your map (no spaces or special characters).\nSaved maps go into the /maps directory of your working directory.");
          nameDialog.setContentText("File name");
          Button btOk = (Button) nameDialog.getDialogPane().lookupButton(ButtonType.OK);
          TextField textfield = nameDialog.getEditor();
          Platform.runLater(() -> textfield.requestFocus());
          btOk.setDisable(true);
          textfield
              .textProperty()
              .addListener(
                  ((observable, oldValue, newValue) -> {
                    btOk.setDisable(newValue.trim().isEmpty());
                  }));

          Optional<String> result = nameDialog.showAndWait();
          result.ifPresent(
              name -> {
                name = name.concat(".map");
                try {
                  Map finalMap = buildAndSaveMap(map);
                  finalMap.saveMap(name);
                  goBack(primaryStage);
                } catch (Exception e) {
                  e.printStackTrace();
                }
              });
        });

    resetButton.setOnMouseClicked(
        click -> {
          for (int y = 0; y < height; y++) {
            for (int x = 0; x < width; x++) {
              Component component = map.getAtLocation(new Coordinate(x, y));
              if (component instanceof Road || component instanceof Intersection) {
                addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView);
              }
            }
          }
        });

    backButton.setOnMouseClicked(
        click -> {
          try {
            goBack(primaryStage);
          } catch (Exception e) {
            e.printStackTrace();
          }
        });

    borderPane.setRight(sideComponents);
    Scene scene = new Scene(borderPane);
    primaryStage.setScene(scene);
    primaryStage.centerOnScreen();
    primaryStage.setResizable(false);
  }
  @Override
  public void start(Stage primaryStage) {

    VBox loginPane = new VBox();
    loginPane.setAlignment(Pos.CENTER);
    primaryStage.setTitle("Amoeba");
    primaryStage.setScene(new Scene(loginPane, 800, 600));
    primaryStage.show();

    TextField username = new TextField();
    username.setPromptText("Username");
    username.setMaxSize(200, 50);

    Timeline renderTimer = new Timeline();
    Timeline inputTimer = new Timeline();

    ColorPicker colorPicker = new ColorPicker();
    colorPicker.setEditable(true);
    colorPicker.setValue(Color.BLACK);

    lagLabel.setTranslateX(25);
    lagLabel.setTranslateY(10);
    lagLabel.setTextFill(Color.RED);

    TextField address = new TextField("localhost");
    address.setPromptText("Server IP Address");
    address.setMaxSize(200, 50);

    TextField port = new TextField("8080");
    port.setPromptText("Port Number");
    port.setMaxSize(200, 50);

    Button btn = new Button("Play");
    btn.setDefaultButton(true);

    loginPane.getChildren().addAll(username, colorPicker, address, port, btn);

    primaryStage.setResizable(false);
    music.setCycleCount(MediaPlayer.INDEFINITE);
    renderPane.setBackground(new Background(backgroundImage));
    renderPane.setPrefSize(800, 600);

    chatBox.setPrefSize(400, 100);
    chatBox.setTranslateX(0);
    chatBox.setTranslateY(468);
    chatBox.setWrapText(true);
    chatBox.setEditable(false);
    chatBox.setStyle("-fx-opacity: 0.5");

    chatInput.setPrefSize(400, 10);
    chatInput.setTranslateX(0);
    chatInput.setTranslateY(570);
    chatInput.setStyle("-fx-opacity: 0.8");

    highScores.setPrefSize(400, 210);
    highScores.setEditable(false);
    currentScores.setPrefSize(400, 250);
    currentScores.setEditable(false);
    currentScores.setLayoutY(210);
    scores.setTranslateX(-390);
    scores.setTranslateY(0);
    scores.setStyle("-fx-opacity: 0.8");

    scores.setOnMouseEntered(
        (e) -> {
          scores.setTranslateX(0);
        });

    scores.setOnMouseExited(
        (e) -> {
          if (e.getX() > 350) {
            scores.setTranslateX(-390);
          }
        });

    btn.setOnAction(
        (e) -> {
          if (!networkController.isConnected()) {
            networkController.connect(address.getText(), Integer.parseInt(port.getText()));
            if (username.getText().isEmpty()) {
              username.setText("Anonymous");
            }
            networkController.sendMessage(new LoginMessage(username.getText(), ""));

            ArrayList<KeyValuePair> properties = new ArrayList<>();
            properties.add(new KeyValuePair("color", colorPicker.getValue().toString()));
            networkController.sendMessage(new SetBlobPropertiesMessage(properties));

            primaryStage.setScene(new Scene(renderPane));
            renderTimer.play();
            inputTimer.play();
            music.play();
          }
        });

    inputTimer.setCycleCount(Timeline.INDEFINITE);
    inputTimer
        .getKeyFrames()
        .add(
            new KeyFrame(
                Duration.seconds(0.05),
                (e) -> {
                  if (sendCoordinates) {
                    networkController.sendMessage(new MoveTowardCoordinatesMessage(x, y));
                  }
                }));

    renderTimer.setCycleCount(Timeline.INDEFINITE);
    renderTimer
        .getKeyFrames()
        .add(
            new KeyFrame(
                Duration.seconds(0.01),
                (e) -> {
                  render();
                }));

    renderPane.setOnMouseReleased(
        (e) -> {
          this.sendCoordinates = false;
        });

    renderPane.setOnMouseDragged(
        (e) -> {
          this.sendCoordinates = true;
          this.x = e.getX();
          this.y = e.getY();
        });

    renderPane.setOnMouseClicked(
        (e) -> {
          if (e.getButton() == MouseButton.SECONDARY) {
            networkController.sendMessage(new BoostMessage());
          } else if (e.getClickCount() > 1 || e.getButton() == MouseButton.MIDDLE) {
            networkController.sendMessage(new SplitMessage());
          }
        });

    renderPane.setOnKeyPressed(
        (e) -> {
          if (e.getCode().equals(KeyCode.ENTER) && !chatInput.getText().isEmpty()) {
            networkController.sendMessage(new ChatMessage("", chatInput.getText()));
            chatInput.clear();
          }
        });

    primaryStage.setOnCloseRequest(
        (e) -> {
          networkController.sendMessage(new LogoutMessage());
          try {
            Thread.sleep(100);
          } catch (InterruptedException ex) {
            Logger.getLogger(AmoebaClient.class.getName()).log(Level.WARNING, null, ex);
          } finally {
            System.exit(0);
          }
        });
  }
  private void updateSelectedEntry() {
    ObservableList<PolizistDaten> Nutzerauswahl = Tabelle.getSelectionModel().getSelectedItems();
    if (Nutzerauswahl.size() != 1) {
      IM.setErrorText("Es muss genau ein Element ausgewählt werden");
      return;
    }
    PolizistDaten Auswahl = Nutzerauswahl.get(0);

    // Jetzt erzeugen wir ein PopUp zum veraendern des Eintrags

    Stage PopUp = new Stage();
    PopUp.initModality(Modality.APPLICATION_MODAL);
    PopUp.setTitle("Neuer Eintrag");
    PopUp.setAlwaysOnTop(true);
    PopUp.setResizable(false);

    GridPane Gitter = new GridPane();
    Gitter.setHgap(10);
    Gitter.setVgap(10);

    Label LabelA = new Label("PersonenID");
    Label LabelAWert = new Label(Integer.toString(Auswahl.getPersonenID()));

    Label LabelB = new Label("Name");
    TextField LabelBWert = new TextField();

    Label LabelC = new Label("Geburtsdatum");
    DatePicker LabelCWert = new DatePicker();

    Label LabelD = new Label("Nationalität");
    TextField LabelDWert = new TextField();

    Label LabelE = new Label("Geschlecht");
    ComboBox LabelEWert = new ComboBox();

    Label LabelF = new Label("Todesdatum");
    DatePicker LabelFWert = new DatePicker();

    Label LabelG = new Label("Dienstgrad");
    TextField LabelGWert = new TextField();

    final Callback<DatePicker, DateCell> TagesZellenFabtrik =
        new Callback<DatePicker, DateCell>() {
          @Override
          public DateCell call(final DatePicker DP) {
            return new DateCell() {
              @Override
              public void updateItem(LocalDate item, boolean empty) {
                super.updateItem(item, empty);

                if (item.isBefore(LabelCWert.getValue().plusDays(1))) {
                  setDisable(true);
                  setStyle("-fx-background-color: #ffc0cb;");
                }
              }
            };
          }
        };
    LabelFWert.setDayCellFactory(TagesZellenFabtrik);

    LabelEWert.getItems().addAll("m", "w");
    LabelEWert.setValue(Auswahl.getGeschlecht());

    LabelBWert.setText(Auswahl.getName());
    LabelCWert.setValue(LocalDate.parse(Auswahl.getGebDatum())); // TODO exception
    LabelDWert.setText(Auswahl.getNation());
    if (!Auswahl.getTodDatum().isEmpty()) {
      LabelFWert.setValue(LocalDate.parse(Auswahl.getTodDatum())); // TODO exception
    }
    LabelGWert.setText(Auswahl.getDienstgrad());

    Button ButtonFort = new Button("Fortfahren");
    Button ButtonAbb = new Button("Abbrechen");

    ButtonFort.defaultButtonProperty();
    ButtonAbb.cancelButtonProperty();

    ButtonFort.setMaxWidth(Double.MAX_VALUE);
    ButtonAbb.setMaxWidth(Double.MAX_VALUE);

    Gitter.addColumn(0, LabelA, LabelB, LabelC, LabelD, LabelE, LabelF, LabelG);
    Gitter.addColumn(
        1, LabelAWert, LabelBWert, LabelCWert, LabelDWert, LabelEWert, LabelFWert, LabelGWert);

    VBox AussenBox = new VBox(10);
    HBox InnenBox = new HBox();

    AussenBox.setSpacing(10);
    AussenBox.setPadding(new Insets(10));
    InnenBox.setSpacing(10);

    AussenBox.setAlignment(Pos.CENTER);
    InnenBox.setAlignment(Pos.BOTTOM_CENTER);

    AussenBox.getChildren().addAll(Gitter, InnenBox);
    InnenBox.getChildren().addAll(ButtonFort, ButtonAbb);

    ButtonAbb.setOnAction(event -> PopUp.close());
    ButtonFort.setOnAction(
        event -> {
          String SQLString;
          if (LabelFWert.getEditor().getText().isEmpty()) {
            SQLString =
                "UPDATE PERSON SET Name=?, Geburtsdatum=?, Nationalität=?, Geschlecht=?, Todesdatum=NULL WHERE PersonenID = "
                    + Auswahl.getPersonenID();
          } else {
            SQLString =
                "UPDATE PERSON SET Name=?, Geburtsdatum=?, Nationalität=?, Geschlecht=?, Todesdatum=? WHERE PersonenID = "
                    + Auswahl.getPersonenID();
          }
          try {
            PreparedStatement InsertStatement = DH.prepareStatement(SQLString);
            InsertStatement.setString(1, LabelBWert.getText());
            InsertStatement.setString(2, LabelCWert.getValue().toString()); // TODO exception
            InsertStatement.setString(3, LabelDWert.getText());
            InsertStatement.setString(4, LabelEWert.getValue().toString());
            if (LabelFWert.getValue() != null && !LabelFWert.getEditor().getText().isEmpty()) {
              InsertStatement.setString(5, LabelFWert.getValue().toString());
            }
            InsertStatement.executeUpdate();
            SQLString =
                "UPDATE POLIZIST SET Dienstgrad = ? WHERE PersonenID = " + Auswahl.getPersonenID();
            InsertStatement = DH.prepareStatement(SQLString);
            InsertStatement.setString(1, LabelGWert.getText());
            InsertStatement.execute();
            IM.setInfoText("Änderung durchgeführt");
          } catch (SQLException e) {
            IM.setErrorText("Ändern Fehlgeschlagen", e);
          }
          refreshPolizistAnsicht();
          PopUp.close();
        });

    PopUp.setScene(new Scene(AussenBox));
    PopUp.showAndWait();
  }
Beispiel #16
0
  private static VBox[] medianCutApply(int[] histo, VBox vbox) {
    if (vbox.count(false) == 0) return null;
    if (vbox.count(false) == 1) {
      return new VBox[] {vbox.copy()};
    }
    int rw = vbox.r2 - vbox.r1 + 1,
        gw = vbox.g2 - vbox.g1 + 1,
        bw = vbox.b2 - vbox.b1 + 1,
        maxw = Math.max(Math.max(rw, gw), bw);

    int total = 0;
    List<Integer> partialsum = new ArrayList<>();
    List<Integer> lookaheadsum = new ArrayList<>();

    if (maxw == rw) {
      for (int i = vbox.r1; i <= vbox.r2; i++) {
        int sum = 0;
        for (int j = vbox.g1; j <= vbox.g2; j++) {
          for (int k = vbox.b1; k <= vbox.b2; k++) {
            sum += histo[getColorIndex(i, j, k)];
          }
        }
        total += sum;
        if (partialsum.size() < i) {
          int toAdd = i - partialsum.size();
          for (int l = partialsum.size(); l < toAdd; l++) {
            partialsum.add(0);
          }
        }
        partialsum.add(i, total);
      }
    } else if (maxw == gw) {
      for (int i = vbox.g1; i <= vbox.g2; i++) {
        int sum = 0;
        for (int j = vbox.r1; j <= vbox.r2; j++) {
          for (int k = vbox.b1; k <= vbox.b2; k++) {
            sum += histo[getColorIndex(j, i, k)];
          }
        }
        total += sum;
        if (partialsum.size() < i) {
          int toAdd = i - partialsum.size();
          for (int l = partialsum.size(); l < toAdd; l++) {
            partialsum.add(0);
          }
        }
        partialsum.add(i, total);
      }
    } else {
      for (int i = vbox.b1; i <= vbox.b2; i++) {
        int sum = 0;
        for (int j = vbox.r1; j <= vbox.r2; j++) {
          for (int k = vbox.g1; k <= vbox.g2; k++) {
            sum += histo[getColorIndex(j, k, i)];
          }
        }
        total += sum;
        if (partialsum.size() < i) {
          int toAdd = i - partialsum.size();
          for (int l = partialsum.size(); l < toAdd; l++) {
            partialsum.add(0);
          }
        }
        partialsum.add(i, total);
      }
    }

    for (int i = 0; i < partialsum.size(); i++) {
      lookaheadsum.add(i, total - partialsum.get(i));
    }

    return maxw == rw
        ? doCut(RED, vbox, partialsum, lookaheadsum, total)
        : maxw == gw
            ? doCut(GREEN, vbox, partialsum, lookaheadsum, total)
            : doCut(BLUE, vbox, partialsum, lookaheadsum, total);
  }
Beispiel #17
0
  @Override
  public void start(Stage primaryStage) throws Exception {

    try {
      screenSize = Screen.getPrimary().getVisualBounds();
      width = screenSize.getWidth(); // gd.getDisplayMode().getWidth();
      height = screenSize.getHeight(); // gd.getDisplayMode().getHeight();
    } catch (Exception excep) {
      System.out.println("<----- Exception in  Get Screen Size ----->");
      excep.printStackTrace();
      System.out.println("<---------->\n");
    }

    try {
      dbCon =
          DriverManager.getConnection(
              "jdbc:mysql://192.168.1.6:3306/ale", "Root", "oqu#$XQgHFzDj@1MGg1G8");
      estCon = true;
    } catch (SQLException sqlExcep) {
      System.out.println("<----- SQL Exception in Establishing Database Connection ----->");
      sqlExcep.printStackTrace();
      System.out.println("<---------->\n");
    }

    xmlParser.generateUserInfo();
    superUser = xmlParser.getSuperUser();

    // ----------------------------------------------------------------------------------------------------> Top Panel Start

    closeBtn = new Button("");
    closeBtn.getStyleClass().add("systemBtn");
    closeBtn.setOnAction(
        e -> {
          systemClose();
        });

    minimizeBtn = new Button("");
    minimizeBtn.getStyleClass().add("systemBtn");
    minimizeBtn.setOnAction(
        e -> {
          primaryStage.setIconified(true);
        });

    miscContainer = new HBox();

    calcBtn = new Button();
    calcBtn.getStyleClass().addAll("calcBtn");
    calcBtn.setOnAction(
        e -> {
          calculator calculator = new calculator();
          scientificCalculator scientificCalculator = new scientificCalculator();
          calculator.start(calculatorName);
        });

    miscContainer.getChildren().add(calcBtn);

    topPanel = new HBox(1);
    topPanel.getStyleClass().add("topPanel");
    topPanel.setPrefWidth(width);
    topPanel.setAlignment(Pos.CENTER_RIGHT);
    topPanel.setPadding(new Insets(0, 0, 0, 0));
    topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn);

    // ------------------------------------------------------------------------------------------------------> Top Panel End

    // ----------------------------------------------------------------------------------------------> Navigation Panel Start

    Line initDivider = new Line();
    initDivider.setStartX(0.0f);
    initDivider.setEndX(205.0f);
    initDivider.setStroke(Color.GRAY);

    // <----- Dashboard ----->
    dashboardToolTip = new Tooltip("Dashboard");

    dashboardBtn = new Button("");
    dashboardBtn.getStyleClass().add("dashboardBtn");
    dashboardBtn.setTooltip(dashboardToolTip);
    dashboardBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(dashBoardBase);
        });

    // <----- Profile ----->
    profileToolTip = new Tooltip("Profile");

    profileBtn = new Button();
    profileBtn.getStyleClass().add("profileBtn");
    profileBtn.setTooltip(profileToolTip);
    profileBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(profilePanel);
        });

    // <----- Courses ----->
    courseToolTip = new Tooltip("Courses");

    coursesBtn = new Button("");
    coursesBtn.getStyleClass().add("coursesBtn");
    coursesBtn.setTooltip(courseToolTip);
    coursesBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(coursesPanel);
          // miscContainer.getChildren().addAll(watchVidBtn);
          coursesPanel.setContent(coursesGridPanel);
        });

    Line mainDivider = new Line();
    mainDivider.setStartX(0.0f);
    mainDivider.setEndX(205.0f);
    mainDivider.setStroke(Color.GRAY);

    // <----- Simulations ----->
    simsToolTip = new Tooltip("Simulations");

    simsBtn = new Button();
    simsBtn.getStyleClass().add("simsBtn");
    simsBtn.setTooltip(simsToolTip);
    simsBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(simsPanel);
          simsPanel.setContent(simsGridPanel);
        });

    // <----- Text Editor ----->
    textEditorToolTip = new Tooltip("Text Editor");

    textEditorBtn = new Button();
    textEditorBtn.getStyleClass().add("textEditorBtn");
    textEditorBtn.setTooltip(textEditorToolTip);
    textEditorBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(textEditorPanel);
          miscContainer.getChildren().addAll(saveDocBtn);
        });

    Line toolsDivider = new Line();
    toolsDivider.setStartX(0.0f);
    toolsDivider.setEndX(205.0f);
    toolsDivider.setStroke(Color.GRAY);

    // <----- Wolfram Alpha ----->
    wolframToolTip = new Tooltip("Wolfram Alpha");

    wolframBtn = new Button();
    wolframBtn.getStyleClass().add("wolframBtn");
    wolframBtn.setTooltip(wolframToolTip);
    wolframBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(wolframPanel);
        });

    // <----- Wikipedia ----->
    wikipediaToolTip = new Tooltip();

    wikipediaBtn = new Button();
    wikipediaBtn.getStyleClass().add("wikipediaBtn");
    wikipediaBtn.setTooltip(wikipediaToolTip);
    wikipediaBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(wikipediaPanel);
        });

    Line sitesDivider = new Line();
    sitesDivider.setStartX(0.0f);
    sitesDivider.setEndX(205.0f);
    sitesDivider.setStroke(Color.GRAY);

    // <----- Settings ----->
    settingsToolTip = new Tooltip("Settings");

    settingsBtn = new Button();
    settingsBtn.getStyleClass().add("settingsBtn");
    settingsBtn.setTooltip(settingsToolTip);
    settingsBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(settingsPanel);
        });

    leftPanel = new VBox(0);
    // leftPanel.setPrefWidth(1);
    leftPanel.getStyleClass().add("leftPane");
    leftPanel
        .getChildren()
        .addAll(
            initDivider,
            dashboardBtn,
            profileBtn,
            coursesBtn,
            mainDivider,
            simsBtn,
            textEditorBtn,
            toolsDivider,
            wolframBtn,
            wikipediaBtn,
            sitesDivider,
            settingsBtn);

    topPanel = new HBox(1);
    topPanel.getStyleClass().add("topPanel");
    topPanel.setPrefWidth(width);
    topPanel.setAlignment(Pos.CENTER_RIGHT);
    topPanel.setPadding(new Insets(0, 0, 0, 0));
    topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn);

    // ------------------------------------------------------------------------------------------------> Navigation Panel End

    // -----------------------------------------------------------------------------------------------> Dashboard Pane Start

    final WebView webVid = new WebView();
    final WebEngine webVidEngine = webVid.getEngine();
    webVid.setPrefHeight(860);
    webVid.setPrefWidth(width - 118);
    webVidEngine.loadContent("");

    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    xAxis.setLabel("Day");
    yAxis.setLabel("Score");
    final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis);

    lineChart.setTitle("Line Chart");
    XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
    series.setName("My Data");

    // populating the series with data
    series.getData().add(new XYChart.Data<Number, Number>(0.25, 36));
    series.getData().add(new XYChart.Data<Number, Number>(1, 23));
    series.getData().add(new XYChart.Data<Number, Number>(2, 114));
    series.getData().add(new XYChart.Data<Number, Number>(3, 15));
    series.getData().add(new XYChart.Data<Number, Number>(4, 124));
    lineChart.getData().add(series);
    lineChart.setPrefWidth(400);
    lineChart.setPrefHeight(300);
    lineChart.setLegendVisible(false);

    chatRoomField = new TextField();
    chatRoomField.getStyleClass().add("textField");
    chatRoomField.setPromptText("Enter Chat Room");
    chatRoomField.setOnKeyPressed(
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.ENTER) {
              chatRoom = chatRoomField.getText();
              client.connect(messageArea, messageInputArea, superUser, chatRoom);
            }
          }
        });

    messageArea = new TextArea();
    messageArea.getStyleClass().add("textArea");
    messageArea.setWrapText(true);
    messageArea.setPrefHeight(740);
    messageArea.setEditable(false);

    messageInputArea = new TextArea();
    messageInputArea.getStyleClass().add("textArea");
    messageInputArea.setWrapText(true);
    messageInputArea.setPrefHeight(100);
    messageInputArea.setPromptText("Enter Message");
    messageInputArea.setOnKeyPressed(
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.ENTER) {
              client.send(messageArea, messageInputArea, superUser, chatRoom);
              event.consume();
            }
          }
        });

    chatBox = new VBox();
    chatBox.setPrefWidth(250);
    chatBox.setMaxWidth(250);
    chatBox.getStyleClass().add("chatBox");
    chatBox.getChildren().addAll(chatRoomField, messageArea, messageInputArea);

    // client.test(messageArea, messageInputArea);

    dashboardGridPanel = new GridPane();
    dashboardGridPanel.getStyleClass().add("gridPane");
    dashboardGridPanel.setVgap(5);
    dashboardGridPanel.setHgap(5);
    dashboardGridPanel.setGridLinesVisible(false);
    dashboardGridPanel.setPrefWidth(width - 430);
    dashboardGridPanel.setPrefHeight(860);

    dashboardGridPanel.setColumnIndex(lineChart, 0);
    dashboardGridPanel.setRowIndex(lineChart, 0);
    dashboardGridPanel.getChildren().addAll(lineChart);

    dashboardPanel = new ScrollPane();
    dashboardPanel.getStyleClass().add("scrollPane");
    dashboardPanel.setPrefWidth(width - 400);
    dashboardPanel.setPrefHeight(860);
    dashboardPanel.setContent(dashboardGridPanel);

    dashBoardBase = new HBox();
    dashBoardBase.setPrefWidth(width - (leftPanel.getWidth() + chatBox.getWidth()));
    dashBoardBase.setPrefHeight(860);
    dashBoardBase.getChildren().addAll(dashboardPanel, chatBox);

    // -------------------------------------------------------------------------------------------------> Dashboard Pane End

    // -------------------------------------------------------------------------------------------------> Profile Pane Start

    profilePictureBtn = new Button();
    profilePictureBtn.getStyleClass().addAll("profilePictureBtn");

    String profileUserName = xmlParser.getSuperUser();

    String profileEmail = xmlParser.getEmail();
    String profileAge = xmlParser.getAge();
    String profileSchool = xmlParser.getSchool();
    String profileCountry = "";
    String profileCity = "";

    userNameLbl = new Label(profileUserName);
    userNameLbl.getStyleClass().add("profileLbl");
    userNameLbl.setAlignment(Pos.CENTER);

    emailLbl = new Label(profileEmail);
    emailLbl.getStyleClass().add("profileLbl");

    ageLbl = new Label(profileAge);
    ageLbl.getStyleClass().add("profileLbl");

    schoolLbl = new Label(profileSchool);
    schoolLbl.getStyleClass().add("profileLbl");

    profileGridPanel = new GridPane();
    profileGridPanel.getStyleClass().add("gridPane");
    profileGridPanel.setVgap(5);
    profileGridPanel.setHgap(5);
    profileGridPanel.setGridLinesVisible(false);
    profileGridPanel.setPrefWidth(width - 208);
    profileGridPanel.setPrefHeight(860);
    profileGridPanel.setAlignment(Pos.TOP_CENTER);

    profileGridPanel.setRowIndex(profilePictureBtn, 0);
    profileGridPanel.setColumnIndex(profilePictureBtn, 0);
    profileGridPanel.setRowIndex(userNameLbl, 1);
    profileGridPanel.setColumnIndex(userNameLbl, 0);
    profileGridPanel.setRowIndex(emailLbl, 2);
    profileGridPanel.setColumnIndex(emailLbl, 0);
    profileGridPanel.setRowIndex(ageLbl, 3);
    profileGridPanel.setColumnIndex(ageLbl, 0);
    profileGridPanel.setRowIndex(schoolLbl, 4);
    profileGridPanel.setColumnIndex(schoolLbl, 0);
    profileGridPanel
        .getChildren()
        .addAll(profilePictureBtn, userNameLbl, emailLbl, ageLbl, schoolLbl);

    profilePanel = new ScrollPane();
    profilePanel.getStyleClass().add("scrollPane");
    profilePanel.setContent(profileGridPanel);

    // ---------------------------------------------------------------------------------------------------> Profile Pane End

    // -------------------------------------------------------------------------------------------------> Courses Pane Start

    String course = "";

    // Media media = new Media("media.mp4");

    // mediaPlayer = new MediaPlayer(media);
    // mediaPlayer.setAutoPlay(true);

    // mediaView = new MediaView(mediaPlayer);

    watchVidBtn = new Button("Watch Video");
    watchVidBtn.getStyleClass().add("btn");
    watchVidBtn.setOnAction(
        e -> {

          // coursesPanel.setContent(mediaView);
        });

    chemistryBtn = new Button();
    chemistryBtn.getStyleClass().add("chemistryBtn");
    chemistryBtn.setOnAction(
        e -> {
          displayCourse("chemistry");
        });

    physicsBtn = new Button();
    physicsBtn.getStyleClass().add("physicsBtn");
    physicsBtn.setOnAction(
        e -> {
          displayCourse("physics");
        });

    mathsBtn = new Button();
    mathsBtn.getStyleClass().add("mathsBtn");

    bioBtn = new Button();
    bioBtn.getStyleClass().add("bioBtn");
    bioBtn.setOnAction(
        e -> {
          rootPane.setCenter(biologyCourse.biologyPane());
        });

    // Course Web View
    try {
      courseView = new WebView();
      courseWebEngine = courseView.getEngine();
      courseView.setPrefHeight(860);
      courseView.setPrefWidth(width - 208);
    } catch (Exception excep) {
      System.out.println("<----- Exception in Course Web ----->");
      excep.printStackTrace();
      System.out.println("<---------->\n");
    }

    coursesGridPanel = new GridPane();
    coursesGridPanel.getStyleClass().add("gridPane");
    coursesGridPanel.setVgap(5);
    coursesGridPanel.setHgap(5);
    coursesGridPanel.setGridLinesVisible(false);
    coursesGridPanel.setPrefWidth(width - 208);
    coursesGridPanel.setPrefHeight(860);

    coursesGridPanel.setRowIndex(chemistryBtn, 1);
    coursesGridPanel.setColumnIndex(chemistryBtn, 1);
    coursesGridPanel.setRowIndex(physicsBtn, 1);
    coursesGridPanel.setColumnIndex(physicsBtn, 2);
    coursesGridPanel.setRowIndex(mathsBtn, 1);
    coursesGridPanel.setColumnIndex(mathsBtn, 3);
    coursesGridPanel.setRowIndex(bioBtn, 1);
    coursesGridPanel.setColumnIndex(bioBtn, 4);
    coursesGridPanel.getChildren().addAll(chemistryBtn, physicsBtn, mathsBtn, bioBtn);

    coursesPanel = new ScrollPane();
    coursesPanel.getStyleClass().add("scrollPane");
    coursesPanel.setPrefWidth(width - 118);
    coursesPanel.setPrefHeight(860);
    coursesPanel.setContent(coursesGridPanel);

    // ---------------------------------------------------------------------------------------------------> Courses Pane End

    // ---------------------------------------------------------------------------------------------> Simulations Pane Start
    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();
    browser.setPrefHeight(860);
    browser.setPrefWidth(width - 208);

    /*
    File phetImageFile = new File("img/styleDark/poweredByPHET.png");
    String phetImageURL = phetImageFile.toURI().toURL().toString();
    Image phetImage = new Image(phetImageURL, false);
    */

    final ImageView phetImageView = new ImageView();
    final Image phetImage =
        new Image(Main.class.getResourceAsStream("img/styleDark/poweredByPHET.png"));
    phetImageView.setImage(phetImage);

    Label motionLbl = new Label("Motion");
    motionLbl.getStyleClass().add("lbl");

    forcesAndMotionBtn = new Button();
    forcesAndMotionBtn.getStyleClass().add("forcesAndMotionBtn");
    forcesAndMotionBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html");
          simsPanel.setContent(browser);
        });

    balancingActBtn = new Button();
    balancingActBtn.getStyleClass().add("balancingActBtn");
    balancingActBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html");
          simsPanel.setContent(browser);
        });

    energySkateParkBtn = new Button();
    energySkateParkBtn.getStyleClass().add("energySkateParkBtn");
    energySkateParkBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/energy-skate-park-basics/latest/"
                  + "energy-skate-park-basics_en.html");
          simsPanel.setContent(browser);
        });

    balloonsAndStaticElectricityBtn = new Button();
    balloonsAndStaticElectricityBtn.getStyleClass().add("balloonsAndStaticElectricityBtn");
    balloonsAndStaticElectricityBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/balloons-and-static-electricity/latest/"
                  + "balloons-and-static-electricity_en.html");
          simsPanel.setContent(browser);
        });

    buildAnAtomBtn = new Button();
    buildAnAtomBtn.getStyleClass().add("buildAnAtomBtn");
    buildAnAtomBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/build-an-atom/latest/build-an-atom_en.html");
          simsPanel.setContent(browser);
        });

    colorVisionBtn = new Button();
    colorVisionBtn.getStyleClass().add("colorVisionBtn");
    colorVisionBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/color-vision/latest/color-vision_en.html");
          simsPanel.setContent(browser);
        });

    Label soundAndWavesLbl = new Label("Sound and Waves");
    soundAndWavesLbl.getStyleClass().add("lbl");

    wavesOnAStringBtn = new Button();
    wavesOnAStringBtn.getStyleClass().add("wavesOnAStringBtn");
    wavesOnAStringBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/wave-on-a-string/latest/wave-on-a-string_en.html");
          simsPanel.setContent(browser);
        });

    /*
    motionSimsFlowPane = new FlowPane();
    motionSimsFlowPane.getStyleClass().add("flowPane");
    motionSimsFlowPane.setVgap(5);
    motionSimsFlowPane.setHgap(5);
    motionSimsFlowPane.setAlignment(Pos.TOP_LEFT);
    motionSimsFlowPane.getChildren().addAll(forcesAndMotionBtn, balancingActBtn, energySkateParkBtn,
            buildAnAtomBtn, colorVisionBtn, wavesOnAStringBtn);


    soundAndWavesFlowPane = new FlowPane();
    soundAndWavesFlowPane.getStyleClass().add("flowPane");
    soundAndWavesFlowPane.setVgap(5);
    soundAndWavesFlowPane.setHgap(5);
    soundAndWavesFlowPane.setAlignment(Pos.TOP_LEFT);
    soundAndWavesFlowPane.getChildren().addAll(wavesOnAStringBtn);


    simsBox = new VBox();
    simsBox.getStyleClass().add("vbox");
    simsBox.setPrefHeight(height);
    simsBox.setPrefWidth(width);
    simsBox.getChildren().addAll(motionLbl, motionSimsFlowPane, soundAndWavesLbl, soundAndWavesFlowPane);
    */

    simsGridPanel = new GridPane();
    simsGridPanel.getStyleClass().add("gridPane");
    simsGridPanel.setVgap(5);
    simsGridPanel.setHgap(5);
    simsGridPanel.setGridLinesVisible(false);
    simsGridPanel.setPrefWidth(width - 208);
    simsGridPanel.setPrefHeight(860);

    simsGridPanel.setRowIndex(phetImageView, 0);
    simsGridPanel.setColumnIndex(phetImageView, 4);

    simsGridPanel.setRowIndex(motionLbl, 0);
    simsGridPanel.setColumnIndex(motionLbl, 0);
    simsGridPanel.setRowIndex(forcesAndMotionBtn, 1);
    simsGridPanel.setColumnIndex(forcesAndMotionBtn, 0);
    simsGridPanel.setRowIndex(balancingActBtn, 1);
    simsGridPanel.setColumnIndex(balancingActBtn, 1);
    simsGridPanel.setRowIndex(energySkateParkBtn, 1);
    simsGridPanel.setColumnIndex(energySkateParkBtn, 2);
    simsGridPanel.setRowIndex(buildAnAtomBtn, 1);
    simsGridPanel.setColumnIndex(buildAnAtomBtn, 3);
    simsGridPanel.setRowIndex(colorVisionBtn, 1);
    simsGridPanel.setColumnIndex(colorVisionBtn, 4);

    simsGridPanel.setRowIndex(soundAndWavesLbl, 2);
    simsGridPanel.setColumnIndex(soundAndWavesLbl, 0);
    simsGridPanel.setColumnSpan(soundAndWavesLbl, 4);
    simsGridPanel.setRowIndex(wavesOnAStringBtn, 3);
    simsGridPanel.setColumnIndex(wavesOnAStringBtn, 0);

    simsGridPanel
        .getChildren()
        .addAll(
            phetImageView,
            motionLbl,
            forcesAndMotionBtn,
            balancingActBtn,
            energySkateParkBtn,
            buildAnAtomBtn,
            colorVisionBtn,
            soundAndWavesLbl,
            wavesOnAStringBtn);

    simsPanel = new ScrollPane();
    simsPanel.getStyleClass().add("scrollPane");
    simsPanel.setContent(simsGridPanel);

    // -----------------------------------------------------------------------------------------------> Simulations Pane End

    // ---------------------------------------------------------------------------------------------> Text Editor Pane Start

    htmlEditor = new HTMLEditor();
    htmlEditor.setPrefHeight(860);
    htmlEditor.setPrefWidth(width - 208);

    // Prevents Scroll on Space Pressed
    htmlEditor.addEventFilter(
        KeyEvent.KEY_PRESSED,
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            if (event.getEventType() == KeyEvent.KEY_PRESSED) {
              if (event.getCode() == KeyCode.SPACE) {
                event.consume();
              }
            }
          }
        });

    XWPFDocument document = new XWPFDocument();
    XWPFParagraph tmpParagraph = document.createParagraph();
    XWPFRun tmpRun = tmpParagraph.createRun();

    saveDocBtn = new Button();
    saveDocBtn.getStyleClass().add("btn");
    saveDocBtn.setText("Save");
    saveDocBtn.setOnAction(
        e -> {
          tmpRun.setText(tools.stripHTMLTags(htmlEditor.getHtmlText()));
          tmpRun.setFontSize(12);
          saveDocument(document, primaryStage);
        });

    textEditorPanel = new ScrollPane();
    textEditorPanel.getStyleClass().add("scrollPane");
    textEditorPanel.setContent(htmlEditor);

    // -----------------------------------------------------------------------------------------------> Text Editor Pane End

    // -------------------------------------------------------------------------------------------------> Wolfram Pane Start

    Boolean wolframActive = false;
    try {
      final WebView wolframWeb = new WebView();
      wolframWeb.getStyleClass().add("webView");
      final WebEngine wolframWebEngine = wolframWeb.getEngine();
      wolframWeb.setPrefHeight(860);
      wolframWeb.setPrefWidth(width - 208);
      if (wolframActive == false) {
        wolframWebEngine.load("http://www.wolframalpha.com/");
        wolframActive = true;
      }
      wolframPanel = new ScrollPane();
      wolframPanel.setContent(wolframWeb);
    } catch (Exception excep) {
      System.out.println("<----- Exception in Wolfram Alpha Web ----->");
      excep.printStackTrace();
      System.out.println("<---------->\n");
    }

    // ---------------------------------------------------------------------------------------------------> Wolfram Pane End

    // ------------------------------------------------------------------------------------------------> Wikipedia Pane Start

    Boolean wikipediaActive = false;
    try {
      final WebView wikipediaWeb = new WebView();
      wikipediaWeb.getStyleClass().add("scrollPane");
      wikipediaWebEngine = wikipediaWeb.getEngine();
      wikipediaWeb.setPrefHeight(860);
      wikipediaWeb.setPrefWidth(width - 208);
      if (wikipediaActive == false) {
        wikipediaWebEngine.load("https://en.wikipedia.org/wiki/Main_Page");
        wikipediaActive = true;
      }
      wikipediaPanel = new ScrollPane();
      wikipediaPanel.setContent(wikipediaWeb);
    } catch (Exception e) {
      e.printStackTrace();
    }

    // --------------------------------------------------------------------------------------------------> Wikipedia Pane End

    // -------------------------------------------------------------------------------------------------> Settings Pane Start

    settingsGridPanel = new GridPane();
    settingsGridPanel.getStyleClass().add("gridPane");
    settingsGridPanel.setPrefWidth(width - 208);
    settingsGridPanel.setPrefHeight(height);
    settingsGridPanel.setVgap(5);
    settingsGridPanel.setHgap(5);

    settingsPanel = new ScrollPane();
    settingsPanel.getStyleClass().add("scrollPane");
    settingsPanel.setContent(settingsGridPanel);

    // ---------------------------------------------------------------------------------------------------> Settings Pane End
    rootPane = new BorderPane();
    rootPane.setLeft(leftPanel);
    rootPane.setTop(topPanel);
    rootPane.setCenter(dashBoardBase);
    rootPane.getStyleClass().add("rootPane");
    rootPane.getStylesheets().add(Main.class.getResource("css/styleDark.css").toExternalForm());

    programWidth = primaryStage.getWidth();
    programHeight = primaryStage.getHeight();

    primaryStage.setTitle("ALE");
    primaryStage.initStyle(StageStyle.UNDECORATED);
    primaryStage
        .getIcons()
        .add(new javafx.scene.image.Image(Main.class.getResourceAsStream("img/aleIcon.png")));
    primaryStage.setScene(new Scene(rootPane, width, height));
    primaryStage.show();
  }
  private void insertNewEntry() {
    Stage PopUp = new Stage();
    PopUp.initModality(Modality.APPLICATION_MODAL);
    PopUp.setTitle("Neuer Eintrag");
    PopUp.setAlwaysOnTop(true);
    PopUp.setResizable(false);

    GridPane Gitter = new GridPane();
    Gitter.setHgap(10);
    Gitter.setVgap(10);

    Label LabelB = new Label("Name");
    TextField LabelBWert = new TextField();

    Label LabelC = new Label("Geburtsdatum");
    DatePicker LabelCWert = new DatePicker();

    Label LabelD = new Label("Nationalität");
    TextField LabelDWert = new TextField();

    Label LabelE = new Label("Geschlecht");
    ComboBox LabelEWert = new ComboBox();

    Label LabelF = new Label("Todesdatum");
    DatePicker LabelFWert = new DatePicker();

    Label LabelG = new Label("Dienstgrad");
    TextField LabelGWert = new TextField();

    final Callback<DatePicker, DateCell> TagesZellenFabtrik =
        new Callback<DatePicker, DateCell>() {
          @Override
          public DateCell call(final DatePicker DP) {
            return new DateCell() {
              @Override
              public void updateItem(LocalDate item, boolean empty) {
                super.updateItem(item, empty);

                if (item.isBefore(LabelCWert.getValue().plusDays(1))) {
                  setDisable(true);
                  setStyle("-fx-background-color: #ffc0cb;");
                }
              }
            };
          }
        };
    LabelFWert.setDayCellFactory(TagesZellenFabtrik);

    LabelEWert.getItems().addAll("m", "w");
    LabelEWert.setValue("m");

    Button ButtonFort = new Button("Fortfahren");
    Button ButtonAbb = new Button("Abbrechen");

    ButtonFort.defaultButtonProperty();
    ButtonAbb.cancelButtonProperty();

    ButtonFort.setMaxWidth(Double.MAX_VALUE);
    ButtonAbb.setMaxWidth(Double.MAX_VALUE);

    Gitter.addColumn(0, LabelB, LabelC, LabelD, LabelE, LabelF, LabelG);
    Gitter.addColumn(1, LabelBWert, LabelCWert, LabelDWert, LabelEWert, LabelFWert, LabelGWert);

    VBox AussenBox = new VBox(10);
    HBox InnenBox = new HBox();

    AussenBox.setSpacing(10);
    AussenBox.setPadding(new Insets(10));
    InnenBox.setSpacing(10);

    AussenBox.setAlignment(Pos.CENTER);
    InnenBox.setAlignment(Pos.BOTTOM_CENTER);

    AussenBox.getChildren().addAll(Gitter, InnenBox);
    InnenBox.getChildren().addAll(ButtonFort, ButtonAbb);

    ButtonAbb.setOnAction(event -> PopUp.close());
    ButtonFort.setOnAction(
        event -> {
          String SQLString;
          if (LabelFWert.getValue() != null) {
            SQLString =
                "INSERT INTO PERSON (Name, Geburtsdatum, Nationalität, Geschlecht, Todesdatum) VALUES (?, ?, ?, ?, ?)";
          } else {
            SQLString =
                "INSERT INTO PERSON (Name, Geburtsdatum, Nationalität, Geschlecht) VALUES (?, ?, ?, ?)";
          }
          try {
            PreparedStatement InsertStatement = DH.prepareStatement(SQLString);
            InsertStatement.setString(1, LabelBWert.getText());
            InsertStatement.setString(2, LabelCWert.getValue().toString()); // TODO exception
            InsertStatement.setString(3, LabelDWert.getText());
            InsertStatement.setString(4, LabelEWert.getValue().toString());
            if (LabelFWert.getValue() != null) {
              InsertStatement.setString(5, LabelFWert.getValue().toString()); // TODO exception
            }
            InsertStatement.executeUpdate();
            ResultSet PersID = DH.getAnfrageObjekt().executeQuery("SELECT last_insert_rowid();");
            if (!PersID.next()) {
              IM.setErrorText("Konnte Primärschlüssel nicht mehr bestimmen.");
            }
            SQLString = "INSERT INTO POLIZIST (PersonenID, Dienstgrad) VALUES (?, ?)";
            InsertStatement = DH.prepareStatement(SQLString);
            InsertStatement.setInt(1, PersID.getInt(1)); // TODO das hier verifizieren
            InsertStatement.setString(2, LabelGWert.getText());
            InsertStatement.executeUpdate();
            IM.setInfoText("Einfügen durchgeführt");
          } catch (SQLException e) {
            IM.setErrorText("Einfügen Fehlgeschlagen", e);
          }
          refreshPolizistAnsicht();
          PopUp.close();
        });

    PopUp.setScene(new Scene(AussenBox));
    PopUp.showAndWait();
  }
Beispiel #19
0
  private void onSelectDispute(Dispute dispute) {
    if (dispute == null) {
      if (root.getChildren().size() > 1) root.getChildren().remove(1);

      selectedDispute = null;
    } else if (selectedDispute != dispute) {
      this.selectedDispute = dispute;

      boolean isTrader = disputeManager.isTrader(dispute);

      TableGroupHeadline tableGroupHeadline = new TableGroupHeadline();
      tableGroupHeadline.setText("Messages");
      tableGroupHeadline.prefWidthProperty().bind(root.widthProperty());
      AnchorPane.setTopAnchor(tableGroupHeadline, 10d);
      AnchorPane.setRightAnchor(tableGroupHeadline, 0d);
      AnchorPane.setBottomAnchor(tableGroupHeadline, 0d);
      AnchorPane.setLeftAnchor(tableGroupHeadline, 0d);

      ObservableList<DisputeDirectMessage> list =
          dispute.getDisputeDirectMessagesAsObservableList();
      SortedList<DisputeDirectMessage> sortedList = new SortedList<>(list);
      sortedList.setComparator((o1, o2) -> o1.getDate().compareTo(o2.getDate()));
      list.addListener((ListChangeListener<DisputeDirectMessage>) c -> scrollToBottom());
      messageListView = new ListView<>(sortedList);
      messageListView.setId("message-list-view");
      messageListView.prefWidthProperty().bind(root.widthProperty());
      messageListView.setMinHeight(150);
      AnchorPane.setTopAnchor(messageListView, 30d);
      AnchorPane.setRightAnchor(messageListView, 0d);
      AnchorPane.setLeftAnchor(messageListView, 0d);

      messagesAnchorPane = new AnchorPane();
      messagesAnchorPane.prefWidthProperty().bind(root.widthProperty());
      VBox.setVgrow(messagesAnchorPane, Priority.ALWAYS);

      inputTextArea = new TextArea();
      inputTextArea.setPrefHeight(70);
      inputTextArea.setWrapText(true);

      Button sendButton = new Button("Send");
      sendButton.setDefaultButton(true);
      sendButton.setOnAction(e -> onSendMessage(inputTextArea.getText(), dispute));
      sendButton.setDisable(true);
      inputTextArea
          .textProperty()
          .addListener(
              (observable, oldValue, newValue) -> {
                sendButton.setDisable(
                    newValue.length() == 0
                        && tempAttachments.size() == 0
                        && dispute.disputeResultProperty().get() == null);
              });

      Button uploadButton = new Button("Add attachments");
      uploadButton.setOnAction(e -> onRequestUpload());

      sendMsgInfoLabel = new Label();
      sendMsgInfoLabel.setVisible(false);
      sendMsgInfoLabel.setManaged(false);
      sendMsgInfoLabel.setPadding(new Insets(5, 0, 0, 0));

      sendMsgProgressIndicator = new ProgressIndicator(0);
      sendMsgProgressIndicator.setPrefHeight(24);
      sendMsgProgressIndicator.setPrefWidth(24);
      sendMsgProgressIndicator.setVisible(false);
      sendMsgProgressIndicator.setManaged(false);

      dispute
          .isClosedProperty()
          .addListener(
              (observable, oldValue, newValue) -> {
                messagesInputBox.setVisible(!newValue);
                messagesInputBox.setManaged(!newValue);
                AnchorPane.setBottomAnchor(messageListView, newValue ? 0d : 120d);
              });
      if (!dispute.isClosed()) {
        HBox buttonBox = new HBox();
        buttonBox.setSpacing(10);
        buttonBox
            .getChildren()
            .addAll(sendButton, uploadButton, sendMsgProgressIndicator, sendMsgInfoLabel);

        if (!isTrader) {
          Button closeDisputeButton = new Button("Close ticket");
          closeDisputeButton.setOnAction(e -> onCloseDispute(dispute));
          closeDisputeButton.setDefaultButton(true);
          Pane spacer = new Pane();
          HBox.setHgrow(spacer, Priority.ALWAYS);
          buttonBox.getChildren().addAll(spacer, closeDisputeButton);
        }

        messagesInputBox = new VBox();
        messagesInputBox.setSpacing(10);
        messagesInputBox.getChildren().addAll(inputTextArea, buttonBox);
        VBox.setVgrow(buttonBox, Priority.ALWAYS);

        AnchorPane.setRightAnchor(messagesInputBox, 0d);
        AnchorPane.setBottomAnchor(messagesInputBox, 5d);
        AnchorPane.setLeftAnchor(messagesInputBox, 0d);

        AnchorPane.setBottomAnchor(messageListView, 120d);

        messagesAnchorPane
            .getChildren()
            .addAll(tableGroupHeadline, messageListView, messagesInputBox);
      } else {
        AnchorPane.setBottomAnchor(messageListView, 0d);
        messagesAnchorPane.getChildren().addAll(tableGroupHeadline, messageListView);
      }

      messageListView.setCellFactory(
          new Callback<ListView<DisputeDirectMessage>, ListCell<DisputeDirectMessage>>() {
            @Override
            public ListCell<DisputeDirectMessage> call(ListView<DisputeDirectMessage> list) {
              return new ListCell<DisputeDirectMessage>() {
                final Pane bg = new Pane();
                final ImageView arrow = new ImageView();
                final Label headerLabel = new Label();
                final Label messageLabel = new Label();
                final HBox attachmentsBox = new HBox();
                final AnchorPane messageAnchorPane = new AnchorPane();
                final Label statusIcon = new Label();
                final double arrowWidth = 15d;
                final double attachmentsBoxHeight = 20d;
                final double border = 10d;
                final double bottomBorder = 25d;
                final double padding = border + 10d;

                {
                  bg.setMinHeight(30);
                  messageLabel.setWrapText(true);
                  headerLabel.setTextAlignment(TextAlignment.CENTER);
                  attachmentsBox.setSpacing(5);
                  statusIcon.setStyle("-fx-font-size: 10;");
                  messageAnchorPane
                      .getChildren()
                      .addAll(bg, arrow, headerLabel, messageLabel, attachmentsBox, statusIcon);
                }

                @Override
                public void updateItem(final DisputeDirectMessage item, boolean empty) {
                  super.updateItem(item, empty);

                  if (item != null && !empty) {
                    /* messageAnchorPane.prefWidthProperty().bind(EasyBind.map(messageListView.widthProperty(),
                    w -> (double) w - padding - GUIUtil.getScrollbarWidth(messageListView)));*/
                    if (!messageAnchorPane.prefWidthProperty().isBound())
                      messageAnchorPane
                          .prefWidthProperty()
                          .bind(
                              messageListView
                                  .widthProperty()
                                  .subtract(padding + GUIUtil.getScrollbarWidth(messageListView)));

                    AnchorPane.setTopAnchor(bg, 15d);
                    AnchorPane.setBottomAnchor(bg, bottomBorder);
                    AnchorPane.setTopAnchor(headerLabel, 0d);
                    AnchorPane.setBottomAnchor(arrow, bottomBorder + 5d);
                    AnchorPane.setTopAnchor(messageLabel, 25d);
                    AnchorPane.setBottomAnchor(attachmentsBox, bottomBorder + 10);

                    boolean senderIsTrader = item.isSenderIsTrader();
                    boolean isMyMsg = isTrader ? senderIsTrader : !senderIsTrader;

                    arrow.setVisible(!item.isSystemMessage());
                    arrow.setManaged(!item.isSystemMessage());
                    statusIcon.setVisible(false);
                    if (item.isSystemMessage()) {
                      headerLabel.setStyle("-fx-text-fill: -bs-green; -fx-font-size: 11;");
                      bg.setId("message-bubble-green");
                      messageLabel.setStyle("-fx-text-fill: white;");
                    } else if (isMyMsg) {
                      headerLabel.setStyle("-fx-text-fill: -fx-accent; -fx-font-size: 11;");
                      bg.setId("message-bubble-blue");
                      messageLabel.setStyle("-fx-text-fill: white;");
                      if (isTrader) arrow.setId("bubble_arrow_blue_left");
                      else arrow.setId("bubble_arrow_blue_right");

                      sendMsgProgressIndicator
                          .progressProperty()
                          .addListener(
                              (observable, oldValue, newValue) -> {
                                if ((double) oldValue == -1 && (double) newValue == 0) {
                                  if (item.arrivedProperty().get()) showArrivedIcon();
                                  else if (item.storedInMailboxProperty().get()) showMailboxIcon();
                                }
                              });

                      if (item.arrivedProperty().get()) showArrivedIcon();
                      else if (item.storedInMailboxProperty().get()) showMailboxIcon();
                      // TODO show that icon on error
                      /*else if (sendMsgProgressIndicator.getProgress() == 0)
                      showNotArrivedIcon();*/
                    } else {
                      headerLabel.setStyle("-fx-text-fill: -bs-light-grey; -fx-font-size: 11;");
                      bg.setId("message-bubble-grey");
                      messageLabel.setStyle("-fx-text-fill: black;");
                      if (isTrader) arrow.setId("bubble_arrow_grey_right");
                      else arrow.setId("bubble_arrow_grey_left");
                    }

                    if (item.isSystemMessage()) {
                      AnchorPane.setLeftAnchor(headerLabel, padding);
                      AnchorPane.setRightAnchor(headerLabel, padding);
                      AnchorPane.setLeftAnchor(bg, border);
                      AnchorPane.setRightAnchor(bg, border);
                      AnchorPane.setLeftAnchor(messageLabel, padding);
                      AnchorPane.setRightAnchor(messageLabel, padding);
                      AnchorPane.setLeftAnchor(attachmentsBox, padding);
                      AnchorPane.setRightAnchor(attachmentsBox, padding);
                    } else if (senderIsTrader) {
                      AnchorPane.setLeftAnchor(headerLabel, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(bg, border + arrowWidth);
                      AnchorPane.setRightAnchor(bg, border);
                      AnchorPane.setLeftAnchor(arrow, border);
                      AnchorPane.setLeftAnchor(messageLabel, padding + arrowWidth);
                      AnchorPane.setRightAnchor(messageLabel, padding);
                      AnchorPane.setLeftAnchor(attachmentsBox, padding + arrowWidth);
                      AnchorPane.setRightAnchor(attachmentsBox, padding);
                      AnchorPane.setRightAnchor(statusIcon, padding);
                    } else {
                      AnchorPane.setRightAnchor(headerLabel, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(bg, border);
                      AnchorPane.setRightAnchor(bg, border + arrowWidth);
                      AnchorPane.setRightAnchor(arrow, border);
                      AnchorPane.setLeftAnchor(messageLabel, padding);
                      AnchorPane.setRightAnchor(messageLabel, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(attachmentsBox, padding);
                      AnchorPane.setRightAnchor(attachmentsBox, padding + arrowWidth);
                      AnchorPane.setLeftAnchor(statusIcon, padding);
                    }

                    AnchorPane.setBottomAnchor(statusIcon, 7d);
                    headerLabel.setText(formatter.formatDateTime(item.getDate()));
                    messageLabel.setText(item.getMessage());
                    if (item.getAttachments().size() > 0) {
                      AnchorPane.setBottomAnchor(
                          messageLabel, bottomBorder + attachmentsBoxHeight + 10);
                      attachmentsBox
                          .getChildren()
                          .add(
                              new Label("Attachments: ") {
                                {
                                  setPadding(new Insets(0, 0, 3, 0));
                                  if (isMyMsg) setStyle("-fx-text-fill: white;");
                                  else setStyle("-fx-text-fill: black;");
                                }
                              });

                      item.getAttachments()
                          .stream()
                          .forEach(
                              attachment -> {
                                final Label icon = new Label();
                                setPadding(new Insets(0, 0, 3, 0));
                                if (isMyMsg) icon.getStyleClass().add("attachment-icon");
                                else icon.getStyleClass().add("attachment-icon-black");

                                AwesomeDude.setIcon(icon, AwesomeIcon.FILE_TEXT);
                                icon.setPadding(new Insets(-2, 0, 0, 0));
                                icon.setTooltip(new Tooltip(attachment.getFileName()));
                                icon.setOnMouseClicked(event -> onOpenAttachment(attachment));
                                attachmentsBox.getChildren().add(icon);
                              });
                    } else {
                      attachmentsBox.getChildren().clear();
                      AnchorPane.setBottomAnchor(messageLabel, bottomBorder + 10);
                    }

                    // TODO There are still some cell rendering issues on updates
                    setGraphic(messageAnchorPane);
                  } else {
                    messageAnchorPane.prefWidthProperty().unbind();

                    AnchorPane.clearConstraints(bg);
                    AnchorPane.clearConstraints(headerLabel);
                    AnchorPane.clearConstraints(arrow);
                    AnchorPane.clearConstraints(messageLabel);
                    AnchorPane.clearConstraints(statusIcon);
                    AnchorPane.clearConstraints(attachmentsBox);

                    setGraphic(null);
                  }
                }

                /*  private void showNotArrivedIcon() {
                    statusIcon.setVisible(true);
                    AwesomeDude.setIcon(statusIcon, AwesomeIcon.WARNING_SIGN, "14");
                    Tooltip.install(statusIcon, new Tooltip("Message did not arrive. Please try to send again."));
                    statusIcon.setTextFill(Paint.valueOf("#dd0000"));
                }*/

                private void showMailboxIcon() {
                  statusIcon.setVisible(true);
                  AwesomeDude.setIcon(statusIcon, AwesomeIcon.ENVELOPE_ALT, "14");
                  Tooltip.install(statusIcon, new Tooltip("Message saved in receivers mailbox"));
                  statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
                }

                private void showArrivedIcon() {
                  statusIcon.setVisible(true);
                  AwesomeDude.setIcon(statusIcon, AwesomeIcon.OK, "14");
                  Tooltip.install(statusIcon, new Tooltip("Message arrived at receiver"));
                  statusIcon.setTextFill(Paint.valueOf("#0f87c3"));
                }
              };
            }
          });

      if (root.getChildren().size() > 1) root.getChildren().remove(1);
      root.getChildren().add(1, messagesAnchorPane);

      scrollToBottom();
    }
  }
Beispiel #20
0
 public void push(VBox box) {
   vboxes.add(0, box.avg(false));
 }
Beispiel #21
0
 @Override
 public int compareTo(Object o) {
   VBox anotherVBox = (VBox) o;
   return count(false) * getVolume(false)
       - anotherVBox.count(false) * anotherVBox.getVolume(false);
 }
  public ConfigurationsDialogBuilder create(
      DependencyDotFileGenerator dependencyDotFileGenerator,
      GradleScriptPreferences preferences,
      Os os,
      String outputFileName) {
    this.outputFileName = outputFileName;
    this.dependencyDotFileGenerator = dependencyDotFileGenerator;
    this.preferences = preferences;
    this.os = os;
    dialog = new ConfigurationChoiceDialog(this);
    dialog.setResizable(true);
    dialog.initStyle(UTILITY);
    dialog.initModality(APPLICATION_MODAL);
    dialog.setIconified(false);
    dialog.centerOnScreen();
    dialog.borderPanel = BorderPaneBuilder.create().styleClass("dialog").build();
    dialog.stackPane = new StackPane();

    StackPane stackPane = dialog.stackPane;

    dialog.log = new TextArea();

    TextArea log = dialog.log;
    BorderPane borderPanel = dialog.borderPanel;

    // message
    dialog.configurationsBox = new VBox();

    VBox configurationsBox = dialog.configurationsBox;

    dialog.configurationsBox = configurationsBox;
    dialog.progressIndicator = new ProgressIndicator();

    ProgressIndicator progressIndicator = dialog.progressIndicator;

    stackPane.getChildren().add(log);
    stackPane.getChildren().add(progressIndicator);
    progressIndicator.setPrefSize(50, 50);
    progressIndicator.setMaxSize(50, 50);
    configurationsBox.setSpacing(15);
    configurationsBox.setAlignment(CENTER_LEFT);
    dialog.scrollPane = new ScrollPane();

    ScrollPane scrollPane = dialog.scrollPane;

    scrollPane.setContent(configurationsBox);
    dialog.borderPanel.setCenter(stackPane);
    BorderPane.setAlignment(configurationsBox, CENTER_LEFT);
    BorderPane.setMargin(configurationsBox, new Insets(MARGIN, MARGIN, MARGIN, 2 * MARGIN));

    // buttons
    dialog.buttonsPanel = new HBox();

    final HBox buttonsPanel = dialog.buttonsPanel;

    buttonsPanel.setSpacing(MARGIN);
    buttonsPanel.setAlignment(BOTTOM_CENTER);
    BorderPane.setMargin(buttonsPanel, new Insets(0, 0, 1.5 * MARGIN, 0));
    borderPanel.setBottom(buttonsPanel);
    borderPanel
        .widthProperty()
        .addListener(
            new ChangeListener<Number>() {
              public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
                buttonsPanel.layout();
              }
            });
    dialog.scene = new Scene(borderPanel);
    dialog.setScene(dialog.scene);

    URL resource =
        ConfigurationsDialogBuilder.class.getResource(
            "/com/nurflugel/gradle/ui/dialogservice/dialog.css");
    String externalForm = resource.toExternalForm();

    // dialog.borderPanel.styleClass("dialog");
    dialog.getScene().getStylesheets().add(externalForm);

    return this;
  }
Beispiel #23
0
  @Override
  public void start(Stage stage) {
    final RadialMenu radialMenu =
        RadialMenuBuilder.create()
            .options(
                OptionsBuilder.create()
                    .degrees(360)
                    .offset(-90)
                    .radius(200)
                    .buttonSize(72)
                    .buttonHideOnSelect(true)
                    .buttonHideOnClose(false)
                    .buttonAlpha(1.0)
                    .simpleMode(true)
                    .strokeVisible(false)
                    .build())
            .items(
                MenuItemBuilder.create()
                    .thumbnailImageName(getClass().getResource("star.png").toExternalForm())
                    .size(64)
                    .build(),
                MenuItemBuilder.create()
                    .symbol(SymbolType.LOCATION)
                    .tooltip("Location")
                    .size(64)
                    .build(),
                MenuItemBuilder.create()
                    .selectable(true)
                    .symbol(SymbolType.MUSIC)
                    .tooltip("Music")
                    .size(64)
                    .build(),
                MenuItemBuilder.create()
                    .symbol(SymbolType.SPEECH_BUBBLE)
                    .tooltip("Chat")
                    .size(64)
                    .build(),
                MenuItemBuilder.create()
                    .symbol(SymbolType.BLUE_TOOTH)
                    .tooltip("Bluetooth")
                    .size(64)
                    .build(),
                MenuItemBuilder.create().symbol(SymbolType.BULB).tooltip("Ideas").size(64).build(),
                MenuItemBuilder.create()
                    .symbol(SymbolType.HEAD_PHONES)
                    .tooltip("Sound")
                    .size(64)
                    .build(),
                MenuItemBuilder.create()
                    .symbol(SymbolType.TWITTER)
                    .tooltip("Twitter")
                    .size(64)
                    .build(),
                MenuItemBuilder.create().symbol(SymbolType.TAGS).tooltip("Tags").size(64).build(),
                MenuItemBuilder.create().symbol(SymbolType.CART).tooltip("Shop").size(64).build(),
                MenuItemBuilder.create().symbol(SymbolType.ALARM).tooltip("Alarm").size(64).build(),
                MenuItemBuilder.create().symbol(SymbolType.CLOCK).tooltip("Clock").size(64).build())
            .build();
    radialMenu.setPrefSize(500, 500);
    radialMenu.setOnItemSelected(
        selectionEvent ->
            System.out.println("item " + selectionEvent.item.getTooltip() + " selected"));
    radialMenu.setOnItemClicked(
        clickEvent -> System.out.println("item " + clickEvent.item.getTooltip() + " clicked"));
    radialMenu.setOnMenuOpenStarted(menuEvent -> System.out.println("Menu starts to open"));
    radialMenu.setOnMenuOpenFinished(menuEvent -> System.out.println("Menu finished to open"));
    radialMenu.setOnMenuCloseStarted(menuEvent -> System.out.println("Menu starts to close"));
    radialMenu.setOnMenuCloseFinished(menuEvent -> System.out.println("Menu finished to close"));

    HBox buttons = new HBox();
    buttons.setSpacing(10);
    buttons.setPadding(new Insets(10, 10, 10, 10));
    Button buttonShow = new Button("Show menu");
    buttonShow.setOnAction(actionEvent -> radialMenu.show());
    buttons.getChildren().add(buttonShow);

    Button buttonHide = new Button("Hide menu");
    buttonHide.setOnAction(actionEvent -> radialMenu.hide());
    buttons.getChildren().add(buttonHide);

    VBox pane = new VBox();
    pane.getChildren().add(radialMenu);
    pane.getChildren().add(buttons);
    pane.setBackground(
        new Background(
            new BackgroundFill(Color.rgb(150, 150, 150), CornerRadii.EMPTY, Insets.EMPTY)));

    Scene scene = new Scene(pane);

    stage.setScene(scene);
    stage.show();
  }
  private void erzeugeDetailAnsicht(PolizistDaten SpaltenDaten) {
    Label LabelA = new Label("PersonenID");
    Label LabelAWert = new Label(Integer.toString(SpaltenDaten.getPersonenID()));

    Label LabelB = new Label("Name");
    Label LabelBWert = new Label(SpaltenDaten.getName());

    Label LabelC = new Label("Geburtsdatum");
    Label LabelCWert = new Label(SpaltenDaten.getGebDatum());

    Label LabelD = new Label("Nationalität");
    Label LabelDWert = new Label(SpaltenDaten.getNation());

    Label LabelE = new Label("Geschlecht");
    Label LabelEWert = new Label(SpaltenDaten.getGeschlecht());

    Label LabelF = new Label("Todesdatum");
    Label LabelFWert = new Label(SpaltenDaten.getTodDatum());

    Label LabelG = new Label("Dienstgrad");
    Label LabelGWert = new Label(SpaltenDaten.getDienstgrad());

    Button ButtonBearbeiten = new Button("Bearbeiten...");
    Button ButtonLoeschen = new Button("Löschen");

    Button ButtonSuchePerson = new Button("Suche nach Person");
    Button ButtonSucheArbeit = new Button("Suche nach Arbeitsverhältnissen");
    Button ButtonSucheArbeitAn = new Button("Suche nach zugewiesenen Fällen");
    Button ButtonSucheNotizen = new Button("Suche nach erstellten Notizen");
    Button ButtonSucheIndizien = new Button("Suche nach eingestellten Indizien");

    Button ButtonClose = new Button("Detailansicht verlassen");

    ButtonBearbeiten.setOnAction(
        event -> {
          Tabelle.getSelectionModel().clearSelection();
          Tabelle.getSelectionModel().select(SpaltenDaten);
          updateSelectedEntry();
          Hauptprogramm.setRechteAnsicht(null);
        });
    ButtonLoeschen.setOnAction(
        event -> {
          Tabelle.getSelectionModel().clearSelection();
          Tabelle.getSelectionModel().select(SpaltenDaten);
          deleteSelectedEntrys();
          Hauptprogramm.setRechteAnsicht(null);
        });

    ButtonSuchePerson.setOnAction(
        event -> {
          Hauptprogramm.setRechteAnsicht(null);
          PersonenAM.PersonenSuchAnsicht(SpaltenDaten.getPersonenID());
        });
    ButtonSucheArbeit.setOnAction(
        event -> {
          Hauptprogramm.setRechteAnsicht(null);
          ArbeitenAM.SucheNachPersonenID(SpaltenDaten.getPersonenID());
        });
    ButtonSucheArbeitAn.setOnAction(
        event -> {
          Hauptprogramm.setRechteAnsicht(null);
          ArbeitenAnAM.SucheNachPersonenID(SpaltenDaten.getPersonenID());
        });
    ButtonSucheNotizen.setOnAction(
        event -> {
          Hauptprogramm.setRechteAnsicht(null);
          NotizAM.SucheNachAnlegendem(SpaltenDaten.getPersonenID());
        });
    ButtonSucheIndizien.setOnAction(
        event -> {
          Hauptprogramm.setRechteAnsicht(null);
          IndizAM.SucheNachAnlegendem(SpaltenDaten.getPersonenID());
        });

    ButtonClose.setOnAction(event -> Hauptprogramm.setRechteAnsicht(null));

    ButtonBearbeiten.setMaxWidth(Double.MAX_VALUE);
    ButtonBearbeiten.setMinWidth(150);
    ButtonLoeschen.setMaxWidth(Double.MAX_VALUE);
    ButtonLoeschen.setMinWidth(150);
    ButtonSuchePerson.setMaxWidth(Double.MAX_VALUE);
    ButtonSucheArbeit.setMaxWidth(Double.MAX_VALUE);
    ButtonSucheArbeitAn.setMaxWidth(Double.MAX_VALUE);
    ButtonSucheNotizen.setMaxWidth(Double.MAX_VALUE);
    ButtonSucheIndizien.setMaxWidth(Double.MAX_VALUE);
    ButtonClose.setMaxWidth(Double.MAX_VALUE);

    // Wir haben ein Gridpane oben, eine HBox unten in einer VBox in einem ScrollPane
    GridPane Oben = new GridPane();
    Oben.setHgap(10);
    Oben.setVgap(10);
    Oben.addColumn(0, LabelA, LabelB, LabelC, LabelD, LabelE, LabelF, LabelG);
    Oben.addColumn(
        1, LabelAWert, LabelBWert, LabelCWert, LabelDWert, LabelEWert, LabelFWert, LabelGWert);
    Oben.getColumnConstraints().add(new ColumnConstraints(100));
    Oben.getColumnConstraints().add(new ColumnConstraints(200));

    HBox Unten = new HBox(10);
    Unten.getChildren().addAll(ButtonBearbeiten, ButtonLoeschen);
    Unten.setMaxWidth(300);
    Unten.alignmentProperty().setValue(Pos.CENTER);

    VBox Mittelteil = new VBox(10);
    Mittelteil.setPadding(new Insets(10, 20, 10, 10));
    Mittelteil.getChildren()
        .addAll(
            Oben,
            Unten,
            ButtonSuchePerson,
            ButtonSucheArbeit,
            ButtonSucheArbeitAn,
            ButtonSucheNotizen,
            ButtonSucheIndizien,
            ButtonClose);

    ScrollPane Aussen = new ScrollPane();

    Aussen.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER);
    Aussen.setContent(Mittelteil);

    Hauptprogramm.setRechteAnsicht(Aussen);
  }
Beispiel #25
0
 private static VBox[] doCut(
     int color, VBox vbox, List<Integer> partialsum, List<Integer> lookaheadsum, int total) {
   int dim1 = 0, dim2 = 0;
   if (color == RED) {
     dim1 = vbox.getR1();
     dim2 = vbox.getR2();
   } else if (color == GREEN) {
     dim1 = vbox.getG1();
     dim2 = vbox.getG2();
   } else if (color == BLUE) {
     dim1 = vbox.getB1();
     dim2 = vbox.getB2();
   }
   VBox vbox1, vbox2;
   int left, right, d2;
   Integer count2;
   for (int i = dim1; i < dim2; i++) {
     if (partialsum.get(i) > total / 2) {
       vbox1 = vbox.copy();
       vbox2 = vbox.copy();
       left = i - dim1;
       right = dim2 - i;
       if (left <= right) {
         d2 = Math.min(dim2 - 1, ~~(i + right / 2));
       } else {
         d2 = Math.max(dim1, ~~(i - 1 - left / 2));
       }
       while (partialsum.get(d2) == null) d2++;
       count2 = lookaheadsum.get(d2);
       while (count2 == null && partialsum.get(d2 - 1) == null) count2 = lookaheadsum.get(--d2);
       if (color == RED) {
         vbox1.setR2(d2);
         vbox2.setR1(vbox1.getR2() + 1);
       } else if (color == GREEN) {
         vbox1.setG2(d2);
         vbox2.setG1(vbox1.getG2() + 1);
       } else if (color == BLUE) {
         vbox1.setB2(d2);
         vbox2.setB1(vbox1.getB2() + 1);
       }
       return new VBox[] {vbox1, vbox2};
     }
   }
   return null;
 }
  public GridPaneSample() {

    VBox vbox = new VBox();

    // grid1 places the child by specifying the rows and columns in
    // GridPane.setContraints()
    Label grid1Caption =
        new Label(
            "The example below shows GridPane content placement by specifying rows and columns:");
    grid1Caption.setWrapText(true);
    GridPane grid1 = new GridPane();
    grid1.setHgap(4);
    grid1.setVgap(6);
    grid1.setPadding(new Insets(18, 18, 18, 18));
    ObservableList<Node> content = grid1.getChildren();

    Label label = new Label("Name:");
    GridPane.setConstraints(label, 0, 0);
    GridPane.setHalignment(label, HPos.RIGHT);
    content.add(label);

    label = new Label("John Q. Public");
    GridPane.setConstraints(label, 1, 0, 2, 1);
    GridPane.setHalignment(label, HPos.LEFT);
    content.add(label);

    label = new Label("Address:");
    GridPane.setConstraints(label, 0, 1);
    GridPane.setHalignment(label, HPos.RIGHT);
    content.add(label);

    label = new Label("12345 Main Street, Some City, CA");
    GridPane.setConstraints(label, 1, 1, 5, 1);
    GridPane.setHalignment(label, HPos.LEFT);
    content.add(label);

    vbox.getChildren().addAll(grid1Caption, grid1, new Separator());

    // grid2 places the child by influencing the rows and columns themselves
    // via GridRowInfo and GridColumnInfo. This grid uses the preferred
    // width/height and max/min width/height.
    Label grid2Caption =
        new Label(
            "The example below shows GridPane content placement by influencing the rows and columns themselves.");
    grid2Caption.setWrapText(true);
    grid2Caption.setWrapText(true);
    GridPane grid2 = new GridPane();
    grid2.setPadding(new Insets(18, 18, 18, 18));
    RowConstraints rowinfo = new RowConstraints(40, 40, 40);
    ColumnConstraints colinfo = new ColumnConstraints(90, 90, 90);

    for (int i = 0; i <= 2; i++) {
      grid2.getRowConstraints().add(rowinfo);
    }

    for (int j = 0; j <= 2; j++) {
      grid2.getColumnConstraints().add(colinfo);
    }

    Label category = new Label("Category:");
    GridPane.setHalignment(category, HPos.RIGHT);
    Label categoryValue = new Label("Wines");
    Label company = new Label("Company:");
    GridPane.setHalignment(company, HPos.RIGHT);
    Label companyValue = new Label("Acme Winery");
    Label rating = new Label("Rating:");
    GridPane.setHalignment(rating, HPos.RIGHT);
    Label ratingValue = new Label("Excellent");

    ImageView imageView = new ImageView(ICON_48);
    GridPane.setHalignment(imageView, HPos.CENTER);

    // Place content
    GridPane.setConstraints(category, 0, 0);
    GridPane.setConstraints(categoryValue, 1, 0);
    GridPane.setConstraints(company, 0, 1);
    GridPane.setConstraints(companyValue, 1, 1);
    GridPane.setConstraints(imageView, 2, 1);
    GridPane.setConstraints(rating, 0, 2);
    GridPane.setConstraints(ratingValue, 1, 2);
    grid2
        .getChildren()
        .addAll(category, categoryValue, company, companyValue, imageView, rating, ratingValue);

    vbox.getChildren().addAll(grid2Caption, grid2, new Separator());

    // grid3 places the child by influencing the rows and columns
    // via GridRowInfo and GridColumnInfo. This grid uses the percentages
    Label grid3Caption =
        new Label(
            "The example below shows GridPane content placement by influencing row and column percentages.  Also, grid lines are made visible in this example.  The lines can be helpful in debugging.");
    grid3Caption.setWrapText(true);
    GridPane grid3 = new GridPane();
    grid3.setPadding(new Insets(18, 18, 18, 18));
    grid3.setGridLinesVisible(true);
    RowConstraints rowinfo3 = new RowConstraints();
    rowinfo3.setPercentHeight(50);

    ColumnConstraints colInfo2 = new ColumnConstraints();
    colInfo2.setPercentWidth(25);

    ColumnConstraints colInfo3 = new ColumnConstraints();
    colInfo3.setPercentWidth(50);

    grid3.getRowConstraints().add(rowinfo3); // 2*50 percent
    grid3.getRowConstraints().add(rowinfo3);

    grid3.getColumnConstraints().add(colInfo2); // 25 percent
    grid3.getColumnConstraints().add(colInfo3); // 50 percent
    grid3.getColumnConstraints().add(colInfo2); // 25 percent

    Label condLabel = new Label(" Member Name:");
    GridPane.setHalignment(condLabel, HPos.RIGHT);
    GridPane.setConstraints(condLabel, 0, 0);
    Label condValue = new Label("MyName");
    GridPane.setMargin(condValue, new Insets(0, 0, 0, 10));
    GridPane.setConstraints(condValue, 1, 0);

    Label acctLabel = new Label("Member Number:");
    GridPane.setHalignment(acctLabel, HPos.RIGHT);
    GridPane.setConstraints(acctLabel, 0, 1);
    TextField textBox = new TextField("Your number");
    GridPane.setMargin(textBox, new Insets(10, 10, 10, 10));
    GridPane.setConstraints(textBox, 1, 1);

    Button button = new Button("Help");
    GridPane.setConstraints(button, 2, 1);
    GridPane.setMargin(button, new Insets(10, 10, 10, 10));
    GridPane.setHalignment(button, HPos.CENTER);

    GridPane.setConstraints(condValue, 1, 0);
    grid3.getChildren().addAll(condLabel, condValue, button, acctLabel, textBox);

    vbox.getChildren().addAll(grid3Caption, grid3);

    getChildren().add(vbox);
  }
  public entryView(Object object) {
    getChildren().clear();
    getStylesheets().add("css/entryView.css");
    giveNode(object);

    BorderPane mainpane = new BorderPane();
    BorderPane centerpane = new BorderPane();
    BorderPane bottompane = new BorderPane();
    GridPane divgrid = new GridPane();
    GridPane maingrid = new GridPane();
    Label emptylab = new Label();
    Label divlab = new Label();
    VBox options = new VBox();
    VBox tlist = new VBox();
    Button ok = new Button("ok");
    Periods periods = new Periods();
    TList loadteacher = new TList();
    DatePicker date = new DatePicker();
    BorderPane datepane = new BorderPane();
    BorderPane nextpane = new BorderPane();
    Button next = new Button("next");

    options.setId("options");
    tlist.setId("tlist");
    divgrid.setId("divgrid");
    bottompane.setId("bottompane");
    periods.setId("period");
    divlab.setId("divlabel");
    datepane.setId("datepane");
    nextpane.setId("nextpane");

    emptylab.setPrefHeight(100);
    bottompane.setStyle("-fx-background-color:#ecf0f1;");

    StringConverter converter =
        new StringConverter<LocalDate>() {
          DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy");

          @Override
          public String toString(LocalDate date) {
            if (date != null) {
              return dateFormatter.format(date);
            } else {
              return "";
            }
          }

          @Override
          public LocalDate fromString(String string) {
            if (string != null && !string.isEmpty()) {
              return LocalDate.parse(string, dateFormatter);
            } else {
              return null;
            }
          }
        };
    date.setConverter(converter);
    date.setPromptText("dd-MM-yyyy".toLowerCase());

    date.setValue(LocalDate.now());

    maingrid = div.loadDiv();
    list = (ListView) div.takelist();
    periods.period();
    list.getSelectionModel().select(0);
    divlab.setText((String) list.getItems().get(0));
    list.setOnMouseClicked(
        e -> {
          divlab.setText((String) list.getSelectionModel().getSelectedItem());
          periods.getChildren().clear();
          periods.period();
        });
    final Node node = maingrid.getChildren().get(0);
    Platform.runLater(
        new Runnable() {
          @Override
          public void run() {
            node.requestFocus();
          }
        });
    next.setOnAction(
        e -> {
          //			list.getSelectionModel().getSelectedIndex()+1
          list.getSelectionModel().select(list.getSelectionModel().getSelectedIndex() + 1);
          divlab.setText((String) list.getSelectionModel().getSelectedItem());
        });

    nextpane.setRight(next);
    datepane.setRight(date);
    options.getChildren().clear();
    options.getChildren().add(maingrid);
    divgrid.setHgap(5);
    //		divgrid.add(emptylab, 0, 1);
    divgrid.add(datepane, 1, 0);
    divgrid.add(divlab, 0, 2);
    divgrid.add(periods, 1, 2);
    divgrid.add(nextpane, 1, 3);
    divgrid.setAlignment(Pos.TOP_CENTER);
    mainpane.setCenter(centerpane);
    mainpane.setLeft(options);
    mainpane.setRight(loadteacher);
    centerpane.setCenter(divgrid);
    centerpane.setBottom(bottompane);
    bottompane.setRight(ok);

    addCloseButton cb = new addCloseButton();
    cb.addxb(1);
    setTop(cb);
    setCenter(mainpane);
  }