List of usage examples for javafx.scene.layout GridPane add
public void add(Node child, int columnIndex, int rowIndex)
From source file:de.pixida.logtest.designer.testrun.TestRunEditor.java
private void insertConfigItemsIntoGrid(final GridPane gp, final List<Triple<String, Node, String>> formItems) { for (int i = 0; i < formItems.size(); i++) { final String title = formItems.get(i).getLeft(); final Node inputElement = formItems.get(i).getMiddle(); final String description = formItems.get(i).getRight(); // Put text flow object into cell. If a Text instance is used only, it will grab the whole cell size and center the text // (horizontally and vertically). Therefore, the table cell alignment does not work. final TextFlow titleText = new TextFlow(new Text(title)); titleText.setStyle("-fx-font-weight: bold;"); final TextFlow fieldName = new TextFlow(titleText); fieldName.autosize();//w w w . ja va 2 s . c o m fieldName.setMinWidth(fieldName.getWidth()); gp.add(fieldName, 0, i); final VBox vbox = new VBox(inputElement); if (StringUtils.isNotBlank(description)) { vbox.getChildren().add(new TextFlow(new Text(description))); } gp.add(vbox, 1, i); } }
From source file:gov.va.isaac.gui.preferences.plugins.ViewCoordinatePreferencesPluginView.java
@Override public Region getContent() { if (hBox == null) { VBox statedInferredToggleGroupVBox = new VBox(); statedInferredToggleGroupVBox.setSpacing(4.0); //Instantiate Everything pathComboBox = new ComboBox<>(); //Path statedInferredToggleGroup = new ToggleGroup(); //Stated / Inferred List<RadioButton> statedInferredOptionButtons = new ArrayList<>(); datePicker = new DatePicker(); //Date timeSelectCombo = new ComboBox<Long>(); //Time //Radio buttons for (StatedInferredOptions option : StatedInferredOptions.values()) { RadioButton optionButton = new RadioButton(); if (option == StatedInferredOptions.STATED) { optionButton.setText("Stated"); } else if (option == StatedInferredOptions.INFERRED_THEN_STATED) { optionButton.setText("Inferred Then Stated"); } else if (option == StatedInferredOptions.INFERRED) { optionButton.setText("Inferred"); } else { throw new RuntimeException("oops"); }//from w ww. j a v a 2 s. c o m optionButton.setUserData(option); optionButton.setTooltip( new Tooltip("Default StatedInferredOption is " + getDefaultStatedInferredOption())); statedInferredToggleGroup.getToggles().add(optionButton); statedInferredToggleGroupVBox.getChildren().add(optionButton); statedInferredOptionButtons.add(optionButton); } statedInferredToggleGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { @Override public void changed(ObservableValue<? extends Toggle> observable, Toggle oldValue, Toggle newValue) { currentStatedInferredOptionProperty.set((StatedInferredOptions) newValue.getUserData()); } }); //Path Combo Box pathComboBox.setCellFactory(new Callback<ListView<UUID>, ListCell<UUID>>() { @Override public ListCell<UUID> call(ListView<UUID> param) { final ListCell<UUID> cell = new ListCell<UUID>() { @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (c == null) { setText(null); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }; return cell; } }); pathComboBox.setButtonCell(new ListCell<UUID>() { // Don't know why this should be necessary, but without this the UUID itself is displayed @Override protected void updateItem(UUID c, boolean emptyRow) { super.updateItem(c, emptyRow); if (emptyRow) { setText(""); } else { String desc = OTFUtility.getDescription(c); setText(desc); } } }); pathComboBox.setOnAction((event) -> { if (!pathComboFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); if (selectedPath != null) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); StampBdb stampDb = Bdb.getStampDb(); NidSet nidSet = new NidSet(); nidSet.add(path); //TODO: Make this multi-threaded and possibly implement setTimeOptions() here also NidSetBI stamps = stampDb.getSpecifiedStamps(nidSet, Long.MIN_VALUE, Long.MAX_VALUE); pathDatesList.clear(); // disableTimeCombo(true); timeSelectCombo.setValue(Long.MAX_VALUE); for (Integer thisStamp : stamps.getAsSet()) { try { Position stampPosition = stampDb.getPosition(thisStamp); this.stampDate = new Date(stampPosition.getTime()); stampDateInstant = stampDate.toInstant().atZone(ZoneId.systemDefault()) .toLocalDate(); this.pathDatesList.add(stampDateInstant); //Build DatePicker } catch (Exception e) { e.printStackTrace(); } } datePicker.setValue(LocalDate.now()); } } else { pathComboFirstRun = false; } }); pathComboBox.setTooltip( new Tooltip("Default path is \"" + OTFUtility.getDescription(getDefaultPath()) + "\"")); //Calendar Date Picker final Callback<DatePicker, DateCell> dayCellFactory = new Callback<DatePicker, DateCell>() { @Override public DateCell call(final DatePicker datePicker) { return new DateCell() { @Override public void updateItem(LocalDate thisDate, boolean empty) { super.updateItem(thisDate, empty); if (pathDatesList != null) { if (pathDatesList.contains(thisDate)) { setDisable(false); } else { setDisable(true); } } } }; } }; datePicker.setDayCellFactory(dayCellFactory); datePicker.setOnAction((event) -> { if (!datePickerFirstRun) { UUID selectedPath = pathComboBox.getSelectionModel().getSelectedItem(); Instant instant = Instant.from(datePicker.getValue().atStartOfDay(ZoneId.systemDefault())); Long dateSelected = Date.from(instant).getTime(); if (selectedPath != null && dateSelected != 0) { int path = OTFUtility.getConceptVersion(selectedPath).getPathNid(); setTimeOptions(path, dateSelected); try { timeSelectCombo.setValue(times.first()); //Default Dropdown Value } catch (Exception e) { // Eat it.. like a sandwich! TODO: Create Read Only Property Conditional for checking if Time Combo is disabled // Right now, Sometimes Time Combo is disabled, so we catch this and eat it // Otherwise make a conditional from the Read Only Boolean Property to check first } } else { disableTimeCombo(false); logger.debug("The path isn't set or the date isn't set. Both are needed right now"); } } else { datePickerFirstRun = false; } }); //Commit-Time ComboBox timeSelectCombo.setMinWidth(200); timeSelectCombo.setCellFactory(new Callback<ListView<Long>, ListCell<Long>>() { @Override public ListCell<Long> call(ListView<Long> param) { final ListCell<Long> cell = new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }; return cell; } }); timeSelectCombo.setButtonCell(new ListCell<Long>() { @Override protected void updateItem(Long item, boolean emptyRow) { super.updateItem(item, emptyRow); if (item == null) { setText(""); } else { if (item == Long.MAX_VALUE) { setText("LATEST TIME"); } else { setText(timeFormatter.format(new Date(item))); } } } }); try { currentPathProperty.bind(pathComboBox.getSelectionModel().selectedItemProperty()); //Set Path Property currentTimeProperty.bind(timeSelectCombo.getSelectionModel().selectedItemProperty()); } catch (Exception e) { e.printStackTrace(); } // DEFAULT VALUES UserProfile loggedIn = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); storedTimePref = loggedIn.getViewCoordinateTime(); storedPathPref = loggedIn.getViewCoordinatePath(); if (storedPathPref != null) { pathComboBox.getItems().clear(); //Set the path Dates by default pathComboBox.getItems().addAll(getPathOptions()); final UUID storedPath = getStoredPath(); if (storedPath != null) { pathComboBox.getSelectionModel().select(storedPath); } if (storedTimePref != null) { final Long storedTime = loggedIn.getViewCoordinateTime(); Calendar cal = Calendar.getInstance(); cal.setTime(new Date(storedTime)); cal.set(Calendar.MILLISECOND, 0); //Strip milliseconds Long storedTruncTime = cal.getTimeInMillis(); if (!storedTime.equals(Long.MAX_VALUE)) { //***** FIX THIS, not checking default vc time value int path = OTFUtility.getConceptVersion(storedPathPref).getPathNid(); setTimeOptions(path, storedTimePref); timeSelectCombo.setValue(storedTruncTime); // timeSelectCombo.getItems().addAll(getTimeOptions()); //The correct way, but doesen't work Date storedDate = new Date(storedTime); datePicker.setValue(storedDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate()); } else { datePicker.setValue(LocalDate.now()); timeSelectCombo.getItems().addAll(Long.MAX_VALUE); //The correct way, but doesen't work timeSelectCombo.setValue(Long.MAX_VALUE); // disableTimeCombo(false); } } else { //Stored Time Pref == null logger.error("ERROR: Stored Time Preference = null"); } } else { //Stored Path Pref == null logger.error("We could not load a stored path, ISAAC cannot run"); throw new Error("No stored PATH could be found. ISAAC can't run without a path"); } GridPane gridPane = new GridPane(); gridPane.setHgap(10); gridPane.setVgap(10); Label pathLabel = new Label("View Coordinate Path"); gridPane.add(pathLabel, 0, 0); //Path Label - Row 0 GridPane.setHalignment(pathLabel, HPos.LEFT); gridPane.add(statedInferredToggleGroupVBox, 1, 0, 1, 2); //--Row 0, span 2 gridPane.add(pathComboBox, 0, 1); //Path Combo box - Row 2 GridPane.setValignment(pathComboBox, VPos.TOP); Label datePickerLabel = new Label("View Coordinate Dates"); gridPane.add(datePickerLabel, 0, 2); //Row 3 GridPane.setHalignment(datePickerLabel, HPos.LEFT); gridPane.add(datePicker, 0, 3); //Row 4 Label timeSelectLabel = new Label("View Coordinate Times"); gridPane.add(timeSelectLabel, 1, 2); //Row 3 GridPane.setHalignment(timeSelectLabel, HPos.LEFT); gridPane.add(timeSelectCombo, 1, 3); //Row 4 // FOR DEBUGGING CURRENTLY SELECTED PATH, TIME AND POLICY /* UserProfile userProfile = ExtendedAppContext.getCurrentlyLoggedInUserProfile(); StatedInferredOptions chosenPolicy = userProfile.getStatedInferredPolicy(); UUID chosenPathUuid = userProfile.getViewCoordinatePath(); Long chosenTime = userProfile.getViewCoordinateTime(); Label printSelectedPathLabel = new Label("Path: " + OTFUtility.getDescription(chosenPathUuid)); gridPane.add(printSelectedPathLabel, 0, 4); GridPane.setHalignment(printSelectedPathLabel, HPos.LEFT); Label printSelectedTimeLabel = null; if(chosenTime != getDefaultTime()) { printSelectedTimeLabel = new Label("Time: " + dateFormat.format(new Date(chosenTime))); } else { printSelectedTimeLabel = new Label("Time: LONG MAX VALUE"); } gridPane.add(printSelectedTimeLabel, 1, 4); GridPane.setHalignment(printSelectedTimeLabel, HPos.LEFT); Label printSelectedPolicyLabel = new Label("Policy: " + chosenPolicy); gridPane.add(printSelectedPolicyLabel, 2, 4); GridPane.setHalignment(printSelectedPolicyLabel, HPos.LEFT); */ hBox = new HBox(); hBox.getChildren().addAll(gridPane); allValid_ = new ValidBooleanBinding() { { bind(currentStatedInferredOptionProperty, currentPathProperty, currentTimeProperty); setComputeOnInvalidate(true); } @Override protected boolean computeValue() { if (currentStatedInferredOptionProperty.get() == null) { this.setInvalidReason("Null/unset/unselected StatedInferredOption"); for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.setTextErrorColor(button); } return false; } else { for (RadioButton button : statedInferredOptionButtons) { TextErrorColorHelper.clearTextErrorColor(button); } } if (currentPathProperty.get() == null) { this.setInvalidReason("Null/unset/unselected path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } if (OTFUtility.getConceptVersion(currentPathProperty.get()) == null) { this.setInvalidReason("Invalid path"); TextErrorColorHelper.setTextErrorColor(pathComboBox); return false; } else { TextErrorColorHelper.clearTextErrorColor(pathComboBox); } // if(currentTimeProperty.get() == null && currentTimeProperty.get() != Long.MAX_VALUE) // { // this.setInvalidReason("View Coordinate Time is unselected"); // TextErrorColorHelper.setTextErrorColor(timeSelectCombo); // return false; // } this.clearInvalidReason(); return true; } }; } // createButton.disableProperty().bind(saveButtonValid.not())); // Reload persisted values every time final StatedInferredOptions storedStatedInferredOption = getStoredStatedInferredOption(); for (Toggle toggle : statedInferredToggleGroup.getToggles()) { if (toggle.getUserData() == storedStatedInferredOption) { toggle.setSelected(true); } } // pathComboBox.setButtonCell(new ListCell<UUID>() { // @Override // protected void updateItem(UUID c, boolean emptyRow) { // super.updateItem(c, emptyRow); // if (emptyRow) { // setText(""); // } else { // String desc = OTFUtility.getDescription(c); // setText(desc); // } // } // }); // timeSelectCombo.setButtonCell(new ListCell<Long>() { // @Override // protected void updateItem(Long item, boolean emptyRow) { // super.updateItem(item, emptyRow); // if (emptyRow) { // setText(""); // } else { // setText(timeFormatter.format(new Date(item))); // } // } // }); // datePickerFirstRun = false; // pathComboFirstRun = false; return hBox; }
From source file:com.chart.SwingChart.java
/** * Background edition/*from w w w .j a v a 2 s . c o m*/ */ final public void backgroundEdition() { final ColorPicker colorPickerChartBackground = new ColorPicker( javafx.scene.paint.Color.web(strChartBackgroundColor)); colorPickerChartBackground.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerGridline = new ColorPicker(javafx.scene.paint.Color.web(strGridlineColor)); colorPickerGridline.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerBackground = new ColorPicker(javafx.scene.paint.Color.web(strBackgroundColor)); colorPickerBackground.setMaxWidth(Double.MAX_VALUE); final ColorPicker colorPickerTick = new ColorPicker(javafx.scene.paint.Color.web(strTickColor)); colorPickerTick.setMaxWidth(Double.MAX_VALUE); final TextField tfFontSize = new TextField(); tfFontSize.setMaxWidth(Double.MAX_VALUE); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(0, 10, 0, 10)); grid.add(new Label("Background color"), 0, 0); grid.add(colorPickerChartBackground, 1, 0); grid.add(new Label("Gridline color"), 0, 1); grid.add(colorPickerGridline, 1, 1); grid.add(new Label("Frame color"), 0, 2); grid.add(colorPickerBackground, 1, 2); grid.add(new Label("Tick color"), 0, 3); grid.add(colorPickerTick, 1, 3); grid.add(new Label("Font size"), 0, 4); grid.add(tfFontSize, 1, 4); tfFontSize.setText(String.valueOf(fontSize)); new PseudoModalDialog(skeleton, grid, true) { @Override public boolean validation() { fontSize = Float.valueOf(tfFontSize.getText().replace(",", ".")); strBackgroundColor = colorPickerBackground.getValue().toString().replace("0x", "#"); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; } } chart.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder( scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))))); chartPanel.setBackground(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); legendFrame.setStyle("marco: " + colorPickerBackground.getValue().toString().replace("0x", "#") + ";-fx-background-color: marco;"); strChartBackgroundColor = colorPickerChartBackground.getValue().toString().replace("0x", "#"); plot.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strChartBackgroundColor))); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; for (Node nn : ((LegendAxis) le).getChildren()) { if (nn instanceof Label) { ((Label) nn).setStyle("fondo: " + colorPickerChartBackground.getValue().toString().replace("0x", "#") + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: " + String.valueOf(fontSize) + "px"); } } } } strGridlineColor = colorPickerGridline.getValue().toString().replace("0x", "#"); plot.setDomainGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); plot.setRangeGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); strTickColor = colorPickerTick.getValue().toString().replace("0x", "#"); abcissaAxis.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize)); abcissaAxis.setTickLabelFont(abcissaAxis.getLabelFont().deriveFont(fontSize)); for (NumberAxis ejeOrdenada : AxesList) { ejeOrdenada.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize)); ejeOrdenada.setTickLabelFont(ejeOrdenada.getLabelFont().deriveFont(fontSize)); } return true; } }.show(); }
From source file:com.chart.SwingChart.java
/** * Series edition/*from www.j a v a 2 s. c o m*/ * @param series Series to edit */ void editSeries(final Series series) { String[] style = series.getStyle().split(";"); String strColor = "black"; final TextField editWidth = new TextField(); String tempS = "null"; for (String e : style) { if (e.contains("color: ")) { strColor = e.replace("color: ", ""); } else if (e.contains("width: ")) { editWidth.setText(e.replace("width: ", "")); } else if (e.contains("shape: ")) { tempS = e.replace("shape: ", ""); } } final String symbol = tempS; final List<SeriesShape> symbolList = new ArrayList<>(); final ObservableList<SeriesShape> symbolListModel; final ListView<SeriesShape> comboSymbol = new ListView(); symbolList.add(new SeriesShape("null", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("rectangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("circle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("triangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("crux", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("diamond", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty rectangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty circle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty triangle", javafx.scene.paint.Color.web(strColor))); symbolList.add(new SeriesShape("empty diamond", javafx.scene.paint.Color.web(strColor))); symbolListModel = FXCollections.observableList(symbolList); comboSymbol.setItems(symbolListModel); comboSymbol.setCellFactory(new Callback<ListView<SeriesShape>, ListCell<SeriesShape>>() { @Override public ListCell<SeriesShape> call(ListView<SeriesShape> p) { ListCell<SeriesShape> cell = new ListCell<SeriesShape>() { @Override protected void updateItem(SeriesShape t, boolean bln) { super.updateItem(t, bln); if (t != null) { setText(""); setGraphic(t.getShapeGraphic()); } } }; return cell; } }); for (SeriesShape smb : symbolListModel) { if (smb.getName().equals(symbol)) { comboSymbol.getSelectionModel().select(smb); } } final ColorPicker colorPicker = new ColorPicker(javafx.scene.paint.Color.web(strColor)); colorPicker.setOnAction((ActionEvent t) -> { String sc = colorPicker.getValue().toString(); symbolListModel.clear(); symbolListModel.add(new SeriesShape("null", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("rectangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("circle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("triangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("crux", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("diamond", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty rectangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty circle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty triangle", javafx.scene.paint.Color.web(sc))); symbolListModel.add(new SeriesShape("empty diamond", javafx.scene.paint.Color.web(sc))); comboSymbol.setItems(symbolListModel); for (SeriesShape smb : symbolListModel) { if (smb.getName().equals(symbol)) { comboSymbol.getSelectionModel().select(smb); } } }); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(0, 10, 0, 10)); grid.add(new Label("Series"), 0, 0); grid.add(new Label(series.getKey().toString()), 1, 0); grid.add(new Label("Color"), 0, 1); grid.add(colorPicker, 1, 1); grid.add(new Label("Width"), 0, 2); grid.add(editWidth, 1, 2); grid.add(new Label("Shape"), 0, 3); grid.add(comboSymbol, 1, 3); new PseudoModalDialog(skeleton, grid, true) { @Override public boolean validation() { String strColor = colorPicker.getValue().toString(); String strWidth = editWidth.getText(); double dWidth = Double.valueOf(strWidth); String strSimbolo = "null"; SeriesShape simb = new SeriesShape(comboSymbol.getSelectionModel().getSelectedItem().toString(), javafx.scene.paint.Color.web(strColor)); XYItemRenderer renderer = (XYItemRenderer) plot.getRenderer(series.getAxisIndex()); renderer.setSeriesPaint(series.getSeriesIndex(), scene2awtColor(colorPicker.getValue())); try { if (Double.valueOf(strWidth) > 0) { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(series.getSeriesIndex(), true); renderer.setSeriesStroke(series.getSeriesIndex(), new BasicStroke(Integer.valueOf(strWidth))); } else { ((XYLineAndShapeRenderer) renderer).setSeriesLinesVisible(series.getSeriesIndex(), false); } } catch (NumberFormatException ex) { } if (simb.getName().contains("null")) { ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(series.getSeriesIndex(), false); renderer.setSeriesShape(series.getSeriesIndex(), null); } else { ((XYLineAndShapeRenderer) renderer).setSeriesShapesVisible(series.getSeriesIndex(), true); renderer.setSeriesShape(series.getSeriesIndex(), simb.getShapeAWT()); if (simb.getName().contains("empty")) { ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(series.getSeriesIndex(), false); } else { ((XYLineAndShapeRenderer) renderer).setSeriesShapesFilled(series.getSeriesIndex(), true); } } series.setStyle( "color: " + strColor + ";width: " + editWidth.getText() + ";shape: " + strSimbolo + ";"); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { for (Node nn : ((LegendAxis) le).getChildren()) { if (nn instanceof Label) { if (((Label) nn).getText().equals(series.getKey().toString())) { ((Label) nn).setGraphic(simb.getShapeGraphic()); } } } } } return true; } }.show(); }
From source file:com.chart.SwingChart.java
/** * Set lower and upper limits for an ordinate * @param axis Axis to configure/*from w w w. ja v a 2 s . co m*/ */ void setOrdinateRange(final NumberAxis axis) { axis.setAutoRange(false); GridPane grid = new GridPane(); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(0, 10, 0, 10)); final TextField tfMax; final TextField tfMin; final TextField tfTick; final TextField tfFuente; grid.add(new Label("Axis"), 0, 0); grid.add(new Label(axis.getLabel()), 1, 0); grid.add(new Label("Lower"), 0, 1); grid.add(tfMin = new TextField(), 1, 1); grid.add(new Label("Upper"), 0, 2); grid.add(tfMax = new TextField(), 1, 2); grid.add(new Label("Space"), 0, 3); grid.add(tfTick = new TextField(), 1, 3); tfMin.setText(String.valueOf(axis.getLowerBound())); tfMax.setText(String.valueOf(axis.getUpperBound())); tfTick.setText(String.valueOf(axis.getTickUnit().getSize())); new PseudoModalDialog(skeleton, grid, true) { @Override public boolean validation() { axis.setLowerBound(Double.valueOf(tfMin.getText())); axis.setUpperBound(Double.valueOf(tfMax.getText())); axis.setTickUnit(new NumberTickUnit(Double.valueOf(tfTick.getText()))); return true; } }.show(); }
From source file:jobhunter.gui.dialog.SubscriptionForm.java
public Optional<Action> show() { Dialog dlg = new Dialog(null, getTranslation("message.add.subscription")); final GridPane content = new GridPane(); content.setHgap(10);/*from w w w .j av a2s .c o m*/ content.setVgap(10); ObservableList<String> portals = FXCollections.observableArrayList(PreferencesController.getPortalsList()); portalField.setItems(portals); portalField.setPrefWidth(400.0); portalField.setEditable(true); portalField.setValue(subscription.getPortal()); portalField.valueProperty().addListener((observable, old, neu) -> { subscription.setPortal(neu); save.disabledProperty().set(!isValid()); }); urlField.setText(subscription.getUri()); urlField.textProperty().addListener((observable, old, neu) -> { subscription.setURI(neu); save.disabledProperty().set(!isValid()); }); titleField.setText(subscription.getTitle()); titleField.textProperty().addListener((observable, old, neu) -> { subscription.setTitle(neu); save.disabledProperty().set(!isValid()); }); historyField.setText(subscription.getHistory().toString()); historyField.textProperty().addListener((observable, old, neu) -> { subscription.setHistory(Integer.valueOf(neu)); save.disabledProperty().set(!isValid()); }); content.add(new Label(getTranslation("label.title")), 0, 0); content.add(titleField, 1, 0); GridPane.setHgrow(titleField, Priority.ALWAYS); content.add(new Label(getTranslation("label.portal")), 0, 1); content.add(portalField, 1, 1); content.add(new Label(getTranslation("label.feed.url")), 0, 2); content.add(urlField, 1, 2); GridPane.setHgrow(urlField, Priority.ALWAYS); content.add(new Label(getTranslation("label.history")), 0, 3); content.add(historyField, 1, 3); GridPane.setHgrow(historyField, Priority.ALWAYS); dlg.setResizable(false); dlg.setIconifiable(false); dlg.setContent(content); dlg.getActions().addAll(save, Dialog.Actions.CANCEL); Platform.runLater(() -> titleField.requestFocus()); l.debug("Showing dialog"); return Optional.of(dlg.show()); }
From source file:Person.java
@Override public void start(Stage primaryStage) { primaryStage.setTitle(""); Group root = new Group(); Scene scene = new Scene(root, 500, 250, Color.WHITE); // create a grid pane GridPane gridpane = new GridPane(); gridpane.setPadding(new Insets(5)); gridpane.setHgap(10);//from ww w . j a v a 2s . c o m gridpane.setVgap(10); ObservableList<Person> leaders = FXCollections.observableArrayList(); leaders.add(new Person("A", "B", "C")); leaders.add(new Person("D", "E", "F")); final ListView<Person> leaderListView = new ListView<Person>(leaders); leaderListView.setPrefWidth(150); leaderListView.setPrefHeight(150); // leaderListView.setCellFactory(new Callback<ListView<Person>, ListCell<Person>>() { public ListCell<Person> call(ListView<Person> param) { final Label leadLbl = new Label(); final Tooltip tooltip = new Tooltip(); final ListCell<Person> cell = new ListCell<Person>() { @Override public void updateItem(Person item, boolean empty) { super.updateItem(item, empty); if (item != null) { leadLbl.setText(item.getAliasName()); setText(item.getFirstName() + " " + item.getLastName()); tooltip.setText(item.getAliasName()); setTooltip(tooltip); } } }; // ListCell return cell; } }); // setCellFactory gridpane.add(leaderListView, 0, 1); leaderListView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Person>() { public void changed(ObservableValue<? extends Person> observable, Person oldValue, Person newValue) { System.out.println("selection changed"); } }); root.getChildren().add(gridpane); primaryStage.setScene(scene); primaryStage.show(); }
From source file:UI.MainStageController.java
/** * creates the file not found alert box// ww w . jav a2 s . c o m */ private void fileNotFoundAlertBox() { fileNotFoundAlert = new Alert(Alert.AlertType.ERROR); fileNotFoundAlert.setTitle("File not found"); fileNotFoundAlert.setHeaderText("File not found"); fileNotFoundAlert.setContentText("Could not find the file you were looking for"); //style the alert DialogPane dialogPane = fileNotFoundAlert.getDialogPane(); dialogPane.getStylesheets().add("/UI/alertStyle.css"); Exception fileNotFoundException = new FileNotFoundException("Could not find your selected file"); //create expandable exception StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); fileNotFoundException.printStackTrace(pw); String exceptionText = sw.toString(); Label label = new Label("The exception stacktrace was: "); TextArea textArea = new TextArea(exceptionText); textArea.setEditable(false); textArea.setWrapText(true); textArea.setMaxWidth(Double.MAX_VALUE); textArea.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(textArea, Priority.ALWAYS); GridPane.setHgrow(textArea, Priority.ALWAYS); GridPane expContent = new GridPane(); expContent.setMaxWidth(Double.MAX_VALUE); expContent.add(label, 0, 0); expContent.add(textArea, 0, 1); // Set expandable Exception into the dialog pane. fileNotFoundAlert.getDialogPane().setExpandableContent(expContent); fileNotFoundAlert.showAndWait(); }
From source file:fruitproject.FruitProject.java
public void second(final String pfname) { final Stage st = new Stage(); Scene scene = null;/*from w ww . ja va2 s . c o m*/ final GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); TableView tv = new TableView(); final TableColumn<Map, String> firstDataColumn = new TableColumn<>("Name"); final TableColumn<Map, String> secondDataColumn = new TableColumn<>("Amount"); final TableColumn<Map, String> thirdDataColumn = new TableColumn<>("Remove"); firstDataColumn.setMinWidth(130); secondDataColumn.setMinWidth(130); thirdDataColumn.setMinWidth(130); if (!pfname.equals("")) { firstDataColumn.setCellValueFactory(new MapValueFactory(Column1MapKey)); secondDataColumn.setCellValueFactory(new MapValueFactory(Column2MapKey)); thirdDataColumn.setCellValueFactory(new MapValueFactory(Column3MapKey)); rows = 0; tv = new TableView<>(generateDataInMap(pfname, addPairs)); } tv.getColumns().setAll(firstDataColumn, secondDataColumn, thirdDataColumn); // secondDataColumn.setCellFactory(TextFieldTableCell.forTableColumn()); ScrollPane sp = new ScrollPane(); sp.setMinWidth(400); sp.setHbarPolicy(ScrollBarPolicy.NEVER); sp.setContent(tv); grid.add(sp, 0, 3); final ComboBox comboBox = new ComboBox(); HBox hb1 = new HBox(); comboBox.setValue("FILE"); comboBox.getItems().addAll("Save this file", "Load a new file"); Button btnOk = new Button(); btnOk.setText("OK"); hb1.getChildren().addAll(comboBox, btnOk); hb1.setSpacing(10); grid.add(hb1, 0, 1); Label label1 = new Label("Title:"); final TextField tfFilename = new TextField(); tfFilename.setText(getTitle(pfname)); HBox hb = new HBox(); hb.getChildren().addAll(label1, tfFilename); hb.setSpacing(10); grid.add(hb, 0, 2); final Stage ps = new Stage(); final TableView tv1 = tv; btnOk.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); if (comboBox.getValue().equals("Load a new file")) { first(ps); st.close(); } else { PrintWriter pw = null; try { pw = new PrintWriter("abc.json"); BufferedWriter bw = new BufferedWriter(new FileWriter(pfname, false)); bw.write("{title:\"" + tfFilename.getText() + "\""); bw.write(",fruits:["); for (int i = 0; i < rows; i++) { bw.write("{name:\"" + String.valueOf(firstDataColumn.getCellData(i)) + "\",amount:" + String.valueOf(secondDataColumn.getCellData(i)) + "}"); if (i != rows - 1) bw.write(","); } bw.write("]}"); bw.close(); } catch (Exception e) { System.out.println(e.toString()); } } } }); Button btn = new Button(); btn.setText("New Fruit"); grid.add(btn, 1, 2); // TableView tv=new TableView(); // TableColumn Col1 = new TableColumn("Name"); // TableColumn Col2 = new TableColumn("Amount"); // TableColumn Col3 = new TableColumn("Remove"); // tv.getColumns().addAll(Col1, Col2, Col3); //sp.setFitToWidth(true); Image img = new Image("file:music.jpg"); ImageView iv2 = new ImageView(); iv2.setImage(img); iv2.setFitWidth(200); iv2.setPreserveRatio(true); iv2.setSmooth(true); iv2.setCache(true); grid.add(iv2, 1, 3); btn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { //System.out.println("Hello World!"); System.out.println(comboBox.valueProperty()); st.close(); third(pfname); } }); scene = new Scene(grid, 700, 450); st.setScene(scene); st.show(); }
From source file:gov.va.isaac.gui.refexViews.refexEdit.AddSememePopup.java
private void buildDataFields(boolean assemblageValid, DynamicSememeDataBI[] currentValues) { if (assemblageValid) { for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) { allValid_.removeBinding(ssp); }//from w ww .j ava2 s.c om currentDataFieldWarnings_.clear(); for (SememeGUIDataTypeNodeDetails nd : currentDataFields_) { nd.cleanupListener(); } currentDataFields_.clear(); GridPane gp = new GridPane(); gp.setHgap(10.0); gp.setVgap(10.0); gp.setStyle("-fx-padding: 5;"); int row = 0; boolean extraInfoColumnIsRequired = false; for (DynamicSememeColumnInfo ci : assemblageInfo_.getColumnInfo()) { SimpleStringProperty valueIsRequired = (ci.isColumnRequired() ? new SimpleStringProperty("") : null); SimpleStringProperty defaultValueTooltip = ((ci.getDefaultColumnValue() == null && ci.getValidator() == null) ? null : new SimpleStringProperty()); ComboBox<DynamicSememeDataType> polymorphicType = null; Label l = new Label(ci.getColumnName()); l.getStyleClass().add("boldLabel"); l.setMinWidth(FxUtils.calculateNecessaryWidthOfBoldLabel(l)); Tooltip.install(l, new Tooltip(ci.getColumnDescription())); int col = 0; gp.add(l, col++, row); if (ci.getColumnDataType() == DynamicSememeDataType.POLYMORPHIC) { polymorphicType = new ComboBox<>(); polymorphicType.setEditable(false); polymorphicType.setConverter(new StringConverter<DynamicSememeDataType>() { @Override public String toString(DynamicSememeDataType object) { return object.getDisplayName(); } @Override public DynamicSememeDataType fromString(String string) { throw new RuntimeException("unecessary"); } }); for (DynamicSememeDataType type : DynamicSememeDataType.values()) { if (type == DynamicSememeDataType.POLYMORPHIC || type == DynamicSememeDataType.UNKNOWN) { continue; } else { polymorphicType.getItems().add(type); } } polymorphicType.getSelectionModel() .select((currentValues == null ? DynamicSememeDataType.STRING : (currentValues[row] == null ? DynamicSememeDataType.STRING : currentValues[row].getDynamicSememeDataType()))); } SememeGUIDataTypeNodeDetails nd = SememeGUIDataTypeFXNodeBuilder.buildNodeForType( ci.getColumnDataType(), ci.getDefaultColumnValue(), (currentValues == null ? null : currentValues[row]), valueIsRequired, defaultValueTooltip, (polymorphicType == null ? null : polymorphicType.getSelectionModel().selectedItemProperty()), allValid_, ci.getValidator(), ci.getValidatorData()); currentDataFieldWarnings_.addAll(nd.getBoundToAllValid()); if (ci.getColumnDataType() == DynamicSememeDataType.POLYMORPHIC) { nd.addUpdateParentListListener(currentDataFieldWarnings_); } currentDataFields_.add(nd); gp.add(nd.getNodeForDisplay(), col++, row); Label colType = new Label(ci.getColumnDataType().getDisplayName()); colType.setMinWidth(FxUtils.calculateNecessaryWidthOfLabel(colType)); gp.add((polymorphicType == null ? colType : polymorphicType), col++, row); if (ci.isColumnRequired() || ci.getDefaultColumnValue() != null || ci.getValidator() != null) { extraInfoColumnIsRequired = true; StackPane stackPane = new StackPane(); stackPane.setMaxWidth(Double.MAX_VALUE); if (ci.getDefaultColumnValue() != null || ci.getValidator() != null) { ImageView information = Images.INFORMATION.createImageView(); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(defaultValueTooltip); Tooltip.install(information, tooltip); tooltip.setAutoHide(true); information.setOnMouseClicked( event -> tooltip.show(information, event.getScreenX(), event.getScreenY())); stackPane.getChildren().add(information); } if (ci.isColumnRequired()) { ImageView exclamation = Images.EXCLAMATION.createImageView(); final BooleanProperty showExclamation = new SimpleBooleanProperty( StringUtils.isNotBlank(valueIsRequired.get())); valueIsRequired.addListener((ChangeListener<String>) (observable, oldValue, newValue) -> showExclamation.set(StringUtils.isNotBlank(newValue))); exclamation.visibleProperty().bind(showExclamation); Tooltip tooltip = new Tooltip(); tooltip.textProperty().bind(valueIsRequired); Tooltip.install(exclamation, tooltip); tooltip.setAutoHide(true); exclamation.setOnMouseClicked( event -> tooltip.show(exclamation, event.getScreenX(), event.getScreenY())); stackPane.getChildren().add(exclamation); } gp.add(stackPane, col++, row); } row++; } ColumnConstraints cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); cc = new ColumnConstraints(); cc.setHgrow(Priority.ALWAYS); gp.getColumnConstraints().add(cc); cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); if (extraInfoColumnIsRequired) { cc = new ColumnConstraints(); cc.setHgrow(Priority.NEVER); gp.getColumnConstraints().add(cc); } if (row == 0) { sp_.setContent(new Label("This assemblage does not allow data fields")); } else { sp_.setContent(gp); } allValid_.invalidate(); } else { sp_.setContent(null); } }