List of usage examples for javafx.scene.layout Pane getChildren
@Override
public ObservableList<Node> getChildren()
From source file:Main.java
@Override public void start(Stage stage) { BorderPane root = new BorderPane(); Pane parentContainer = new Pane(); parentContainer.setPrefSize(500, 500); parentContainer.setPickOnBounds(false); //Pane parent = new Pane(); Group parent = new Group(); boundsLayoutNode = parent;/*from www . j av a2 s .c om*/ //parent.setPrefSize(300, 200); parent.setLayoutX(200); parent.setLayoutY(200); parent.setStyle("-fx-background-color:white;"); parent.getChildren().addAll(new Group(localXAxisGroup, localYAxisGroup), new Group(parentXAxisGroup, parentYAxisGroup), new Group(parentBoundsRect, PARENT_BOUNDS_PATH_CIRCLE), new Group(localBoundsRect, LOCAL_BOUNDS_PATH_CIRCLE), new Group(layoutBoundsRect, LAYOUT_BOUNDS_PATH_CIRCLE), new Group(mainRect)); parentContainer.getChildren().addAll(parent); VBox transformsControls = getTransformationControls(); VBox resultsControls = getResultsControls(); BorderPane nestedPane = new BorderPane(); nestedPane.setCenter(parentContainer); nestedPane.setBottom(resultsControls); //nestedPane.setTop(printDataTextArea); //printDataTextArea.setPrefColumnCount(40); //printDataTextArea.setPrefRowCount(3); root.setCenter(nestedPane); root.setRight(transformsControls); //root.setBottom(resultsControls); //root.setCenter(parentContainer); // Attach event handlers attachEventHandlers(); Scene scene = new Scene(root); //, 600, 400); stage.setScene(scene); stage.setTitle("Bounds of a Node"); Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds(); stage.setX(visualBounds.getMinX()); stage.setY(visualBounds.getMinY()); stage.setWidth(visualBounds.getWidth()); stage.setHeight(visualBounds.getHeight()); stage.show(); // Make sure everything is in sync relayout(); }
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(); }/* w w w .j ava 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.github.drbookings.ui.controller.BookingDetailsController.java
private void addRowNetEarnings(final Pane content, final BookingBean be) { final HBox box = new HBox(); box.setSpacing(boxSpacing);// ww w. j a v a 2s . c om box.setPadding(boxPadding); box.setAlignment(Pos.CENTER_LEFT); box.setFillHeight(true); final TextField grossEarningsExpression = new TextField(be.getGrossEarningsExpression()); grossEarningsExpression.setPrefWidth(prefTextInputFieldWidth * 1.5); booking2GrossEarnings.put(be, grossEarningsExpression); final Text grossEarnings = new Text(decimalFormat.format(be.getGrossEarnings())); final TextFlow tf = new TextFlow(new Text("Gross Earnings: "), grossEarningsExpression, new Text(" = "), grossEarnings, new Text("")); box.getChildren().addAll(tf); if (be.getGrossEarnings() <= 0) { box.getStyleClass().addAll("warning", "warning-bg"); } final HBox box2 = new HBox(); box2.setSpacing(boxSpacing); box2.setPadding(boxPadding); box2.setAlignment(Pos.CENTER_LEFT); box2.setFillHeight(true); Text text = new Text("Amount received: "); TextField textField = new TextField(); textField.setText(new NumberStringConverter().toString(be.getPaymentSoFar())); textField.setEditable(false); be.paymentSoFarProperty().addListener((c, o, n) -> { textField.setText(new NumberStringConverter().toString(n)); }); box2.getChildren().addAll(text, textField); content.getChildren().addAll(box, box2); }
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private void addRow5(final Pane content, final BookingBean be) { final HBox box = new HBox(); box.setPadding(new Insets(4)); box.setFillHeight(true);/* w w w . j a va 2 s . c om*/ final Text text = new Text("Welcome Mail sent: "); final CheckBox checkBox = new CheckBox(); checkBox.setSelected(be.isWelcomeMailSend()); booking2WelcomeMail.put(be, checkBox); final Text t1 = new Text(" \tPayment done: "); final CheckBox cb1 = new CheckBox(); cb1.setSelected(be.isPaymentDone()); //if (logger.isDebugEnabled()) { // logger.debug("DateOfPayment for " + be + "(" + be.hashCode() + ") is " + be.getDateOfPayment()); //} final DatePicker dp = new DatePicker(); dp.setValue(be.getDateOfPayment()); dp.setPrefWidth(140); booking2PaymentDate.put(be, dp); booking2Payment.put(be, cb1); final TextFlow tf = new TextFlow(); tf.getChildren().addAll(text, checkBox, t1, cb1, dp); box.getChildren().add(tf); if (!be.isWelcomeMailSend() || !be.isPaymentDone()) { box.getStyleClass().addAll("warning", "warning-bg"); } else { box.getStyleClass().removeAll("warning", "warning-bg"); } HBox box2 = new HBox(); box2.setPadding(new Insets(4)); box2.setFillHeight(true); TextField newPayment = new TextField(); Button addNewPaymentButton = new Button("Add payment"); addNewPaymentButton.setOnAction(e -> { addNewPayment(newPayment.getText(), be); }); box2.getChildren().addAll(newPayment, addNewPaymentButton); content.getChildren().addAll(box, box2); }
From source file:com.github.drbookings.ui.controller.BookingDetailsController.java
private void addRowFees(final Pane content, final BookingBean be) { final HBox box = new HBox(); // configure box box.setSpacing(8);// w w w . j av a 2s . c om box.setPadding(boxPadding); box.setAlignment(Pos.CENTER); box.setFillHeight(true); // add cleaning fees final TextField cleaningFeesTextField = new TextField(); Bindings.bindBidirectional(cleaningFeesTextField.textProperty(), be.cleaningFeesProperty(), new NumberStringConverter(decimalFormat)); cleaningFeesTextField.setPrefWidth(prefTextInputFieldWidth); final TextFlow cleaningFeesTextFlow = new TextFlow(new Text("Cleaning Fees: "), cleaningFeesTextField, new Text(" ")); box.getChildren().add(cleaningFeesTextFlow); // add cleaning costs final CleaningEntry ce = be.getCleaning(); if (ce != null) { final TextField cleaningCostsTextField = new TextField(); Bindings.bindBidirectional(cleaningCostsTextField.textProperty(), ce.cleaningCostsProperty(), new NumberStringConverter(decimalFormat)); cleaningCostsTextField.setPrefWidth(prefTextInputFieldWidth); final TextFlow cleaningCostsTextFlow = new TextFlow(new Text("Cleaning Costs: "), cleaningCostsTextField, new Text(" ")); box.getChildren().add(cleaningCostsTextFlow); } else { final TextField cleaningCostsTextField = new TextField("No Cleaning"); cleaningCostsTextField.setEditable(false); cleaningCostsTextField.setPrefWidth(prefTextInputFieldWidth); final TextFlow cleaningCostsTextFlow = new TextFlow(new Text("Cleaning Costs: "), cleaningCostsTextField); cleaningCostsTextField.getStyleClass().add("warning"); box.getChildren().add(cleaningCostsTextFlow); } // add service fees final TextField serviceFeesTextField = new TextField(); Bindings.bindBidirectional(serviceFeesTextField.textProperty(), be.serviceFeeProperty(), new NumberStringConverter(decimalFormat)); serviceFeesTextField.setPrefWidth(prefTextInputFieldWidth); final TextFlow serviceFeesAbsTextFlow = new TextFlow(new Text("Service Fees: "), serviceFeesTextField, new Text(" ")); box.getChildren().add(serviceFeesAbsTextFlow); // add service fees percent final TextField serviceFeesPercentTextField = new TextField(); Bindings.bindBidirectional(serviceFeesPercentTextField.textProperty(), be.serviceFeesPercentProperty(), new NumberStringConverter(decimalFormat)); serviceFeesPercentTextField.setPrefWidth(prefTextInputFieldWidth); final TextFlow serviceFeesPercentTextFlow = new TextFlow(new Text("Service Fees: "), serviceFeesPercentTextField, new Text(" %")); box.getChildren().add(serviceFeesPercentTextFlow); // add box to parent content.getChildren().add(box); }
From source file:snpviewer.SnpViewer.java
private void clearSplitPanes() { for (Iterator it = chromSplitPane.getItems().iterator(); it.hasNext();) { Object child = it.next(); if (child instanceof Pane) { Pane p = (Pane) child; for (Iterator pit = p.getChildren().iterator(); pit.hasNext();) { Object pChild = pit.next(); if (pChild instanceof ImageView) { ImageView i = (ImageView) pChild; i.fitHeightProperty().unbind(); i.fitWidthProperty().unbind(); } else if (pChild instanceof Line) { Line l = (Line) pChild; l.startXProperty().unbind(); l.endXProperty().unbind(); l.startYProperty().unbind(); l.endYProperty().unbind(); }// w ww . j ava 2 s .com } p.minWidthProperty().unbind(); p.minHeightProperty().unbind(); } } for (Iterator it = labelSplitPane.getItems().iterator(); it.hasNext();) { Object child = it.next(); if (child instanceof Pane) { Pane p = (Pane) child; p.minWidthProperty().unbind(); p.minHeightProperty().unbind(); } } chromSplitPane.getItems().clear(); labelSplitPane.getItems().clear(); }
From source file:editeurpanovisu.EquiCubeDialogController.java
/** * * @param strTypeTransf/*from w w w . j a va2 s.co m*/ * @throws Exception Exceptions */ public void afficheFenetre(String strTypeTransf) throws Exception { lvListeFichier.getItems().clear(); stTransformations = new Stage(StageStyle.UTILITY); apTransformations = new AnchorPane(); stTransformations.initModality(Modality.APPLICATION_MODAL); stTransformations.setResizable(true); apTransformations.setStyle("-fx-background-color : #ff0000;"); VBox vbFenetre = new VBox(); HBox hbChoix = new HBox(); Pane paneChoixFichier = new Pane(); btnAjouteFichiers = new Button("Ajouter des Fichiers"); paneChoixTypeFichier = new Pane(); Label lblType = new Label("Type des Fichiers de sortie"); rbJpeg = new RadioButton("JPEG (.jpg)"); rbBmp = new RadioButton("BMP (.bmp)"); rbTiff = new RadioButton("TIFF (.tif)"); cbSharpen = new CheckBox("Masque de nettet"); cbSharpen.setSelected(EditeurPanovisu.isbNetteteTransf()); slSharpen = new Slider(0, 2, EditeurPanovisu.getNiveauNetteteTransf()); lblSharpen = new Label(); double lbl = (Math.round(EditeurPanovisu.getNiveauNetteteTransf() * 20.d) / 20.d); lblSharpen.setText(lbl + ""); slSharpen.setDisable(!EditeurPanovisu.isbNetteteTransf()); lblSharpen.setDisable(!EditeurPanovisu.isbNetteteTransf()); Pane paneboutons = new Pane(); btnAnnuler = new Button("Fermer la fentre"); btnValider = new Button("Lancer le traitement"); strTypeTransformation = strTypeTransf; Image imgTransf; if (strTypeTransf.equals(EquiCubeDialogController.EQUI2CUBE)) { stTransformations.setTitle("Transformation d'quirectangulaire en faces de cube"); imgTransf = new Image( "file:" + EditeurPanovisu.getStrRepertAppli() + File.separator + "images/equi2cube.png"); } else { stTransformations.setTitle("Transformation de faces de cube en quirectangulaire"); imgTransf = new Image( "file:" + EditeurPanovisu.getStrRepertAppli() + File.separator + "images/cube2equi.png"); } ImageView ivTypeTransfert = new ImageView(imgTransf); ivTypeTransfert.setLayoutX(35); ivTypeTransfert.setLayoutY(280); paneChoixTypeFichier.getChildren().add(ivTypeTransfert); apTransformations.setPrefHeight(EditeurPanovisu.getHauteurE2C()); apTransformations.setPrefWidth(EditeurPanovisu.getLargeurE2C()); paneChoixFichier.setPrefHeight(350); paneChoixFichier.setPrefWidth(410); paneChoixFichier.setStyle("-fx-background-color: #d0d0d0; -fx-border-color: #bbb;"); paneChoixTypeFichier.setPrefHeight(350); paneChoixTypeFichier.setPrefWidth(180); paneChoixTypeFichier.setStyle("-fx-background-color: #d0d0d0; -fx-border-color: #bbb;"); hbChoix.getChildren().addAll(paneChoixFichier, paneChoixTypeFichier); vbFenetre.setPrefHeight(400); vbFenetre.setPrefWidth(600); apTransformations.getChildren().add(vbFenetre); hbChoix.setPrefHeight(350); hbChoix.setPrefWidth(600); hbChoix.setStyle("-fx-background-color: #d0d0d0;"); paneboutons.setPrefHeight(50); paneboutons.setPrefWidth(600); paneboutons.setStyle("-fx-background-color: #d0d0d0;"); vbFenetre.setStyle("-fx-background-color: #d0d0d0;"); btnAnnuler.setLayoutX(296); btnAnnuler.setLayoutY(10); btnValider.setLayoutX(433); btnValider.setLayoutY(10); lvListeFichier.setPrefHeight(290); lvListeFichier.setPrefWidth(380); lvListeFichier.setEditable(true); lvListeFichier.setLayoutX(14); lvListeFichier.setLayoutY(14); btnAjouteFichiers.setLayoutX(259); btnAjouteFichiers.setLayoutY(319); paneChoixFichier.getChildren().addAll(lvListeFichier, btnAjouteFichiers); if (strTypeTransf.equals(EquiCubeDialogController.EQUI2CUBE)) { lblDragDropE2C = new Label(rbLocalisation.getString("transformation.dragDropE2C")); } else { lblDragDropE2C = new Label(rbLocalisation.getString("transformation.dragDropC2E")); } lblDragDropE2C.setMinHeight(lvListeFichier.getPrefHeight()); lblDragDropE2C.setMaxHeight(lvListeFichier.getPrefHeight()); lblDragDropE2C.setMinWidth(lvListeFichier.getPrefWidth()); lblDragDropE2C.setMaxWidth(lvListeFichier.getPrefWidth()); lblDragDropE2C.setLayoutX(14); lblDragDropE2C.setLayoutY(14); lblDragDropE2C.setAlignment(Pos.CENTER); lblDragDropE2C.setTextFill(Color.web("#c9c7c7")); lblDragDropE2C.setTextAlignment(TextAlignment.CENTER); lblDragDropE2C.setWrapText(true); lblDragDropE2C.setStyle("-fx-font-size : 24px"); lblDragDropE2C.setStyle("-fx-background-color : rgba(128,128,128,0.1)"); paneChoixFichier.getChildren().add(lblDragDropE2C); lblType.setLayoutX(14); lblType.setLayoutY(14); rbBmp.setLayoutX(43); rbBmp.setLayoutY(43); rbBmp.setUserData("bmp"); if (EditeurPanovisu.getStrTypeFichierTransf().equals("bmp")) { rbBmp.setSelected(true); } rbBmp.setToggleGroup(tgTypeFichier); rbJpeg.setLayoutX(43); rbJpeg.setLayoutY(71); rbJpeg.setUserData("jpg"); if (EditeurPanovisu.getStrTypeFichierTransf().equals("jpg")) { rbJpeg.setSelected(true); } rbJpeg.setToggleGroup(tgTypeFichier); if (EditeurPanovisu.getStrTypeFichierTransf().equals("tif")) { rbTiff.setSelected(true); } rbTiff.setLayoutX(43); rbTiff.setLayoutY(99); rbTiff.setToggleGroup(tgTypeFichier); rbTiff.setUserData("tif"); tgTypeFichier.selectedToggleProperty().addListener((ov, old_toggle, new_toggle) -> { EditeurPanovisu.setStrTypeFichierTransf(tgTypeFichier.getSelectedToggle().getUserData().toString()); }); cbSharpen.setLayoutX(43); cbSharpen.setLayoutY(127); cbSharpen.selectedProperty().addListener((ov, old_val, new_val) -> { slSharpen.setDisable(!new_val); lblSharpen.setDisable(!new_val); EditeurPanovisu.setbNetteteTransf(new_val); }); slSharpen.setShowTickMarks(true); slSharpen.setShowTickLabels(true); slSharpen.setMajorTickUnit(0.5f); slSharpen.setMinorTickCount(4); slSharpen.setBlockIncrement(0.05f); slSharpen.setSnapToTicks(true); slSharpen.setLayoutX(23); slSharpen.setLayoutY(157); slSharpen.setTooltip(new Tooltip("Choisissez le niveau d'accentuation de l'image")); slSharpen.valueProperty().addListener((observableValue, oldValue, newValue) -> { if (newValue == null) { lblSharpen.setText(""); return; } DecimalFormat dfArrondi = new DecimalFormat(); dfArrondi.setMaximumFractionDigits(2); //arrondi 2 chiffres apres la virgules dfArrondi.setMinimumFractionDigits(2); dfArrondi.setDecimalSeparatorAlwaysShown(true); lblSharpen.setText(dfArrondi.format(Math.round(newValue.floatValue() * 20.f) / 20.f) + ""); EditeurPanovisu.setNiveauNetteteTransf(newValue.doubleValue()); }); slSharpen.setPrefWidth(120); lblSharpen.setLayoutX(150); lblSharpen.setLayoutY(150); lblSharpen.setMinWidth(30); lblSharpen.setMaxWidth(30); lblSharpen.setTextAlignment(TextAlignment.RIGHT); paneChoixTypeFichier.getChildren().addAll(lblType, rbBmp, rbJpeg, rbTiff, cbSharpen, slSharpen, lblSharpen); pbBarreImage.setLayoutX(40); pbBarreImage.setLayoutY(190); pbBarreImage.setStyle("-fx-accent : #0000bb"); pbBarreImage.setVisible(false); paneChoixTypeFichier.getChildren().add(pbBarreImage); pbBarreAvancement = new ProgressBar(); pbBarreAvancement.setLayoutX(40); pbBarreAvancement.setLayoutY(220); pbBarreImage.setStyle("-fx-accent : #00bb00"); paneChoixTypeFichier.getChildren().add(pbBarreAvancement); pbBarreAvancement.setVisible(false); paneboutons.getChildren().addAll(btnAnnuler, btnValider); vbFenetre.getChildren().addAll(hbChoix, paneboutons); Scene scnTransformations = new Scene(apTransformations); stTransformations.setScene(scnTransformations); stTransformations.show(); btnAnnuler.setOnAction((e) -> { annulerE2C(); }); btnValider.setOnAction((e) -> { if (!bTraitementEffectue) { validerE2C(); } }); btnAjouteFichiers.setOnAction((e) -> { lblTermine.setText(""); fileLstFichier = choixFichiers(); if (fileLstFichier != null) { if (bTraitementEffectue) { lvListeFichier.getItems().clear(); bTraitementEffectue = false; } for (File fileLstFichier1 : fileLstFichier) { String strNomFich = fileLstFichier1.getAbsolutePath(); lvListeFichier.getItems().add(strNomFich); } } }); lvListeFichier.setCellFactory(new Callback<ListView<String>, ListCell<String>>() { @Override public ListCell<String> call(ListView<String> list) { return new ListeTransformationCouleur(); } }); apTransformations.setOnDragOver((event) -> { Dragboard dbFichiersTransformation = event.getDragboard(); if (dbFichiersTransformation.hasFiles()) { event.acceptTransferModes(TransferMode.ANY); } else { event.consume(); } }); stTransformations.widthProperty().addListener((arg0, arg1, arg2) -> { EditeurPanovisu.setLargeurE2C(stTransformations.getWidth()); apTransformations.setPrefWidth(stTransformations.getWidth()); vbFenetre.setPrefWidth(stTransformations.getWidth()); btnAnnuler.setLayoutX(stTransformations.getWidth() - 314); btnValider.setLayoutX(stTransformations.getWidth() - 157); paneChoixFichier.setPrefWidth(stTransformations.getWidth() - 200); lvListeFichier.setPrefWidth(stTransformations.getWidth() - 240); lblDragDropE2C.setMinWidth(lvListeFichier.getPrefWidth()); lblDragDropE2C.setMaxWidth(lvListeFichier.getPrefWidth()); btnAjouteFichiers.setLayoutX(stTransformations.getWidth() - 341); }); stTransformations.heightProperty().addListener((arg0, arg1, arg2) -> { EditeurPanovisu.setHauteurE2C(stTransformations.getHeight()); apTransformations.setPrefHeight(stTransformations.getHeight()); vbFenetre.setPrefHeight(stTransformations.getHeight()); paneChoixFichier.setPrefHeight(stTransformations.getHeight() - 80); hbChoix.setPrefHeight(stTransformations.getHeight() - 80); lvListeFichier.setPrefHeight(stTransformations.getHeight() - 140); lblDragDropE2C.setMinHeight(lvListeFichier.getPrefHeight()); lblDragDropE2C.setMaxHeight(lvListeFichier.getPrefHeight()); btnAjouteFichiers.setLayoutY(stTransformations.getHeight() - 121); }); stTransformations.setWidth(EditeurPanovisu.getLargeurE2C()); stTransformations.setHeight(EditeurPanovisu.getHauteurE2C()); apTransformations.setOnDragDropped((event) -> { Dragboard dbFichiersTransformation = event.getDragboard(); boolean bSucces = false; File[] fileLstFich; fileLstFich = null; if (dbFichiersTransformation.hasFiles()) { lblTermine.setText(""); bSucces = true; String[] stringFichiersPath = new String[200]; int i = 0; for (File file1 : dbFichiersTransformation.getFiles()) { stringFichiersPath[i] = file1.getAbsolutePath(); i++; } int iNb = i; i = 0; boolean bAttention = false; File[] fileLstFich1 = new File[stringFichiersPath.length]; for (int j = 0; j < iNb; j++) { String strNomfich = stringFichiersPath[j]; File fileTransf = new File(strNomfich); String strExtension = strNomfich.substring(strNomfich.lastIndexOf(".") + 1, strNomfich.length()) .toLowerCase(); if (strExtension.equals("bmp") || strExtension.equals("jpg") || strExtension.equals("tif")) { if (i == 0) { strRepertFichier = fileTransf.getParent(); } Image img = null; if (strExtension != "tif") { img = new Image("file:" + fileTransf.getAbsolutePath()); } else { try { img = ReadWriteImage.readTiff(strNomfich); } catch (ImageReadException ex) { Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null, ex); } } if (strTypeTransformation.equals(EquiCubeDialogController.EQUI2CUBE)) { if (img.getWidth() == 2 * img.getHeight()) { fileLstFich1[i] = fileTransf; i++; } else { bAttention = true; } } else { if (img.getWidth() == img.getHeight()) { String strNom = fileTransf.getAbsolutePath().substring(0, fileTransf.getAbsolutePath().length() - 6); boolean bTrouve = false; for (int ik = 0; ik < i; ik++) { String strNom1 = fileLstFich1[ik].getAbsolutePath().substring(0, fileTransf.getAbsolutePath().length() - 6); if (strNom.equals(strNom1)) { bTrouve = true; } } if (!bTrouve) { fileLstFich1[i] = fileTransf; i++; } } else { bAttention = true; } } } } if (bAttention) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle(rbLocalisation.getString("transformation.traiteImages")); alert.setHeaderText(null); alert.setContentText(rbLocalisation.getString("transformation.traiteImagesType")); alert.showAndWait(); } fileLstFichier = new File[i]; System.arraycopy(fileLstFich1, 0, fileLstFichier, 0, i); } if (fileLstFichier != null) { if (bTraitementEffectue) { lvListeFichier.getItems().clear(); bTraitementEffectue = false; } for (File lstFichier1 : fileLstFichier) { String nomFich = lstFichier1.getAbsolutePath(); lvListeFichier.getItems().add(nomFich); } } lblDragDropE2C.setVisible(false); event.setDropCompleted(bSucces); event.consume(); }); }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param lstPano// ww w.ja v a2 s . co m * @param numPano * @return */ public Pane affichageHS(String lstPano, int numPano) { Pane panneauHotSpots = new Pane(); panneauHotSpots.setTranslateY(10); panneauHotSpots.setTranslateX(30); VBox vb1 = new VBox(5); panneauHotSpots.getChildren().add(vb1); Label lblPoint; Label sep = new Label(" "); Label sep1 = new Label(" "); int o; for (o = 0; o < panoramiquesProjet[numPano].getNombreHotspots(); o++) { VBox vbPanneauHS = new VBox(); double deplacement = 20; vbPanneauHS.setLayoutX(deplacement); Pane pannneauHS = new Pane(vbPanneauHS); pannneauHS.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3;"); panneauHotSpots.setId("HS" + o); lblPoint = new Label("Point n" + (o + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.setTranslateX(-deplacement); lblPoint.setStyle("-fx-background-color : #333;"); lblPoint.setTextFill(Color.WHITE); Separator sp = new Separator(Orientation.HORIZONTAL); sp.setTranslateX(-deplacement); sp.setPrefWidth(300); pannneauHS.setPrefWidth(300); pannneauHS.setTranslateX(5); vbPanneauHS.getChildren().addAll(lblPoint, sp); if (lstPano != null) { Label lblLien = new Label("Panoramique de destination"); ComboBox cbDestPano = new ComboBox(); String[] liste = lstPano.split(";"); cbDestPano.getItems().addAll(Arrays.asList(liste)); cbDestPano.valueProperty().addListener(new ChangeListener<String>() { @Override public void changed(ObservableValue ov, String t, String t1) { valideHS(); } }); cbDestPano.setTranslateX(60); cbDestPano.setId("cbpano" + o); String f1XML = panoramiquesProjet[numPano].getHotspot(o).getFichierXML(); if (f1XML != null) { cbDestPano.setValue(f1XML.split("\\.")[0]); } int num = cbDestPano.getSelectionModel().getSelectedIndex(); vbPanneauHS.getChildren().addAll(lblLien, cbDestPano, sep); } Label lblTexteHS = new Label("Texte du Hotspot"); TextArea txtTexteHS = new TextArea(); if (panoramiquesProjet[numPano].getHotspot(o).getInfo() != null) { txtTexteHS.setText(panoramiquesProjet[numPano].getHotspot(o).getInfo()); } txtTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); txtTexteHS.setId("txtHS" + o); txtTexteHS.setPrefSize(200, 25); txtTexteHS.setMaxSize(200, 20); txtTexteHS.setTranslateX(60); CheckBox cbAnime = new CheckBox("HostSpot Anim"); cbAnime.setId("anime" + o); cbAnime.selectedProperty().addListener((final ObservableValue<? extends Boolean> observable, final Boolean oldValue, final Boolean newValue) -> { valideHS(); }); if (panoramiquesProjet[numPano].getHotspot(o).isAnime()) { cbAnime.setSelected(true); } cbAnime.setPadding(new Insets(5)); cbAnime.setTranslateX(60); vbPanneauHS.getChildren().addAll(lblTexteHS, txtTexteHS, cbAnime, sep1); vb1.getChildren().addAll(pannneauHS, sep); } int nbHS = o; for (o = 0; o < panoramiquesProjet[numPano].getNombreHotspotImage(); o++) { VBox vbPanneauHS = new VBox(); Pane pannneauHS = new Pane(vbPanneauHS); pannneauHS.setStyle("-fx-border-color : #777777;-fx-border-width : 1px;-fx-border-radius : 3;"); panneauHotSpots.setId("HSImg" + o); lblPoint = new Label("Image n" + (o + 1)); lblPoint.setPadding(new Insets(5, 10, 5, 5)); lblPoint.setStyle("-fx-background-color : #666;"); lblPoint.setTextFill(Color.WHITE); Separator sp = new Separator(Orientation.HORIZONTAL); sp.setPrefWidth(300); pannneauHS.setPrefWidth(300); pannneauHS.setTranslateX(5); vbPanneauHS.getChildren().addAll(lblPoint, sp); Label lblLien = new Label("Image choisie :"); String f1XML = panoramiquesProjet[numPano].getHotspotImage(o).getLienImg(); ImageView IMChoisie = new ImageView( new Image("file:" + repertTemp + File.separator + "images" + File.separator + f1XML, 100, -1, true, true)); IMChoisie.setTranslateX(100); vbPanneauHS.getChildren().addAll(lblLien, IMChoisie, sep); Label lblTexteHS = new Label("Texte du Hotspot"); TextArea txtTexteHS = new TextArea(); if (panoramiquesProjet[numPano].getHotspotImage(o).getInfo() != null) { txtTexteHS.setText(panoramiquesProjet[numPano].getHotspotImage(o).getInfo()); } txtTexteHS.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { valideHS(); }); txtTexteHS.setId("txtHSImage" + o); txtTexteHS.setPrefSize(200, 25); txtTexteHS.setMaxSize(200, 20); txtTexteHS.setTranslateX(60); CheckBox cbAnime = new CheckBox("HostSpot Anim"); cbAnime.setId("animeImage" + o); cbAnime.selectedProperty().addListener((final ObservableValue<? extends Boolean> observable, final Boolean oldValue, final Boolean newValue) -> { valideHS(); }); if (panoramiquesProjet[numPano].getHotspotImage(o).isAnime()) { cbAnime.setSelected(true); } cbAnime.setPadding(new Insets(5)); cbAnime.setTranslateX(60); vbPanneauHS.getChildren().addAll(lblTexteHS, txtTexteHS, cbAnime, sep1); vb1.getChildren().addAll(pannneauHS, sep); } valideHS(); nbHS += o; // if (nbHS == 0) { // } else { // btnValider.setVisible(true); // } return panneauHotSpots; }
From source file:snpviewer.SnpViewer.java
public void drawCoordinatesWithIterator(final SnpFile sfile, final Pane pane, final String pngPath, final Iterator<SnpFile> sIter, final Iterator<Pane> pIter, final int currentFile, final int totalFiles, final String chrom, final Double start, final Double end, final boolean forceRedraw, final SplitPane splitPane) { Stage stage = (Stage) splitPane.getScene().getWindow(); fixStageSize(stage, true);/*from w w w . j a v a2 s .co m*/ //stage.setResizable(false);//we have to disable this when using windows due to a bug (in javafx?) File pngFile = new File(sfile.getOutputDirectoryName() + "/" + chrom + ".png"); if (pngPath != null && pngPath.length() > 0) { pngFile = new File(sfile.getOutputDirectoryName() + "/" + pngPath + "/" + chrom + ".png"); } if (!forceRedraw && pngFile.exists()) { try { progressBar.progressProperty().unbind(); progressBar.setProgress((double) currentFile / (double) totalFiles); BufferedImage bufferedImage = ImageIO.read(pngFile); Image image = SwingFXUtils.toFXImage(bufferedImage, null); ImageView chromImage = new ImageView(image); //chromImage.setCache(true); pane.getChildren().clear(); pane.getChildren().add(chromImage); //pane.setCache(true); chromImage.fitWidthProperty().bind(pane.widthProperty()); chromImage.fitHeightProperty().bind(pane.heightProperty()); pane.minHeightProperty().bind(splitPane.heightProperty().divide(totalFiles)); pane.minWidthProperty().bind(splitPane.widthProperty()); if (sIter.hasNext()) { SnpFile nextFile = sIter.next(); Pane nextPane = pIter.next(); drawCoordinatesWithIterator(nextFile, nextPane, pngPath, sIter, pIter, currentFile + 1, totalFiles, chrom, start, end, forceRedraw, splitPane); } else { progressBar.progressProperty().unbind(); progressBar.setProgress(0); setProgressMode(false); fixStageSize(stage, false);//for windows only stage.setResizable(true); } } catch (IOException ex) { Dialogs.showErrorDialog(null, "IO error reading cached image", "Error displaying chromosome image", "SnpViewer", ex); return; } } else { final DrawSnpsToPane draw = new DrawSnpsToPane(pane, sfile, chrom, Colors.aa.value, Colors.bb.value, Colors.ab.value, start, end); progressBar.progressProperty().unbind(); //progressBar.setProgress(0); //progressBar.progressProperty().bind(draw.progressProperty()); progressTitle.setText("Drawing " + currentFile + " of " + totalFiles); progressMessage.textProperty().bind(draw.messageProperty()); cancelButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent actionEvent) { draw.cancel(); } }); draw.setOnCancelled(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent t) { progressBar.progressProperty().unbind(); progressBar.setProgress(0); progressTitle.setText("Drawing Cancelled"); progressMessage.textProperty().unbind(); progressMessage.setText("Drawing Cancelled"); setProgressMode(false); selectionOverlayPane.getChildren().clear(); selectionOverlayPane.getChildren().add(dragSelectRectangle); Stage stage = (Stage) splitPane.getScene().getWindow(); stage.setResizable(true); fixStageSize(stage, false);//for windows only } }); draw.setOnSucceeded(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent t) { ArrayList<HashMap<String, Double>> result = (ArrayList<HashMap<String, Double>>) t.getSource() .getValue(); progressBar.progressProperty().unbind(); progressBar.setProgress((double) currentFile / (2 * (double) totalFiles)); progressTitle.setText(""); progressMessage.textProperty().unbind(); progressMessage.setText(""); /*if (pane.getMinHeight() < 200){ pane.setMinHeight(200); } if (pane.getMinWidth() < 800){ pane.setMinWidth(800); }*/ if (result != null) { List<Line> lines = drawLinesToPane(pane, result); pane.getChildren().addAll(lines); pane.setVisible(true); convertSampleViewToImage(sfile, pane, chrom, pngPath); /*for (Line l: lines){ l.startXProperty().unbind(); l.startYProperty().unbind(); l.endXProperty().unbind(); l.endYProperty().unbind(); }*/ lines.clear(); } progressBar.setProgress((double) currentFile / (double) totalFiles); pane.minWidthProperty().bind(splitPane.widthProperty()); pane.minHeightProperty().bind(splitPane.heightProperty().divide(totalFiles)); // pane.setCache(true); if (sIter.hasNext()) { SnpFile nextFile = sIter.next(); Pane nextPane = pIter.next(); drawCoordinatesWithIterator(nextFile, nextPane, pngPath, sIter, pIter, currentFile + 1, totalFiles, chrom, start, end, forceRedraw, splitPane); } else { setProgressMode(false); progressBar.progressProperty().unbind(); progressBar.setProgress(0); Stage stage = (Stage) splitPane.getScene().getWindow(); stage.setResizable(true); fixStageSize(stage, false);//for windows only } } }); draw.setOnFailed(new EventHandler<WorkerStateEvent>() { @Override public void handle(WorkerStateEvent t) { draw.reset(); progressBar.progressProperty().unbind(); progressBar.setProgress(0); progressTitle.setText("ERROR!"); progressMessage.textProperty().unbind(); progressMessage.setText("Drawing failed!"); setProgressMode(false); selectionOverlayPane.getChildren().clear(); selectionOverlayPane.getChildren().add(dragSelectRectangle); // Stage stage = (Stage) chromSplitPane.getScene().getWindow(); // stage.setResizable(true); } }); draw.start(); } }
From source file:editeurpanovisu.EditeurPanovisu.java
/** * * @param primaryStage/* ww w.ja v a 2 s. c om*/ * @param width * @param height * @throws Exception */ private void creeEnvironnement(Stage primaryStage, int width, int height) throws Exception { popUp = new PopUpDialogController(); primaryStage.setMaximized(true); double largeurOutils = 380; hauteurInterface = height; largeurInterface = width; /** * Cration des lments constitutifs de l'cran */ VBox root = new VBox(); creeMenu(root, width); tabPaneEnvironnement = new TabPane(); // tabPaneEnvironnement.setTranslateZ(5); tabPaneEnvironnement.setMinHeight(height - 60); tabPaneEnvironnement.setMaxHeight(height - 60); Pane barreStatus = new Pane(); barreStatus.setPrefSize(width + 20, 30); barreStatus.setTranslateY(25); barreStatus.setStyle("-fx-background-color:#c00;-fx-border-color:#aaa"); tabVisite = new Tab(); Pane visualiseur; Pane panneauPlan; tabInterface = new Tab(); tabPlan = new Tab(); gestionnaireInterface.creeInterface(width, height - 60); visualiseur = gestionnaireInterface.tabInterface; gestionnairePlan.creeInterface(width, height - 60); panneauPlan = gestionnairePlan.tabInterface; tabInterface.setContent(visualiseur); tabPlan.setContent(panneauPlan); HBox hbEnvironnement = new HBox(); TextArea txtTitrePano; TextArea tfTitreVisite; RadioButton radSphere; RadioButton radCube; CheckBox chkAfficheTitre; CheckBox chkAfficheInfo; tabPaneEnvironnement.getTabs().addAll(tabVisite, tabInterface, tabPlan); //tabPaneEnvironnement.setTranslateY(80); tabPaneEnvironnement.setSide(Side.TOP); tabPaneEnvironnement.getSelectionModel().selectedItemProperty() .addListener((ObservableValue<? extends Tab> ov, Tab t, Tab t1) -> { gestionnaireInterface.rafraichit(); }); tabVisite.setText(rb.getString("main.creationVisite")); tabVisite.setClosable(false); tabInterface.setText(rb.getString("main.creationInterface")); tabInterface.setClosable(false); tabPlan.setText(rb.getString("main.tabPlan")); tabPlan.setClosable(false); tabPlan.setDisable(true); tabVisite.setContent(hbEnvironnement); double largeur; String labelStyle = "-fx-color : white;-fx-background-color : #fff;-fx-padding : 5px; -fx-border : 1px solid #777;-fx-width : 100px;-fx-margin : 5px; "; scene = new Scene(root, width, height, Color.rgb(221, 221, 221)); // if (systemeExploitation.indexOf("inux") != -1) { // root.setStyle("-fx-font-size : 7pt;-fx-font-family: sans-serif;"); // } else { root.setStyle("-fx-font-size : 9pt;-fx-font-family: Arial;"); // } panneauOutils = new ScrollPane(); panneauOutils.setId("panOutils"); // panneauOutils.setStyle("-fx-background-color : #ccc;"); outils = new VBox(); paneChoixPanoramique = new VBox(); paneChoixPanoramique.setTranslateX(10); paneChoixPanoramique.setId("choixPanoramique"); Label lblTitreVisite = new Label(rb.getString("main.titreVisite")); lblTitreVisite.setStyle("-fx-font-size : 10pt;-fx-font-weight : bold;"); lblTitreVisite.setPadding(new Insets(15, 5, 5, 0)); lblTitreVisite.setMinWidth(largeurOutils - 20); lblTitreVisite.setAlignment(Pos.CENTER); tfTitreVisite = new TextArea(); tfTitreVisite.setId("titreVisite"); tfTitreVisite.setPrefSize(200, 25); tfTitreVisite.setMaxSize(340, 25); Separator sepTitre = new Separator(Orientation.HORIZONTAL); sepTitre.setMinHeight(10); Label lblChoixPanoramiqueEntree = new Label(rb.getString("main.panoEntree")); lblChoixPanoramiqueEntree.setStyle("-fx-font-size : 10pt;-fx-font-weight : bold;"); lblChoixPanoramiqueEntree.setPadding(new Insets(15, 5, 5, 0)); lblChoixPanoramiqueEntree.setMinWidth(largeurOutils - 20); lblChoixPanoramiqueEntree.setAlignment(Pos.CENTER); lblChoixPanoramique = new Label(rb.getString("main.panoAffiche")); lblChoixPanoramique.setStyle("-fx-font-size : 10pt;-fx-font-weight : bold;"); lblChoixPanoramique.setPadding(new Insets(10, 5, 5, 0)); lblChoixPanoramique.setMinWidth(largeurOutils - 20); lblChoixPanoramique.setAlignment(Pos.CENTER); Separator sepPano = new Separator(Orientation.HORIZONTAL); sepPano.setMinHeight(10); listeChoixPanoramique.setVisibleRowCount(10); listeChoixPanoramique.setTranslateX(60); Pane fond = new Pane(); fond.setCursor(Cursor.HAND); ImageView ivSupprPanoramique = new ImageView( new Image("file:" + repertAppli + File.separator + "images/suppr.png", 30, 30, true, true)); fond.setTranslateX(260); fond.setTranslateY(-40); Tooltip t = new Tooltip(rb.getString("main.supprimePano")); t.setStyle(tooltipStyle); Tooltip.install(fond, t); fond.getChildren().add(ivSupprPanoramique); fond.setOnMouseClicked((MouseEvent me) -> { retirePanoCourant(); }); listeChoixPanoramiqueEntree.setTranslateX(60); Separator sepInfo = new Separator(Orientation.HORIZONTAL); Label lblTitrePano = new Label(rb.getString("main.titrePano")); lblTitrePano.setStyle("-fx-font-size : 10pt;-fx-font-weight : bold;"); lblTitrePano.setPadding(new Insets(5, 5, 5, 0)); lblTitrePano.setMinWidth(largeurOutils - 20); lblTitrePano.setAlignment(Pos.CENTER); txtTitrePano = new TextArea(); txtTitrePano.setId("txttitrepano"); txtTitrePano.setPrefSize(200, 25); txtTitrePano.setMaxSize(340, 25); txtTitrePano.textProperty().addListener((final ObservableValue<? extends String> observable, final String oldValue, final String newValue) -> { clickBtnValidePano(); }); paneChoixPanoramique.getChildren().addAll(lblTitreVisite, tfTitreVisite, lblChoixPanoramiqueEntree, listeChoixPanoramiqueEntree, sepPano, lblChoixPanoramique, listeChoixPanoramique, fond, lblTitrePano, txtTitrePano, sepInfo); paneChoixPanoramique.setSpacing(10); /* modifier pour afficher le panneau des derniers fichiers; */ //outils.getChildren().addAll(lastFiles, paneChoixPanoramique); outils.getChildren().addAll(paneChoixPanoramique); paneChoixPanoramique.setVisible(false); /* Cration du panneau d'info du panoramique */ vuePanoramique = new ScrollPane(); coordonnees = new HBox(); pano = new Pane(); panneau2 = new AnchorPane(); lblLong = new Label(""); lblLat = new Label(""); imagePanoramique = new ImageView(); primaryStage.setScene(scene); //scene.getStylesheets().add("file:css/test.css"); /** * */ vuePanoramique.setPrefSize(width - largeurOutils - 20, height - 130); vuePanoramique.setMaxSize(width - largeurOutils - 20, height - 130); vuePanoramique.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); vuePanoramique.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); vuePanoramique.setTranslateY(5); //vuePanoramique.setStyle("-fx-background-color : #c00;"); /** * */ panneauOutils.setContent(outils); panneauOutils.setVbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); panneauOutils.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); panneauOutils.setPrefSize(largeurOutils, height - 240); panneauOutils.setMaxWidth(largeurOutils); panneauOutils.setMaxHeight(height - 240); panneauOutils.setTranslateY(15); panneauOutils.setTranslateX(20); // panneauOutils.setStyle("-fx-background-color : #ccc;"); /** * */ pano.setCursor(Cursor.CROSSHAIR); outils.setPrefWidth(largeurOutils - 20); // outils.setStyle("-fx-background-color : #ccc;"); outils.minHeight(height - 130); outils.setLayoutX(10); // lblLong.setStyle(labelStyle); // lblLat.setStyle(labelStyle); lblLong.setPrefSize(100, 15); lblLat.setPrefSize(100, 15); lblLat.setTranslateX(50); // panneau2.setStyle("-fx-background-color : #ddd;"); panneau2.setPrefSize(width - largeurOutils - 20, height - 140); imagePanoramique.setCache(true); largeur = largeurMax - 60; imagePanoramique.setFitWidth(largeur); imagePanoramique.setFitHeight(largeur / 2.0d); imagePanoramique.setLayoutX((largeurMax - largeur) / 2.d); pano.getChildren().add(imagePanoramique); pano.setPrefSize(imagePanoramique.getFitWidth(), imagePanoramique.getFitHeight()); pano.setMaxSize(imagePanoramique.getFitWidth(), imagePanoramique.getFitHeight()); pano.setLayoutY(20); lblLong.setTranslateX(50); lblLat.setTranslateX(80); coordonnees.getChildren().setAll(lblLong, lblLat); vuePanoramique.setContent(panneau2); hbEnvironnement.getChildren().setAll(vuePanoramique, panneauOutils); AnchorPane paneEnv = new AnchorPane(); paneAttends = new AnchorPane(); paneAttends.setPrefHeight(250); paneAttends.setPrefWidth(400); paneAttends.setStyle("-fx-background-color : #ccc;" + "-fx-border-color: #666;" + "-fx-border-radius: 5px;" + "-fx-border-width: 1px;"); paneAttends.setLayoutX((width - 400) / 2.d); paneAttends.setLayoutY((height - 250) / 2.d - 55); ProgressIndicator p1 = new ProgressIndicator(); p1.setPrefSize(100, 100); p1.setLayoutX(150); p1.setLayoutY(50); Label lblAttends = new Label(rb.getString("main.attendsChargement")); lblAttends.setMinWidth(400); lblAttends.setAlignment(Pos.CENTER); lblAttends.setLayoutY(20); lblCharge = new Label(); lblCharge.setMinWidth(400); lblCharge.setLayoutY(200); paneAttends.getChildren().addAll(lblAttends, p1, lblCharge); paneAttends.setVisible(false); paneEnv.getChildren().addAll(tabPaneEnvironnement, paneAttends); // paneEnv.getChildren().addAll(tabPaneEnvironnement); root.getChildren().addAll(paneEnv); panneau2.getChildren().setAll(coordonnees, pano); primaryStage.show(); popUp.affichePopup(); lblDragDrop = new Label(rb.getString("main.dragDrop")); lblDragDrop.setMinHeight(vuePanoramique.getPrefHeight()); lblDragDrop.setMaxHeight(vuePanoramique.getPrefHeight()); lblDragDrop.setMinWidth(vuePanoramique.getPrefWidth()); lblDragDrop.setMaxWidth(vuePanoramique.getPrefWidth()); lblDragDrop.setAlignment(Pos.CENTER); lblDragDrop.setTextFill(Color.web("#c9c7c7")); lblDragDrop.setTextAlignment(TextAlignment.CENTER); lblDragDrop.setWrapText(true); lblDragDrop.setStyle("-fx-font-size:72px"); lblDragDrop.setTranslateY(-100); panneau2.getChildren().addAll(lblDragDrop, afficheLegende()); }