From afe112b4061ce18dfa89491904a863ee96dd6fee Mon Sep 17 00:00:00 2001 From: walterxie Date: Wed, 9 Feb 2022 16:47:24 +1300 Subject: [PATCH] Tracer crashes on very small positive values #167 --- src/tracer/application/TracerApp.java | 3 ++- src/tracer/traces/ContinuousDensityPanel.java | 6 +++--- src/tracer/traces/ContinuousJointDensityPanel.java | 9 +++++---- .../traces/DiscreteContinuousJointDensityPanel.java | 2 +- src/tracer/traces/DiscreteDensityPanel.java | 6 ++++-- src/tracer/traces/DiscreteJointDensityPanel.java | 7 +------ src/tracer/traces/FrequencyPanel.java | 12 ++++++++---- src/tracer/traces/IntervalsPanel.java | 2 +- src/tracer/traces/RawTracePanel.java | 5 +++-- 9 files changed, 28 insertions(+), 24 deletions(-) diff --git a/src/tracer/application/TracerApp.java b/src/tracer/application/TracerApp.java index 4768037..ecc85fe 100644 --- a/src/tracer/application/TracerApp.java +++ b/src/tracer/application/TracerApp.java @@ -69,11 +69,12 @@ static public void main(String[] args) { public void run() { try { for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { - System.out.println(info.getName() + " - " + info.getClassName()); +// System.out.println(info.getName() + " - " + info.getClassName()); // Tracer Issue #172 Mac OS X - com.apple.laf.AquaLookAndFeel if (info.getName().startsWith("Mac")) { UIManager.setLookAndFeel(info.getClassName()); lafLoaded = true; + System.out.println("Set look & feel to : " + info.getName() + " - " + info.getClassName()); } } // UIManager.setLookAndFeel("org.violetlib.aqua.AquaLookAndFeel"); diff --git a/src/tracer/traces/ContinuousDensityPanel.java b/src/tracer/traces/ContinuousDensityPanel.java index feddd59..6b28576 100644 --- a/src/tracer/traces/ContinuousDensityPanel.java +++ b/src/tracer/traces/ContinuousDensityPanel.java @@ -111,17 +111,17 @@ public ContinuousDensityPanel(final JFrame frame) { setOpaque(false); - kdeChart = new JChart(new LinearAxis(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis()); + kdeChart = new JChart(new LinearAxis2(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis2()); kdeChartPanel = new JChartPanel(kdeChart, "","",""); kdeToolBar = createToolBar(Type.KDE, currentSettings); densityChartSetupDialog = new ChartSetupDialog(frame, true, false, true, false, Axis.AT_MAJOR_TICK, Axis.AT_MAJOR_TICK, Axis.AT_ZERO, Axis.AT_MAJOR_TICK); - histogramChart = new JChart(new LinearAxis(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis()); + histogramChart = new JChart(new LinearAxis2(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis2()); histogramChartPanel = new JChartPanel(histogramChart, "","",""); histogramToolBar = createToolBar(Type.HISTOGRAM, currentSettings); - violinChart = new JParallelChart(false, new LinearAxis(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS)); + violinChart = new JParallelChart(false, new LinearAxis2(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS)); violinChartPanel = new JChartPanel(violinChart, "","",""); violinToolBar = createToolBar(Type.VIOLIN, currentSettings); violinChartSetupDialog = new ChartSetupDialog(frame, false, true, false, true, diff --git a/src/tracer/traces/ContinuousJointDensityPanel.java b/src/tracer/traces/ContinuousJointDensityPanel.java index 1512e41..6d7413b 100644 --- a/src/tracer/traces/ContinuousJointDensityPanel.java +++ b/src/tracer/traces/ContinuousJointDensityPanel.java @@ -26,7 +26,8 @@ package tracer.traces; import dr.app.gui.chart.*; -import dr.inference.trace.*; +import dr.inference.trace.TraceCorrelation; +import dr.inference.trace.TraceList; import dr.stats.Variate; import javax.swing.*; @@ -68,7 +69,7 @@ class Settings extends TraceChartPanel.Settings { public ContinuousJointDensityPanel(final JFrame frame) { super(frame); - chart = new JChart(new LinearAxis(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS)); + chart = new JChart(new LinearAxis2(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis2(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS)); chartPanel = new JChartPanel(chart, "", "", ""); // xAxisTitle, yAxisTitle toolBar = createSinglePairToolBar(frame); @@ -235,8 +236,8 @@ private void createContinuousScatterPlot(TraceList traceList1, int traceIndex1, k += minCount / sampleSize; } - getChart().setXAxis(new LinearAxis()); - getChart().setYAxis(new LinearAxis()); + getChart().setXAxis(new LinearAxis2()); + getChart().setYAxis(new LinearAxis2()); // add plot ScatterPlot plot = new ScatterPlot(samples1, samples2); diff --git a/src/tracer/traces/DiscreteContinuousJointDensityPanel.java b/src/tracer/traces/DiscreteContinuousJointDensityPanel.java index b50e9b7..1173c8c 100644 --- a/src/tracer/traces/DiscreteContinuousJointDensityPanel.java +++ b/src/tracer/traces/DiscreteContinuousJointDensityPanel.java @@ -63,7 +63,7 @@ public class DiscreteContinuousJointDensityPanel extends TraceChartPanel { public DiscreteContinuousJointDensityPanel(final JFrame frame) { super(frame); - parallelChart = new JParallelChart(false, new LinearAxis(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS)); + parallelChart = new JParallelChart(false, new LinearAxis2(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS)); chartPanel = new JChartPanel(parallelChart, "", "", ""); // xAxisTitle, yAxisTitle toolBar = createToolBar(frame); diff --git a/src/tracer/traces/DiscreteDensityPanel.java b/src/tracer/traces/DiscreteDensityPanel.java index 8aca58a..b7451c7 100644 --- a/src/tracer/traces/DiscreteDensityPanel.java +++ b/src/tracer/traces/DiscreteDensityPanel.java @@ -26,7 +26,9 @@ package tracer.traces; import dr.app.gui.chart.*; -import dr.inference.trace.*; +import dr.inference.trace.Trace; +import dr.inference.trace.TraceList; +import dr.inference.trace.TraceType; import dr.stats.Variate; import javax.swing.*; @@ -63,7 +65,7 @@ private class Settings extends TraceChartPanel.Settings { */ public DiscreteDensityPanel(final JFrame frame) { super(frame); - densityChart = new JChart(new LinearAxis(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis(Axis.AT_ZERO, Axis.AT_MAJOR_TICK_PLUS)); + densityChart = new JChart(new LinearAxis2(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis2(Axis.AT_ZERO, Axis.AT_MAJOR_TICK_PLUS)); densityChartPanel = new JChartPanel(densityChart, "","",""); toolBar = createToolBar(currentSettings); } diff --git a/src/tracer/traces/DiscreteJointDensityPanel.java b/src/tracer/traces/DiscreteJointDensityPanel.java index eea1d79..46d51ab 100644 --- a/src/tracer/traces/DiscreteJointDensityPanel.java +++ b/src/tracer/traces/DiscreteJointDensityPanel.java @@ -27,17 +27,12 @@ import dr.app.gui.chart.*; import dr.inference.trace.TraceCorrelation; -import dr.inference.trace.TraceDistribution; import dr.inference.trace.TraceList; -import dr.inference.trace.TraceType; import dr.stats.Variate; import javax.swing.*; -import java.awt.*; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** * A panel that displays correlation plots of 2 discrete traces @@ -66,7 +61,7 @@ public class DiscreteJointDensityPanel extends TraceChartPanel { public DiscreteJointDensityPanel(final JFrame frame) { super(frame); - chart = new JChart(new LinearAxis(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS)); + chart = new JChart(new LinearAxis2(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis2(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS)); chartPanel = new JChartPanel(chart, "", "", ""); // xAxisTitle, yAxisTitle toolBar = createSinglePairToolBar(frame); diff --git a/src/tracer/traces/FrequencyPanel.java b/src/tracer/traces/FrequencyPanel.java index fd76300..113f600 100644 --- a/src/tracer/traces/FrequencyPanel.java +++ b/src/tracer/traces/FrequencyPanel.java @@ -26,12 +26,15 @@ package tracer.traces; import dr.app.gui.chart.*; -import dr.inference.trace.*; +import dr.inference.trace.Trace; +import dr.inference.trace.TraceCorrelation; +import dr.inference.trace.TraceList; +import dr.inference.trace.TraceType; import javax.swing.*; import java.awt.*; import java.awt.event.ActionEvent; -import java.util.*; +import java.util.Set; /** @@ -60,8 +63,9 @@ public class FrequencyPanel extends TraceChartPanel { */ public FrequencyPanel(final JFrame frame) { super(frame); + // LinearAxis2 can handle small ranged values (range < 1E-30) correctly, but LinearAxis cannot traceChart = new JChart( - new LinearAxis(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis()); + new LinearAxis2(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS), new LinearAxis()); traceChartPanel = new JChartPanel(traceChart, "","", "Frequency"); // xAxisTitle, yAxisTitle toolBar = createToolBar(currentSettings); } @@ -146,7 +150,7 @@ protected void setupTraces() { if (td != null) { histogramPlot.setIntervals(td.getUpperHPD(), td.getLowerHPD()); } - getChartPanel().getChart().setXAxis(new LinearAxis(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS)); + getChartPanel().getChart().setXAxis(new LinearAxis2(Axis.AT_MAJOR_TICK_PLUS, Axis.AT_MAJOR_TICK_PLUS)); plot = histogramPlot; } else if (traceType.isDiscrete()) { diff --git a/src/tracer/traces/IntervalsPanel.java b/src/tracer/traces/IntervalsPanel.java index 9ee51f6..b06352b 100644 --- a/src/tracer/traces/IntervalsPanel.java +++ b/src/tracer/traces/IntervalsPanel.java @@ -65,7 +65,7 @@ public class IntervalsPanel extends TraceChartPanel { */ public IntervalsPanel(final JFrame frame) { super(frame); - intervalsChart = new JParallelChart(false, new LinearAxis(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS)); + intervalsChart = new JParallelChart(false, new LinearAxis2(Axis.AT_MAJOR_TICK_MINUS, Axis.AT_MAJOR_TICK_PLUS)); chartPanel = new JChartPanel(intervalsChart, "", "", ""); // xAxisTitle, yAxisTitle toolBar = createToolBar(); diff --git a/src/tracer/traces/RawTracePanel.java b/src/tracer/traces/RawTracePanel.java index 4522145..b70e122 100644 --- a/src/tracer/traces/RawTracePanel.java +++ b/src/tracer/traces/RawTracePanel.java @@ -71,7 +71,8 @@ public class RawTracePanel extends TraceChartPanel { */ public RawTracePanel(final JFrame frame) { super(frame); - traceChart = new JTraceChart(new LinearAxis(Axis.AT_ZERO, Axis.AT_DATA), new LinearAxis()); + // LinearAxis2 can handle small ranged values (range < 1E-30) correctly, but LinearAxis cannot + traceChart = new JTraceChart(new LinearAxis(Axis.AT_ZERO, Axis.AT_DATA), new LinearAxis2()); chartPanel = new JChartPanel(traceChart, "", "", ""); // xAxisTitle, yAxisTitle toolBar = createToolBar(currentSettings); } @@ -281,7 +282,7 @@ protected void setupTraces() { getChart().getYAxis().setRange(0.0, 1.0); } } else { - getChart().setYAxis(new LinearAxis(Axis.AT_DATA, Axis.AT_DATA)); + getChart().setYAxis(new LinearAxis2(Axis.AT_DATA, Axis.AT_DATA)); } int selectedColour = currentSettings.cm.addTraceColour(tl.getFullName(), name, currentSettings.colourBy); // System.out.println(tl.getName() + " : " + name + " : " + values.size() + " " + stateStart + " " + stateStep);