private void configurePull() { if (cfg.topProperty().get()) pull.setText(resources.getString("pullTop")); else if (cfg.bottomProperty().get()) pull.setText(resources.getString("pullBottom")); else if (cfg.leftProperty().get()) { pull.setText(resources.getString("pullBottom")); pull.setAlignment(Pos.CENTER_RIGHT); } else if (cfg.rightProperty().get()) { pull.setText(resources.getString("pullTop")); pull.setAlignment(Pos.CENTER_LEFT); } }
public static Label loadIconLabel(String filename) { Image img = loadIcon(filename); Label label = new Label() { @Override public boolean equals(Object obj) { if (obj instanceof Label) { Label l2 = (Label) obj; return super.equals(l2) || l2.getText().equals(getText()); } else { return super.equals(obj); } } @Override public int hashCode() { return getText().hashCode(); } }; label.setGraphic(new ImageView(img)); label.setAlignment(Pos.CENTER); label.setContentDisplay(ContentDisplay.TOP); label.setTextFill(Color.WHITE); DropShadow shadow = new DropShadow(5.0, Color.BLACK); label.setEffect(shadow); return label; }
private Label createNoMatchingUsersLabel() { Label noMatchingUsersLabel = new Label(MESSAGE_NO_MATCHES); noMatchingUsersLabel.setPrefHeight(40); noMatchingUsersLabel.setPrefWidth(398); noMatchingUsersLabel.setAlignment(Pos.CENTER); return noMatchingUsersLabel; }
private static Label createLabel(String pText, String pColor) { Label label = new Label(pText); label.setAlignment(Pos.CENTER); label.setTextAlignment(TextAlignment.CENTER); label.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); label.setStyle("-fx-background-color: #" + pColor + ";"); return label; }
private void nextGame() { done = false; sp.setText("Start Next Level"); for (int i = 0; i < 16; i++) { gpane.getChildren().remove(iv[i]); } levelComplete0 = new Label(); levelComplete0.setId("lc0"); levelComplete0.setAlignment(Pos.CENTER); levelComplete0.setText("Level " + (level - 1) + " completed"); levelComplete0.setPrefSize(320, 80); levelComplete1 = new Label(); levelComplete1.setId("lc1"); levelComplete1.setAlignment(Pos.CENTER); levelComplete1.setText("Your score " + ((level * 10) - 10) + " Points"); levelComplete1.setPrefSize(320, 160); levelComplete2 = new Label(); levelComplete2.setId("lc2"); levelComplete2.setAlignment(Pos.CENTER); levelComplete2.setText("Next Level : " + level); levelComplete2.setPrefSize(320, 80); gpane.add(levelComplete0, 0, 0, 4, 1); gpane.add(levelComplete1, 0, 1, 4, 2); gpane.add(levelComplete2, 0, 3, 4, 1); mediaPlayer.stop(); // songName = new TextField("w.mp3"); // songPath = "C:\\Users\\Nihal\\Google Drive\\SCHOOL\\Java // 2\\Programs\\JavaFinalProject\\src\\javafinalproject\\"; // MiniMP3Player(); // mediaPlayer.play(); sp.setOnAction( e -> { iniGame(); }); }
/** Creates a new Footer object */ private Footer() { super(); getStyleClass().add("footer"); Separator separator = new Separator(); splitPane = new SplitPane(); splitPane.setId("footer-split-pane"); fileExplorerBox = new HBox(); fileExplorerStatus = new Label(); fileExplorerStatus.setPadding(new Insets(5, 5, 5, 15)); fileExplorerStatus.setAlignment(Pos.CENTER_LEFT); fileExplorerStatus.setTextAlignment(TextAlignment.CENTER); fileExplorerBox.getChildren().add(fileExplorerStatus); HBox otherBox = new HBox(); classPlanStatus = new Label(); classPlanStatus.setPadding(new Insets(5, 5, 5, 15)); classPlanStatus.setAlignment(Pos.CENTER_LEFT); classPlanStatus.setTextAlignment(TextAlignment.CENTER); HBox space = new HBox(); HBox.setHgrow(space, Priority.ALWAYS); memoryUsage = new Label(); memoryUsage.setPadding(new Insets(5, 15, 5, 5)); memoryUsage.setAlignment(Pos.CENTER_RIGHT); memoryUsage.setTextAlignment(TextAlignment.CENTER); otherBox.getChildren().addAll(classPlanStatus, space, memoryUsage); splitPane.getItems().addAll(fileExplorerBox, otherBox); this.getChildren().addAll(separator, splitPane); memoryAutoUpdater(); }
private GridPane buildRecordingGrid(Recording recording) { GridPane grid = new GridPane(); grid.setHgap(5); grid.setVgap(5); Label status = new Label(); status.setAlignment(Pos.CENTER); status.setMinWidth(STATUS_MIN_WIDTH); updateStatusIcon(recording, status); recording .fileExistsActionProperty() .addListener(observable -> updateStatusIcon(recording, status)); Label title = new Label(); title.setMinWidth(TITLE_MIN_WIDTH); title.textProperty().bind(recording.fullTitleProperty()); Label destination = new Label(); destination.getStyleClass().add("destination"); destination.textProperty().bind(recording.destinationProperty().asString()); LocalDate dateArchived = recording.getDateArchived(); if (dateArchived != null) { String dateArchivedText = String.format("Archived %s", DateUtils.formatArchivedOnDate(dateArchived)); Tooltip tooltip = new Tooltip(dateArchivedText); title.setTooltip(tooltip); destination.setTooltip(tooltip); } ReplaceOrRenameActionBar actionBar = new ReplaceOrRenameActionBar(recording, userPrefs); actionBar.setMinWidth(ACTION_BAR_MIN_WIDTH); GridPane.setHalignment(actionBar, HPos.RIGHT); GridPane.setHgrow(actionBar, Priority.ALWAYS); GridPane.setMargin(actionBar, new Insets(0, 0, 0, 10)); grid.add(status, 0, 0, 1, 2); grid.add(title, 1, 0); grid.add(destination, 1, 1); grid.add(actionBar, 2, 0, 1, 2); return grid; }
@Override public void init() { ImageView splash = new ImageView(new Image(SPLASH_IMAGE)); loadProgress = new ProgressBar(); loadProgress.setPrefWidth(SPLASH_WIDTH); progressText = new Label("Will find friends for peanuts . . ."); splashLayout = new VBox(); splashLayout.getChildren().addAll(splash, loadProgress, progressText); progressText.setAlignment(Pos.CENTER); splashLayout.setStyle( "-fx-padding: 5; " + "-fx-background-color: white; " + "-fx-border-width:5; " + "-fx-border-color: " + "linear-gradient(" + "to bottom, " + "green, " + "derive(green, 50%)" + ");"); splashLayout.setEffect(new DropShadow()); }
@SuppressWarnings("unchecked") public StackPane viewStock(String categoryId, String categoryName) { stack = new StackPane(); GridPane grid = new GridPane(); grid.setVgap(8); grid.setPadding(new Insets(30)); final ObservableList<ItemVO> dataTable; // final ObservableList<ItemVO> dataTable1; // final ObservableList<ItemVO> dataTable2; ObservableList<CategoryTypeVO> typeList; Rectangle roundRect = RectangleBuilder.create() .x(50) .y(50) .width(Screen.getPrimary().getVisualBounds().getWidth() - 428) .height(Screen.getPrimary().getVisualBounds().getHeight() - 150) .arcWidth(30) .arcHeight(30) .build(); roundRect.setFill(Color.DARKGRAY); roundRect.setOpacity(0.2); roundRect.setStroke(Color.TRANSPARENT); HBox hlabel = new HBox(); hlabel.setMaxWidth(Screen.getPrimary().getVisualBounds().getWidth() - 170); hlabel.setMaxHeight(30); hlabel.setStyle("-fx-background-color:black;"); hlabel.setOpacity(0.3); hlabel.setLayoutX(20); try { typeList = FXCollections.observableArrayList(); typeList = UtiliesDAO.getUtiliesDAO().fetchTypes(categoryId); dataTable = FXCollections.observableArrayList(); dataTable.addAll(stockDetailsService.viewStock(categoryId)); /*dataTable1 = FXCollections.observableArrayList(); dataTable2 = FXCollections.observableArrayList(); for(int i=0;i<dataTable.size();i++) { dataTable1.add(dataTable.get(i++)); if(i<=dataTable.size()-1) { dataTable2.add(dataTable.get(i)); } }*/ final Label label = new Label(categoryName + " Stock"); final Text text5 = new Text(25, 175, categoryName + " Stock"); text5.setFill(Color.DARKORANGE); // text5.setFont(Font.font ("Edwardian Script ITC", 50)); text5.setFont(Font.loadFont("file:resources/fonts/ITCEDSCR.TTF", 50)); final Light.Distant light = new Light.Distant(); light.setAzimuth(-135.0); final Lighting lighting = new Lighting(); lighting.setLight(light); lighting.setSurfaceScale(9.0); text5.setEffect(lighting); label.setAlignment(Pos.CENTER_LEFT); // grid.add(label,1,0); final TableView<ItemVO> table1 = new TableView<ItemVO>(); table1.setEditable(false); // table1.setMaxSize(roundRect.getWidth()*0.41, roundRect.getHeight()*0.519);//400,300 table1.setMinSize(roundRect.getWidth() * 0.41, roundRect.getHeight() * 0.519); // 400,300 table1.setMaxSize(roundRect.getWidth() - 50, roundRect.getHeight() - 200); table1.getSelectionModel().setCellSelectionEnabled(false); table1.setStyle("-fx-background-color: transparent;"); TableColumn<ItemVO, String> itemName = new TableColumn<ItemVO, String>("Item"); itemName.setResizable(false); itemName.setMaxWidth(roundRect.getWidth() * 0.5); itemName.setMinWidth(roundRect.getWidth() * 0.5); // 200 itemName.setCellValueFactory(new PropertyValueFactory<ItemVO, String>("itemName")); TableColumn<ItemVO, Integer> quantity = new TableColumn<ItemVO, Integer>("Quantity#"); quantity.setResizable(false); quantity.setMinWidth(roundRect.getWidth() * 0.107); // 200 /*quantity.setCellValueFactory( new PropertyValueFactory<ItemVO, Integer>("quantity"));*/ for (final CategoryTypeVO type : typeList) { TableColumn<ItemVO, Integer> col = new TableColumn<ItemVO, Integer>(type.getTypeName()); col.setMinWidth(roundRect.getWidth() * 0.107); // 100 col.setResizable(false); col.setCellValueFactory( new Callback<CellDataFeatures<ItemVO, Integer>, ObservableValue<Integer>>() { @Override public ObservableValue<Integer> call(CellDataFeatures<ItemVO, Integer> item) { ItemVO itemVO = item.getValue(); if (itemVO == null) { return null; // or perhaps // return new ReadOnlyObjectWrapper<Integer>(null); } else { ObservableMap<String, ItemTypeVO> itemTypesMap = FXCollections.observableHashMap(); itemTypesMap = item.getValue().getListType(); return new ReadOnlyObjectWrapper<Integer>( itemTypesMap.get(type.getTypeId()).getQuantity()); } } }); col.setCellFactory( new Callback<TableColumn<ItemVO, Integer>, TableCell<ItemVO, Integer>>() { @Override public TableCell<ItemVO, Integer> call(TableColumn<ItemVO, Integer> paramP) { // TODO Auto-generated method stub return new TableCell<ItemVO, Integer>() { @Override public void updateItem(Integer item, boolean empty) { super.updateItem(item, empty); if (!isEmpty()) { setText(item.toString()); if (item <= 5) { this.getStyleClass().add("celllow"); setTextFill(Color.RED); } } } }; } }); quantity.getColumns().add(col); } if (quantity.getColumns().size() >= 5 && quantity.getColumns().size() <= 7) { itemName.setMinWidth(itemName.getWidth() - (quantity.getColumns().size() - 4) * 100); } if (quantity.getColumns().size() > 7) { itemName.setMinWidth(itemName.getWidth() - ((7 - 4) * 100)); } table1.setItems(dataTable); final TableColumn[] columns1 = {itemName, quantity}; table1.getColumns().addAll(columns1); table1 .getColumns() .addListener( new ListChangeListener() { public boolean suspended; @Override public void onChanged(Change change) { change.next(); if (change.wasReplaced() && !suspended) { this.suspended = true; table1.getColumns().setAll(columns1); this.suspended = false; } } }); /*//final TableView<ItemVO> table2 = new TableView<ItemVO>(); table2.setEditable(false); table2.setMaxSize(roundRect.getWidth()*0.41, roundRect.getHeight()*0.519); table2.setMinSize(roundRect.getWidth()*0.35, roundRect.getHeight()*0.519);//400,300 table2.setStyle("-fx-background-color: transparent;"); TableColumn<ItemVO,String> itemName2 = new TableColumn<ItemVO,String> ("Item"); itemName2.setMinWidth(roundRect.getWidth()*0.3);//200 itemName2.setCellValueFactory( new PropertyValueFactory<ItemVO, String>("itemName")); TableColumn<ItemVO, Integer> quantity2 = new TableColumn<ItemVO, Integer> ("Quantity#"); quantity2.setMinWidth(roundRect.getWidth()*0.107);//200 quantity.setCellValueFactory( new PropertyValueFactory<ItemVO, Integer>("quantity")); for (final CategoryTypeVO type : typeList) { TableColumn<ItemVO, Integer> col2 = new TableColumn<ItemVO, Integer>(type.getTypeName()); col2.setMinWidth(roundRect.getWidth()*0.107);//100 col2.setResizable(false); col2.setCellValueFactory(new Callback<CellDataFeatures<ItemVO,Integer>, ObservableValue<Integer>>() { @Override public ObservableValue<Integer> call(CellDataFeatures<ItemVO,Integer> item) { ItemVO itemVO = item.getValue(); if (itemVO == null) { return null ; // or perhaps // return new ReadOnlyObjectWrapper<Integer>(null); } else { ObservableMap<String,ItemTypeVO> itemTypesMap = FXCollections.observableHashMap(); itemTypesMap = item.getValue().getListType(); return new ReadOnlyObjectWrapper<Integer>(itemTypesMap.get(type.getTypeId()).getQuantity()); } } }); col2.setCellFactory(new Callback<TableColumn<ItemVO,Integer>, TableCell<ItemVO,Integer>>() { @Override public TableCell<ItemVO, Integer> call(TableColumn<ItemVO, Integer> paramP) { // TODO Auto-generated method stub return new TableCell<ItemVO, Integer>(){ @Override public void updateItem(Integer item, boolean empty) { super.updateItem(item, empty); if(item!=null) { setText(item.toString()); if(item<=5) { this.getStyleClass().add("celllow"); setTextFill(Color.RED); } } } }; } }); quantity2.getColumns().add(col2); } table2.setItems(dataTable2); final TableColumn[] columns2 = {itemName2, quantity2}; table2.getColumns().addAll(columns2); table2.getColumns().addListener(new ListChangeListener() { public boolean suspended; @Override public void onChanged(Change change) { change.next(); if (change.wasReplaced() && !suspended) { this.suspended = true; table2.getColumns().setAll(columns2); this.suspended = false; } } });*/ Rectangle qtyRect = RectangleBuilder.create().x(50).y(50).width(10).height(10).build(); qtyRect.setFill(Color.rgb(240, 128, 128)); grid.add(table1, 0, 12); // grid.add(table2,1,12); grid.setAlignment(Pos.TOP_CENTER); Text man_text = new Text(CommonConstants.STAR_MSG); man_text.setFill(Color.DARKKHAKI); man_text.setFont(Font.font("Arial", 12)); Text msg_qty = new Text(CommonConstants.QTY_MSG1); msg_qty.setFill(Color.DARKKHAKI); msg_qty.setFont(Font.font("Arial", 12)); Text msg_qtyLow = new Text(CommonConstants.QTY_LOW); msg_qtyLow.setFill(Color.DARKKHAKI); msg_qtyLow.setFont(Font.font("Arial", 12)); StackPane.setMargin(grid, new Insets(10, 0, 0, 0)); StackPane.setMargin(qtyRect, new Insets(197, 850, 100, 0)); StackPane.setAlignment(qtyRect, Pos.BASELINE_CENTER); StackPane.setMargin(msg_qtyLow, new Insets(197, 765, 100, 0)); StackPane.setAlignment(msg_qtyLow, Pos.BASELINE_CENTER); StackPane.setAlignment(roundRect, Pos.TOP_CENTER); StackPane.setMargin(text5, new Insets(50, 8, 8, 8)); StackPane.setAlignment(text5, Pos.TOP_CENTER); StackPane.setMargin(man_text, new Insets(197, 100, 20, 0)); StackPane.setAlignment(man_text, Pos.BASELINE_RIGHT); StackPane.setMargin(msg_qty, new Insets(210, 95, 20, 0)); StackPane.setAlignment(msg_qty, Pos.BASELINE_RIGHT); stack.getChildren().addAll(text5, roundRect, grid, man_text, msg_qty, qtyRect, msg_qtyLow); } catch (Exception e) { e.printStackTrace(); } return stack; }
public void start(final Stage stage) { for (ConditionalFeature f : EnumSet.allOf(ConditionalFeature.class)) { System.err.println(f + ": " + Platform.isSupported(f)); } Rectangle2D screen = Screen.getPrimary().getVisualBounds(); final Random rand = new Random(); /* final Group starfield = new Group(); for(int i=0;i<66;i++) { int size = rand.nextInt(3)+1; if(size==3) { size = rand.nextInt(3)+1; } Circle circ = new Circle(rand.nextInt((int)screen.getWidth()), rand.nextInt(200+(int)screen.getHeight())-200, size); circ.setFill(Color.rgb(200,200,200+rand.nextInt(56))); circ.setTranslateZ(1+rand.nextInt(40)); starfield.getChildren().add(circ); } */ final List<Starfield> stars = new ArrayList<>(); for (int i = 0; i < 10; i++) { int sw = (int) screen.getWidth(), sh = (int) screen.getHeight(); Starfield sf = new Starfield(rand, -sw, -sh, 2 * sw, 2 * sh, rand.nextInt(30) + 10); sf.setTranslateZ(rand.nextInt(2000) + 50); stars.add(sf); } // final Starfield starfield2 = new Starfield(rand, -200, -200, (int)screen.getWidth(), // (int)screen.getHeight()+200, 40); final Ruleset1D rules = new Ruleset1D(new int[] {Colors.randomColor(rand), Colors.randomColor(rand)}); final Ruleset rules2 = new Rulespace1D(rules); // Rule rule = rules.random(rand).next(); Iterator<Rule> it = rules.iterator(); GridPane gridp = new GridPane(); int i = 0, j = 0; while (it.hasNext()) { Rule rule = it.next(); CA ca = new CA(rule, new RandomInitializer(), rand, 42, 100, 100); Plane plane = ca.createPlane(); ImageView imview = new ImageView(plane.toImage()); imview.setSmooth(true); imview.setFitWidth(30); imview.setPreserveRatio(true); gridp.add(imview, i, j); if (++i == 16) { i = 0; j++; } } // gridp.setScaleX(0.3); // gridp.setScaleY(0.3); // gridp.setPrefSize(100*3/3, 100*3/3); // gridp.setMaxSize(100*3/3, 100*3/3); final double XTRANS = screen.getWidth() / 2 - 30 * 16 / 2; final double YTRANS = screen.getHeight() / 2 - 30 * 16 / 2; // gridp.setTranslateX((screen.getWidth()/2+100*16/2)*0.3); // gridp.setTranslateX(0); gridp.setTranslateX(XTRANS); gridp.setTranslateY(YTRANS); // gridp.setAlignment(Pos.CENTER); Group grid = new Group(gridp); // grid.setTranslateX(0); // grid.setTranslateY(0); // gridp.relocate(-400, -400); // gridp.setTranslateX(-300); // gridp.setTranslateY(-150); /* final RotateTransition rt = new RotateTransition(Duration.millis(3000), gridp); rt.setByAngle(180); rt.setCycleCount(4); rt.setAutoReverse(true); */ // rt.setAutoReverse(false); /*` final BorderPane border = new BorderPane(); */ // Label title = new Label("EXPLORATIONS IN CELLULAR SPACES"); Label title = new Label("E X P L O R A T I O N S"); title.setFont(new Font("Helvetica Neue Condensed Bold", 36)); title.setTextFill(Color.WHITE); // Label title2 = new Label("IN CELLULAR SPACES"); Label title2 = new Label("EXPLORATIONS IN CELLULAR SPACES"); title2.setFont(new Font("Helvetica Neue Condensed Bold", 28)); title2.setTextFill(Color.WHITE); /*` title.setAlignment(Pos.CENTER); title.setContentDisplay(ContentDisplay.CENTER); title.setTextAlignment(TextAlignment.CENTER); */ final HBox toptitle = new HBox(); toptitle.setAlignment(Pos.CENTER); toptitle.getChildren().add(title); toptitle.setTranslateX(XTRANS); toptitle.setTranslateY(YTRANS - 36); final HBox btitle = new HBox(); btitle.setAlignment(Pos.CENTER); title2.setAlignment(Pos.CENTER); btitle.getChildren().add(title2); btitle.setTranslateX(XTRANS); // btitle.setTranslateX(screen.getWidth()/2-title2.getPrefWidth()/2); btitle.setTranslateY(YTRANS + 30 * 16); Group border = new Group(); // border.getChildren().add(toptitle); for (Starfield st : stars) { border.getChildren().add(st); } // border.getChildren().add(starfield2); border.getChildren().add(btitle); border.getChildren().add(grid); final List<TranslateTransition> tts = new ArrayList<>(); final TranslateTransition tt = new TranslateTransition(Duration.millis(6000), grid); tt.setByY(2000); tts.add(tt); for (Starfield sf : stars) { TranslateTransition st = new TranslateTransition(Duration.millis(6000), sf); st.setByY(200); st.setByZ(100 + rand.nextInt(100)); tts.add(st); } /* final TranslateTransition tt2 = new TranslateTransition(Duration.millis(6000), starfield1); tt2.setByY(200); tt2.setByZ(200); final TranslateTransition tt3 = new TranslateTransition(Duration.millis(6000), starfield2); tt3.setByY(300); tt3.setByZ(200); */ // final ParallelTransition infinite = new ParallelTransition(tt, tt2, tt3); final ParallelTransition infinite = new ParallelTransition(tts.toArray(new TranslateTransition[0])); final BorderPane ctrl = new BorderPane(); // ctrl.setPrefSize(200, 100); // ctrl.setMaxSize(200, 100); Label start = new Label("Start"); start.setTextFill(Color.WHITE); start.setFont(new Font("Helvetica", 28)); start.setAlignment(Pos.CENTER_LEFT); start.setContentDisplay(ContentDisplay.CENTER); start.setTranslateX(XTRANS + 30 * 16 + 100); start.setTranslateY(screen.getHeight() / 2); // start.setTranslateX(-400); Circle ico = new Circle(15); ico.setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { FadeTransition ft = new FadeTransition(Duration.millis(500), ctrl); ft.setFromValue(1.0); ft.setToValue(0.0); FadeTransition tft = new FadeTransition(Duration.millis(500), btitle); tft.setFromValue(1.0); tft.setToValue(0.0); ParallelTransition pt = new ParallelTransition(ft, tft); // TranslateTransition fft = new TranslateTransition(Duration.millis(3000), border); // tt.setByY(2000); SequentialTransition st = new SequentialTransition(pt, infinite); st.setOnFinished( new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { State state = State.state().rules(rules2).random(new Rand()).size(400); Iterator<Rule> it = state.rules().random(state.random().create()); CA ca = new CA( it.next(), new RandomInitializer(), state.random().create(), 0, state.size(), state.size()); state.ca(ca); // final Futures futures = new Futures(rules2, new Rand()); final Controls controls = new Controls(state); // controls.setTranslateX(screen.getWidth()/2 - // futures.getPossibilityWidth()/2); // controls.setTranslateY(screen.getHeight()/2 - // futures.getPossiblityHeight()/2-20); // controls.setTranslateX(screen.getWidth()/2 - (3*200+2*10)/2); // controls.setTranslateY(screen.getHeight()/2 - (3*200+2*10)/2-20); for (Starfield sf : stars) { state.addListener(sf); // futures.addFutureListener(sf); } // futures.addFutureListener(starfield1); // futures.addFutureListener(starfield2); border.getChildren().remove(grid); border.getChildren().remove(btitle); // border.getChildren().add(futures); border.getChildren().add(controls); // futures.setTranslateX(screen.getWidth()/2 - futures.getPossibilityWidth()/2); // futures.setTranslateY(screen.getHeight()/2 - // futures.getPossiblityHeight()/2); // border.setCenter(futures); // border.setAlignment(futures, Pos.CENTER); } }); st.play(); } }); // Sphere ico = new Sphere(15); // ico.setDrawMode(DrawMode.LINE); ico.setFill(Color.rgb(10, 10, 10)); ico.setStroke(Color.WHITE); ico.setStrokeWidth(3); ico.setTranslateX(XTRANS + 30 * 16 + 100); ico.setTranslateY(screen.getHeight() / 2); // ctrl.setTop(ico); ctrl.setCenter(ico); /* border.setRight(ctrl); border.setMaxSize(800,600); border.setPrefSize(800,600); */ border.getChildren().add(ctrl); Group root = new Group(); root.getChildren().add(border); // root.setAutoSizeChildren(false); // root.setLayoutX(-400); // root.setLayoutY(-400); // Scene scene = new Scene(root, 1200, 1000); Scene scene = new Scene(root, 1280, 1024, true, SceneAntialiasing.DISABLED); scene.setFill(Color.BLACK); scene.setCamera(new PerspectiveCamera()); // set Stage boundaries to visible bounds of the main screen stage.setX(screen.getMinX()); stage.setY(screen.getMinY()); stage.setWidth(screen.getWidth()); stage.setHeight(screen.getHeight()); stage.setTitle("Explorations in Cellular Spaces"); stage.setScene(scene); stage.setResizable(false); // root.autosize(); // stage.sizeToScene(); stage.show(); }
private void updateStatisticsData(List<TaskWithWorklogs> displayResult) { if (!SettingsUtil.loadSettings().isShowStatistics()) { return; } statisticsView.getChildren().clear(); WorklogStatistics statistics = new WorklogStatistics(); // generic statistics displayResult.forEach( taskWithWorklogs -> { statistics.getTotalTimeSpent().addAndGet(taskWithWorklogs.getTotalInMinutes()); for (WorklogItem worklogItem : taskWithWorklogs.getWorklogItemList()) { String employee = worklogItem.getUserDisplayname(); // employee total time spent AtomicLong totalTimeSpent = statistics.getEmployeeToTotaltimeSpent().get(employee); if (totalTimeSpent == null) { totalTimeSpent = new AtomicLong(0); statistics.getEmployeeToTotaltimeSpent().put(employee, totalTimeSpent); } totalTimeSpent.addAndGet(worklogItem.getDurationInMinutes()); // distinct tasks per employee Set<String> totalDistinctTasks = statistics.getEmployeeToTotalDistinctTasks().get(employee); if (totalDistinctTasks == null) { totalDistinctTasks = new HashSet<>(); statistics.getEmployeeToTotalDistinctTasks().put(employee, totalDistinctTasks); } totalDistinctTasks.add(taskWithWorklogs.getIssue()); // distinct tasks per employee per project Map<String, Set<String>> projectToDistinctTasks = statistics.getEmployeeToProjectToDistinctTasks().get(employee); if (projectToDistinctTasks == null) { projectToDistinctTasks = new HashMap<>(); statistics .getEmployeeToProjectToDistinctTasks() .put(employee, projectToDistinctTasks); } Set<String> distinctTasks = projectToDistinctTasks.get(taskWithWorklogs.getProject()); if (distinctTasks == null) { distinctTasks = new HashSet<>(); projectToDistinctTasks.put(taskWithWorklogs.getProject(), distinctTasks); } distinctTasks.add(taskWithWorklogs.getIssue()); // time spent per project Map<String, AtomicLong> projectToTimespent = statistics.getEmployeeToProjectToWorktime().get(employee); if (projectToTimespent == null) { projectToTimespent = new HashMap<>(); statistics.getEmployeeToProjectToWorktime().put(employee, projectToTimespent); } AtomicLong timespentOnProject = projectToTimespent.get(taskWithWorklogs.getProject()); if (timespentOnProject == null) { timespentOnProject = new AtomicLong(0); projectToTimespent.put(taskWithWorklogs.getProject(), timespentOnProject); } timespentOnProject.addAndGet(worklogItem.getDurationInMinutes()); } }); // render grid and bar graph final AtomicInteger currentGridRow = new AtomicInteger(0); GridPane employeeProjectSummaryGrid = new GridPane(); employeeProjectSummaryGrid.setHgap(5); employeeProjectSummaryGrid.setVgap(5); NumberAxis projectEmployeeXAxis = new NumberAxis(); projectEmployeeXAxis.setLabel(FormattingUtil.getFormatted("view.statistics.timespentinhours")); projectEmployeeXAxis.setTickLabelRotation(90); NumberAxis employeeProjectXAxis = new NumberAxis(); employeeProjectXAxis.setLabel(FormattingUtil.getFormatted("view.statistics.timespentinhours")); employeeProjectXAxis.setTickLabelRotation(90); CategoryAxis projectEmployeeYAxis = new CategoryAxis(); CategoryAxis employeeProjectYAxis = new CategoryAxis(); StackedBarChart<Number, String> projectEmployeeBargraph = new StackedBarChart<>(projectEmployeeXAxis, projectEmployeeYAxis); StackedBarChart<Number, String> employeeProjectBargraph = new StackedBarChart<>(employeeProjectXAxis, employeeProjectYAxis); projectEmployeeBargraph.setTitle( FormattingUtil.getFormatted("view.statistics.byprojectandemployee")); employeeProjectBargraph.setTitle( FormattingUtil.getFormatted("view.statistics.byemployeeandproject")); Set<String> projectsToDisplay = new HashSet<>(); displayResult.forEach( taskWithWorklogs -> { projectsToDisplay.add(taskWithWorklogs.getProject()); }); int projectEmployeeBargraphPreferedHeight = HEIGHT_PER_Y_AXIS_ELEMENT * projectsToDisplay.size() + HEIGHT_PER_X_AXIS_ELEMENT * statistics.getEmployeeToTotaltimeSpent().keySet().size() + ADDITIONAL_HEIGHT; projectEmployeeBargraph.setPrefHeight(projectEmployeeBargraphPreferedHeight); VBox.setVgrow(projectEmployeeBargraph, Priority.ALWAYS); int employeeProjectBargraphPreferedHeight = HEIGHT_PER_Y_AXIS_ELEMENT * statistics.getEmployeeToProjectToWorktime().keySet().size() + HEIGHT_PER_X_AXIS_ELEMENT * projectsToDisplay.size() + ADDITIONAL_HEIGHT; employeeProjectBargraph.setPrefHeight(employeeProjectBargraphPreferedHeight); VBox.setVgrow(employeeProjectBargraph, Priority.ALWAYS); Map<String, XYChart.Series<Number, String>> projectNameToSeries = Maps.newHashMap(); statistics .getEmployeeToProjectToWorktime() .keySet() .stream() .sorted(COLLATOR::compare) .forEach( employee -> { // employee headline label Set<String> totalDistinctTasksOfEmployee = statistics.getEmployeeToTotalDistinctTasks().get(employee); Label employeeLabel = getBoldLabel( FormattingUtil.getFormatted( "view.statistics.somethingtoamountoftickets", employee, totalDistinctTasksOfEmployee.size())); employeeLabel.setPadding(new Insets(20, 0, 0, 0)); GridPane.setConstraints(employeeLabel, 0, currentGridRow.getAndIncrement()); GridPane.setColumnSpan(employeeLabel, 4); employeeProjectSummaryGrid.getChildren().addAll(employeeLabel); // bar graph data container XYChart.Series<Number, String> projectEmployeeSeries = new XYChart.Series<>(); projectEmployeeSeries.setName(employee); projectEmployeeBargraph.getData().add(projectEmployeeSeries); // time spent per project Map<String, AtomicLong> projectToWorktime = statistics.getEmployeeToProjectToWorktime().get(employee); Map<String, Label> projectToPercentageLabel = Maps.newHashMap(); projectToWorktime .keySet() .stream() .sorted(COLLATOR::compare) .forEach( projectName -> { XYChart.Series<Number, String> employeeProjectSeries = projectNameToSeries.get(projectName); if (employeeProjectSeries == null) { employeeProjectSeries = new XYChart.Series<>(); employeeProjectSeries.setName(projectName); employeeProjectBargraph.getData().add(employeeProjectSeries); projectNameToSeries.put(projectName, employeeProjectSeries); } // percentage label Label percentageLabel = getBoldLabel("PLACEHOLDER"); percentageLabel.setAlignment(Pos.CENTER_RIGHT); percentageLabel.setPadding(new Insets(0, 0, 0, 20)); GridPane.setConstraints(percentageLabel, 1, currentGridRow.get()); GridPane.setHalignment(percentageLabel, HPos.RIGHT); projectToPercentageLabel.put(projectName, percentageLabel); // project label Set<String> distinctTasksPerProject = statistics .getEmployeeToProjectToDistinctTasks() .get(employee) .get(projectName); Label projectLabel = getBoldLabel( FormattingUtil.getFormatted( "view.statistics.somethingtoamountoftickets", projectName, distinctTasksPerProject.size())); GridPane.setConstraints(projectLabel, 2, currentGridRow.get()); // time spent for project label long timespentInMinutes = projectToWorktime.get(projectName).longValue(); Label timespentLabel = new Label(FormattingUtil.formatMinutes(timespentInMinutes, true)); GridPane.setConstraints(timespentLabel, 3, currentGridRow.get()); GridPane.setHgrow(timespentLabel, Priority.ALWAYS); GridPane.setHalignment(timespentLabel, HPos.RIGHT); employeeProjectSummaryGrid .getChildren() .addAll(percentageLabel, projectLabel, timespentLabel); currentGridRow.incrementAndGet(); // bargraph data projectEmployeeSeries .getData() .add(new XYChart.Data<>(timespentInMinutes / 60d, projectName)); employeeProjectSeries .getData() .addAll(new XYChart.Data<>(timespentInMinutes / 60d, employee)); }); // total time spent Label totalLabel = getBoldLabel(FormattingUtil.getFormatted("view.statistics.totaltimespent")); GridPane.setConstraints(totalLabel, 0, currentGridRow.get()); GridPane.setColumnSpan(totalLabel, 4); Label timespentLabel = new Label( FormattingUtil.formatMinutes( statistics.getEmployeeToTotaltimeSpent().get(employee).get(), true)); GridPane.setConstraints(timespentLabel, 3, currentGridRow.get()); GridPane.setHgrow(timespentLabel, Priority.ALWAYS); GridPane.setHalignment(timespentLabel, HPos.RIGHT); employeeProjectSummaryGrid.getChildren().addAll(totalLabel, timespentLabel); // set label now that we can calculate the percentage projectToWorktime .keySet() .forEach( projectName -> { Label percentageLabel = projectToPercentageLabel.get(projectName); double totalSpentTime = statistics.getEmployeeToTotaltimeSpent().get(employee).doubleValue(); double spentTimeOnProject = projectToWorktime.get(projectName).doubleValue(); double percentage = spentTimeOnProject / totalSpentTime; String percentageFormatted = FormattingUtil.formatPercentage(percentage); percentageLabel.setText(percentageFormatted); }); currentGridRow.incrementAndGet(); }); // employeeProjectBargraph statisticsView .getChildren() .addAll(employeeProjectSummaryGrid, projectEmployeeBargraph, employeeProjectBargraph); // custom view statistics addAdditionalStatistics(statisticsView, statistics, displayResult); }
public FinalGame() { sp = new Button(); sp.setAlignment(Pos.CENTER); sp.setText("Start"); sp.setPrefSize(160, 80); stop = new Button(); stop.setAlignment(Pos.CENTER); stop.setText("Stop"); stop.setPrefSize(160, 80); exit = new Button(); exit.setAlignment(Pos.CENTER); exit.setText("Exit"); exit.setPrefSize(200, 80); mv = new Label(); mv.setId("mv"); mv.setAlignment(Pos.CENTER); mv.setText("MOVES"); mv.setPrefSize(200, 80); lvl = new Label(); lvl.setId("lvl"); lvl.setAlignment(Pos.CENTER); lvl.setText("LEVEL"); lvl.setPrefSize(200, 80); clock = new Label(); clock.setId("clock"); clock.setAlignment(Pos.CENTER); clock.setText("TIMER"); clock.setPrefSize(200, 80); hc = new Label(); hc.setId("hc"); hc.setAlignment(Pos.CENTER); hc.setText("HIGH SCORE"); hc.setPrefSize(200, 80); gpane = new GridPane(); gpane.setId("pane"); iv = new ImageView[16]; rct = new Rectangle2D[17]; rct[0] = new Rectangle2D(0, 0, 80, 80); rct[1] = new Rectangle2D(80, 0, 80, 80); rct[2] = new Rectangle2D(160, 0, 80, 80); rct[3] = new Rectangle2D(240, 0, 80, 80); rct[4] = new Rectangle2D(0, 80, 80, 80); rct[5] = new Rectangle2D(80, 80, 80, 80); rct[6] = new Rectangle2D(160, 80, 80, 80); rct[7] = new Rectangle2D(240, 80, 80, 80); rct[8] = new Rectangle2D(0, 160, 80, 80); rct[9] = new Rectangle2D(80, 160, 80, 80); rct[10] = new Rectangle2D(160, 160, 80, 80); rct[11] = new Rectangle2D(240, 160, 80, 80); rct[12] = new Rectangle2D(0, 240, 80, 80); rct[13] = new Rectangle2D(80, 240, 80, 80); rct[14] = new Rectangle2D(160, 240, 80, 80); rct[16] = new Rectangle2D(240, 240, 80, 80); rct[15] = new Rectangle2D(320, 0, 80, 80); iniGame(); addObjects(); }
/** * @param owner * @param title * @param titleLong * @param message * @return */ public Response show(Stage owner, String title, String titleLong, String message) { final Stage stage = new Stage(); final BooleanProperty isOK = new SimpleBooleanProperty(false); stage.setTitle(title); stage.initModality(Modality.APPLICATION_MODAL); stage.initOwner(owner); // BorderPane root = new BorderPane(); VBox root = new VBox(); Scene scene = new Scene(root); stage.setScene(scene); stage.setWidth(500); stage.setHeight(250); stage.initStyle(StageStyle.UTILITY); stage.setResizable(false); Node header = DialogHeader.getDialogHeader(ICON, titleLong); ImageView imageView = ResourceLoader.getImage(ICON, 65, 65); stage.getIcons().add(imageView.getImage()); HBox buttonPanel = new HBox(); Button ok = new Button("OK"); ok.setDefaultButton(true); buttonPanel.getChildren().addAll(ok); buttonPanel.setAlignment(Pos.CENTER_RIGHT); buttonPanel.setPadding(new Insets(10, 10, 10, 10)); buttonPanel.setSpacing(10); buttonPanel.setMaxHeight(25); HBox messagePanel = new HBox(); messagePanel.setPadding(new Insets(30, 30, 30, 30)); Label mewssage = new Label(message); messagePanel.getChildren().add(mewssage); mewssage.setWrapText(true); mewssage.setAlignment(Pos.CENTER_LEFT); Separator sep = new Separator(Orientation.HORIZONTAL); sep.setMinHeight(10); root.getChildren() .addAll(header, new Separator(Orientation.HORIZONTAL), messagePanel, buttonPanel); VBox.setVgrow(messagePanel, Priority.ALWAYS); VBox.setVgrow(buttonPanel, Priority.NEVER); VBox.setVgrow(header, Priority.NEVER); ok.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { // System.out.println("Size: h:" + stage.getHeight() + " w:" + // stage.getWidth()); stage.close(); // isOK.setValue(true); response = Response.OK; } }); stage.showAndWait(); return response; }
private Button createCommandLinksButton(ButtonType buttonType) { // look up the CommandLinkButtonType for the given ButtonType CommandLinksButtonType commandLink = typeMap.getOrDefault(buttonType, new CommandLinksButtonType(buttonType)); // put the content inside a button final Button button = new Button(); button.getStyleClass().addAll("command-link-button"); // $NON-NLS-1$ button.setMaxHeight(Double.MAX_VALUE); button.setMaxWidth(Double.MAX_VALUE); button.setAlignment(Pos.CENTER_LEFT); final ButtonData buttonData = buttonType.getButtonData(); button.setDefaultButton(buttonData != null && buttonData.isDefaultButton()); button.setOnAction(ae -> setResult(buttonType)); final Label titleLabel = new Label(commandLink.getButtonType().getText()); titleLabel .minWidthProperty() .bind( new DoubleBinding() { { bind(titleLabel.prefWidthProperty()); } @Override protected double computeValue() { return titleLabel.getPrefWidth() + 400; } }); titleLabel.getStyleClass().addAll("line-1"); // $NON-NLS-1$ titleLabel.setWrapText(true); titleLabel.setAlignment(Pos.TOP_LEFT); GridPane.setVgrow(titleLabel, Priority.NEVER); Label messageLabel = new Label(commandLink.getLongText()); messageLabel.getStyleClass().addAll("line-2"); // $NON-NLS-1$ messageLabel.setWrapText(true); messageLabel.setAlignment(Pos.TOP_LEFT); messageLabel.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(messageLabel, Priority.SOMETIMES); Node commandLinkImage = commandLink.getGraphic(); Node view = commandLinkImage == null ? new ImageView( CommandLinksDialog.class.getResource("arrow-green-right.png").toExternalForm()) : //$NON-NLS-1$ commandLinkImage; Pane graphicContainer = new Pane(view); graphicContainer.getStyleClass().add("graphic-container"); // $NON-NLS-1$ GridPane.setValignment(graphicContainer, VPos.TOP); GridPane.setMargin(graphicContainer, new Insets(0, 10, 0, 0)); GridPane grid = new GridPane(); grid.minWidthProperty().bind(titleLabel.prefWidthProperty()); grid.setMaxHeight(Double.MAX_VALUE); grid.setMaxWidth(Double.MAX_VALUE); grid.getStyleClass().add("container"); // $NON-NLS-1$ grid.add(graphicContainer, 0, 0, 1, 2); grid.add(titleLabel, 1, 0); grid.add(messageLabel, 1, 1); button.setGraphic(grid); button.minWidthProperty().bind(titleLabel.prefWidthProperty()); if (commandLink.isHidden) { button.setVisible(false); button.setPrefHeight(1); } return button; }
@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(); }
/** * Das GUI besteht aus zwei wesentlichen Komponenten, einer GridPane namens entryArea und einem * TextAreaHandler, beide sind in eine BorderPane eingebettet. */ @Override protected Scene create_GUI() { // ServiceLocator und Translator werden gesetzt. ServiceLocator sl = ServiceLocator.getServiceLocator(); Translator t = sl.getTranslator(); // Die MenuBar enthält die Sprachauswahl MenuBar menuBar = new MenuBar(); menuFile = new Menu(t.getString("program.menu.file")); menuFileLanguage = new Menu(t.getString("program.menu.file.language")); menuFile.getItems().add(menuFileLanguage); for (Locale locale : sl.getLocales()) { MenuItem language = new MenuItem(locale.getLanguage()); menuFileLanguage.getItems().add(language); language.setOnAction( event -> { sl.setTranslator(new Translator(locale.getLanguage())); updateTexts(); }); } BorderPane root = new BorderPane(); root.setPrefSize(409, 219); menuBar.getMenus().addAll(menuFile); root.setTop(menuBar); /** * ______________________________________________________________________________________________ * START OF GRIDPANE !!! ENTRYAREA !!! */ // Serverentry Area GridPane entryArea = new GridPane(); entryArea.setAlignment(Pos.CENTER); root.setCenter(entryArea); Label lblIP = new Label(); lblIP.setText("IP: "); ; lblIP.setAlignment(Pos.CENTER_LEFT); entryArea.add(lblIP, 0, 0); GridPane.setMargin(lblIP, new Insets(5, 5, 0, 50)); Label lblPort = new Label(); lblPort.setText("Port: "); lblPort.setAlignment(Pos.CENTER_LEFT); entryArea.add(lblPort, 0, 1); GridPane.setMargin(lblPort, new Insets(5, 5, 0, 50)); lblHostName = new Label(); lblHostName.setAlignment(Pos.CENTER_LEFT); lblHostName.setId("lblHostName"); entryArea.add(lblHostName, 0, 2); GridPane.setMargin(lblHostName, new Insets(5, 5, 0, 50)); tfIP = new TextField(); tfIP.setId("tfIP"); tfIP.setEditable(false); entryArea.add(tfIP, 1, 0); GridPane.setMargin(tfIP, new Insets(5, 5, 0, 0)); tfPort = new TextField(); tfPort.setId("tfPort"); tfPort.setText("14000"); tfPort.setPromptText("Bitte Portnummer eingeben."); entryArea.add(tfPort, 1, 1); GridPane.setMargin(tfPort, new Insets(5, 5, 0, 0)); btnStart = new Button(); btnStart.setId("btnStart"); btnStart.setText(t.getString("button.start")); entryArea.add(btnStart, 2, 0); GridPane.setMargin(btnStart, new Insets(5, 5, 0, 50)); btnClose = new Button(); btnClose.setId("btnClose"); btnClose.setText(t.getString("button.close")); entryArea.add(btnClose, 2, 1); GridPane.setMargin(btnClose, new Insets(5, 5, 0, 50)); /** * ______________________________________________________________________________________________ * START OF !!! TEXTAREAHANDLER !!! */ textAreaHandler = new TextAreaHandler(); taLogger = textAreaHandler.getTextArea(); taLogger.setId("taLogger"); taLogger.setEditable(false); root.setBottom(taLogger); Scene scene = new Scene(root); return scene; }
/** {@inheritDoc} */ @Override public void buildContent() { Calendar calendar = calendarView.calendarProperty().get(); // get the maximum number of days in a week for this calendar. numberOfDaysPerWeek = calendar.getMaximum(Calendar.DAY_OF_WEEK); // get the maximum number of days a month could have. int maxNumberOfDaysInMonth = calendar.getMaximum(Calendar.DAY_OF_MONTH); // assume the first row has only 1 day, then distribute the rest among the remaining weeks and // add the first week. int numberOfRows = (int) Math.ceil((maxNumberOfDaysInMonth - 1) / (double) numberOfDaysPerWeek) + 1; // remove all controls getChildren().clear(); int colOffset = calendarView.getShowWeeks() ? 1 : 0; if (calendarView.getShowWeeks()) { Label empty = new Label(); empty.setMaxWidth(Double.MAX_VALUE); empty.getStyleClass().add(CSS_CALENDAR_WEEKDAYS); add(empty, 0, 0); } // iterate through the columns for (int i = 0; i < numberOfDaysPerWeek; i++) { Label label = new Label(); label.getStyleClass().add(CSS_CALENDAR_WEEKDAYS); label.setMaxWidth(Double.MAX_VALUE); label.setAlignment(Pos.CENTER); add(label, i + colOffset, 0); } // iterate through the rows for (int rowIndex = 0; rowIndex < numberOfRows; rowIndex++) { if (calendarView.getShowWeeks()) { Label label = new Label(); label.setMaxWidth(Double.MAX_VALUE); label.setMaxHeight(Double.MAX_VALUE); label.getStyleClass().add(CSS_CALENDAR_WEEK_NUMBER); add(label, 0, rowIndex + 1); } // iterate through the columns for (int colIndex = 0; colIndex < numberOfDaysPerWeek; colIndex++) { final Button button = new Button(); button.setMaxWidth(Double.MAX_VALUE); button.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(button, Priority.ALWAYS); GridPane.setHgrow(button, Priority.ALWAYS); button.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { calendarView.selectedDate.set((Date) button.getUserData()); } }); // add the button, starting at second row. add(button, colIndex + colOffset, rowIndex + 1); } } }
/* * Creates the relationship tab in the popup. Relationships are handled differently from properties and are constructed using the {@code createRelationshipBox} method. * @param artifact * @return */ private VBox createRelationshipTab(final PackageArtifact artifact) { final VBox relationshipsBox = new VBox(38); relationshipsBox.getStyleClass().add(PACKAGE_TOOL_POPUP_PROPERTY_TAB); // If there aren't any existing relationships add an empty relationship box // add advice explaining that hierarchical relationships are not modifiable Label hierarchicalAdviceLabel = new Label(labels.get(Labels.LabelKey.HIERARCHICAL_ADVICE_LABEL)); hierarchicalAdviceLabel.setAlignment(Pos.TOP_LEFT); relationshipsBox.getChildren().add(hierarchicalAdviceLabel); // Create the button for adding new relationships this will add a new set of relationship // controls. final Button addNewRelationshipButton = new Button(labels.get(Labels.LabelKey.ADD_RELATIONSHIP_BUTTON)); addNewRelationshipButton.setMaxWidth(addNewButtonMaxWidth); final EmptyFieldButtonDisableListener addNewRelationshipListener = new EmptyFieldButtonDisableListener(addNewRelationshipButton); if (artifact.getRelationships().isEmpty()) { PackageDescriptionViewImpl.ArtifactRelationshipContainer container = new PackageDescriptionViewImpl.ArtifactRelationshipContainer(); artifactRelationshipFields.add(container); relationshipsBox .getChildren() .add( new RelationshipSelectionBox( artifact, null, container, availableRelationshipGroups, labels, packageOntologyService, addNewRelationshipListener)); addNewRelationshipButton.setDisable(true); } else { // Otherwise loop through the relationships and create a box for each one. for (PackageRelationship relationship : artifact.getRelationships()) { PackageDescriptionViewImpl.ArtifactRelationshipContainer container = new PackageDescriptionViewImpl.ArtifactRelationshipContainer(); artifactRelationshipFields.add(container); relationshipsBox .getChildren() .add( new RelationshipSelectionBox( artifact, relationship, container, availableRelationshipGroups, labels, packageOntologyService, addNewRelationshipListener)); if (relationship.getTargets() == null || relationship.getTargets().isEmpty()) { addNewRelationshipButton.setDisable(true); } } } relationshipsBox.getChildren().add(addNewRelationshipButton); addNewRelationshipButton.setOnAction( arg0 -> { PackageDescriptionViewImpl.ArtifactRelationshipContainer container = new PackageDescriptionViewImpl.ArtifactRelationshipContainer(); artifactRelationshipFields.add(container); VBox newRelationshipBox = new RelationshipSelectionBox( artifact, null, container, availableRelationshipGroups, labels, packageOntologyService, addNewRelationshipListener); int buttonIndex = relationshipsBox.getChildren().indexOf(addNewRelationshipButton); relationshipsBox.getChildren().add(buttonIndex, newRelationshipBox); addNewRelationshipButton.setDisable(true); requestFocusForNewGroup(newRelationshipBox); }); return relationshipsBox; }
public void readLyrics() throws IOException { String filename = songName + ".txt"; lyrStage = new Stage(); lyrStage.setTitle("Lyrics"); lyrStage.setHeight(420); AnchorPane root = new AnchorPane(); root.setStyle( "-fx-border-color: black, transparent; -fx-border-width: 1px, 5px; -fx-border-insets: 0px, 1px"); root.setOnMouseDragged( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent me) { lyrStage.setX(me.getScreenX()); lyrStage.setY(me.getScreenY()); } }); lyrStage.initStyle(StageStyle.UNDECORATED); Scene scene = new Scene(root); lyrStage.setScene(scene); Boolean songTitle = true; final Label label = new Label(); ScrollBar sc = new ScrollBar(); sc.setMin(0); sc.setValue(0); sc.setPrefWidth(3); sc.setPrefHeight(140); sc.setVisibleAmount(10); sc.setOrientation(Orientation.VERTICAL); sc.valueProperty() .addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> ov, Number old_val, Number new_val) { label.setLayoutY(-new_val.doubleValue()); } }); int row = 0; try (FileReader re = new FileReader(filename)) { BufferedReader br = new BufferedReader(re); String content; while ((content = br.readLine()) != null) { if (songTitle == true) { content = content.toUpperCase(); content = content.substring(0, content.length() - 4); songText = " "; songTitle = false; } songText += (content + "\n "); row++; } } catch (IOException ex) { System.out.println("Cant read but why?!!!"); } sc.setMax(row * 10); label.setAlignment(Pos.CENTER_RIGHT); label.setMinSize(50, 80); label.setText(songText); // label.boundsInParentProperty(); root.getChildren().addAll(label, sc); lyrStage.setX(50); lyrStage.setY(50); lyrStage.show(); }