Skip to content

Commit

Permalink
Tracer crashes on very small positive values #167
Browse files Browse the repository at this point in the history
  • Loading branch information
walterxie committed Feb 9, 2022
1 parent c249ecc commit afe112b
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 24 deletions.
3 changes: 2 additions & 1 deletion src/tracer/application/TracerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
6 changes: 3 additions & 3 deletions src/tracer/traces/ContinuousDensityPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions src/tracer/traces/ContinuousJointDensityPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/tracer/traces/DiscreteContinuousJointDensityPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/tracer/traces/DiscreteDensityPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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);
}
Expand Down
7 changes: 1 addition & 6 deletions src/tracer/traces/DiscreteJointDensityPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
12 changes: 8 additions & 4 deletions src/tracer/traces/FrequencyPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;


/**
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion src/tracer/traces/IntervalsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions src/tracer/traces/RawTracePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit afe112b

Please sign in to comment.