List of usage examples for javafx.scene.layout GridPane GridPane
public GridPane()
From source file:FeeBooster.java
private GridPane broadcastTxGrid(Transaction tx) { // Setup Grid GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER);// ww w . j a v a 2 s. c om grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); // Instructions Text Text instructions = new Text("Enter your signed transaction into the space below."); grid.add(instructions, 0, 0); // Put signed transaction in text area TextArea signedTxTxt = new TextArea(); signedTxTxt.setWrapText(true); grid.add(signedTxTxt, 0, 1); // Display some info about Transaction after sent Text txInfo = new Text(); grid.add(txInfo, 0, 4); // Add Next Button Button nextBtn = new Button("Send Transaction"); nextBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Transaction signedTx = new Transaction(); Transaction.deserializeStr(signedTxTxt.getText(), signedTx); txInfo.setText("Transaction being broadcast. TXID: " + signedTx.getHash() + "\nPlease wait a few minutes for best results, but you may now exit."); Broadcaster.broadcastTransaction(Transaction.serialize(signedTx, false)); } }); HBox btnHbox = new HBox(10); // Back Button Button backBtn = new Button("Back"); backBtn.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { sceneCursor--; stage.setScene(scenes.get(sceneCursor)); } }); btnHbox.getChildren().add(backBtn); btnHbox.getChildren().add(nextBtn); // Cancel Button Button cancelBtn = new Button("Exit"); cancelBtn.setOnAction(cancelEvent); btnHbox.getChildren().add(cancelBtn); grid.add(btnHbox, 0, 2); return grid; }
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); }// w ww. j av a 2s. c o m 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); } }
From source file:gov.va.isaac.gui.refexViews.refexEdit.AddRefexPopup.java
private void buildDataFields(boolean assemblageValid, RefexDynamicDataBI[] currentValues) { if (assemblageValid) { for (ReadOnlyStringProperty ssp : currentDataFieldWarnings_) { allValid_.removeBinding(ssp); }/*from ww w . j a v a2s .co m*/ currentDataFieldWarnings_.clear(); for (RefexDataTypeNodeDetails 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 (RefexDynamicColumnInfo ci : assemblageInfo_.getColumnInfo()) { SimpleStringProperty valueIsRequired = (ci.isColumnRequired() ? new SimpleStringProperty("") : null); SimpleStringProperty defaultValueTooltip = ((ci.getDefaultColumnValue() == null && ci.getValidator() == null) ? null : new SimpleStringProperty()); ComboBox<RefexDynamicDataType> 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() == RefexDynamicDataType.POLYMORPHIC) { polymorphicType = new ComboBox<>(); polymorphicType.setEditable(false); polymorphicType.setConverter(new StringConverter<RefexDynamicDataType>() { @Override public String toString(RefexDynamicDataType object) { return object.getDisplayName(); } @Override public RefexDynamicDataType fromString(String string) { throw new RuntimeException("unecessary"); } }); for (RefexDynamicDataType type : RefexDynamicDataType.values()) { if (type == RefexDynamicDataType.POLYMORPHIC || type == RefexDynamicDataType.UNKNOWN) { continue; } else { polymorphicType.getItems().add(type); } } polymorphicType.getSelectionModel() .select((currentValues == null ? RefexDynamicDataType.STRING : (currentValues[row] == null ? RefexDynamicDataType.STRING : currentValues[row].getRefexDataType()))); } RefexDataTypeNodeDetails nd = RefexDataTypeFXNodeBuilder.buildNodeForType(ci.getColumnDataType(), ci.getDefaultColumnValue(), (currentValues == null ? null : currentValues[row]), valueIsRequired, defaultValueTooltip, (polymorphicType == null ? null : polymorphicType.getSelectionModel().selectedItemProperty()), allValid_, new SimpleObjectProperty<>(ci.getValidator()), new SimpleObjectProperty<>(ci.getValidatorData())); currentDataFieldWarnings_.addAll(nd.getBoundToAllValid()); if (ci.getColumnDataType() == RefexDynamicDataType.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); } }
From source file:qupath.lib.gui.panels.survival.KaplanMeierDisplay.java
@SuppressWarnings("unchecked") private void generatePlot() { KaplanMeierDisplay.ScoreData newScoreData = scoreData; // If we have a hierarchy, update the scores with the most recent data if (hierarchy != null) { List<TMACoreObject> cores = PathObjectTools.getTMACoreObjects(hierarchy, false); double[] survival = new double[cores.size()]; boolean[] censored = new boolean[cores.size()]; double[] scores = new double[cores.size()]; // // Optionally sort by scores... helps a bit when debugging e.g. p-values, Hazard ratios etc. // cores.sort((c1, c2) -> Double.compare(c1.getMeasurementList().getMeasurementValue(scoreColumn), c2.getMeasurementList().getMeasurementValue(scoreColumn))); // scoreColumn = "Positive %"; // scoreColumn = "RoughScore"; for (int i = 0; i < cores.size(); i++) { TMACoreObject core = cores.get(i); MeasurementList ml = core.getMeasurementList(); survival[i] = core.getMeasurementList().getMeasurementValue(survivalColumn); double censoredValue = core.getMeasurementList().getMeasurementValue(censoredColumn); boolean hasCensoredValue = !Double.isNaN(censoredValue) && (censoredValue == 0 || censoredValue == 1); censored[i] = censoredValue != 0; if (!hasCensoredValue) { // If we don't have a censored value, ensure we mask out everything else scores[i] = Double.NaN; survival[i] = Double.NaN; } else if (ml.containsNamedMeasurement(scoreColumn)) // Get the score if we can scores[i] = ml.getMeasurementValue(scoreColumn); else { // // Try to compute score if we need to // Map<String, Number> map = ROIMeaningfulMeasurements.getPathClassSummaryMeasurements(core.getChildObjects(), true); // Number value = map.get(scoreColumn); // if (value == null) scores[i] = Double.NaN; // else // scores[i] = value.doubleValue(); }/*from w w w . j a va 2 s.c o m*/ } // Mask out any scores that don't have associated survival data for (int i = 0; i < survival.length; i++) { if (Double.isNaN(survival[i])) scores[i] = Double.NaN; } newScoreData = new ScoreData(scores, survival, censored); } if (newScoreData == null || newScoreData.scores.length == 0) return; // KaplanMeier kmHigh = new KaplanMeier("Above threshold"); // KaplanMeier kmLow = new KaplanMeier("Below threshold"); double[] quartiles = StatisticsHelper.getQuartiles(newScoreData.scores); double q1 = quartiles[0]; double median = quartiles[1]; double q3 = quartiles[2]; double[] thresholds; if (params != null) { Object thresholdMethod = params.getChoiceParameterValue("scoreThresholdMethod"); if (thresholdMethod.equals("Median")) { // panelParams.setNumericParameterValue("scoreThreshold", median); // ((DoubleParameter)params.getParameters().get("scoreThreshold")).setValue(median); // TODO: UPDATE DIALOG! thresholds = new double[] { median }; } else if (thresholdMethod.equals("Tertiles")) { // ((DoubleParameter)params.getParameters().get("scoreThreshold")).setValue(median); // TODO: UPDATE DIALOG! thresholds = StatisticsHelper.getTertiles(newScoreData.scores); } else if (thresholdMethod.equals("Quartiles")) { // ((DoubleParameter)params.getParameters().get("scoreThreshold")).setValue(median); // TODO: UPDATE DIALOG! thresholds = new double[] { q1, median, q3 }; } else if (thresholdMethod.equals("Manual (1)")) { thresholds = new double[] { params.getDoubleParameterValue("threshold1") }; } else if (thresholdMethod.equals("Manual (2)")) { thresholds = new double[] { params.getDoubleParameterValue("threshold1"), params.getDoubleParameterValue("threshold2") }; } else //if (thresholdMethod.equals("Manual (3)")) { thresholds = new double[] { params.getDoubleParameterValue("threshold1"), params.getDoubleParameterValue("threshold2"), params.getDoubleParameterValue("threshold3") }; } else thresholds = new double[] { median }; double minVal = Double.POSITIVE_INFINITY; double maxVal = Double.NEGATIVE_INFINITY; int numNonNaN = 0; for (double d : newScoreData.scores) { if (Double.isNaN(d)) continue; if (d < minVal) minVal = d; if (d > maxVal) maxVal = d; numNonNaN++; } boolean scoresValid = maxVal > minVal; // If not this, we don't have valid scores that we can work with double maxTimePoint = 0; for (double d : newScoreData.survival) { if (Double.isNaN(d)) continue; if (d > maxTimePoint) maxTimePoint = d; } if (panelParams != null && maxTimePoint > ((IntParameter) params.getParameters().get("censorTimePoints")).getUpperBound()) { panelParams.setNumericParameterValueRange("censorTimePoints", 0, Math.ceil(maxTimePoint)); } // Optionally censor at specified time double censorThreshold = params == null ? maxTimePoint : params.getIntParameterValue("censorTimePoints"); // Compute log-rank p-values for *all* possible thresholds // Simultaneously determine the threshold that yields the lowest p-value, // resolving ties in favour of a more even split between high/low numbers of events boolean pValuesChanged = false; if (calculateAllPValues) { if (!(pValues != null && pValueThresholds != null && newScoreData.equals(scoreData) && censorThreshold == lastPValueCensorThreshold)) { Map<Double, Double> mapLogRank = new TreeMap<>(); Set<Double> setObserved = new HashSet<>(); for (int i = 0; i < newScoreData.scores.length; i++) { Double d = newScoreData.scores[i]; boolean observed = !newScoreData.censored[i] && newScoreData.survival[i] < censorThreshold; if (observed) setObserved.add(d); if (mapLogRank.containsKey(d)) continue; List<KaplanMeierData> kmsTemp = splitByThresholds(newScoreData, new double[] { d }, censorThreshold, false); // if (kmsTemp.get(1).nObserved() == 0 || kmsTemp.get(1).nObserved() == 0) // continue; LogRankResult test = LogRankTest.computeLogRankTest(kmsTemp.get(0), kmsTemp.get(1)); double pValue = test.getPValue(); // double pValue = test.hazardRatio < 1 ? test.hazardRatio : 1.0/test.hazardRatio; // Checking usefulness of Hazard ratios... if (!Double.isFinite(pValue)) continue; // if (!Double.isFinite(test.getHazardRatio())) { //// continue; // pValue = Double.NaN; // } mapLogRank.put(d, pValue); } pValueThresholds = new double[mapLogRank.size()]; pValues = new double[mapLogRank.size()]; pValueThresholdsObserved = new boolean[mapLogRank.size()]; int count = 0; for (Entry<Double, Double> entry : mapLogRank.entrySet()) { pValueThresholds[count] = entry.getKey(); pValues[count] = entry.getValue(); if (setObserved.contains(entry.getKey())) pValueThresholdsObserved[count] = true; count++; } // Find the longest 'significant' stretch int maxSigCount = 0; int maxSigInd = -1; int sigCurrent = 0; int[] sigCount = new int[pValues.length]; for (int i = 0; i < pValues.length; i++) { if (pValues[i] < 0.05) { sigCurrent++; sigCount[i] = sigCurrent; if (sigCurrent > maxSigCount) { maxSigCount = sigCurrent; maxSigInd = i; } } else sigCurrent = 0; } if (maxSigCount == 0) { logger.info("No p-values < 0.05"); } else { double minThresh = maxSigInd - maxSigCount < 0 ? pValueThresholds[0] - 0.0000001 : pValueThresholds[maxSigInd - maxSigCount]; double maxThresh = pValueThresholds[maxSigInd]; int nBetween = 0; int nBetweenObserved = 0; for (int i = 0; i < newScoreData.scores.length; i++) { if (newScoreData.scores[i] > minThresh && newScoreData.scores[i] <= maxThresh) { nBetween++; if (newScoreData.survival[i] < censorThreshold && !newScoreData.censored[i]) nBetweenObserved++; } } logger.info("Longest stretch of p-values < 0.05: {} - {} ({} entries, {} observed)", minThresh, maxThresh, nBetween, nBetweenObserved); } pValuesSmoothed = new double[pValues.length]; Arrays.fill(pValuesSmoothed, Double.NaN); int n = (pValues.length / 20) * 2 + 1; logger.info("Smoothing log-rank test p-values by " + n); for (int i = n / 2; i < pValues.length - n / 2; i++) { double sum = 0; for (int k = i - n / 2; k < i - n / 2 + n; k++) { sum += pValues[k]; } pValuesSmoothed[i] = sum / n; } // for (int i = 0; i < pValues.length; i++) { // double sum = 0; // for (int k = Math.max(0, i-n/2); k < Math.min(pValues.length, i-n/2+n); k++) { // sum += pValues[k]; // } // pValuesSmoothed[i] = sum/n; // } // pValues = pValuesSmoothed; lastPValueCensorThreshold = censorThreshold; pValuesChanged = true; } } else { lastPValueCensorThreshold = Double.NaN; pValueThresholds = null; pValues = null; } // if (params != null && !Double.isNaN(bestThreshold) && (params.getChoiceParameterValue("scoreThresholdMethod").equals("Lowest p-value"))) if (params != null && (params.getChoiceParameterValue("scoreThresholdMethod").equals("Lowest p-value"))) { int bestIdx = -1; double bestPValue = Double.POSITIVE_INFINITY; for (int i = pValueThresholds.length / 10; i < pValueThresholds.length * 9 / 10; i++) { if (pValues[i] < bestPValue) { bestIdx = i; bestPValue = pValues[i]; } } thresholds = bestIdx >= 0 ? new double[] { pValueThresholds[bestIdx] } : new double[0]; } else if (params != null && (params.getChoiceParameterValue("scoreThresholdMethod").equals("Lowest smoothed p-value"))) { int bestIdx = -1; double bestPValue = Double.POSITIVE_INFINITY; for (int i = pValueThresholds.length / 10; i < pValueThresholds.length * 9 / 10; i++) { if (pValuesSmoothed[i] < bestPValue) { bestIdx = i; bestPValue = pValuesSmoothed[i]; } } thresholds = bestIdx >= 0 ? new double[] { pValueThresholds[bestIdx] } : new double[0]; } // Split into different curves using the provided thresholds List<KaplanMeierData> kms = splitByThresholds(newScoreData, thresholds, censorThreshold, params != null && "Quartiles".equals(params.getChoiceParameterValue("scoreThresholdMethod"))); // for (KaplanMeier km : kms) // km.censorAtTime(censorThreshold); //// kmHigh.censorAtTime(censorThreshold); //// kmLow.censorAtTime(censorThreshold); // logger.info("High: " + kmHigh.toString()); // logger.info("Low: " + kmLow.toString()); // logger.info("Log rank comparison: {}", LogRankTest.computeLogRankTest(kmLow, kmHigh)); if (plotter == null) { plotter = new KaplanMeierChartWrapper(survivalColumn + " time"); // plotter.setBorder(BorderFactory.createTitledBorder("Survival plot")); // plotter.getCanvas().setWidth(300); // plotter.getCanvas().setHeight(300); } KaplanMeierData[] kmArray = new KaplanMeierData[kms.size()]; plotter.setKaplanMeierCurves(survivalColumn + " time", kms.toArray(kmArray)); tableModel.setSurvivalCurves(thresholds, params != null && params.getChoiceParameterValue("scoreThresholdMethod").equals("Lowest p-value"), kmArray); // Bar width determined using 'Freedman and Diaconis' rule' (but overridden if this gives < 16 bins...) double barWidth = (2 * q3 - q1) * Math.pow(numNonNaN, -1.0 / 3.0); int nBins = 100; if (!Double.isNaN(barWidth)) barWidth = (int) Math.max(16, Math.ceil((maxVal - minVal) / barWidth)); Histogram histogram = scoresValid ? new Histogram(newScoreData.scores, nBins) : null; if (histogramPanel == null) { GridPane paneHistogram = new GridPane(); histogramPanel = new HistogramPanelFX(); histogramPanel.getChart().setAnimated(false); histogramWrapper = new ThresholdedChartWrapper(histogramPanel.getChart()); for (ObservableNumberValue val : threshProperties) histogramWrapper.addThreshold(val, ColorToolsFX.getCachedColor(240, 0, 0, 128)); histogramWrapper.getPane().setPrefHeight(150); paneHistogram.add(histogramWrapper.getPane(), 0, 0); Tooltip.install(histogramPanel.getChart(), new Tooltip("Distribution of scores")); GridPane.setHgrow(histogramWrapper.getPane(), Priority.ALWAYS); GridPane.setVgrow(histogramWrapper.getPane(), Priority.ALWAYS); NumberAxis xAxis = new NumberAxis(); xAxis.setLabel("Score threshold"); NumberAxis yAxis = new NumberAxis(); yAxis.setLowerBound(0); yAxis.setUpperBound(1); yAxis.setTickUnit(0.1); yAxis.setAutoRanging(false); yAxis.setLabel("P-value"); chartPValues = new LineChart<>(xAxis, yAxis); chartPValues.setAnimated(false); chartPValues.setLegendVisible(false); // Make chart so it can be navigated ChartToolsFX.makeChartInteractive(chartPValues, xAxis, yAxis); pValuesChanged = true; Tooltip.install(chartPValues, new Tooltip( "Distribution of p-values (log-rank test) comparing low vs. high for all possible score thresholds")); // chartPValues.getYAxis().setAutoRanging(false); pValuesWrapper = new ThresholdedChartWrapper(chartPValues); for (ObservableNumberValue val : threshProperties) pValuesWrapper.addThreshold(val, ColorToolsFX.getCachedColor(240, 0, 0, 128)); pValuesWrapper.getPane().setPrefHeight(150); paneHistogram.add(pValuesWrapper.getPane(), 0, 1); GridPane.setHgrow(pValuesWrapper.getPane(), Priority.ALWAYS); GridPane.setVgrow(pValuesWrapper.getPane(), Priority.ALWAYS); ContextMenu popup = new ContextMenu(); ChartToolsFX.addChartExportMenu(chartPValues, popup); RadioMenuItem miZoomY1 = new RadioMenuItem("0-1"); miZoomY1.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(1); yAxis.setTickUnit(0.2); }); RadioMenuItem miZoomY05 = new RadioMenuItem("0-0.5"); miZoomY05.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(0.5); yAxis.setTickUnit(0.1); }); RadioMenuItem miZoomY02 = new RadioMenuItem("0-0.2"); miZoomY02.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(0.2); yAxis.setTickUnit(0.05); }); RadioMenuItem miZoomY01 = new RadioMenuItem("0-0.1"); miZoomY01.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(0.1); yAxis.setTickUnit(0.05); }); RadioMenuItem miZoomY005 = new RadioMenuItem("0-0.05"); miZoomY005.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(0.05); yAxis.setTickUnit(0.01); }); RadioMenuItem miZoomY001 = new RadioMenuItem("0-0.01"); miZoomY001.setOnAction(e -> { yAxis.setAutoRanging(false); yAxis.setUpperBound(0.01); yAxis.setTickUnit(0.005); }); ToggleGroup tgZoom = new ToggleGroup(); miZoomY1.setToggleGroup(tgZoom); miZoomY05.setToggleGroup(tgZoom); miZoomY02.setToggleGroup(tgZoom); miZoomY01.setToggleGroup(tgZoom); miZoomY005.setToggleGroup(tgZoom); miZoomY001.setToggleGroup(tgZoom); Menu menuZoomY = new Menu("Set y-axis range"); menuZoomY.getItems().addAll(miZoomY1, miZoomY05, miZoomY02, miZoomY01, miZoomY005, miZoomY001); MenuItem miCopyData = new MenuItem("Copy chart data"); miCopyData.setOnAction(e -> { String dataString = ChartToolsFX.getChartDataAsString(chartPValues); ClipboardContent content = new ClipboardContent(); content.putString(dataString); Clipboard.getSystemClipboard().setContent(content); }); popup.getItems().addAll(miCopyData, menuZoomY); chartPValues.setOnContextMenuRequested(e -> { popup.show(chartPValues, e.getScreenX(), e.getScreenY()); }); for (int col = 0; col < tableModel.getColumnCount(); col++) { TableColumn<Integer, String> column = new TableColumn<>(tableModel.getColumnName(col)); int colNumber = col; column.setCellValueFactory( new Callback<CellDataFeatures<Integer, String>, ObservableValue<String>>() { @Override public ObservableValue<String> call(CellDataFeatures<Integer, String> p) { return new SimpleStringProperty( (String) tableModel.getValueAt(p.getValue(), colNumber)); } }); column.setCellFactory(new Callback<TableColumn<Integer, String>, TableCell<Integer, String>>() { @Override public TableCell<Integer, String> call(TableColumn<Integer, String> param) { TableCell<Integer, String> cell = new TableCell<Integer, String>() { @Override protected void updateItem(String item, boolean empty) { super.updateItem(item, empty); setText(item); setTooltip(new Tooltip(item)); } }; return cell; } }); table.getColumns().add(column); } table.setPrefHeight(250); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); table.maxHeightProperty().bind(table.prefHeightProperty()); params = new ParameterList(); // maxTimePoint = 0; // for (TMACoreObject core : hierarchy.getTMAGrid().getTMACoreList()) { // double os = core.getMeasurementList().getMeasurementValue(TMACoreObject.KEY_OVERALL_SURVIVAL); // double rfs = core.getMeasurementList().getMeasurementValue(TMACoreObject.KEY_RECURRENCE_FREE_SURVIVAL); // if (os > maxTimePoint) // maxTimePoint = os; // if (rfs > maxTimePoint) // maxTimePoint = rfs; // } params.addIntParameter("censorTimePoints", "Max censored time", (int) (censorThreshold + 0.5), null, 0, (int) Math.ceil(maxTimePoint), "Latest time point beyond which data will be censored"); // params.addChoiceParameter("scoreThresholdMethod", "Threshold method", "Manual", Arrays.asList("Manual", "Median", "Log-rank test")); if (calculateAllPValues) // Don't include "Lowest smoothed p-value" - it's not an established method and open to misinterpretation... params.addChoiceParameter("scoreThresholdMethod", "Threshold method", "Median", Arrays.asList("Manual (1)", "Manual (2)", "Manual (3)", "Median", "Tertiles", "Quartiles", "Lowest p-value")); // params.addChoiceParameter("scoreThresholdMethod", "Threshold method", "Median", Arrays.asList("Manual (1)", "Manual (2)", "Manual (3)", "Median", "Tertiles", "Quartiles", "Lowest p-value", "Lowest smoothed p-value")); else params.addChoiceParameter("scoreThresholdMethod", "Threshold method", "Median", Arrays.asList("Manual (1)", "Manual (2)", "Manual (3)", "Median", "Tertiles", "Quartiles")); params.addDoubleParameter("threshold1", "Threshold 1", thresholds.length > 0 ? thresholds[0] : (minVal + maxVal) / 2, null, "Threshold to distinguish between patient groups"); params.addDoubleParameter("threshold2", "Threshold 2", thresholds.length > 1 ? thresholds[1] : (minVal + maxVal) / 2, null, "Threshold to distinguish between patient groups"); params.addDoubleParameter("threshold3", "Threshold 3", thresholds.length > 2 ? thresholds[2] : (minVal + maxVal) / 2, null, "Threshold to distinguish between patient groups"); params.addBooleanParameter("showAtRisk", "Show at risk", plotter.getShowAtRisk(), "Show number of patients at risk below the plot"); params.addBooleanParameter("showTicks", "Show censored ticks", plotter.getShowCensoredTicks(), "Show ticks to indicate censored data"); params.addBooleanParameter("showKey", "Show key", plotter.getShowKey(), "Show key indicating display of each curve"); // params.addBooleanParameter("useColor", "Use color", plotter.getUseColor(), "Show each curve in a different color"); // params.addBooleanParameter("useStrokes", "Use strokes", plotter.getUseStrokes(), "Show each curve with a differed line stroke"); // Hide threshold parameters if threshold can't be used if (!scoresValid) { // params.setHiddenParameters(true, "scoreThresholdMethod", "scoreThreshold"); histogramPanel.getChart().setVisible(false); } panelParams = new ParameterPanelFX(params); panelParams.addParameterChangeListener(this); updateThresholdsEnabled(); for (int i = 0; i < threshProperties.length; i++) { String p = "threshold" + (i + 1); threshProperties[i].addListener((v, o, n) -> { if (interactiveThresholds()) { // Need to do a decent double check with tolerance to text field value changing while typing if (!GeneralTools.almostTheSame(params.getDoubleParameterValue(p), n.doubleValue(), 0.0001)) panelParams.setNumericParameterValue(p, n); } }); } BorderPane paneBottom = new BorderPane(); TitledPane paneOptions = new TitledPane("Options", panelParams.getPane()); // paneOptions.setCollapsible(false); Pane paneCanvas = new StackPane(); paneCanvas.getChildren().add(plotter.getCanvas()); GridPane paneLeft = new GridPane(); paneLeft.add(paneOptions, 0, 0); paneLeft.add(table, 0, 1); GridPane.setHgrow(paneOptions, Priority.ALWAYS); GridPane.setHgrow(table, Priority.ALWAYS); paneBottom.setLeft(paneLeft); paneBottom.setCenter(paneHistogram); paneMain.setCenter(paneCanvas); paneMain.setBottom(paneBottom); paneMain.setPadding(new Insets(10, 10, 10, 10)); } else if (thresholds.length > 0) { // Ensure the sliders/text fields are set sensibly if (!GeneralTools.almostTheSame(thresholds[0], params.getDoubleParameterValue("threshold1"), 0.0001)) { panelParams.setNumericParameterValue("threshold1", thresholds[0]); } if (thresholds.length > 1 && !GeneralTools.almostTheSame(thresholds[1], params.getDoubleParameterValue("threshold2"), 0.0001)) { panelParams.setNumericParameterValue("threshold2", thresholds[1]); } if (thresholds.length > 2 && !GeneralTools.almostTheSame(thresholds[2], params.getDoubleParameterValue("threshold3"), 0.0001)) { panelParams.setNumericParameterValue("threshold3", thresholds[2]); } } if (histogram != null) { histogramPanel.getHistogramData() .setAll(HistogramPanelFX.createHistogramData(histogram, false, (Color) null)); histogramPanel.getChart().getXAxis().setLabel(scoreColumn); histogramPanel.getChart().getYAxis().setLabel("Count"); ChartToolsFX.addChartExportMenu(histogramPanel.getChart(), null); // histogramWrapper.setVerticalLines(thresholds, ColorToolsFX.getCachedColor(240, 0, 0, 128)); // Deal with threshold adjustment // histogramWrapper.getThresholds().addListener((Observable o) -> generatePlot()); } if (pValues != null) { // TODO: Raise earlier where p-value calculation is if (pValuesChanged) { ObservableList<XYChart.Data<Number, Number>> data = FXCollections.observableArrayList(); for (int i = 0; i < pValueThresholds.length; i++) { double pValue = pValues[i]; if (Double.isNaN(pValue)) continue; data.add(new XYChart.Data<>(pValueThresholds[i], pValue, pValueThresholdsObserved[i])); } ObservableList<XYChart.Data<Number, Number>> dataSmoothed = null; if (pValuesSmoothed != null) { dataSmoothed = FXCollections.observableArrayList(); for (int i = 0; i < pValueThresholds.length; i++) { double pValueSmoothed = pValuesSmoothed[i]; if (Double.isNaN(pValueSmoothed)) continue; dataSmoothed.add(new XYChart.Data<>(pValueThresholds[i], pValueSmoothed)); } } // Don't bother showing the smoothed data... it tends to get in the way... // if (dataSmoothed != null) // chartPValues.getData().setAll(new XYChart.Series<>("P-values", data), new XYChart.Series<>("Smoothed P-values", dataSmoothed)); // else chartPValues.getData().setAll(new XYChart.Series<>("P-values", data)); // Add line to show 0.05 significance threshold if (pValueThresholds.length > 1) { Data<Number, Number> sigData1 = new Data<>(pValueThresholds[0], 0.05); Data<Number, Number> sigData2 = new Data<>(pValueThresholds[pValueThresholds.length - 1], 0.05); XYChart.Series<Number, Number> dataSignificant = new XYChart.Series<>("Signficance 0.05", FXCollections.observableArrayList(sigData1, sigData2)); chartPValues.getData().add(dataSignificant); sigData1.getNode().setVisible(false); sigData2.getNode().setVisible(false); } // chartPValues.getData().get(0).getNode().setVisible(true); // pValuesWrapper.clearThresholds(); for (XYChart.Data<Number, Number> dataPoint : data) { if (!Boolean.TRUE.equals(dataPoint.getExtraValue())) dataPoint.getNode().setVisible(false); } // if (dataSmoothed != null) { // for (XYChart.Data<Number, Number> dataPoint : dataSmoothed) { // dataPoint.getNode().setVisible(false); // } // chartPValues.getData().get(1).getNode().setOpacity(0.5); // } // int count = 0; // for (int i = 0; i < pValueThresholds.length; i++) { // double pValue = pValues[i]; // if (Double.isNaN(pValue)) // continue; // boolean observed = pValueThresholdsObserved[i]; //// if (observed) //// pValuesWrapper.addThreshold(new ReadOnlyDoubleWrapper(pValueThresholds[i]), Color.rgb(0, 0, 0, 0.05)); // // if (!observed) { //// StackPane pane = (StackPane)data.get(count).getNode(); //// pane.setEffect(new DropShadow()); // data.get(count).getNode().setVisible(false); // } // count++; // } } for (int i = 0; i < threshProperties.length; i++) { if (i < thresholds.length) threshProperties[i].set(thresholds[i]); else threshProperties[i].set(Double.NaN); } boolean isInteractive = interactiveThresholds(); histogramWrapper.setIsInteractive(isInteractive); pValuesWrapper.setIsInteractive(isInteractive); chartPValues.setVisible(true); } // else // chartPValues.setVisible(false); // Store values for next time scoreData = newScoreData; }
From source file:com.chart.SwingChart.java
/** * Series edition//from ww w. ja 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:statos2_0.MainA.java
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle(nameseller + "[" + storename + "]"); primaryStage.show();/*w ww . jav a 2 s .c om*/ primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { public void handle(WindowEvent we) { updsel(m, 1); } }); GridPane grid = new GridPane(); grid.setHgap(14); grid.setVgap(14); grid.setPadding(new Insets(5, 5, 5, 5)); //System.out.println("****"+m); txg3.setVisible(false); // , 1 sp1.setValueFactory(spfd); spb1.setValueFactory(sfi); sp2.setValueFactory(sfi2); sp3.setValueFactory(sfi3); p1.setId("firstlab"); p2.setId("firstlab"); p3.setId("firstlab"); kasnbn.setId("secondlab"); kasvnbn.setId("secondlab"); sumnbn.setId("secondlab"); vyr.setId("vyr"); sumvnbn.setId("secondlab"); JSONParser jP5 = new JSONParser(); JSONObject jsons5 = new JSONObject(); List<NameValuePair> para5 = new ArrayList<NameValuePair>(); para5.add(new BasicNameValuePair("idm", String.valueOf(m))); jsons5 = jP5.makeHttpRequest(url_cashgetm, "POST", para5); int success = jsons5.getInt("success"); if (!jsons5.isNull("success")) { //res=true; // System.out.println("TRUE"); double all = jsons5.getDouble("all"); double dayall = Double.parseDouble(jsons5.get("dayall").toString()); double daybn = Double.parseDouble(jsons5.get("daybn").toString()); days = dayall + daybn; if (days <= 7999 & days > 0) { smvyr += (days / 100) * 3; } else if (days > 7999) { smvyr += (days / 100) * 4; } vyr.setText(":" + smvyr); sumnbn.setText(all + " ."); sumvnbn.setText(dayall + " / " + daybn); } litg.setText(":"); {// sp1.setVisible(false); spb1.setVisible(false); lb1.setVisible(false); t1.setVisible(false); bt1.setVisible(false); lbb1.setVisible(false); cbx4.setVisible(false); } {// , sp2.setVisible(false); lb2.setVisible(false); t2.setVisible(false); bt2.setVisible(false); } {// sp3.setVisible(false); lb3.setVisible(false); t3.setVisible(false); bt3.setVisible(false); } res.editableProperty().setValue(Boolean.FALSE); t1.editableProperty().setValue(Boolean.FALSE); t2.editableProperty().setValue(Boolean.FALSE); t3.editableProperty().setValue(Boolean.FALSE); titg.editableProperty().setValue(Boolean.FALSE); //cbx1.setItems(GetByTag(TAG_NAME, "1")); //cbx2.setItems(GetByTag(TAG_NAME, "2")); //cbx3.setItems(GetByTag(TAG_NAME, "3")); //cbx4.setItems(GetByTag(TAG_NAME, "4")); //cbx1.valueProperty().addListener(new ); cbx1.setId("comboprod"); cbx2.setId("comboprod"); cbx3.setId("comboprod"); txg3.setPrefSize(70, 80); sp1.setPrefSize(75, 80); sp2.setPrefSize(75, 80); sp3.setPrefSize(75, 80); spb1.setPrefSize(75, 80); lb1.setId("labl"); lb2.setId("labl"); lb3.setId("labl"); lbb1.setId("labl"); t1.setId("textost"); t2.setId("textost"); t3.setId("textost"); bt1.setId("btitg"); bt2.setId("btitg"); bt3.setId("btitg"); cbx4.setId("combbot"); //lb1.setPrefSize(25, 40); //lb2.setPrefSize(25, 40); //lb3.setPrefSize(25, 40); //t1.setPrefSize(150, 40); //t2.setPrefSize(150, 40); //t3.setPrefSize(150, 40); //cbx4.setPrefSize(160,40); //bt2.setPrefSize(40, 40); //bt3.setPrefSize(40, 40); //spb1.setPrefSize(80, 40); //lbb1.setPrefSize(40,40); //bt1.setPrefSize(40, 40); titg.setPrefSize(120, 80); litg.setId("itgl"); res.setPrefSize(300, 300); lb1.setText(""); lb2.setText(""); lb3.setText(""); bt1.setText("+"); bt2.setText("+"); bt3.setText("+"); lbb1.setText(""); bres.setText(""); bitg.setText(""); bdlg.setText(""); bbn.setText("/"); //sp1.setValueFactory(); grid.add(p1, 0, 0); grid.add(p2, 0, 1); grid.add(p3, 0, 2); grid.add(cbx1, 1, 0); grid.add(cbx2, 1, 1); grid.add(cbx3, 1, 2); grid.add(sp1, 2, 0); grid.add(sp2, 2, 1); grid.add(sp3, 2, 2); grid.add(txg3, 2, 2); grid.add(lb1, 3, 0); grid.add(lb2, 3, 1); grid.add(lb3, 3, 2); grid.add(t1, 4, 0); grid.add(t2, 4, 1); grid.add(t3, 4, 2); grid.add(cbx4, 5, 0); grid.add(bt2, 5, 1); grid.add(bt3, 5, 2); grid.add(spb1, 6, 0); grid.add(lbb1, 7, 0); grid.add(bt1, 8, 0); //grid.add(res, 1, 4, 3, 3); grid.add(res, 0, 3, 2, 3); litg.setAlignment(Pos.BASELINE_RIGHT); grid.add(litg, 2, 3); grid.add(titg, 3, 3, 2, 1); grid.add(bitg, 2, 4); grid.add(btcl, 4, 4); grid.add(kasnbn, 10, 0); grid.add(sumnbn, 10, 1); grid.add(kasvnbn, 10, 2); grid.add(sumvnbn, 10, 3); grid.add(vyr, 10, 4); grid.add(close, 10, 8); close.setOnAction(event -> { /** Dialog<Void> dialog = new Dialog<>(); dialog.initModality(Modality.WINDOW_MODAL); dialog.initOwner(primaryStage);//stage here is the stage of your webview //dialog.initStyle(StageStyle.TRANSPARENT); Label loader = new Label("LOADING"); //loader.setContentDisplay(ContentDisplay.DOWN); loader.setGraphic(new ProgressIndicator()); dialog.getDialogPane().setGraphic(loader); DropShadow ds = new DropShadow(); ds.setOffsetX(1.3); ds.setOffsetY(1.3); ds.setColor(Color.DARKGRAY); dialog.getDialogPane().setEffect(ds); //ButtonType btn = new ButtonType("OK",ButtonData.CANCEL_CLOSE); //dialog.getDialogPane().getButtonTypes().add(btn); dialog.show(); runJsons(); dialog.hide(); dialog.close(); **/ Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(""); alert.setHeaderText(" "); alert.setContentText(" ?"); ButtonType buttonTypeOne = new ButtonType(""); ButtonType buttonTypeCancel = new ButtonType("", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeCancel); Optional<ButtonType> result2 = alert.showAndWait(); if (result2.get() == buttonTypeOne) { updsel(m, 1); cashday(m); System.exit(0); } }); btcl.setOnAction(event -> { jsares.clear(); res.setText(""); titg.setText(""); itog = 0; chcount = 1; cbx1.getSelectionModel().clearSelection(); cbx2.getSelectionModel().clearSelection(); cbx3.getSelectionModel().clearSelection(); cbx4.getSelectionModel().clearSelection(); cbx4.setVisible(false); sp1.getValueFactory().setValue(0.0); sp2.getValueFactory().setValue(0); sp3.getValueFactory().setValue(0); spb1.getValueFactory().setValue(0); sp1.setVisible(false); sp2.setVisible(false); sp3.setVisible(false); spb1.setVisible(false); lb1.setVisible(false); lb2.setVisible(false); lb3.setVisible(false); lbb1.setVisible(false); t1.setVisible(false); t2.setVisible(false); t3.setVisible(false); bt1.setVisible(false); bt2.setVisible(false); bt3.setVisible(false); }); bitg.setOnAction(event -> { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(""); alert.setHeaderText(" "); alert.setContentText(" ?"); ButtonType buttonOK = new ButtonType(""); ButtonType buttonCancel = new ButtonType("", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonOK, buttonCancel); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == buttonOK) { alert = new Alert(AlertType.CONFIRMATION); alert.setTitle(""); alert.setHeaderText(" "); alert.setContentText(" "); ButtonType buttonTypeOne = new ButtonType(""); ButtonType buttonTypeTwo = new ButtonType(""); //ButtonType buttonTypeThree = new ButtonType("Three"); ButtonType buttonTypeCancel = new ButtonType("", ButtonData.CANCEL_CLOSE); alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeTwo, /*buttonTypeThree,*/ buttonTypeCancel); Optional<ButtonType> result2 = alert.showAndWait(); if (result2.get() == buttonTypeOne) { // ... user chose "One" typepay = ""; finishnal(titg.getText(), res.getText(), 1); } else if (result2.get() == buttonTypeTwo) { // ... user chose "Two" typepay = ""; finishnal(titg.getText(), res.getText(), 2); } /* else if (result2.get() == buttonTypeThree) { // ... user chose "Three" }*/ else { // ... user chose CANCEL or closed the dialog } } else { // ... user chose CANCEL or closed the dialog } }); txg3.setOnMouseClicked(event -> { Dialog dialog = new Dialog(); GridPane gr = new GridPane(); gr.setHgap(3); gr.setVgap(5); gr.setPadding(new Insets(10, 10, 10, 10)); Button b1 = new Button("1"); b1.setPrefSize(50, 50); Button b2 = new Button("2"); b2.setPrefSize(50, 50); Button b3 = new Button("3"); b3.setPrefSize(50, 50); Button b4 = new Button("4"); b4.setPrefSize(50, 50); Button b5 = new Button("5"); b5.setPrefSize(50, 50); Button b6 = new Button("6"); b6.setPrefSize(50, 50); Button b7 = new Button("7"); b7.setPrefSize(50, 50); Button b8 = new Button("8"); b8.setPrefSize(50, 50); Button b9 = new Button("9"); b9.setPrefSize(50, 50); Button b0 = new Button("0"); b0.setPrefSize(50, 50); Button bd = new Button("."); bd.setPrefSize(50, 50); Button bc = new Button("C"); bc.setPrefSize(50, 50); Button bok = new Button(""); bc.setPrefSize(50, 50); Button bno = new Button(""); bc.setPrefSize(50, 50); gr.add(b1, 0, 0); gr.add(b2, 1, 0); gr.add(b3, 2, 0); gr.add(b4, 0, 1); gr.add(b5, 1, 1); gr.add(b6, 2, 1); gr.add(b7, 0, 2); gr.add(b8, 1, 2); gr.add(b9, 2, 2); gr.add(bd, 0, 3); gr.add(b0, 1, 3); gr.add(bc, 2, 3); //gr.add(bok, 0, 4); //gr.add(bno, 3, 4); b1.setOnAction(even -> { txg3.setText(txg3.getText() + "1"); }); b2.setOnAction(even -> { txg3.setText(txg3.getText() + "2"); }); b3.setOnAction(even -> { txg3.setText(txg3.getText() + "3"); }); b4.setOnAction(even -> { txg3.setText(txg3.getText() + "4"); }); b5.setOnAction(even -> { txg3.setText(txg3.getText() + "5"); }); b6.setOnAction(even -> { txg3.setText(txg3.getText() + "6"); }); b7.setOnAction(even -> { txg3.setText(txg3.getText() + "7"); }); b8.setOnAction(even -> { txg3.setText(txg3.getText() + "8"); }); b9.setOnAction(even -> { txg3.setText(txg3.getText() + "9"); }); bc.setOnAction(even -> { txg3.setText(""); }); bd.setOnAction(even -> { txg3.setText(txg3.getText() + "."); }); b0.setOnAction(even -> { txg3.setText(txg3.getText() + "0"); }); ButtonType okk = new ButtonType("OK", ButtonData.OK_DONE); ButtonType no = new ButtonType("", ButtonData.CANCEL_CLOSE); //gr.add(okk, 0, 4); dialog.getDialogPane().setContent(gr); dialog.getDialogPane().getButtonTypes().addAll(no, okk); dialog.setX(350); dialog.setY(260); Optional res = dialog.showAndWait(); runJsons(); // dialog.setResult(ButtonData.CANCEL_CLOSE); //dialog.showAndWait(); }); txg3.lengthProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { if (newValue.intValue() > oldValue.intValue()) { char ch = txg3.getText().charAt(oldValue.intValue()); // Check if the new character is the number or other's if ((!(ch >= '0' && ch <= '9'))) { // if it's not number then just setText to previous one if (ch == '.') { } else { txg3.setText(txg3.getText().substring(0, txg3.getText().length() - 1)); } } double res; if (cbx3.getSelectionModel().getSelectedIndex() >= 0) { res = Double.parseDouble(txg3.getText()); res = res / 1000; //System.out.println("RES-"+res+"balanc"+balancech(cbx3.getSelectionModel().getSelectedItem().toString())+"BASE"+Double.parseDouble(getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(),MT))); if ((res + balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3)) > Double .parseDouble( getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT))) { txg3.setText(""); Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" \n !"); alert.showAndWait(); } } } } }); cbx1.setOnMouseClicked(new EventHandler() { @Override public void handle(Event event) { spb1.getValueFactory().setValue(0); sp1.getValueFactory().setValue(0.0); runJsons(); cbx1.setItems(GetByTag(TAG_NAME, "1")); //cbx1.getSelectionModel().clearSelection(); int[] remove = new int[cbx1.getItems().size()]; for (int i = 0; i < cbx1.getItems().size(); i++) { //System.out.println("****"+m); if (!isHave(cbx1.getItems().get(i).toString(), 1)) { // } else { } } cbx1.show(); } }); sp1.setOnMouseClicked(event -> { if (cbx1.getSelectionModel().getSelectedItem() != null) { double spres = Double.parseDouble(sp1.getEditor().getText().toString().replace(",", ".")); double salesres = balancech(cbx1.getSelectionModel().getSelectedItem().toString(), 1); double balancestore = Double .parseDouble(getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, MT)); // System.out.println(balancestore+" "+spres+" "+salesres); if ((balancestore - (spres + salesres)) >= 0) { } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" \n !"); alert.showAndWait(); sp1.getValueFactory().setValue(0.0); } } }); sp2.setOnMouseClicked(event -> { if (cbx2.getSelectionModel().getSelectedIndex() >= 0) { double spres = Double.parseDouble(sp2.getEditor().getText().toString()); double salesres = balancech(cbx2.getSelectionModel().getSelectedItem().toString(), 2); double balancestore = Double .parseDouble(getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, MT)); if ((balancestore - (spres + salesres)) >= 0) { } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" \n !"); alert.showAndWait(); sp2.getValueFactory().setValue(0); } } }); spb1.setOnMouseClicked(event -> { if (cbx4.getSelectionModel().getSelectedIndex() >= 0) { double spres = Double.parseDouble(spb1.getEditor().getText().toString()); double salesres = balancech(cbx4.getSelectionModel().getSelectedItem().toString(), 4); double balancestore = Double .parseDouble(getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, MT)); if ((balancestore - (spres + salesres)) >= 0) { } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" \n !"); alert.showAndWait(); spb1.getValueFactory().setValue(0); } } }); sp3.setOnMouseClicked(event -> { if (cbx3.getSelectionModel().getSelectedIndex() >= 0) { double spres = Double.parseDouble(sp3.getEditor().getText().toString()); double salesres = balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3); double balancestore = Double .parseDouble(getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT)); if ((balancestore - (spres + salesres)) >= 0) { } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" \n !"); alert.showAndWait(); sp3.getValueFactory().setValue(0); } } }); cbx4.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (observable.getValue() == null) { } else { if (!isHave(cbx4.getSelectionModel().getSelectedItem().toString(), 4)) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText( cbx4.getSelectionModel().getSelectedItem().toString() + " !"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { cbx4.getSelectionModel().clearSelection(); } else { cbx4.getSelectionModel().clearSelection(); } } else { } } } }); cbx1.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (observable.getValue() == null) { } else { if (!isHave(cbx1.getSelectionModel().getSelectedItem().toString(), 1)) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText( cbx1.getSelectionModel().getSelectedItem().toString() + " !"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { sp1.setVisible(false); sp1.getValueFactory().setValue(0.0); lb1.setVisible(false); t1.setVisible(false); cbx4.setVisible(false); spb1.setVisible(false); spb1.getValueFactory().setValue(0); lbb1.setVisible(false); bt1.setVisible(false); cbx1.getSelectionModel().clearSelection(); } else { sp1.setVisible(false); sp1.getValueFactory().setValue(0.0); lb1.setVisible(false); t1.setVisible(false); cbx4.setVisible(false); spb1.setVisible(false); spb1.getValueFactory().setValue(0); lbb1.setVisible(false); bt1.setVisible(false); cbx1.getSelectionModel().clearSelection(); } } else { sp2.setVisible(false); lb2.setVisible(false); t2.setVisible(false); bt2.setVisible(false); sp2.getValueFactory().setValue(0); cbx2.getSelectionModel().clearSelection(); txg3.setVisible(false); sp3.setVisible(false); lb3.setVisible(false); t3.setVisible(false); bt3.setVisible(false); sp3.getValueFactory().setValue(0); cbx3.getSelectionModel().clearSelection(); double curbal = Double.parseDouble( getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, MT)) - balancech(cbx1.getSelectionModel().getSelectedItem().toString(), 1); t1.setText(ost + " " + curbal + " ."); cbx4.setItems(GetByTag(TAG_NAME, "4")); sp1.setVisible(true); lb1.setVisible(true); t1.setVisible(true); cbx4.setVisible(true); spb1.setVisible(true); lbb1.setVisible(true); bt1.setVisible(true); if (cbx1.getSelectionModel().getSelectedItem().toString().matches("")) { sp1.setVisible(false); t1.setVisible(false); lb1.setVisible(false); } } } } }); bt1.setOnAction(event -> { if (cbx1.getSelectionModel().getSelectedItem().toString().matches("")) { if (spb1.getValueFactory().getValue() < 1) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else { double bottlprice = Double.parseDouble( getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "price")); int bottlc = spb1.getValueFactory().getValue(); double bottleitg = bottlc * bottlprice; res.setText(res.getText() + printCh2(cbx4.getSelectionModel().getSelectedItem().toString(), "", bottlc, bottlprice) + "\n"); itog = itog + bottleitg; titg.setText(String.valueOf(itog)); jsores = new JSONObject(); jsores.put(TIP, getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "id")); jsores.put(TCOUNT, bottlc); jsores.put(TRES, bottleitg); jsores.put(TM, m); jsores.put(TSELLER, selid);// ID SimpleDateFormat fff = new SimpleDateFormat("dd.MM.yyyy HH.mm"); jsores.put(TDATE, fff.format(System.currentTimeMillis())); jsores.put(TAG_CHECK, checkcheck()); jsares.add(jsores); sp1.setVisible(!true); lb1.setVisible(!true); t1.setVisible(!true); cbx4.setVisible(!true); spb1.setVisible(!true); lbb1.setVisible(!true); bt1.setVisible(!true); spb1.getValueFactory().setValue(0); sp1.getValueFactory().setValue(0.0); cbx1.getSelectionModel().clearSelection(); cbx4.getSelectionModel().clearSelection(); } } else { if (sp1.getValueFactory().getValue() < 0.5) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (cbx4.getSelectionModel().getSelectedItem() == null) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (spb1.getValueFactory().getValue() < 1) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } /*else if(cbx4.getSelectionModel().getSelectedItem().toString().matches("")){ Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); }*/else { double liters = sp1.getValueFactory().getValue(); double bottlc = spb1.getValueFactory().getValue(); String sb = cbx4.getSelectionModel().getSelectedItem().toString(); double bottlsz = 0; if (sb.contains("0.5") | sb.contains("0,5")) { bottlsz = 0.5; } else if (sb.contains("1.0") | sb.contains("1,0")) { bottlsz = 1.0; } else if (sb.contains("1.5") | sb.contains("1,5")) { bottlsz = 1.5; } else if (sb.contains("2,0") | sb.contains("2.0") | sb.contains("2")) { bottlsz = 2.0; } else if (sb.contains("3,0") | sb.contains("3.0") | sb.contains("3")) { bottlsz = 3.0; } else if (sb.contains("")) { bottlsz = 0.5; } if ((bottlsz * bottlc) == liters) { double price = Double.parseDouble( getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, TAG_PRICE)); String prodn = cbx1.getSelectionModel().getSelectedItem().toString(); double itg = 0; if (getTwotag(prodn, 1, "sales").matches("1")) { if (liters % 3 == 0) { price = ((liters * price) - ((liters / 3) * price)) / liters; itg = liters * price; } else { itg = liters * price; } } else { itg = liters * price; } double bottlprice = 0; if (sp1.isVisible() & !cbx4.getSelectionModel().getSelectedItem().toString().contains("")) { bottlprice = Double.parseDouble( getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "price")); } else if (sp1.isVisible() & cbx4.getSelectionModel().getSelectedItem().toString().contains("")) { bottlprice = 0; } else if (!sp1.isVisible() & cbx4.getSelectionModel().getSelectedItem().toString().contains("")) { bottlprice = 0; } res.setText(res.getText() + printCh2(cbx1.getSelectionModel().getSelectedItem().toString(), "", liters, price) + "\n"); res.setText(res.getText() + printCh2(cbx4.getSelectionModel().getSelectedItem().toString(), "", bottlc, bottlprice) + "\n"); itog += itg; jsores = new JSONObject(); jsores.put(TIP, getTwotag(cbx1.getSelectionModel().getSelectedItem().toString(), 1, "id")); jsores.put(TCOUNT, String.valueOf(liters)); jsores.put(TRES, itg); jsores.put(TM, m); jsores.put(TSELLER, selid);// ID //jsores.put("balance", (balance1.get(cbx1.getSelectionModel().getSelectedIndex()) - coun)); SimpleDateFormat ff = new SimpleDateFormat("dd.MM.yyyy HH.mm"); jsores.put(TDATE, ff.format(System.currentTimeMillis())); //jsores.put("seltype","1"); //jsores.put("dolgid","1"); jsores.put(TAG_CHECK, checkcheck()); jsares.add(jsores); double bottleitg = bottlprice * bottlc; itog = itog + bottleitg; titg.setText(String.valueOf(itog)); jsores = new JSONObject(); jsores.put(TIP, getTwotag(cbx4.getSelectionModel().getSelectedItem().toString(), 4, "id")); jsores.put(TCOUNT, bottlc); jsores.put(TRES, bottleitg); jsores.put(TM, m); jsores.put(TSELLER, selid);// ID //jsores.put("balance", (balanceb.get(cbx4.getSelectionModel().getSelectedIndex()) - counb)); SimpleDateFormat fff = new SimpleDateFormat("dd.MM.yyyy HH.mm"); jsores.put(TDATE, fff.format(System.currentTimeMillis())); //jsores.put("seltype",1); ! //jsores.put("dolgid",1); jsores.put(TAG_CHECK, checkcheck()); jsares.add(jsores); //System.out.println(jsares); sp1.setVisible(!true); lb1.setVisible(!true); t1.setVisible(!true); cbx4.setVisible(!true); spb1.setVisible(!true); lbb1.setVisible(!true); bt1.setVisible(!true); spb1.getValueFactory().setValue(0); sp1.getValueFactory().setValue(0.0); cbx1.getSelectionModel().clearSelection(); cbx4.getSelectionModel().clearSelection(); } else { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } } } }); cbx2.setOnMouseClicked(new EventHandler() { @Override public void handle(Event event) { runJsons(); cbx2.setItems(GetByTag(TAG_NAME, "2")); cbx2.show(); } }); cbx2.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (observable.getValue() == null) { } else { if (!isHave(cbx2.getSelectionModel().getSelectedItem().toString(), 2)) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText( cbx2.getSelectionModel().getSelectedItem().toString() + " !"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { sp2.setVisible(false); sp2.getValueFactory().setValue(0); lb2.setVisible(false); t2.setVisible(false); bt2.setVisible(false); cbx2.getSelectionModel().clearSelection(); } else { sp2.setVisible(false); sp2.getValueFactory().setValue(0); lb2.setVisible(false); t2.setVisible(false); bt2.setVisible(false); cbx2.getSelectionModel().clearSelection(); } } else { txg3.setVisible(false); sp3.setVisible(!true); lb3.setVisible(!true); t3.setVisible(!true); bt3.setVisible(!true); sp3.getValueFactory().setValue(0); cbx3.getSelectionModel().clearSelection(); cbx4.setVisible(!true); sp1.setVisible(!true); lb1.setVisible(!true); t1.setVisible(!true); spb1.setVisible(!true); lbb1.setVisible(!true); bt1.setVisible(!true); sp1.getValueFactory().setValue(0.0); spb1.getValueFactory().setValue(0); cbx1.getSelectionModel().clearSelection(); sp2.setVisible(true); lb2.setVisible(true); t2.setVisible(true); bt2.setVisible(true); sp2.getValueFactory().setValue(0); //System.out.println("////////"+newValue+"/////"); double curbal = Double.parseDouble( getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, MT)) - balancech(cbx2.getSelectionModel().getSelectedItem().toString(), 2); t2.setText(ost + " " + curbal + " ."); } } } }); bt2.setOnAction(event -> { if (sp2.getValueFactory().getValue() < 1) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else { int coun = Integer.parseInt(sp2.getEditor().getText()); double price = Double.parseDouble( getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, TAG_PRICE)); double itg = coun * price; res.setText(res.getText() + printCh2(cbx2.getSelectionModel().getSelectedItem().toString(), "", coun, price) + "\n"); itog = itog + itg; titg.setText(String.valueOf(itog)); jsores = new JSONObject(); jsores.put(TIP, getTwotag(cbx2.getSelectionModel().getSelectedItem().toString(), 2, TAG_ID)); jsores.put(TCOUNT, String.valueOf(coun)); jsores.put(TRES, itg); jsores.put(TM, m); jsores.put(TSELLER, selid);// ID //jsores.put("balance", (balance2.get(cbx2.getSelectionModel().getSelectedIndex()) - coun)); SimpleDateFormat ff = new SimpleDateFormat("dd.MM.yyyy HH.mm"); jsores.put(TDATE, ff.format(System.currentTimeMillis())); //jsores.put("seltype","1"); !!!!!! //jsores.put("dolgid","1"); jsores.put(TAG_CHECK, checkcheck()); jsares.add(jsores); sp2.setVisible(!true); lb2.setVisible(!true); t2.setVisible(!true); bt2.setVisible(!true); sp2.getValueFactory().setValue(0); cbx2.getSelectionModel().clearSelection(); } }); cbx3.setOnMouseClicked(new EventHandler() { @Override public void handle(Event event) { sp3.getValueFactory().setValue(0); runJsons(); cbx3.setItems(GetByTag(TAG_NAME, "3")); cbx3.show(); } }); cbx3.getSelectionModel().selectedItemProperty().addListener(new ChangeListener() { @Override public void changed(ObservableValue observable, Object oldValue, Object newValue) { if (observable.getValue() == null) { } else { if (!isHave(cbx3.getSelectionModel().getSelectedItem().toString(), 3)) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText( cbx3.getSelectionModel().getSelectedItem().toString() + " !"); Optional<ButtonType> result = alert.showAndWait(); if (result.get() == ButtonType.OK) { sp3.setVisible(false); sp3.getValueFactory().setValue(0); lb3.setVisible(false); t3.setVisible(false); bt3.setVisible(false); cbx3.getSelectionModel().clearSelection(); } else { sp3.setVisible(false); sp3.getValueFactory().setValue(0); lb3.setVisible(false); t3.setVisible(false); bt3.setVisible(false); cbx3.getSelectionModel().clearSelection(); } } else { sp1.setVisible(!true); lb1.setVisible(!true); t1.setVisible(!true); cbx4.setVisible(!true); spb1.setVisible(!true); lbb1.setVisible(!true); bt1.setVisible(!true); //spb1.getEditor().setText("0"); //sp1.getEditor().setText("0"); cbx1.getSelectionModel().clearSelection(); sp2.setVisible(!true); lb2.setVisible(!true); t2.setVisible(!true); bt2.setVisible(!true); sp2.getValueFactory().setValue(0); cbx2.getSelectionModel().clearSelection(); sp3.setVisible(true); lb3.setVisible(true); t3.setVisible(true); bt3.setVisible(true); sp3.getValueFactory().setValue(0); if (getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, TAG_ZT) .equals("2")) { double curbal = Double.parseDouble( getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT)) - (balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3)); String pattern = "##0.00"; DecimalFormat decimalFormat = new DecimalFormat(pattern); String format = decimalFormat.format(curbal); t3.setText(ost + " " + format + " ."); lb3.setText(""); sp3.setVisible(false); txg3.setVisible(true); txg3.setText(""); } else { double curbal = Double.parseDouble( getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, MT)) - balancech(cbx3.getSelectionModel().getSelectedItem().toString(), 3); t3.setText(ost + " " + curbal + " ."); lb3.setText(""); txg3.setVisible(false); sp3.setVisible(true); } } } } }); bt3.setOnAction(event -> { int typez = Integer.parseInt(getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, "zt")); if (sp3.isVisible() & sp3.getValueFactory().getValue() < 1) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!"); alert.setContentText(" !"); alert.showAndWait(); } else if (txg3.isVisible() & txg3.getText().equals("")) { Alert alert = new Alert(Alert.AlertType.ERROR); alert.setTitle("!"); alert.setHeaderText("!!"); alert.setContentText(" !"); alert.showAndWait(); } else { double coun = 0; double price = Double.parseDouble( getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, TAG_PRICE)); double itg = 0; double itgcoun = 0; if (lb3.getText().equals("")) { //System.out.println(lb3.getText()); coun = sp3.getValueFactory().getValue(); itg = coun * price; itgcoun = coun; // System.out.println("SPINNER" + coun); res.setText(res.getText() + printCh2(cbx3.getSelectionModel().getSelectedItem().toString(), "", coun, price) + "\n"); } else if (lb3.getText().equals("")) { // System.out.println(lb3.getText()); coun = Double.parseDouble(txg3.getText()); itg = ((price * coun) / 100); // System.out.println("!!!???!!!"+coun+" "+price); res.setText(res.getText() + printCh3(cbx3.getSelectionModel().getSelectedItem().toString(), "", coun, price) + "\n"); itgcoun = (double) coun / 1000; //System.out.println("TEXT" + coun+" "+itgcoun); } String pattern = "##0.0"; DecimalFormat decimalFormat = new DecimalFormat(pattern); String format = decimalFormat.format(itg); itog = itog + itg; titg.setText(String.valueOf(itog)); jsores = new JSONObject(); jsores.put(TIP, getTwotag(cbx3.getSelectionModel().getSelectedItem().toString(), 3, TAG_ID)); jsores.put(TCOUNT, Double.parseDouble(String.valueOf(itgcoun))); jsores.put(TRES, itg); jsores.put(TM, m); jsores.put(TSELLER, selid);// ID //jsores.put("balance", (balance3.get(cbx3.getSelectionModel().getSelectedIndex()) - coun)); SimpleDateFormat ff = new SimpleDateFormat("dd.MM.yyyy HH.mm"); jsores.put(TDATE, ff.format(System.currentTimeMillis())); //jsores.put("seltype","1"); !!!!! //jsores.put("dolgid","1"); jsores.put(TAG_CHECK, checkcheck()); //System.out.println(jsores); jsares.add(jsores); sp3.setVisible(!true); lb3.setVisible(!true); t3.setVisible(!true); bt3.setVisible(!true); sp3.getValueFactory().setValue(0); cbx3.getSelectionModel().clearSelection(); txg3.setVisible(false); // } } }); Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize(); Scene scene = new Scene(grid, sSize.width, sSize.height); primaryStage.setScene(scene); scene.getStylesheets().add(MainA.class.getResource("main.css").toExternalForm()); primaryStage.show(); }
From source file:com.chart.SwingChart.java
/** * Background edition//from w w w. j a v a 2s .co 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:qupath.lib.gui.tma.TMASummaryViewer.java
private Pane createSidePane() { BorderPane pane = new BorderPane(); TabPane tabPane = new TabPane(); kmDisplay = new KaplanMeierDisplay(null, null, null, null); BorderPane paneKaplanMeier = new BorderPane(); paneKaplanMeier.setCenter(kmDisplay.getView()); paneKaplanMeier.setPadding(new Insets(10, 10, 10, 10)); // comboMainMeasurement.prefWidthProperty().bind(paneKaplanMeier.widthProperty()); comboMainMeasurement.setMaxWidth(Double.MAX_VALUE); comboMainMeasurement.setTooltip(new Tooltip("Measurement thresholded to create survival curves etc.")); GridPane kmTop = new GridPane(); kmTop.add(new Label("Score"), 0, 0); kmTop.add(comboMainMeasurement, 1, 0); kmTop.add(new Label("Survival type"), 0, 1); kmTop.add(comboSurvival, 1, 1);/*from w w w .j a v a 2 s .c o m*/ comboSurvival.setTooltip(new Tooltip("Specify overall or recurrence-free survival (if applicable)")); comboSurvival.setMaxWidth(Double.MAX_VALUE); GridPane.setHgrow(comboMainMeasurement, Priority.ALWAYS); GridPane.setHgrow(comboSurvival, Priority.ALWAYS); kmTop.setHgap(5); paneKaplanMeier.setTop(kmTop); // kmDisplay.setOrientation(Orientation.VERTICAL); histogramDisplay = new HistogramDisplay(model, false); comboMainMeasurement.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshCombo(); histogramDisplay.showHistogram(n); updateSurvivalCurves(); }); comboMeasurementMethod.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { histogramDisplay.refreshHistogram(); scatterPane.updateChart(); updateSurvivalCurves(); }); comboSurvival.getSelectionModel().selectedItemProperty().addListener((v, o, n) -> { updateSurvivalCurves(); }); // Create a Tab for showing images BorderPane paneImages = new BorderPane(); CheckBox cbShowOverlay = new CheckBox("Show overlay"); imageAvailability.addListener((c, v, n) -> { if (n == ImageAvailability.OVERLAY_ONLY) cbShowOverlay.setSelected(true); else if (n == ImageAvailability.IMAGE_ONLY) cbShowOverlay.setSelected(false); cbShowOverlay.setDisable(n != ImageAvailability.BOTH); }); ListView<TMAEntry> listImages = new ListView<>(); listImages.setCellFactory(v -> new ImageListCell(cbShowOverlay.selectedProperty(), imageCache)); listImages.widthProperty().addListener((v, o, n) -> listImages.refresh()); listImages.setStyle("-fx-control-inner-background-alt: -fx-control-inner-background ;"); table.getSelectionModel().getSelectedItems().addListener((Change<? extends TreeItem<TMAEntry>> e) -> { List<TMAEntry> entries = new ArrayList<>(); for (TreeItem<TMAEntry> item : e.getList()) { if (item.getChildren().isEmpty()) { if (item.getValue().hasImage() || item.getValue().hasOverlay()) entries.add(item.getValue()); } else { for (TreeItem<TMAEntry> item2 : item.getChildren()) { if (item2.getValue().hasImage() || item2.getValue().hasOverlay()) entries.add(item2.getValue()); } } listImages.getItems().setAll(entries); } }); cbShowOverlay.setAlignment(Pos.CENTER); cbShowOverlay.setMaxWidth(Double.MAX_VALUE); cbShowOverlay.setPadding(new Insets(5, 5, 5, 5)); cbShowOverlay.selectedProperty().addListener((v, o, n) -> listImages.refresh()); paneImages.setCenter(listImages); paneImages.setTop(cbShowOverlay); // Determine visibility based upon whether there are any images to show // Tab tabImages = new Tab("Images", paneImages); ScrollPane scrollPane = new ScrollPane(paneKaplanMeier); scrollPane.setFitToWidth(true); scrollPane.setFitToHeight(true); scrollPane.setVbarPolicy(ScrollBarPolicy.AS_NEEDED); scrollPane.setHbarPolicy(ScrollBarPolicy.AS_NEEDED); Tab tabSurvival = new Tab("Survival", scrollPane); tabPane.getTabs().addAll(new Tab("Table", getCustomizeTablePane()), // tabImages, new Tab("Histogram", histogramDisplay.getPane()), new Tab("Scatterplot", scatterPane.getPane()), tabSurvival); tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE); // if (imageAvailability.get() != ImageAvailability.NONE) // tabPane.getTabs().add(1, tabImages); // // imageAvailability.addListener((c, v, n) -> { // if (n == ImageAvailability.NONE) // tabPane.getTabs().remove(tabImages); // else if (!tabPane.getTabs().contains(tabImages)) // tabPane.getTabs().add(1, tabImages); // }); // tabSurvival.visibleProperty().bind( // Bindings.createBooleanBinding(() -> !survivalColumns.isEmpty(), survivalColumns) // ); pane.setCenter(tabPane); pane.setMinWidth(350); return pane; }
From source file:Main.java
private TitledPane getShowBoundsControls() { ChangeListener<Boolean> cl = new ChangeListener<Boolean>() { @Override/* ww w . j a v a 2s . c o m*/ public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldValue, Boolean newValue) { relayout(); } }; ChangeListener<Boolean> cl2 = new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observableValue, Boolean oldValue, Boolean newValue) { animate(); } }; layoutCbx.selectedProperty().addListener(cl); localCbx.selectedProperty().addListener(cl); parentCbx.selectedProperty().addListener(cl); effectGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) { relayout(); } }); layoutAnimateCbx.selectedProperty().addListener(cl2); localAnimateCbx.selectedProperty().addListener(cl2); parentAnimateCbx.selectedProperty().addListener(cl2); double w = 20.0; double h = 10.0; Rectangle rLayout = new Rectangle(w, h); rLayout.setFill(LAYOUT_BOUNDS_RECT_FILL_COLOR); rLayout.setStrokeWidth(BOUNDS_STROKE_WIDTH); rLayout.setStroke(LAYOUT_BOUNDS_RECT_STROKE_COLOR); Rectangle rLocal = new Rectangle(w, h); rLocal.setFill(LOCAL_BOUNDS_RECT_FILL_COLOR); rLocal.setStrokeWidth(BOUNDS_STROKE_WIDTH); rLocal.setStroke(LOCAL_BOUNDS_RECT_STROKE_COLOR); Rectangle rParent = new Rectangle(w, h); rParent.setFill(PARENT_BOUNDS_RECT_FILL_COLOR); rParent.setStrokeWidth(BOUNDS_STROKE_WIDTH); rParent.setStroke(PARENT_BOUNDS_RECT_STROKE_COLOR); GridPane gp = new GridPane(); gp.addRow(1, rLayout, new Text("Layout Bounds:"), layoutCbx, layoutAnimateCbx); gp.addRow(2, rLocal, new Text("Local Bounds:"), localCbx, localAnimateCbx); gp.addRow(3, rParent, new Text("Parent Bounds:"), parentCbx, parentAnimateCbx); TitledPane titledPane = new TitledPane("Show Bounds", gp); return titledPane; }
From source file:com.chart.SwingChart.java
/** * Set lower and upper limits for an ordinate * @param axis Axis to configure//from w ww . jav a 2 s .c om */ 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(); }