diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/AbstractDataView.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/AbstractDataView.java index 16a3e1af..15ebdba5 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/AbstractDataView.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/AbstractDataView.java @@ -49,8 +49,9 @@ public abstract class AbstractDataView extends Canvas { protected BigDecimal[] ticsX; protected BigDecimal[] ticsY; // protected BigDecimal[] ticsYII; - private double displayOffsetY = 0; - private double displayOffsetX = 0; + protected double displayOffsetY = 0; + protected double displayOffsetX = 0; + protected String xAxisLabel; private AbstractDataView() { super(); @@ -108,9 +109,9 @@ public void labelXAxis(String label) { public void showTitle(String title) { Paint savedPaint = getGraphicsContext2D().getFill(); - getGraphicsContext2D().setFont(Font.font("SansSerif", 14)); + getGraphicsContext2D().setFont(Font.font("SansSerif", 10)); getGraphicsContext2D().setFill(Paint.valueOf("RED")); - getGraphicsContext2D().fillText(title, leftMargin + 25, topMargin + 12); + getGraphicsContext2D().fillText(title, leftMargin + 25, topMargin + 7); getGraphicsContext2D().setFill(savedPaint); } diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/GBeamLinePlot.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/GBeamLinePlot.java index 92236a7a..54e5f176 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/GBeamLinePlot.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/GBeamLinePlot.java @@ -80,7 +80,7 @@ public void paint(GraphicsContext g2d) { g2d.beginPath(); g2d.setStroke(Paint.valueOf("Blue")); g2d.setLineDashes(0); - // x = magnetMass y = intensity + // x = magnetMass y = blockIntensities for (int i = 0; i < xMass.length; i++) { g2d.lineTo(mapX(xMass[i]), mapY(yIntensity[i])); diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/HistogramPlot.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/HistogramPlot.java index 4961d447..3ecd0a1d 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/HistogramPlot.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/HistogramPlot.java @@ -45,12 +45,13 @@ public void preparePanel() { minX = xAxisData[0]; maxX = xAxisData[xAxisData.length - 1]; if (histogramBuilder.getHistograms().length > 1) { - // assume only 2 for now - minX = Math.min(minX, histogramBuilder.getHistograms()[1].binCenters()[0]); - maxX = Math.max(maxX, histogramBuilder.getHistograms()[1].binCenters()[histogramBuilder.getHistograms()[1].binCount() - 1]); + for (int histogramIndex = 0; histogramIndex < histogramBuilder.getHistograms().length; histogramIndex++) { + minX = Math.min(minX, histogramBuilder.getHistograms()[histogramIndex].binCenters()[0]); + maxX = Math.max(maxX, histogramBuilder.getHistograms()[histogramIndex].binCenters()[histogramBuilder.getHistograms()[histogramIndex].binCount() - 1]); + } } - double xMarginStretch = TicGeneratorForAxes.generateMarginAdjustment(minX, maxX, 0.05); + double xMarginStretch = TicGeneratorForAxes.generateMarginAdjustment(minX, maxX, 0.25); minX -= xMarginStretch; maxX += xMarginStretch; ticsX = TicGeneratorForAxes.generateTics(minX, maxX, (int) (graphWidth / 40.0)); @@ -64,16 +65,17 @@ public void preparePanel() { maxY = StrictMath.max(maxY, yAxisDatum); } if (histogramBuilder.getHistograms().length > 1) { - // assume only 2 for now - for (double yAxisDatum : histogramBuilder.getHistograms()[1].binCounts()) { - minY = StrictMath.min(minY, yAxisDatum); - maxY = StrictMath.max(maxY, yAxisDatum); + for (int histogramIndex = 0; histogramIndex < histogramBuilder.getHistograms().length; histogramIndex++) { + for (double yAxisDatum : histogramBuilder.getHistograms()[histogramIndex].binCounts()) { + minY = StrictMath.min(minY, yAxisDatum); + maxY = StrictMath.max(maxY, yAxisDatum); + } } } // customized for histogram minY = 0; - ticsY = TicGeneratorForAxes.generateTics(minY, maxY, (int) (graphHeight / 10.0)); + ticsY = TicGeneratorForAxes.generateTics(minY, maxY, (int) (graphHeight / 20.0)); // check for no data if ((ticsY != null) && (ticsY.length > 1)) { @@ -111,11 +113,15 @@ public void paint(GraphicsContext g2d) { if (histogramBuilder.getHistograms().length > 1) { g2d.setFill(Paint.valueOf("GREEN")); - xAxisData = histogramBuilder.getHistograms()[1].binCenters(); - yAxisData = histogramBuilder.getHistograms()[1].binCounts(); - binWidth = histogramBuilder.getHistograms()[1].binWidth(); - doFrameBins = (mapX(xAxisData[1]) - mapX(xAxisData[0])) > 1.0; - plotData(g2d, binWidth, doFrameBins); + + for (int histogramIndex = 0; histogramIndex < histogramBuilder.getHistograms().length; histogramIndex++) { + xAxisData = histogramBuilder.getHistograms()[histogramIndex].binCenters(); + yAxisData = histogramBuilder.getHistograms()[histogramIndex].binCounts(); + binWidth = histogramBuilder.getHistograms()[histogramIndex].binWidth(); + doFrameBins = (mapX(xAxisData[1]) - mapX(xAxisData[0])) > 1.0; + plotData(g2d, binWidth, doFrameBins); + } + xAxisData = histogramBuilder.getHistograms()[0].binCenters(); yAxisData = histogramBuilder.getHistograms()[0].binCounts(); } @@ -143,7 +149,7 @@ public void paint(GraphicsContext g2d) { text.setText(bigDecimal.toString()); textWidth = (int) text.getLayoutBounds().getWidth(); g2d.fillText(text.getText(),// - (float) mapX(minX) - textWidth - 5f, + (float) mapX(minX) - textWidth - 2.5f, (float) mapY(bigDecimal.doubleValue()) + verticalTextShift); // right side @@ -181,7 +187,7 @@ private void plotData(GraphicsContext g2d, double binWidth, boolean doFrameBins) g2d.fillRect( mapX(xAxisData[i] - binWidth / 2.0) + (doFrameBins ? 1.0 : 0.0), mapY(yAxisData[i]), - mapX(xAxisData[1]) - mapX(xAxisData[0]) - (doFrameBins ? 1.0 : 0.0), + mapX(xAxisData[1]) - mapX(xAxisData[0]) - (doFrameBins ? 1.0 : -0.5), mapY(0.0) - mapY(yAxisData[i])); } } diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/MultiLineLinePlot.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/MultiLineLinePlot.java new file mode 100644 index 00000000..00c7b8f5 --- /dev/null +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/MultiLineLinePlot.java @@ -0,0 +1,141 @@ +package org.cirdles.tripoli.gui.dataViews.plots; + +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.paint.Paint; +import javafx.scene.shape.Path; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Font; +import javafx.scene.text.Text; +import org.cirdles.tripoli.visualizationUtilities.linePlots.MultiLinePlotBuilder; + + +public class MultiLineLinePlot extends AbstractDataView { + + private final MultiLinePlotBuilder multiLinePlotBuilder; + private double[][] yData; + + /** + * @param bounds + * @param linePlotBuilder + */ + public MultiLineLinePlot(Rectangle bounds, MultiLinePlotBuilder multiLinePlotBuilder) { + super(bounds, 50, 5); + this.multiLinePlotBuilder = multiLinePlotBuilder; + } + + @Override + public void preparePanel() { + xAxisData = multiLinePlotBuilder.getxData(); + yData = multiLinePlotBuilder.getyData(); + + minX = xAxisData[0]; + maxX = xAxisData[xAxisData.length - 1]; + + ticsX = TicGeneratorForAxes.generateTics(minX, maxX, (int) (graphWidth / 40.0)); + double xMarginStretch = TicGeneratorForAxes.generateMarginAdjustment(minX, maxX, 0.01); + minX -= xMarginStretch; + maxX += xMarginStretch; + + minY = Double.MAX_VALUE; + maxY = -Double.MAX_VALUE; + + for (int i = 0; i < yData.length; i++) { + for (int j = 0; j < yData[i].length; j++) { + minY = StrictMath.min(minY, yData[i][j]); + maxY = StrictMath.max(maxY, yData[i][j]); + } + } + ticsY = TicGeneratorForAxes.generateTics(minY, maxY, (int) (graphHeight / 15.0)); + if ((ticsY != null) && (ticsY.length > 1)) { + // force y to tics + minY = ticsY[0].doubleValue(); + maxY = ticsY[ticsY.length - 1].doubleValue(); + // adjust margins + double yMarginStretch = TicGeneratorForAxes.generateMarginAdjustment(minY, maxY, 0.1); + minY -= yMarginStretch * 2.0; + maxY += yMarginStretch; + } + + setDisplayOffsetY(0.0); + setDisplayOffsetX(0.0); + + this.repaint(); + } + + @Override + public void paint(GraphicsContext g2d) { + super.paint(g2d); + + Text text = new Text(); + text.setFont(Font.font("SansSerif", 12)); + int textWidth = 0; + + showTitle(multiLinePlotBuilder.getTitle()); + + // new line plots + g2d.setLineWidth(1.0); + g2d.setStroke(Paint.valueOf("Black")); + for (int lineIndex = 0; lineIndex < yData.length; lineIndex++) { + g2d.setLineDashes(8); + g2d.beginPath(); + g2d.moveTo(mapX(xAxisData[0]), mapY(yData[lineIndex][0])); + for (int i = 0; i < xAxisData.length; i++) { + // line tracing through points + g2d.lineTo(mapX(xAxisData[i]), mapY(yData[lineIndex][i])); + } + g2d.stroke(); + } + g2d.setLineDashes(0); + + if (ticsY.length > 1) { + // border and fill + g2d.setLineWidth(0.5); + g2d.setStroke(Paint.valueOf("BLACK")); + g2d.strokeRect( + mapX(minX), + mapY(ticsY[ticsY.length - 1].doubleValue()), + graphWidth, + StrictMath.abs(mapY(ticsY[ticsY.length - 1].doubleValue()) - mapY(ticsY[0].doubleValue()))); + + g2d.setFill(Paint.valueOf("BLACK")); + + // ticsY + float verticalTextShift = 3.2f; + g2d.setFont(Font.font("SansSerif", 10)); + if (ticsY != null) { + for (int i = 0; i < ticsY.length; i++) { + g2d.strokeLine( + mapX(minX), mapY(ticsY[i].doubleValue()), mapX(maxX), mapY(ticsY[i].doubleValue())); + + // left side + text.setText(ticsY[i].toString()); + textWidth = (int) text.getLayoutBounds().getWidth(); + g2d.fillText(text.getText(),// + (float) mapX(minX) - textWidth - 5f, + (float) mapY(ticsY[i].doubleValue()) + verticalTextShift); + + } + // ticsX + if (ticsX != null) { + for (int i = 0; i < ticsX.length - 1; i++) { + try { + g2d.strokeLine( + mapX(ticsX[i].doubleValue()), + mapY(ticsY[0].doubleValue()), + mapX(ticsX[i].doubleValue()), + mapY(ticsY[0].doubleValue()) + 5); + + // bottom + String xText = ticsX[i].toPlainString(); + g2d.fillText(xText, + (float) mapX(ticsX[i].doubleValue()) - 5f, + (float) mapY(ticsY[0].doubleValue()) + 15); + + } catch (Exception e) { + } + } + } + } + } + } +} \ No newline at end of file diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/PeakCentresLinePlot.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/PeakCentresLinePlot.java index 3f7f19d0..6bc28eca 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/PeakCentresLinePlot.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/PeakCentresLinePlot.java @@ -86,7 +86,7 @@ public void paint(GraphicsContext g2d) { g2d.beginPath(); g2d.setStroke(Paint.valueOf("Black")); g2d.setLineDashes(0); - // x = magnetMass y = intensity + // x = magnetMass y = blockIntensities for (int i = 0; i < xAxisData.length; i++) { g2d.lineTo(mapX(xAxisData[i]), mapY(yAxisData[i])); @@ -216,4 +216,4 @@ public void handle(MouseEvent mouseEvent) { } } -} +} \ No newline at end of file diff --git a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/RJMCMCPlots/RJMCMCPlotsController.java b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/RJMCMCPlots/RJMCMCPlotsController.java index 8cba61fa..55bbac78 100644 --- a/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/RJMCMCPlots/RJMCMCPlotsController.java +++ b/TripoliApp/src/main/java/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/RJMCMCPlots/RJMCMCPlotsController.java @@ -9,6 +9,8 @@ import javafx.scene.layout.GridPane; import javafx.scene.layout.VBox; import javafx.scene.shape.Rectangle; +import org.cirdles.commons.util.ResourceExtractor; +import org.cirdles.tripoli.Tripoli; import org.cirdles.tripoli.gui.dataViews.plots.*; import org.cirdles.tripoli.sessions.analysis.methods.AnalysisMethod; import org.cirdles.tripoli.sessions.analysis.methods.AnalysisMethodBuiltinFactory; @@ -99,6 +101,9 @@ public class RJMCMCPlotsController { @FXML private Button processFileButton; + @FXML + private Button processFileButton2; + @FXML private ToolBar toolbar; @@ -106,21 +111,25 @@ public class RJMCMCPlotsController { @FXML - void demo1ButtonAction(ActionEvent event) throws IOException { + void demo1_2IsotopeButtonAction(ActionEvent event) throws IOException { processDataFileAndShowPlotsOfRJMCMC( listViewOfSyntheticFiles.getSelectionModel().selectedItemProperty().getValue().toPath(), AnalysisMethodBuiltinFactory.analysisMethodsBuiltinMap.get("BurdickBlSyntheticData")); - + ((Button) event.getSource()).setDisable(true); + processFileButton2.setDisable(true); + } + @FXML + void demo1_5IsotopeButtonAction(ActionEvent event) throws IOException { // Jim's playground for 5 isotopes -// ResourceExtractor RESOURCE_EXTRACTOR= new ResourceExtractor(Tripoli.class); -// Path dataFile = RESOURCE_EXTRACTOR -// .extractResourceAsFile("/org/cirdles/tripoli/dataProcessors/dataSources/synthetic/fiveIsotopeSyntheticData/SyntheticDataset_01R.txt").toPath(); -// processDataFileAndShowPlotsOfRJMCMC( -// dataFile, -// AnalysisMethodBuiltinFactory.analysisMethodsBuiltinMap.get("KU_204_5_6_7_8_Daly_AllFaradayPb")); - + ResourceExtractor RESOURCE_EXTRACTOR = new ResourceExtractor(Tripoli.class); + Path dataFile = RESOURCE_EXTRACTOR + .extractResourceAsFile("/org/cirdles/tripoli/dataProcessors/dataSources/synthetic/fiveIsotopeSyntheticData/SyntheticDataset_01R.txt").toPath(); + processDataFileAndShowPlotsOfRJMCMC( + dataFile, + AnalysisMethodBuiltinFactory.analysisMethodsBuiltinMap.get("KU_204_5_6_7_8_Daly_AllFaradayPb")); ((Button) event.getSource()).setDisable(true); + processFileButton.setDisable(true); } @FXML @@ -159,6 +168,7 @@ void initialize() { populateListOfSyntheticData2IsotopesFiles(); processFileButton.setDisable(listViewOfSyntheticFiles.getItems().isEmpty()); + processFileButton2.setDisable(listViewOfSyntheticFiles.getItems().isEmpty()); } private void populateListOfSyntheticData2IsotopesFiles() { @@ -242,10 +252,10 @@ public void processDataFileAndShowPlotsOfRJMCMC(Path dataFile, AnalysisMethod an (plotTabPane.getHeight() - TAB_HEIGHT) / ensembleGridPane.getRowCount()), (HistogramBuilder) dalyFaradayHistogramBuilder); - AbstractDataView intensityLinePlot = new BasicLinePlot( + AbstractDataView intensityLinePlot = new MultiLineLinePlot( new Rectangle(ensembleGridPane.getWidth(), (plotTabPane.getHeight() - TAB_HEIGHT) / ensembleGridPane.getRowCount()), - (LinePlotBuilder) intensityLinePlotBuilder + (MultiLinePlotBuilder) intensityLinePlotBuilder ); AbstractDataView signalNoiseHistogramPlot = new HistogramPlot( @@ -400,7 +410,7 @@ public void processDataFileAndShowPlotsOfRJMCMC(Path dataFile, AnalysisMethod an intensityLinePlot.preparePanel(); ensembleGridPane.add(intensityLinePlot, 0, 2, 2, 1); signalNoiseHistogramPlot.preparePanel(); - ensembleGridPane.add(signalNoiseHistogramPlot, 0, 4, 2, 1); + ensembleGridPane.add(signalNoiseHistogramPlot, 0, 3, 2, 1); convergeRatioLinePlot.preparePanel(); convergeRatioAnchorPane.getChildren().add(convergeRatioLinePlot); diff --git a/TripoliApp/src/main/resources/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/RJMCMCPlots.fxml b/TripoliApp/src/main/resources/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/RJMCMCPlots.fxml index 2abcea72..0b0f202f 100644 --- a/TripoliApp/src/main/resources/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/RJMCMCPlots.fxml +++ b/TripoliApp/src/main/resources/org/cirdles/tripoli/gui/dataViews/plots/plotsControllers/RJMCMCPlots.fxml @@ -16,12 +16,21 @@ * limitations under the License. --> - - - + + + + + + + + + + + + + + + @@ -31,30 +40,19 @@ - + - - + + - - - - - + + + + -