diff --git a/nb-configuration.xml b/nb-configuration.xml index 80c97dd0..5b0f1f83 100644 --- a/nb-configuration.xml +++ b/nb-configuration.xml @@ -14,6 +14,5 @@ That way multiple projects can share the same settings (useful for formatting ru Any value defined here will override the pom.xml file value but is only applicable to the current project. --> true - JDK_1.8 diff --git a/pom.xml b/pom.xml index 9c2cc736..dbe6fbc4 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ org.cirdles ET_Redux ET_Redux - 3.6.71 + 3.6.72 Successor to U-Pb_Redux https://cirdles.org 2006 diff --git a/src/main/java/org/earthtime/ETReduxFrame.java b/src/main/java/org/earthtime/ETReduxFrame.java index fb07b6b9..73d0be55 100644 --- a/src/main/java/org/earthtime/ETReduxFrame.java +++ b/src/main/java/org/earthtime/ETReduxFrame.java @@ -1603,9 +1603,15 @@ public void updateReportTable(boolean performReduction, boolean inLiveMode, Stri ((SampleDateInterpretationsManager) sampleDateInterpDialog).setSample(theSample); } - try { - ((SampleDateInterpretationsManager) sampleDateInterpDialog).refreshSampleDateInterpretations(false, inLiveMode); - } catch (Exception e) { + + if ((theSample.getSampleAnalysisType().length() == 0) + ||theSample.isAnalysisTypeUSERIES()) { + // oct 2018 problem of time sink involving setselectedrow of tree + } else { + try { + ((SampleDateInterpretationsManager) sampleDateInterpDialog).refreshSampleDateInterpretations(false, inLiveMode); + } catch (Exception e) { + } } } @@ -3660,12 +3666,12 @@ private void manageSampleDateInterpretation(SampleTreeI dateTreeByAliquot, Sampl myPlotAnyPanel = new PlotAny2Panel(theSample, this); myUseriesIsochronPanel = new IsochronsPanel(theSample, this); - if (myEvolutionPlotPanel == null) { + // if (myEvolutionPlotPanel == null) { // myEvolutionPlotPanel = null; myEvolutionPlotPanel = new EvolutionPlotPanelII(theSample, this); // PlaceHolderForJavaFxThread placeHolderForJavaFXThread = new PlaceHolderForJavaFxThread(); // placeHolderForJavaFXThread.runme(); - } + // } theSample.getSampleDateInterpretationGUISettings().// setConcordiaOptions(((ConcordiaPlotDisplayInterface) myConcordiaGraphPanel).getConcordiaOptions()); diff --git a/src/main/java/org/earthtime/UPb_Redux/dateInterpretation/SampleTreeAnalysisMode.java b/src/main/java/org/earthtime/UPb_Redux/dateInterpretation/SampleTreeAnalysisMode.java index 67ddb1cc..496a80ea 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dateInterpretation/SampleTreeAnalysisMode.java +++ b/src/main/java/org/earthtime/UPb_Redux/dateInterpretation/SampleTreeAnalysisMode.java @@ -638,7 +638,7 @@ public void actionPerformed(ActionEvent arg0) { } }); popup.add(menuItem); - + if (sample.getIsotopeSystem().compareToIgnoreCase("UTh") == 0) { menuItem = new JMenuItem("Set Isochrons for this model"); menuItem.addActionListener((ActionEvent arg0) -> { @@ -647,7 +647,7 @@ public void actionPerformed(ActionEvent arg0) { myIsochronDialog.setSize(325, 385); myIsochronDialog.setVisible(true); ((SampleDateModel) nodeInfo).setIsochronModels(((IsochronsSelectorDialog) myIsochronDialog).getSelectedIsochrons()); - + getSampleTreeChange().sampleTreeChangeAnalysisMode(node); }); popup.add(menuItem); diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/sampleDateInterpretationManagers/SampleDateInterpretationsManager.form b/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/sampleDateInterpretationManagers/SampleDateInterpretationsManager.form index 982bfc91..77d4d742 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/sampleDateInterpretationManagers/SampleDateInterpretationsManager.form +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/sampleDateInterpretationManagers/SampleDateInterpretationsManager.form @@ -979,6 +979,13 @@ + + + + + + + @@ -990,6 +997,210 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/sampleDateInterpretationManagers/SampleDateInterpretationsManager.java b/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/sampleDateInterpretationManagers/SampleDateInterpretationsManager.java index 375bb818..3008b12d 100644 --- a/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/sampleDateInterpretationManagers/SampleDateInterpretationsManager.java +++ b/src/main/java/org/earthtime/UPb_Redux/dialogs/sampleManagers/sampleDateInterpretationManagers/SampleDateInterpretationsManager.java @@ -18,9 +18,7 @@ */ package org.earthtime.UPb_Redux.dialogs.sampleManagers.sampleDateInterpretationManagers; -import java.awt.BorderLayout; import java.awt.Component; -import java.awt.Dimension; import java.awt.Frame; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -60,7 +58,6 @@ import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeNode; import org.apache.batik.swing.JSVGCanvas; -import org.earthtime.Tripoli.dataViews.AbstractRawDataView; import org.earthtime.UPb_Redux.beans.ReduxSpinner; import org.earthtime.UPb_Redux.beans.ReduxSuppressComponentEventsI; import org.earthtime.UPb_Redux.customJTrees.CheckBoxNode; @@ -99,8 +96,10 @@ import org.earthtime.plots.PlotAxesSetupInterface; import org.earthtime.plots.PlotInterface; import org.earthtime.plots.anyTwo.PlotAny2Panel; +import org.earthtime.plots.evolution.EvolutionPlotPanelII; import org.earthtime.plots.isochrons.IsochronsPanel; import org.earthtime.plots.isochrons.UseriesIsochronPlotDisplayInterface; +import org.earthtime.plots.isochrons.evolution.IsochronsEvolutionSelectorDialog; import org.earthtime.reduxLabData.ReduxLabData; import org.earthtime.reports.ReportColumnInterface; import org.earthtime.samples.SampleInterface; @@ -495,11 +494,16 @@ private void initUseriesIsochronPanel() { private void initEvolutionPlotPanel() { - // set toolbar choices per options - // Map UIO = sample.getSampleDateInterpretationGUISettings().getuSeriesIsochronOptions(); + evolutionLayeredPane.add(evolutionPlotPanel); - evolutionLayeredPane.setLayout(new BorderLayout()); - evolutionLayeredPane.add(evolutionPlotPanel, BorderLayout.CENTER); + int heightWE = evolutionLayeredPane.getHeight(); + int widthWE = evolutionLayeredPane.getWidth(); + + evolutionToolPanel.setBounds( + 1, + heightWE - 27, + widthWE, + 35); ((AliquotDetailsDisplayInterface) evolutionPlotPanel).// setSelectedFractions(sample.getFractions()); @@ -971,8 +975,7 @@ public void synchronizePanelSizes(PlotAxesSetupInterface currentGraphAxesSetup) } catch (Exception e) { } - evolutionPlotPanel.setPreferredSize(new Dimension(adjustedWidth, adjustedHeight)); - + // evolutionPlotPanel.setPreferredSize(new Dimension(adjustedWidth, adjustedHeight - 400)); ((WeightedMeanGraphPanel) weightedMeanGraphPanel).setGraphWidth(adjustedWidth); ((WeightedMeanGraphPanel) weightedMeanGraphPanel).setGraphHeight(adjustedHeight); @@ -1074,6 +1077,21 @@ private void initializeWeightedMeanOptions( } } + private void selectEvolutionIsochrons() { + DialogEditor myDialog + = new IsochronsEvolutionSelectorDialog( + null, + true, + ((SampleDateModel) sample.getSampleDateModelByName("DEFAULT"))); + myDialog.setSize(340, 625); + myDialog.setVisible(true); + + myDialog.dispose(); + + ((EvolutionPlotPanelII) evolutionPlotPanel).buildIsochronsAndContours(); + evolutionPlotPanel.repaint(); + } + // June 2010 new sections for additional tabs // any 2 ratios plot tab // Revisited for first time in Dec 2016 now that McLeanRegression Library is available @@ -1225,6 +1243,13 @@ private void initComponents() { fractionOrderByRandom_radioButton = new javax.swing.JRadioButton(); fractionOrderByDate_radioButton = new javax.swing.JRadioButton(); evolutionLayeredPane = new javax.swing.JLayeredPane(); + evolutionToolPanel = new javax.swing.JPanel(); + resetEvolution_button = new ET_JButton(); + ellipseCentersEvolutionOnToggle_checkbox = new javax.swing.JCheckBox(); + ellipseLabelsEvolutionOnToggle_checkbox = new javax.swing.JCheckBox(); + zoomBoxEvolution_toggleButton = new ET_JToggleButton(); + showTightEvolution_toggleButton = new ET_JToggleButton(); + isochrons_button = new ET_JButton(); useriesIsochronLayeredPane = new javax.swing.JLayeredPane(); uSeriesIsochronToolPanel = new javax.swing.JPanel(); zoomInX2Isochron_button = new ET_JButton(); @@ -1665,6 +1690,103 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { weightedMeanToolPanel.setBounds(1, 604, 910, 36); graphPanels_TabbedPane.addTab("Weighted Mean", weightedMeanLayeredPane); + + evolutionLayeredPane.setBackground(new java.awt.Color(231, 255, 253)); + evolutionLayeredPane.setName("Evolution"); // NOI18N + evolutionLayeredPane.setOpaque(true); + + evolutionToolPanel.setBackground(new java.awt.Color(231, 255, 253)); + evolutionToolPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); + evolutionToolPanel.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + resetEvolution_button.setBackground(new java.awt.Color(255, 255, 255)); + resetEvolution_button.setFont(new java.awt.Font("SansSerif", 1, 9)); // NOI18N + resetEvolution_button.setText("Reset"); + resetEvolution_button.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + resetEvolution_button.setMargin(new java.awt.Insets(0, 0, 0, 0)); + resetEvolution_button.setOpaque(true); + resetEvolution_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + resetEvolution_buttonActionPerformed(evt); + } + }); + evolutionToolPanel.add(resetEvolution_button, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 2, 35, 30)); + + ellipseCentersEvolutionOnToggle_checkbox.setBackground(new java.awt.Color(231, 255, 253)); + ellipseCentersEvolutionOnToggle_checkbox.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N + ellipseCentersEvolutionOnToggle_checkbox.setSelected(true); + ellipseCentersEvolutionOnToggle_checkbox.setText("Ellipse Centers"); + ellipseCentersEvolutionOnToggle_checkbox.setOpaque(true); + ellipseCentersEvolutionOnToggle_checkbox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + ellipseCentersEvolutionOnToggle_checkboxActionPerformed(evt); + } + }); + evolutionToolPanel.add(ellipseCentersEvolutionOnToggle_checkbox, new org.netbeans.lib.awtextra.AbsoluteConstraints(556, 6, -1, -1)); + + ellipseLabelsEvolutionOnToggle_checkbox.setBackground(new java.awt.Color(231, 255, 253)); + ellipseLabelsEvolutionOnToggle_checkbox.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N + ellipseLabelsEvolutionOnToggle_checkbox.setText("Labels"); + ellipseLabelsEvolutionOnToggle_checkbox.setOpaque(true); + ellipseLabelsEvolutionOnToggle_checkbox.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + ellipseLabelsEvolutionOnToggle_checkboxActionPerformed(evt); + } + }); + evolutionToolPanel.add(ellipseLabelsEvolutionOnToggle_checkbox, new org.netbeans.lib.awtextra.AbsoluteConstraints(685, 6, -1, -1)); + + zoomBoxEvolution_toggleButton.setBackground(new java.awt.Color(255, 255, 255)); + concordiaPanZoom_buttonGroup.add(zoomBoxEvolution_toggleButton); + zoomBoxEvolution_toggleButton.setFont(new java.awt.Font("SansSerif", 1, 9)); // NOI18N + zoomBoxEvolution_toggleButton.setText("Zoom-Box"); + zoomBoxEvolution_toggleButton.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + zoomBoxEvolution_toggleButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); + zoomBoxEvolution_toggleButton.setName("ZOOM"); // NOI18N + zoomBoxEvolution_toggleButton.setOpaque(true); + zoomBoxEvolution_toggleButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + zoomBoxEvolution_toggleButtonActionPerformed(evt); + } + }); + evolutionToolPanel.add(zoomBoxEvolution_toggleButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(95, 2, 55, 30)); + + showTightEvolution_toggleButton.setBackground(new java.awt.Color(255, 255, 255)); + concordiaPanZoom_buttonGroup.add(showTightEvolution_toggleButton); + showTightEvolution_toggleButton.setFont(new java.awt.Font("SansSerif", 1, 9)); // NOI18N + showTightEvolution_toggleButton.setText("Tight"); + showTightEvolution_toggleButton.setToolTipText("Zooms in until ellipses touch borders."); + showTightEvolution_toggleButton.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + showTightEvolution_toggleButton.setContentAreaFilled(false); + showTightEvolution_toggleButton.setMargin(new java.awt.Insets(0, 0, 0, 0)); + showTightEvolution_toggleButton.setName("TIGHT"); // NOI18N + showTightEvolution_toggleButton.setOpaque(true); + showTightEvolution_toggleButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + showTightEvolution_toggleButtonActionPerformed(evt); + } + }); + evolutionToolPanel.add(showTightEvolution_toggleButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 2, 30, 30)); + + isochrons_button.setBackground(new java.awt.Color(255, 255, 255)); + isochrons_button.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N + isochrons_button.setText("Isochrons"); + isochrons_button.setAlignmentY(0.0F); + isochrons_button.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + isochrons_button.setFocusable(false); + isochrons_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); + isochrons_button.setMargin(new java.awt.Insets(0, 0, 0, 0)); + isochrons_button.setOpaque(true); + isochrons_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); + isochrons_button.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + isochrons_buttonActionPerformed(evt); + } + }); + evolutionToolPanel.add(isochrons_button, new org.netbeans.lib.awtextra.AbsoluteConstraints(180, 2, 70, 30)); + + evolutionLayeredPane.add(evolutionToolPanel); + evolutionToolPanel.setBounds(0, 604, 790, 35); + graphPanels_TabbedPane.addTab("Evolution", evolutionLayeredPane); useriesIsochronLayeredPane.setBackground(new java.awt.Color(255, 237, 255)); @@ -2549,8 +2671,8 @@ private void graphPanelsTabbedPaneResized(java.awt.event.ComponentEvent evt) {// } catch (Exception e) { } - evolutionPlotPanel.setBounds(evolutionLayeredPane.getBounds()); - evolutionPlotPanel.setSize(evolutionLayeredPane.getSize()); + // evolutionPlotPanel.setBounds(0,0,evolutionLayeredPane.getWidth(), evolutionLayeredPane.getHeight() - 400); + //evolutionPlotPanel.setSize(evolutionLayeredPane.getSize()); ((org.earthtime.plots.AbstractDataView) evolutionPlotPanel).refreshPanel(true); ((WeightedMeanGraphPanel) weightedMeanGraphPanel).setGraphWidth(adjustedWidth); @@ -3029,6 +3151,34 @@ private void writeVisiblePlotSvgPdf_buttonActionPerformed(java.awt.event.ActionE delegatePlotFileWriting(); }//GEN-LAST:event_writeVisiblePlotSvgPdf_buttonActionPerformed + private void resetEvolution_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetEvolution_buttonActionPerformed + ((EvolutionPlotPanelII) evolutionPlotPanel).showLoose(); + }//GEN-LAST:event_resetEvolution_buttonActionPerformed + + private void ellipseCentersEvolutionOnToggle_checkboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ellipseCentersEvolutionOnToggle_checkboxActionPerformed + ((EvolutionPlotPanelII) evolutionPlotPanel) + .setShowCenters(ellipseCentersEvolutionOnToggle_checkbox.isSelected()); + ((EvolutionPlotPanelII) evolutionPlotPanel).repaint(); + }//GEN-LAST:event_ellipseCentersEvolutionOnToggle_checkboxActionPerformed + + private void ellipseLabelsEvolutionOnToggle_checkboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ellipseLabelsEvolutionOnToggle_checkboxActionPerformed + ((EvolutionPlotPanelII) evolutionPlotPanel) + .setShowLabels(ellipseLabelsEvolutionOnToggle_checkbox.isSelected()); + ((EvolutionPlotPanelII) evolutionPlotPanel).repaint(); + }//GEN-LAST:event_ellipseLabelsEvolutionOnToggle_checkboxActionPerformed + + private void zoomBoxEvolution_toggleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoomBoxEvolution_toggleButtonActionPerformed + ((EvolutionPlotPanelII) evolutionPlotPanel).putInImageModeZoom(); + }//GEN-LAST:event_zoomBoxEvolution_toggleButtonActionPerformed + + private void showTightEvolution_toggleButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showTightEvolution_toggleButtonActionPerformed + ((EvolutionPlotPanelII) evolutionPlotPanel).showTight(); + }//GEN-LAST:event_showTightEvolution_toggleButtonActionPerformed + + private void isochrons_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_isochrons_buttonActionPerformed + selectEvolutionIsochrons(); + }//GEN-LAST:event_isochrons_buttonActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JRadioButton DatePbCorrSchemeA_radio; private javax.swing.JRadioButton ageBest_radio; @@ -3056,12 +3206,15 @@ private void writeVisiblePlotSvgPdf_buttonActionPerformed(java.awt.event.ActionE private javax.swing.JButton defaultFilters_button; private javax.swing.JMenu displayOptions_menu; private javax.swing.JCheckBox ellipseCentersAny2OnToggle_checkbox; + private javax.swing.JCheckBox ellipseCentersEvolutionOnToggle_checkbox; private javax.swing.JCheckBox ellipseCentersIsochron_Checkbox; private javax.swing.JCheckBox ellipseCenters_checkbox; private javax.swing.JCheckBox ellipseLabelsAny2OnToggle_checkbox; + private javax.swing.JCheckBox ellipseLabelsEvolutionOnToggle_checkbox; private javax.swing.JCheckBox ellipseLabelsIsochron_checkbox; private javax.swing.JCheckBox ellipseLabels_checkbox; private javax.swing.JLayeredPane evolutionLayeredPane; + private javax.swing.JPanel evolutionToolPanel; private javax.swing.JRadioButton fractionOrderByDate_radioButton; private javax.swing.JRadioButton fractionOrderByName_radioButton; private javax.swing.JRadioButton fractionOrderByRandom_radioButton; @@ -3070,6 +3223,7 @@ private void writeVisiblePlotSvgPdf_buttonActionPerformed(java.awt.event.ActionE private javax.swing.JMenu heatMap_Menu; private javax.swing.JSpinner histogramBinCount_spinner; private javax.swing.JSplitPane interpretations_SplitPane; + private javax.swing.JButton isochrons_button; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel4; @@ -3091,6 +3245,7 @@ private void writeVisiblePlotSvgPdf_buttonActionPerformed(java.awt.event.ActionE private javax.swing.JPanel probabilityToolPanel; private javax.swing.JCheckBox protactiniumCorrectionSelector_checkbox; private javax.swing.JRadioButton radiumFlavorIsochron_radioButton; + private javax.swing.JButton resetEvolution_button; private javax.swing.JButton resetGraphAny2Display_button; private javax.swing.JButton resetGraphDisplayIsochron_button; private javax.swing.JButton resetGraphDisplay_button; @@ -3108,6 +3263,7 @@ private void writeVisiblePlotSvgPdf_buttonActionPerformed(java.awt.event.ActionE private javax.swing.JCheckBox showRegressionLineIsochron_checkbox; private javax.swing.JCheckBox showRegressionUnctIsochron_checkbox; private javax.swing.JToggleButton showTightAny2_toggleButton; + private javax.swing.JToggleButton showTightEvolution_toggleButton; private javax.swing.JButton showTightGraphProbability_button; private javax.swing.JToggleButton showTightIsochron_toggleButton; private javax.swing.JToggleButton showTight_toggleButton; @@ -3127,6 +3283,7 @@ private void writeVisiblePlotSvgPdf_buttonActionPerformed(java.awt.event.ActionE private javax.swing.JMenu weightedMeansPlotOptions_menu; private javax.swing.JButton writeVisiblePlotSvgPdf_button; private javax.swing.JToggleButton zoomBoxAny2_toggleButton; + private javax.swing.JToggleButton zoomBoxEvolution_toggleButton; private javax.swing.JToggleButton zoomBox_toggleButton; private javax.swing.JToggleButton zoomBox_toggleIsochron_button; private javax.swing.JButton zoomInAny2X2_button; @@ -3264,7 +3421,7 @@ public void sampleTreeChangeAnalysisMode(Object node) { ((AliquotDetailsDisplayInterface) evolutionPlotPanel).// setSelectedFractions(sample.getFractions()); ((AbstractDataView) evolutionPlotPanel).refreshPanel(true); - + // update weighted means in case of delete or (oct 2010) add weightedMeanOptions = sample.getSampleDateInterpretationGUISettings().getWeightedMeanOptions(); ((WeightedMeanGraphPanel) weightedMeanGraphPanel).setWeightedMeanOptions(weightedMeanOptions); @@ -3356,7 +3513,7 @@ public void sampleTreeChangeAnalysisMode(Object node) { setSelectedFractions(((ReduxAliquotInterface) aliquotNodeInfo). getAliquotSampleDateModelSelectedFractions(((SampleDateModel) nodeInfo). getIncludedFractionIDsVector())); - evolutionPlotPanel.repaint(); + ((AbstractDataView) evolutionPlotPanel).refreshPanel(true); // ((AliquotDetailsDisplayInterface) useriesIsochronPanel).// // setDeSelectedFractions(((ReduxAliquotInterface) aliquotNodeInfo).// // getAliquotSampleDateModelDeSelectedFractions(((SampleDateModel) nodeInfo).// @@ -3537,7 +3694,8 @@ public void sampleTreeChangeAnalysisMode(Object node) { setPreferredDatePanel(dateInterpretationBoxPanel); concordiaGraphPanel.repaint(); } else if ((graphPanels_TabbedPane.getSelectedIndex() == graphPanels_TabbedPane.indexOfTab("Any 2")) - || (graphPanels_TabbedPane.getSelectedIndex() == graphPanels_TabbedPane.indexOfTab("USeries Isochrons"))) { + || (graphPanels_TabbedPane.getSelectedIndex() == graphPanels_TabbedPane.indexOfTab("USeries Isochrons")) + || (graphPanels_TabbedPane.getSelectedIndex() == graphPanels_TabbedPane.indexOfTab("Evolution"))) { // dec 2016 ((AliquotDetailsDisplayInterface) plotAny2Panel).// setSelectedFractions(((ReduxAliquotInterface) aliquotNodeInfo).// @@ -3565,14 +3723,22 @@ public void sampleTreeChangeAnalysisMode(Object node) { ((AliquotDetailsDisplayInterface) useriesIsochronPanel).// setDeSelectedFractions(((ReduxAliquotInterface) aliquotNodeInfo).// getAliquotSampleDateModelDeSelectedFractions(((SampleDateModel) sampleDateNodeInfo).getIncludedFractionIDsVector())); + useriesIsochronPanel.repaint(); + ((AliquotDetailsDisplayInterface) evolutionPlotPanel).// + setSelectedFractions(((ReduxAliquotInterface) aliquotNodeInfo).// + getAliquotSampleDateModelSelectedFractions(((SampleDateModel) sampleDateNodeInfo).getIncludedFractionIDsVector())); +// ((AliquotDetailsDisplayInterface) evolutionToolPanel).// +// setDeSelectedFractions(((ReduxAliquotInterface) aliquotNodeInfo).// +// getAliquotSampleDateModelDeSelectedFractions(((SampleDateModel) sampleDateNodeInfo).getIncludedFractionIDsVector())); + ((AbstractDataView) evolutionPlotPanel).refreshPanel(true); + // // fix dateTreeByAliquot // ((DefaultTreeModel) ((JTree) dateTreeByAliquot).getModel()).// // nodeChanged(((TreeNode) node).// // getParent().// // getParent().// // getChildAt(0)); - useriesIsochronPanel.repaint(); } else if (graphPanels_TabbedPane.getSelectedIndex() == graphPanels_TabbedPane.indexOfTab("Weighted Mean")) { @@ -3769,7 +3935,11 @@ private Vector filterActiveUPbFractions(Vector isochronModels; + private boolean automaticIsochronSelection; /** * creates a new instance of SampleDateModel with all of its @@ -192,6 +193,7 @@ public SampleDateModel() { //this.unitsForYears = "Ma"; this.isochronModels = new TreeSet<>(); + this.automaticIsochronSelection = true; } /** @@ -3174,4 +3176,18 @@ public SortedSet getIsochronModels() { public void setIsochronModels(SortedSet isochronModels) { this.isochronModels = isochronModels; } + + /** + * @return the automaticIsochronSelection + */ + public boolean isAutomaticIsochronSelection() { + return automaticIsochronSelection; + } + + /** + * @param automaticIsochronSelection the automaticIsochronSelection to set + */ + public void setAutomaticIsochronSelection(boolean automaticIsochronSelection) { + this.automaticIsochronSelection = automaticIsochronSelection; + } } diff --git a/src/main/java/org/earthtime/UTh_Redux/samples/SampleUTh.java b/src/main/java/org/earthtime/UTh_Redux/samples/SampleUTh.java index 1df956fc..34e1f029 100644 --- a/src/main/java/org/earthtime/UTh_Redux/samples/SampleUTh.java +++ b/src/main/java/org/earthtime/UTh_Redux/samples/SampleUTh.java @@ -539,7 +539,9 @@ public static ValueModel generateDefaultSampleDateModel(){ ValueModel defaultSDM = new SampleDateModel(); defaultSDM.setName("DEFAULT"); - ((SampleDateModel)defaultSDM).setIsochronModels(IsochronModel.generateDefaultEvolutionIsochronModels()); + ((SampleDateModel)defaultSDM).setIsochronModels( + IsochronModel.generateDefaultEvolutionIsochronModels()); + ((SampleDateModel)defaultSDM).setAutomaticIsochronSelection(true); return defaultSDM; } diff --git a/src/main/java/org/earthtime/plots/AbstractDataView.java b/src/main/java/org/earthtime/plots/AbstractDataView.java index c210fea6..5933769c 100644 --- a/src/main/java/org/earthtime/plots/AbstractDataView.java +++ b/src/main/java/org/earthtime/plots/AbstractDataView.java @@ -20,8 +20,10 @@ package org.earthtime.plots; import Jama.Matrix; +import java.awt.AlphaComposite; import java.awt.BasicStroke; import java.awt.Color; +import java.awt.Composite; import java.awt.Cursor; import java.awt.Font; import java.awt.Graphics2D; @@ -58,8 +60,9 @@ */ public abstract class AbstractDataView extends JLayeredPane implements AliquotDetailsDisplayInterface, MouseInputListener, MouseWheelListener { - protected static final double ZOOM_FACTOR = 50.0; + protected static final double ZOOM_FACTOR = 10.0; protected static final int minGraphWidthHeight = 100; + protected static final int maxGraphWidthHeight = 500; protected double width; protected double height; @@ -141,6 +144,11 @@ public abstract class AbstractDataView extends JLayeredPane implements AliquotDe // <0 = zoom out, 0 = original, >0 = zoom in protected int zoomCount; + protected String imageMode; + + protected boolean showCenters; + protected boolean showLabels; + /** * */ @@ -174,6 +182,11 @@ protected AbstractDataView(Rectangle bounds, int leftMargin, int topMargin) { this.zoomCount = 0; + putInImageModePan(); + + this.showCenters = true; + this.showLabels = false; + addMeAsMouseListener(); } @@ -274,6 +287,7 @@ public void refreshPanel(boolean doReset) { /** * + * @param doReset * @param doReScale the value of doReScale * @param inLiveMode the value of inLiveMode */ @@ -288,20 +302,6 @@ protected void drawAxesAndTicks(Graphics2D g2d, double rangeX, double rangeY) { g2d.setPaint(Color.BLACK); g2d.setStroke(new BasicStroke(2.0f)); -// // determine the axis ticks -// BigDecimal[] ticsYaxis = TicGeneratorForAxes.generateTics(getMinY_Display(), getMaxY_Display(), 15); -// -// // forced ticsYaxis here temp for evolution -// ticsYaxis = new BigDecimal[(int) maxY * 4 + 4]; -// for (int i = 0; i < (int) maxY * 4 + 4; i++) { -// ticsYaxis[i] = new BigDecimal(i * (0.25)); -// } - // trap for bad plot - if (ticsYaxis.length <= 1) { - ticsYaxis = new BigDecimal[0]; - } - double minXDisplay = 0.0; - int yAxisTicWidth = 8; int yTicLabelFrequency = 1; int labeledTicCountYAxis = 0; @@ -416,6 +416,71 @@ protected void drawAxesAndTicks(Graphics2D g2d, double rangeX, double rangeY) { g2d.drawRect( leftMargin, topMargin, graphWidth - 1, graphHeight - 1); + + // label axes + String xAxisLabel = "[230Th/238U]t";//axes[0].getAxisLabel(); + g2d.setFont(new Font("Monospaced", Font.BOLD, 18)); + double xAxisLabelLength = calculateLengthOfStringPlot(g2d, xAxisLabel); + + String yAxisLabel = "[234U/238U]t";//axes[1].getAxisLabel(); + double yAxisLabelLength = calculateLengthOfStringPlot(g2d, yAxisLabel); + + g2d.setFont(new Font("Monospaced", Font.BOLD, 12)); + g2d.drawString("230", + leftMargin + (int) (graphWidth / 2.0) - (int) (xAxisLabelLength / 2.0) + 10, + topMargin + (int) graphHeight + 30); + g2d.drawString("238", + leftMargin + (int) (graphWidth / 2.0) - (int) (xAxisLabelLength / 2.0) + 65, + topMargin + (int) graphHeight + 30); + g2d.drawString("t", + leftMargin + (int) (graphWidth / 2.0) - (int) (xAxisLabelLength / 2.0) + 105, + topMargin + (int) graphHeight + 40); + + g2d.setFont(new Font("Monospaced", Font.BOLD, 18)); + g2d.drawString("[", + leftMargin + (int) (graphWidth / 2.0) - (int) (xAxisLabelLength / 2.0), + topMargin + (int) graphHeight + 35); + g2d.drawString("Th/", + leftMargin + (int) (graphWidth / 2.0) - (int) (xAxisLabelLength / 2.0) + 30, + topMargin + (int) graphHeight + 35); + g2d.drawString("U]", + leftMargin + (int) (graphWidth / 2.0) - (int) (xAxisLabelLength / 2.0) + 85, + topMargin + (int) graphHeight + 35); + + // y axis + g2d.rotate(-Math.PI / 2.0); + g2d.setFont(new Font("Monospaced", Font.BOLD, 12)); + g2d.drawString("234", + -(topMargin / 2 + (int) (graphHeight / 2.0) + (int) (yAxisLabelLength / 2.0) - 10), + leftMargin - 30); + g2d.drawString("238", + -(topMargin / 2 + (int) (graphHeight / 2.0) + (int) (yAxisLabelLength / 2.0) - 55), + leftMargin - 30); + g2d.drawString("t", + -(topMargin / 2 + (int) (graphHeight / 2.0) + (int) (yAxisLabelLength / 2.0) - 95), + leftMargin - 20); + + g2d.setFont(new Font("Monospaced", Font.BOLD, 18)); + g2d.drawString("[", + -(topMargin / 2 + (int) (graphHeight / 2.0) + (int) (yAxisLabelLength / 2.0)), + leftMargin - 25); + g2d.drawString("U/", + -(topMargin / 2 + (int) (graphHeight / 2.0) + (int) (yAxisLabelLength / 2.0) - 30), + leftMargin - 25); + g2d.drawString("U]", + -(topMargin / 2 + (int) (graphHeight / 2.0) + (int) (yAxisLabelLength / 2.0) - 75), + leftMargin - 25); + + g2d.rotate(Math.PI / 2.0); + } + + private double calculateLengthOfStringPlot(Graphics2D g2d, String label) { + TextLayout mLayout + = new TextLayout( + label, g2d.getFont(), g2d.getFontRenderContext()); + + Rectangle2D bounds = mLayout.getBounds(); + return bounds.getWidth(); } /** @@ -577,19 +642,45 @@ public void mouseReleased(MouseEvent evt) { int myX = evt.getX(); int myY = evt.getY(); + if (isInImageModeZoom() // + && (zoomMaxX != zoomMinX) //using != provides for legal inverting of zoom box + && (zoomMaxY != zoomMinY)) { + + // may 2010 check for bad zooms + double zMinX = convertMouseXToValue(Math.min(zoomMinX, zoomMaxX)); + double zMinY = convertMouseYToValue(Math.max(zoomMinY, zoomMaxY)); + double zMaxX = convertMouseXToValue(Math.max(zoomMaxX, zoomMinX)); + double zMaxY = convertMouseYToValue(Math.min(zoomMaxY, zoomMinY)); + + if ((zMaxX > zMinX) && (zMaxY > zMinY)) { + minX = zMinX; + minY = zMinY; + maxX = zMaxX; + maxY = zMaxY; + + displayOffsetX = 0.0; + displayOffsetY = 0.0; + + zoomMaxX = zoomMinX; + zoomMaxY = zoomMinY; + + putInImageModePan(); + } + } + if (eastResizing ^ southResizing) { if (eastResizing) { - this.graphWidth = (myX - leftMargin > minGraphWidthHeight) ? myX - leftMargin : minGraphWidthHeight; + this.graphWidth = Math.min(maxGraphWidthHeight, (myX - leftMargin > minGraphWidthHeight) ? myX - leftMargin : minGraphWidthHeight); } else { - this.graphHeight = (myY - topMargin > minGraphWidthHeight) ? myY - topMargin : minGraphWidthHeight; + this.graphHeight = Math.min(maxGraphWidthHeight, (myY - topMargin > minGraphWidthHeight) ? myY - topMargin : minGraphWidthHeight); } - this.setBounds(leftMargin, topMargin, graphWidth, graphHeight); + this.setBounds(0, 0, graphWidth + leftMargin * 2, graphHeight + topMargin * 2); } if (eastResizing && southResizing) { - this.graphWidth = (myX - leftMargin > minGraphWidthHeight) ? myX - leftMargin : minGraphWidthHeight; - this.graphHeight = (myY - topMargin > minGraphWidthHeight) ? myY - topMargin : minGraphWidthHeight; - this.setBounds(leftMargin, topMargin, graphWidth, graphHeight); + this.graphWidth = Math.min(maxGraphWidthHeight, (myX - leftMargin > minGraphWidthHeight) ? myX - leftMargin : minGraphWidthHeight); + this.graphHeight = Math.min(maxGraphWidthHeight, (myY - topMargin > minGraphWidthHeight) ? myY - topMargin : minGraphWidthHeight); + this.setBounds(0, 0, graphWidth + leftMargin * 2, graphHeight + topMargin * 2); } eastResizing = false; @@ -625,18 +716,20 @@ public void mouseDragged(MouseEvent evt) { zoomMaxX = evt.getX(); zoomMaxY = evt.getY(); - // prevent all but upper right quadrant - double calcDisplayOffsetXDelta = convertMouseXToValue(zoomMinX) - convertMouseXToValue(zoomMaxX); - displayOffsetX += (((minX + displayOffsetX + calcDisplayOffsetXDelta) > 0) ? calcDisplayOffsetXDelta : 0.0); + if (isInImageModePan()) { + // prevent all but upper right quadrant + double calcDisplayOffsetXDelta = convertMouseXToValue(zoomMinX) - convertMouseXToValue(zoomMaxX); + displayOffsetX += (((minX + displayOffsetX + calcDisplayOffsetXDelta) > 0) ? calcDisplayOffsetXDelta : 0.0); - double calcDisplayOffsetYDelta = convertMouseYToValue(zoomMinY) - convertMouseYToValue(zoomMaxY); - displayOffsetY += (((minY + displayOffsetY + calcDisplayOffsetYDelta) > 0) ? calcDisplayOffsetYDelta : 0.0); + double calcDisplayOffsetYDelta = convertMouseYToValue(zoomMinY) - convertMouseYToValue(zoomMaxY); + displayOffsetY += (((minY + displayOffsetY + calcDisplayOffsetYDelta) > 0) ? calcDisplayOffsetYDelta : 0.0); - zoomMinX = zoomMaxX; - zoomMinY = zoomMaxY; + zoomMinX = zoomMaxX; + zoomMinY = zoomMaxY; - ticsYaxis = TicGeneratorForAxes.generateTics(getMinY_Display(), getMaxY_Display(), 10); - ticsXaxis = TicGeneratorForAxes.generateTics(getMinX_Display(), getMaxX_Display(), 10); + ticsYaxis = TicGeneratorForAxes.generateTics(getMinY_Display(), getMaxY_Display(), 10); + ticsXaxis = TicGeneratorForAxes.generateTics(getMinX_Display(), getMaxX_Display(), 10); + } repaint(); } @@ -684,7 +777,9 @@ protected void plotAFraction( Color centerColor, float centerSize, String ellipseLabelFont, - String ellipseLabelFontSize) { + String ellipseLabelFontSize, + boolean showCenters, + boolean showLabels) { Path2D ellipse = f.getErrorEllipsePath(); if (svgStyle) { @@ -692,13 +787,20 @@ protected void plotAFraction( } else { // draw ellipse g2d.setStroke(new BasicStroke(borderWeight)); - g2d.setPaint(borderColor); + g2d.setPaint(centerColor); g2d.draw(ellipse); + + Composite originalComposite = g2d.getComposite(); + g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f)); +// g2d.setPaint(fillColor); g2d.fill(ellipse); + //restore composite + g2d.setComposite(originalComposite); +// g2d.fill(ellipse); } // draw ellipse centers - if (true) {// (isShowEllipseCenters()) { + if (showCenters) { float centerXbox = (float) (ellipse.getBounds().x + ellipse.getBounds().width / 2.0 - centerSize / 2.0); float centerYbox = (float) (ellipse.getBounds().y + ellipse.getBounds().height / 2.0 - centerSize / 2.0); @@ -708,12 +810,12 @@ protected void plotAFraction( centerYbox, centerSize, centerSize); - g2d.setPaint(centerColor); + g2d.setPaint(Color.BLACK); g2d.setStroke(new BasicStroke(1.0f)); g2d.fill(fractionbox); } - if (false) {//(isShowEllipseLabels()) { + if (showLabels) { g2d.setPaint(borderColor); g2d.setFont(new Font( ellipseLabelFont, @@ -742,9 +844,9 @@ protected void generateEllipsePathIII( ETFractionInterface f, double ellipseSize) { - ValueModel xAxisRatio = null; - ValueModel yAxisRatio = null; - ValueModel correlationCoefficient = null; + ValueModel xAxisRatio; + ValueModel yAxisRatio; + ValueModel correlationCoefficient; xAxisRatio = f.getLegacyActivityRatioByName(UThAnalysisMeasures.ar230Th_238Ufc.getName()); yAxisRatio = f.getLegacyActivityRatioByName(UThAnalysisMeasures.ar234U_238Ufc.getName()); @@ -846,4 +948,33 @@ public void setShowFilteredEllipses(boolean showFilteredEllipses) { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } + public boolean isInImageModePan() { + return imageMode.compareToIgnoreCase("PAN") == 0; + } + + public boolean isInImageModeZoom() { + return imageMode.compareToIgnoreCase("ZOOM") == 0; + } + + public final void putInImageModePan() { + imageMode = "PAN"; + } + + public void putInImageModeZoom() { + imageMode = "ZOOM"; + } + + /** + * @param showCenters the showCenters to set + */ + public void setShowCenters(boolean showCenters) { + this.showCenters = showCenters; + } + + /** + * @param showLabels the showLabels to set + */ + public void setShowLabels(boolean showLabels) { + this.showLabels = showLabels; + } } diff --git a/src/main/java/org/earthtime/plots/evolution/EvolutionPlotPanelII.java b/src/main/java/org/earthtime/plots/evolution/EvolutionPlotPanelII.java index 4fa958df..6c462879 100644 --- a/src/main/java/org/earthtime/plots/evolution/EvolutionPlotPanelII.java +++ b/src/main/java/org/earthtime/plots/evolution/EvolutionPlotPanelII.java @@ -27,27 +27,45 @@ import java.awt.event.MouseWheelEvent; import java.awt.geom.CubicCurve2D; import java.awt.geom.Path2D; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStreamWriter; +import java.io.UnsupportedEncodingException; +import java.io.Writer; import java.math.BigDecimal; import java.math.RoundingMode; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.SortedSet; import java.util.Vector; +import org.apache.batik.apps.rasterizer.SVGConverter; +import org.apache.batik.apps.rasterizer.SVGConverterException; +import org.apache.batik.dom.GenericDOMImplementation; +import org.apache.batik.svggen.SVGGraphics2D; +import org.apache.batik.svggen.SVGGraphics2DIOException; +import org.earthtime.UPb_Redux.dateInterpretation.concordia.PlottingDetailsDisplayInterface; import org.earthtime.UPb_Redux.valueModels.SampleDateModel; +import org.earthtime.UPb_Redux.valueModels.ValueModel; import org.earthtime.dataDictionaries.UThAnalysisMeasures; import org.earthtime.fractions.ETFractionInterface; import org.earthtime.plots.AbstractDataView; +import org.earthtime.plots.PlotAxesSetupInterface; import org.earthtime.plots.isochrons.IsochronModel; import org.earthtime.reportViews.ReportUpdaterInterface; import org.earthtime.samples.SampleInterface; import org.earthtime.utilities.TicGeneratorForAxes; +import org.w3c.dom.DOMImplementation; +import org.w3c.dom.Document; /** * * @author James F. Bowring */ -public final class EvolutionPlotPanelII extends AbstractDataView { +public final class EvolutionPlotPanelII extends AbstractDataView implements PlottingDetailsDisplayInterface { protected transient ReportUpdaterInterface reportUpdater; @@ -67,12 +85,12 @@ public final class EvolutionPlotPanelII extends AbstractDataView { public EvolutionPlotPanelII(SampleInterface mySample, ReportUpdaterInterface reportUpdater) { super(); - this.leftMargin = 100; - this.topMargin = 100; + this.leftMargin = 50; + this.topMargin = 50; this.graphWidth = 500; this.graphHeight = 500; - this.setBounds(leftMargin, topMargin, graphWidth, graphHeight); + this.setBounds(0, 0, graphWidth + leftMargin * 2, graphHeight + topMargin * 2); setOpaque(true); @@ -93,6 +111,19 @@ public EvolutionPlotPanelII(SampleInterface mySample, ReportUpdaterInterface rep this.xy = new double[0][0][0]; this.dardt = new double[0][0][0]; + this.ticsYaxis = new BigDecimal[0]; + this.ticsXaxis = new BigDecimal[0]; + + this.eastResizing = false; + this.southResizing = false; + + this.zoomCount = 0; + + putInImageModePan(); + + this.showCenters = true; + this.showLabels = false; + addMouseListener(this); addMouseMotionListener(this); addMouseWheelListener(this); @@ -109,9 +140,12 @@ public void paintComponent(Graphics g) { public void paint(Graphics2D g2d, boolean svgStyle) { paintInit(g2d); - g2d.setPaint(Color.black); + //draw component border + g2d.setPaint(Color.blue); + g2d.drawRect(0, 0, (int) graphWidth + leftMargin * 2 - 1, (int) graphHeight + topMargin * 2 - 1); - // draw border + // draw graph border + g2d.setPaint(Color.black); g2d.drawRect(leftMargin, topMargin, (int) graphWidth, (int) graphHeight); // draw isochrons @@ -131,7 +165,8 @@ public void paint(Graphics2D g2d, boolean svgStyle) { mapX(getMaxX_Display()), // mapY(yItercepts[i] + slopes[i] * getMaxX_Display())); - if (i == (annumIsochrons.length - 1)) { + if ((i == (annumIsochrons.length - 1)) + && annumIsochrons[i] >= 10e10) { g2d.setPaint(Color.black); } g2d.draw(isochronLine); @@ -148,7 +183,7 @@ public void paint(Graphics2D g2d, boolean svgStyle) { lowIndex = index; } if (ar48icntrs[index] < getMaxY_Display()) { - highIndex = Math.min(ar48icntrs.length - 1, index + 6 + (zoomCount / 25) * 1); + highIndex = Math.min(ar48icntrs.length - 1, index + 6 + (zoomCount / 10) * 1); } } for (int i = lowIndex; i < highIndex; i++) { @@ -168,11 +203,12 @@ public void paint(Graphics2D g2d, boolean svgStyle) { g2d.draw(ar48iContour); + DecimalFormat myFormatter = new DecimalFormat("#.##"); if (!labelPrinted && (xy[i][0][j - 1] > getMinX_Display()) && (ar48icntrs[i] > 0.0)) { double angleOfText = (Math.atan(xy[i][1][j - 1] - xy[i][1][j]) / (xy[i][0][j - 1] - xy[i][0][j])); // System.out.println(ar48icntrs[i] + " > " + angleOfText); g2d.rotate(-angleOfText, leftMargin + 20, mapY(xy[i][1][j - 1])); - g2d.drawString(String.valueOf(ar48icntrs[i]), leftMargin + 10, (float) mapY(xy[i][1][j - 1]) - 5); + g2d.drawString(myFormatter.format(ar48icntrs[i]), leftMargin + 10, (float) mapY(xy[i][1][j - 1]) - 5); g2d.rotate(angleOfText, leftMargin + 20, mapY(xy[i][1][j - 1])); labelPrinted = true; } @@ -189,19 +225,23 @@ public void paint(Graphics2D g2d, boolean svgStyle) { String ellipseLabelFontSize = "12"; for (ETFractionInterface f : selectedFractions) { - generateEllipsePathIII(// - f, - 2.0f); - if (f.getErrorEllipsePath() != null) { - plotAFraction(g2d, - svgStyle, + if (!f.isRejected()) { + generateEllipsePathIII(// f, - includedBorderColor, - 0.5f, - includedCenterColor, - includedCenterSize, - ellipseLabelFont, - ellipseLabelFontSize); + 2.0f); + if (f.getErrorEllipsePath() != null) { + plotAFraction(g2d, + svgStyle, + f, + includedBorderColor, + 0.5f, + includedCenterColor, + includedCenterSize, + ellipseLabelFont, + ellipseLabelFontSize, + showCenters, + showLabels); + } } } @@ -244,36 +284,53 @@ public void paint(Graphics2D g2d, boolean svgStyle) { (float) mapY(yItercepts[i] + slopes[i] * (labelX))); } } + + // draw zoom box if in use + if (isInImageModeZoom() + && (Math.abs(zoomMaxX - zoomMinX) * Math.abs(zoomMinY - zoomMaxY)) > 0) { + g2d.setStroke(new BasicStroke(2.0f)); + g2d.setColor(Color.red); + g2d.drawRect(// + Math.min(zoomMinX, zoomMaxX), + Math.min(zoomMaxY, zoomMinY), + Math.abs(zoomMaxX - zoomMinX), + Math.abs(zoomMinY - zoomMaxY)); + } } @Override public void preparePanel(boolean doReset) { if (doReset) { - zoomMaxX = 0; - zoomMaxY = 0; - zoomMinX = 0; - zoomMinY = 0; - - displayOffsetX = 0.0; - displayOffsetY = 0.0; removeAll(); - minX = 0.0; - minY = 0.0; - maxX = (xAxisMax == 0) ? 1.5 : xAxisMax; xAxisMax = maxX; maxY = (yAxisMax == 0) ? 2.0 : yAxisMax; yAxisMax = maxY; - // determine default zoom - //todo: fix logic - minX = Double.MAX_VALUE; - maxX = -Double.MAX_VALUE; - minY = Double.MAX_VALUE; - maxY = -Double.MAX_VALUE; - for (ETFractionInterface f : selectedFractions) { + showTight(); + } + + putInImageModePan(); + repaint(); + } + + public void showTight() { + // determine default zoom + zoomMaxX = 0; + zoomMaxY = 0; + zoomMinX = 0; + zoomMinY = 0; + + displayOffsetX = 0.0; + displayOffsetY = 0.0; + minX = Double.MAX_VALUE; + maxX = -Double.MAX_VALUE; + minY = Double.MAX_VALUE; + maxY = -Double.MAX_VALUE; + for (ETFractionInterface f : selectedFractions) { + if (!f.isRejected()) { double xAxisRatio = f.getLegacyActivityRatioByName(UThAnalysisMeasures.ar230Th_238Ufc.getName()).getValue().doubleValue(); double xAxis2Sigma = f.getLegacyActivityRatioByName(UThAnalysisMeasures.ar230Th_238Ufc.getName()).getTwoSigmaAbs().doubleValue(); @@ -285,44 +342,77 @@ public void preparePanel(boolean doReset) { minY = Math.min(minY, yAxisRatio - 2.0 * yAxis2Sigma); maxY = Math.max(maxY, yAxisRatio + 2.0 * yAxis2Sigma); } + } - // maintain 2/1.5 aspect ratio - if (getRangeY_Display() / getRangeX_Display() < 2.0 / 1.5) { - // increase Y - double yDelta = (2.0 / 1.5) * getRangeX_Display() - getRangeY_Display(); - minY -= yDelta / 2.0; - maxY += yDelta / 2.0; + // maintain 2/1.5 aspect ratio + if (getRangeY_Display() / getRangeX_Display() < 2.0 / 1.5) { + // increase Y + double yDelta = (2.0 / 1.5) * getRangeX_Display() - getRangeY_Display(); + minY -= yDelta / 2.0; + maxY += yDelta / 2.0; + + zoomCount = (int) Math.min(10.0, 10.0 / getRangeY_Display()); + } else { + // increase x + double xDelta = (1.5 / 2.0) * getRangeY_Display() - getRangeX_Display(); + minX -= xDelta / 2.0; + maxX += xDelta / 2.0; + + zoomCount = (int) Math.min(10.0, 10.0 / getRangeX_Display()); + } - zoomCount = (int) Math.min(100.0, 10.0 / getRangeY_Display()); - } else { - // increase x - double xDelta = (1.5 / 2.0) * getRangeY_Display() - getRangeX_Display(); - minX -= xDelta / 2.0; - maxX += xDelta / 2.0; + buildIsochronsAndContours(); - zoomCount = (int) Math.min(100.0, 10.0 / getRangeX_Display()); - } + ticsYaxis = TicGeneratorForAxes.generateTics(getMinY_Display(), getMaxY_Display(), 10); + ticsXaxis = TicGeneratorForAxes.generateTics(getMinX_Display(), getMaxX_Display(), 10); - buildIsochronsAndContours(); - repaint(); - validate(); + repaint(); + validate(); - ticsYaxis = TicGeneratorForAxes.generateTics(getMinY_Display(), getMaxY_Display(), 10); - ticsXaxis = TicGeneratorForAxes.generateTics(getMinX_Display(), getMaxX_Display(), 10); - } + } + + public void showLoose() { + // determine default zoom + zoomMaxX = 0; + zoomMaxY = 0; + zoomMinX = 0; + zoomMinY = 0; + + displayOffsetX = 0.0; + displayOffsetY = 0.0; + + zoomCount = 0; + + minX = 0.0; + maxX = 1.5; + xAxisMax = maxX; + + minY = 0.0; + maxY = 2.0; + yAxisMax = maxY; + + buildIsochronsAndContours(); + + ticsYaxis = TicGeneratorForAxes.generateTics(getMinY_Display(), getMaxY_Display(), 10); + ticsXaxis = TicGeneratorForAxes.generateTics(getMinX_Display(), getMaxX_Display(), 10); repaint(); + validate(); } - private void buildIsochronsAndContours() { + public void buildIsochronsAndContours() { // math adapted from Noah's matlab code - - SortedSet selectedIsochrons = ((SampleDateModel) sample.getSampleDateModelByName("DEFAULT")).getIsochronModels(); + ValueModel sampleDateModel = ((SampleDateModel) sample.getSampleDateModelByName("DEFAULT")); + SortedSet selectedIsochrons = ((SampleDateModel) sampleDateModel).getIsochronModels(); List annumList = new ArrayList<>(); Iterator isochronIterator = selectedIsochrons.iterator(); while (isochronIterator.hasNext()) { IsochronModel isochronModel = isochronIterator.next(); - isochronModel.setVisible(isochronModel.getDensityLevel()<= (zoomCount / 25)); + if (((SampleDateModel) sampleDateModel).isAutomaticIsochronSelection()) { + isochronModel.setVisible( + (zoomCount >= 0) ? (isochronModel.getDensityLevel() <= (zoomCount / 4)) + : (isochronModel.getDensityLevel() == 0)); + } if (isochronModel.isVisible()) { annumList.add(isochronModel.getDateInAnnum()); } @@ -339,7 +429,7 @@ private void buildIsochronsAndContours() { // if (zoomCount >= 50) { // annumIsochrons = new double[]{25.0e3, 50.0e3, 75.0e3, 85.0e3, 100.0e3, 115.0e3, 130.0e3, 140.0e3, 150.0e3, 160.0e3, 180.0e3, 200.0e3, 225.0e3, 250.0e3, 275.0e3, 300.0e3, 350.0e3, 400.0e3, 500.0e3, 10e16}; // plotted isochrons // } - int init48Density = (int) Math.pow(2, (2 + zoomCount / 25)); + int init48Density = (int) Math.pow(2, (2 + zoomCount / 10)); ar48icntrs = new double[(int) maxY * init48Density + init48Density + 1]; for (int i = 0; i < ar48icntrs.length; i++) { ar48icntrs[i] = i * (double) (1.0 / (double) init48Density); @@ -574,54 +664,146 @@ public void mouseWheelMoved(MouseWheelEvent e) { zoomMaxX = e.getX(); zoomMaxY = e.getY(); - int notches = e.getWheelRotation(); - if (notches < 0) {// zoom in - minX += getRangeX_Display() / ZOOM_FACTOR; - maxX -= getRangeX_Display() / ZOOM_FACTOR; - minY += getRangeY_Display() / ZOOM_FACTOR; - maxY -= getRangeY_Display() / ZOOM_FACTOR; - - zoomCount++; - - } else {// zoom out - minX -= getRangeX_Display() / ZOOM_FACTOR; - minX = Math.max(minX, 0.0); - - minY -= getRangeY_Display() / ZOOM_FACTOR; - minY = Math.max(minY, 0.0); - - zoomCount--; - // stop zoom out - if (minX * minY > 0.0) { - maxX += getRangeX_Display() / ZOOM_FACTOR; - maxY += getRangeY_Display() / ZOOM_FACTOR; + // https://java.com/en/download/faq/release_changes.xml + double notches = e.getPreciseWheelRotation(); + if (notches == Math.rint(notches)) { + if (notches < 0) {// zoom in + minX += getRangeX_Display() / ZOOM_FACTOR; + maxX -= getRangeX_Display() / ZOOM_FACTOR; + minY += getRangeY_Display() / ZOOM_FACTOR; + maxY -= getRangeY_Display() / ZOOM_FACTOR; + + zoomCount++; + + } else {// zoom out + minX -= getRangeX_Display() / ZOOM_FACTOR; + minX = Math.max(minX, 0.0); + + minY -= getRangeY_Display() / ZOOM_FACTOR; + minY = Math.max(minY, 0.0); + + zoomCount--; + // stop zoom out + if (minX * minY > 0.0) { + maxX += getRangeX_Display() / ZOOM_FACTOR; + maxY += getRangeY_Display() / ZOOM_FACTOR; + + } else { + minX = 0.0; + maxX = xAxisMax; + minY = 0.0; + maxY = yAxisMax; + zoomCount = 0; + } + } - } else { + if (minX <= 0.0) { minX = 0.0; - maxX = xAxisMax; + displayOffsetX = 0.0; + } + if (minY <= 0.0) { minY = 0.0; - maxY = yAxisMax; - zoomCount = 0; + displayOffsetY = 0.0; } - } - if (minX <= 0.0) { - minX = 0.0; - displayOffsetX = 0.0; - } - if (minY <= 0.0) { - minY = 0.0; - displayOffsetY = 0.0; + zoomMinX = zoomMaxX; + zoomMinY = zoomMaxY; + + buildIsochronsAndContours(); + ticsYaxis = TicGeneratorForAxes.generateTics(getMinY_Display(), getMaxY_Display(), 10); + ticsXaxis = TicGeneratorForAxes.generateTics(getMinX_Display(), getMaxX_Display(), 10); + + repaint(); } + } + } + + /** + * + * @param file + */ + public void outputToSVG(File file) { + + // Get a DOMImplementation. + DOMImplementation domImpl + = GenericDOMImplementation.getDOMImplementation(); + + // Create an instance of org.w3c.dom.Document. + String svgNS = "http://www.w3.org/2000/svg"; + Document document = domImpl.createDocument(svgNS, "svg", null); + + // Create an instance of the SVG Generator. + SVGGraphics2D svgGenerator = new SVGGraphics2D(document); + + // Ask the test to render into the SVG Graphics2D implementation. + paint(svgGenerator, false); + + // Finally, stream out SVG to the standard output using + // UTF-8 encoding. + boolean useCSS = true; // we want to use CSS style attributes + + Writer out = null; + try { + out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); + } catch (FileNotFoundException | UnsupportedEncodingException fileNotFoundException) { + } + try { + svgGenerator.stream(out, useCSS); + } catch (SVGGraphics2DIOException sVGGraphics2DIOException) { + } + } + + /** + * + * @param file + */ + public void outputToPDF(File file) { + SVGConverter myConv = new SVGConverter(); + myConv.setDestinationType(org.apache.batik.apps.rasterizer.DestinationType.PDF); + try { + myConv.setSources(new String[]{file.getCanonicalPath()}); - zoomMinX = zoomMaxX; - zoomMinY = zoomMaxY; + } catch (IOException iOException) { + } + myConv.setWidth((float) getWidth() + 2); + myConv.setHeight((float) getHeight() + 2); - buildIsochronsAndContours(); - ticsYaxis = TicGeneratorForAxes.generateTics(getMinY_Display(), getMaxY_Display(), 10); - ticsXaxis = TicGeneratorForAxes.generateTics(getMinX_Display(), getMaxX_Display(), 10); + try { + myConv.execute(); - repaint(); + } catch (SVGConverterException sVGConverterException) { + System.out.println("Error in pdf conversion: " + sVGConverterException.getMessage()); } + + } + + @Override + public void preparePanel(boolean doReScale, boolean inLiveMode) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void refreshPanel(boolean doReScale, boolean inLiveMode) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void resetPanel(boolean doReScale, boolean inLiveMode) { + refreshPanel(doReScale); + } + + @Override + public void setShowTightToEdges(boolean showTightToEdges) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void performZoom(double factor) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public PlotAxesSetupInterface getCurrentPlotAxesSetup() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } } diff --git a/src/main/java/org/earthtime/plots/isochrons/IsochronModel.java b/src/main/java/org/earthtime/plots/isochrons/IsochronModel.java index e70ed00e..40267e98 100644 --- a/src/main/java/org/earthtime/plots/isochrons/IsochronModel.java +++ b/src/main/java/org/earthtime/plots/isochrons/IsochronModel.java @@ -99,6 +99,23 @@ public String prettyPrintI() { String retVal = new BigDecimal(dateInAnnum) .movePointRight(ReduxConstants.getUnitConversionMoveCount(units)) .setScale(0).toPlainString() + " " + units; + + if (dateInAnnum >= 10e10){ + retVal = " \u221E" + " " + units; + } + + return retVal; + } + + public String prettyPrintINoUnits() { + String retVal = new BigDecimal(dateInAnnum) + .movePointRight(ReduxConstants.getUnitConversionMoveCount(units)) + .setScale(0).toPlainString(); + + if (dateInAnnum >= 10e10){ + retVal = " \u221E" + " " + units; + } + return retVal; } diff --git a/src/main/java/org/earthtime/plots/isochrons/evolution/IsochronsEvolutionSelectorDialog.form b/src/main/java/org/earthtime/plots/isochrons/evolution/IsochronsEvolutionSelectorDialog.form index 3e0375d8..a66c463b 100644 --- a/src/main/java/org/earthtime/plots/isochrons/evolution/IsochronsEvolutionSelectorDialog.form +++ b/src/main/java/org/earthtime/plots/isochrons/evolution/IsochronsEvolutionSelectorDialog.form @@ -3,7 +3,7 @@
- + @@ -49,7 +49,7 @@ - + @@ -78,7 +78,7 @@ - + @@ -122,48 +122,72 @@ - + + - + - + + - + - + - - - - - - - - - + + + + + + + + + + + + + + + - + - + + + + + + + + + + + + + + + + + - + diff --git a/src/main/java/org/earthtime/plots/isochrons/evolution/IsochronsEvolutionSelectorDialog.java b/src/main/java/org/earthtime/plots/isochrons/evolution/IsochronsEvolutionSelectorDialog.java index 715e7a9d..964ce9db 100644 --- a/src/main/java/org/earthtime/plots/isochrons/evolution/IsochronsEvolutionSelectorDialog.java +++ b/src/main/java/org/earthtime/plots/isochrons/evolution/IsochronsEvolutionSelectorDialog.java @@ -18,8 +18,6 @@ */ package org.earthtime.plots.isochrons.evolution; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; @@ -31,6 +29,10 @@ import javax.swing.JList; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import org.earthtime.UPb_Redux.valueModels.SampleDateModel; +import org.earthtime.UPb_Redux.valueModels.ValueModel; import org.earthtime.beans.ET_JButton; import org.earthtime.dialogs.DialogEditor; import org.earthtime.plots.isochrons.IsochronModel; @@ -43,67 +45,57 @@ public class IsochronsEvolutionSelectorDialog extends DialogEditor { // Fields + private final ValueModel sampleDateModel; private SortedSet selectedIsochrons; private CheckBoxList isochronCheckBoxes; + private final boolean automaticIsochronSelection; /** * Creates new form IsochronsSelectorDialog * * @param parent * @param modal + * @param sampleDateModel * @param selectedIsochrons */ public IsochronsEvolutionSelectorDialog(// java.awt.Frame parent, boolean modal, - SortedSet selectedIsochrons) { + ValueModel sampleDateModel) { super(parent, modal); - this.selectedIsochrons = selectedIsochrons; + this.sampleDateModel = sampleDateModel; + this.selectedIsochrons = ((SampleDateModel) sampleDateModel).getIsochronModels(); if (this.selectedIsochrons == null) { this.selectedIsochrons = new TreeSet<>(); } - - initComponents(); - isochronCheckBoxes = new CheckBoxList(); - isochronsLayeredPane.add(isochronCheckBoxes); + this.automaticIsochronSelection + = ((SampleDateModel) sampleDateModel).isAutomaticIsochronSelection(); - initLists(); + initComponents(); + initLists(); } - private class IsochronModelList extends AbstractListModel { - - List isochronModels; - - public IsochronModelList() { - isochronModels = new ArrayList<>(); - } - - @Override - public int getSize() { - return isochronModels.size(); - } - - @Override - public IsochronModel getElementAt(int index) { - return isochronModels.get(index); - } - - public void addElement(IsochronModel im) { - isochronModels.add(im); - Collections.sort(isochronModels); + private void initLists() { + try { + isochronsLayeredPane.remove(isochronCheckBoxes); + } catch (Exception e) { } + isochronCheckBoxes = new CheckBoxList(); + isochronsLayeredPane.add(isochronCheckBoxes); - public void removeElement(IsochronModel im) { - isochronModels.remove(im); - Collections.sort(isochronModels); - } - } + automaticIsochronSelectionChoice.setSelected(automaticIsochronSelection); + automaticIsochronSelectionChoice.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + ((SampleDateModel) sampleDateModel).setAutomaticIsochronSelection( + automaticIsochronSelectionChoice.isSelected()); + } + }); - private void initLists() { JCheckBox[] isochronCheckBoxArray = new JCheckBox[selectedIsochrons.size()]; // used to get quick access to isochrons @@ -121,14 +113,25 @@ private void initLists() { checkBox.addChangeListener((ChangeEvent e) -> { isochrons[Integer.parseInt(((JCheckBox) e.getSource()).getName())] .setVisible(((JCheckBox) e.getSource()).isSelected()); + isochronDateInKaText.setText( + isochrons[Integer.parseInt(((JCheckBox) e.getSource()).getName())] + .prettyPrintINoUnits()); }); isochronCheckBoxArray[count] = checkBox; count++; } isochronCheckBoxes.removeAll(); - isochronCheckBoxes.setBounds(100, 50, 100, count * 20); + isochronCheckBoxes.setBounds(50, 50, 100, count * 18); isochronCheckBoxes.setListData(isochronCheckBoxArray); + isochronCheckBoxes.addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent e) { + isochronDateInKaText.setText( + ((JCheckBox)((CheckBoxList)e.getSource()) + .getSelectedValue()).getText().split(" ka")[0]); + } + }); } @@ -145,12 +148,14 @@ private void initComponents() { isochronsLayeredPane = new javax.swing.JLayeredPane(); specifyIsochron_label = new javax.swing.JLabel(); availableListLabel = new javax.swing.JLabel(); - dateInKaText = new javax.swing.JTextField(); + isochronDateInKaText = new javax.swing.JTextField(); specifyDateka_label = new javax.swing.JLabel(); - defaultSetButton = new ET_JButton(); + automaticIsochronSelectionChoice = new javax.swing.JCheckBox(); + addIsochronButton = new ET_JButton(); + removeIsochronButton = new ET_JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); - setTitle("Available Sample Date Interpretation Models"); + setTitle("Isochron Chooser"); setAlwaysOnTop(true); setBackground(new java.awt.Color(245, 236, 206)); setForeground(java.awt.Color.white); @@ -171,9 +176,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { close_buttonActionPerformed(evt); } }); - buttonsPanel.add(close_button, new org.netbeans.lib.awtextra.AbsoluteConstraints(35, 4, 270, 25)); + buttonsPanel.add(close_button, new org.netbeans.lib.awtextra.AbsoluteConstraints(35, 2, 270, 25)); - getContentPane().add(buttonsPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 570, 340, 30)); + getContentPane().add(buttonsPanel, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 575, 340, 27)); isochronsLayeredPane.setBackground(new java.awt.Color(255, 237, 255)); isochronsLayeredPane.setOpaque(true); @@ -187,25 +192,40 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { isochronsLayeredPane.add(availableListLabel); availableListLabel.setBounds(20, 30, 300, 16); - dateInKaText.setText("0"); - isochronsLayeredPane.add(dateInKaText); - dateInKaText.setBounds(150, 520, 50, 26); + isochronDateInKaText.setHorizontalAlignment(javax.swing.JTextField.CENTER); + isochronDateInKaText.setText("0"); + isochronsLayeredPane.add(isochronDateInKaText); + isochronDateInKaText.setBounds(242, 310, 60, 26); - specifyDateka_label.setText("Enter Date in ka:"); + specifyDateka_label.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); + specifyDateka_label.setText("Specify Date in ka:"); isochronsLayeredPane.add(specifyDateka_label); - specifyDateka_label.setBounds(30, 530, 110, 16); + specifyDateka_label.setBounds(210, 290, 120, 16); + + automaticIsochronSelectionChoice.setBackground(new java.awt.Color(255, 237, 255)); + automaticIsochronSelectionChoice.setSelected(true); + automaticIsochronSelectionChoice.setText("Automatic Isochron Selection"); + automaticIsochronSelectionChoice.setOpaque(true); + isochronsLayeredPane.add(automaticIsochronSelectionChoice); + automaticIsochronSelectionChoice.setBounds(30, 540, 230, 23); - defaultSetButton.setForeground(new java.awt.Color(255, 51, 0)); - defaultSetButton.setText("Default Set"); - defaultSetButton.setMargin(new java.awt.Insets(0, 1, 0, 1)); - defaultSetButton.setPreferredSize(new java.awt.Dimension(140, 23)); - defaultSetButton.addActionListener(new java.awt.event.ActionListener() { + addIsochronButton.setText("+"); + addIsochronButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - defaultSetButtonActionPerformed(evt); + addIsochronButtonActionPerformed(evt); } }); - isochronsLayeredPane.add(defaultSetButton); - defaultSetButton.setBounds(0, 550, 100, 23); + isochronsLayeredPane.add(addIsochronButton); + addIsochronButton.setBounds(245, 340, 25, 25); + + removeIsochronButton.setText("-"); + removeIsochronButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + removeIsochronButtonActionPerformed(evt); + } + }); + isochronsLayeredPane.add(removeIsochronButton); + removeIsochronButton.setBounds(275, 340, 25, 25); getContentPane().add(isochronsLayeredPane, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 340, 570)); @@ -215,22 +235,34 @@ private void close_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN- close(); }//GEN-LAST:event_close_buttonActionPerformed - private void defaultSetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_defaultSetButtonActionPerformed - selectedIsochrons.clear(); - selectedIsochrons.addAll(IsochronModel.generateDefaultEvolutionIsochronModels()); - initLists(); - repaint(); - }//GEN-LAST:event_defaultSetButtonActionPerformed + private void addIsochronButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addIsochronButtonActionPerformed + double isoDateKa = 0; + try { + isoDateKa = Double.parseDouble(isochronDateInKaText.getText()); + } catch (NumberFormatException numberFormatException) { + } - private void updateList(JList jlist, AbstractListModel listModel) { - jlist.setModel(new IsochronModelList()); - jlist.setModel(listModel); - jlist.validate(); - } + if ((isoDateKa > 0) && (isoDateKa < 10000)) { + IsochronModel model = new IsochronModel(isoDateKa * 1000); + selectedIsochrons.add(model); + initLists(); + } - private void OK() { + }//GEN-LAST:event_addIsochronButtonActionPerformed - } + private void removeIsochronButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeIsochronButtonActionPerformed + double isoDateKa = 0; + try { + isoDateKa = Double.parseDouble(isochronDateInKaText.getText()); + } catch (NumberFormatException numberFormatException) { + } + + if ((isoDateKa > 0) && (isoDateKa < 10000)) { + IsochronModel model = new IsochronModel(isoDateKa * 1000); + selectedIsochrons.remove(model); + initLists(); + } + }//GEN-LAST:event_removeIsochronButtonActionPerformed /** * @return the selectedIsochrons @@ -248,12 +280,14 @@ public void setSelectedIsochrons(SortedSet selectedIsochrons) { // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton addIsochronButton; + private javax.swing.JCheckBox automaticIsochronSelectionChoice; private javax.swing.JLabel availableListLabel; private javax.swing.JPanel buttonsPanel; private javax.swing.JButton close_button; - private javax.swing.JTextField dateInKaText; - private javax.swing.JButton defaultSetButton; + private javax.swing.JTextField isochronDateInKaText; private javax.swing.JLayeredPane isochronsLayeredPane; + private javax.swing.JButton removeIsochronButton; private javax.swing.JLabel specifyDateka_label; private javax.swing.JLabel specifyIsochron_label; // End of variables declaration//GEN-END:variables diff --git a/src/main/java/org/earthtime/projects/projectImporters/UPbProjectImporters/ProjectOfSamplesImporterFromCSVFile_Squid3.java b/src/main/java/org/earthtime/projects/projectImporters/UPbProjectImporters/ProjectOfSamplesImporterFromCSVFile_Squid3.java index afc2b06e..e4c87c11 100644 --- a/src/main/java/org/earthtime/projects/projectImporters/UPbProjectImporters/ProjectOfSamplesImporterFromCSVFile_Squid3.java +++ b/src/main/java/org/earthtime/projects/projectImporters/UPbProjectImporters/ProjectOfSamplesImporterFromCSVFile_Squid3.java @@ -74,6 +74,8 @@ protected ProjectInterface extractProjectFromDelimitedTextFile(ProjectInterface throws FileNotFoundException { ArrayList projectSamples = new ArrayList<>(); + + int columnStartReduxData = -1; SampleInterface currentSample = null; AliquotInterface currentAliquot = null; @@ -91,6 +93,17 @@ protected ProjectInterface extractProjectFromDelimitedTextFile(ProjectInterface @SuppressWarnings("UseOfObsoleteCollectionType") Vector myFractionData = processLegacyCSVLine(scanner.nextLine()); if (myFractionData.size() > 1) { + + // use first line to determine starting column of "Correction-Independent Data" + if (myFractionData.get(1).startsWith("Spot Fundamentals")) { + // walk vector to find entry + for (int i = 0; i < myFractionData.size(); i ++){ + if (myFractionData.get(i).compareToIgnoreCase("Correction-Independent Data") ==0){ + columnStartReduxData = i; + break; + } + } + } if (myFractionData.get(0).startsWith("Fraction")) { // the next line(s) contain fraction data or are blank @@ -136,17 +149,6 @@ protected ProjectInterface extractProjectFromDelimitedTextFile(ProjectInterface } } -// else if (myFractionData.get(7).compareTo(savedAliquotName) != 0) { -// SampleInterface.copyAliquotIntoSample(project.getSuperSample(), -// currentSample.getAliquotByName(currentAliquot.getAliquotName()), new UPbReduxAliquot()); -// -// savedAliquotName = myFractionData.get(7); -// try { -// currentAliquot = currentSample.addNewAliquot(myFractionData.get(7)); -// aliquotCounter++; -// } catch (ETException eTException) { -// } -// } } if (readingFractions) { @@ -166,21 +168,21 @@ protected ProjectInterface extractProjectFromDelimitedTextFile(ProjectInterface ratioName = "concU"; myFraction.getCompositionalMeasureByName(ratioName)// - .setValue(readDelimitedTextCell(myFractionData.get(48)).// + .setValue(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 4)).// movePointLeft(6)); ratioName = "concTh"; myFraction.getCompositionalMeasureByName(ratioName)// - .setValue(readDelimitedTextCell(myFractionData.get(49)).// + .setValue(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 5)).// movePointLeft(6)); ratioName = "rTh_Usample"; myFraction.getCompositionalMeasureByName(ratioName)// - .setValue(readDelimitedTextCell(myFractionData.get(50))); + .setValue(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 6))); ratioName = "radToCommonTotal"; // Pb*/Pb myFraction.getCompositionalMeasureByName(ratioName)// - .setValue(readDelimitedTextCell(myFractionData.get(62))); + .setValue(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 18))); // ratioName = "totCommonPbMass"; //Pbc // myFraction.getCompositionalMeasureByName(ratioName)// @@ -195,50 +197,50 @@ protected ProjectInterface extractProjectFromDelimitedTextFile(ProjectInterface // .setValue(readDelimitedTextCell(myFractionData.get(index++))); ratioName = "r207_206r"; myFraction.getRadiogenicIsotopeRatioByName(ratioName)// - .setValue(readDelimitedTextCell(myFractionData.get(77))); + .setValue(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 33))); ValueModel ratio = myFraction.getRadiogenicIsotopeRatioByName(ratioName); // convert 1-sigma to 1-sigma - BigDecimal oneSigmaPct = readDelimitedTextCell(myFractionData.get(78)).// + BigDecimal oneSigmaPct = readDelimitedTextCell(myFractionData.get(columnStartReduxData + 34)).// divide(new BigDecimal(1.0)); myFraction.getRadiogenicIsotopeRatioByName(ratioName)// .setOneSigma(ValueModel.convertOneSigmaPctToAbsIfRequired(ratio, oneSigmaPct)); ratioName = "r207_235r"; myFraction.getRadiogenicIsotopeRatioByName(ratioName)// - .setValue(readDelimitedTextCell(myFractionData.get(79))); + .setValue(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 35))); ratio = myFraction.getRadiogenicIsotopeRatioByName(ratioName); // convert 2-sigma to 1-sigma - oneSigmaPct = readDelimitedTextCell(myFractionData.get(80)).// + oneSigmaPct = readDelimitedTextCell(myFractionData.get(columnStartReduxData + 36)).// divide(new BigDecimal(1.0)); myFraction.getRadiogenicIsotopeRatioByName(ratioName)// .setOneSigma(ValueModel.convertOneSigmaPctToAbsIfRequired(ratio, oneSigmaPct)); ratioName = "r206_238r"; myFraction.getRadiogenicIsotopeRatioByName(ratioName)// - .setValue(readDelimitedTextCell(myFractionData.get(81))); + .setValue(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 37))); ratio = myFraction.getRadiogenicIsotopeRatioByName(ratioName); // convert 2-sigma to 1-sigma - oneSigmaPct = readDelimitedTextCell(myFractionData.get(82)).// + oneSigmaPct = readDelimitedTextCell(myFractionData.get(columnStartReduxData + 38)).// divide(new BigDecimal(1.0)); myFraction.getRadiogenicIsotopeRatioByName(ratioName)// .setOneSigma(ValueModel.convertOneSigmaPctToAbsIfRequired(ratio, oneSigmaPct)); ratioName = "rhoR206_238r__r207_235r"; myFraction.getRadiogenicIsotopeRatioByName(ratioName)// - .setValue(readDelimitedTextCell(myFractionData.get(83))); + .setValue(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 39))); ((UPbFractionI) myFraction).calculateTeraWasserburgRho(); // Isotopic Dates ratioName = RadDates.age207_206r.getName(); myFraction.getRadiogenicIsotopeDateByName(ratioName)// - .setValue(readDelimitedTextCell(myFractionData.get(68)).// + .setValue(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 24)).// movePointRight(6)); myFraction.getRadiogenicIsotopeDateByName(ratioName)// - .setOneSigma(readDelimitedTextCell(myFractionData.get(69)).// + .setOneSigma(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 25)).// divide(new BigDecimal(1.0)).movePointRight(6)); // ratioName = RadDates.age207_235r.getName(); @@ -250,10 +252,10 @@ protected ProjectInterface extractProjectFromDelimitedTextFile(ProjectInterface // divide(new BigDecimal(2.0)).movePointRight(6)); ratioName = RadDates.age206_238r.getName(); myFraction.getRadiogenicIsotopeDateByName(ratioName)// - .setValue(readDelimitedTextCell(myFractionData.get(66)).// + .setValue(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 22)).// movePointRight(6)); myFraction.getRadiogenicIsotopeDateByName(ratioName)// - .setOneSigma(readDelimitedTextCell(myFractionData.get(67)).// + .setOneSigma(readDelimitedTextCell(myFractionData.get(columnStartReduxData + 23)).// divide(new BigDecimal(1.0)).movePointRight(6)); // calculate percentDiscordance diff --git a/src/main/java/org/earthtime/reportViews/ReportAliquotFractionsView.java b/src/main/java/org/earthtime/reportViews/ReportAliquotFractionsView.java index b6e1ad74..14c37f42 100644 --- a/src/main/java/org/earthtime/reportViews/ReportAliquotFractionsView.java +++ b/src/main/java/org/earthtime/reportViews/ReportAliquotFractionsView.java @@ -1044,7 +1044,8 @@ public void paint(Graphics2D g2D) { ETFractionInterface fraction = null; try { - fraction = sample.getFractionByIDAndAliquotNumber(reportFractions[row][2].trim(), ((ReduxAliquotInterface) aliquot).getAliquotNumber()); + fraction = sample.getFractionByIDAndAliquotNumber(reportFractions[row][2].trim(), + ((ReduxAliquotInterface) aliquot).getAliquotNumber()); TableRowObject currentFractionTableRowObject = new TableRowObject( // drawnHeight + topMargin + lineHeight + 1,// diff --git a/src/main/java/org/earthtime/utilities/FileHelper.java b/src/main/java/org/earthtime/utilities/FileHelper.java index c94134ef..c1394746 100644 --- a/src/main/java/org/earthtime/utilities/FileHelper.java +++ b/src/main/java/org/earthtime/utilities/FileHelper.java @@ -90,6 +90,7 @@ public boolean accept(File file, String string) { fc.setSelectedFile(new File(directory + File.separator + fractionFileName)); fc.setFileFilter(nonMacFileFilter); fc.setDialogTitle(dialogTitle); + fc.grabFocus(); // Show save dialog; this method does not return until the dialog is closed int result = fc.showSaveDialog(new Frame()); @@ -99,7 +100,7 @@ public boolean accept(File file, String string) { int response = 0; if (selectedFile.exists()) { // Modal dialog with OK/cancel and a text field - response = JOptionPane.showConfirmDialog(null, + response = JOptionPane.showConfirmDialog(parentFrame, new String[]{"The file exists.", "Do you want to replace it?" },