Skip to content

Commit ba02d06

Browse files
committed
X-Y trajectory plot
1 parent eae0277 commit ba02d06

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

src/asg/ion/TrajectorySolver.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import info.monitorenter.gui.chart.IAxis.AxisTitle;
88
import info.monitorenter.gui.chart.ITrace2D;
99
import info.monitorenter.gui.chart.ZoomableChart;
10-
import info.monitorenter.gui.chart.traces.Trace2DLtd;
1110
import info.monitorenter.gui.chart.traces.Trace2DSimple;
1211
import info.monitorenter.gui.chart.views.ChartPanel;
1312
import java.awt.Color;
@@ -261,6 +260,7 @@ public void showGraph() {
261260
frame.getContentPane().add(new ChartPanel(energyPlottingCallback.createChart()));
262261
frame.getContentPane().add(new ChartPanel(coordPlottingCallback.createChart()));
263262
frame.getContentPane().add(new ChartPanel(intensityPlottingCallback.createChart()));
263+
frame.getContentPane().add(new ChartPanel(xyPlottingCallback.createChart()));
264264

265265
chartFrame = frame;
266266
}
@@ -271,6 +271,7 @@ public void showGraph() {
271271

272272
private PlottingCallback energyPlottingCallback = new EnergyPlottingCallback();
273273
private PlottingCallback coordPlottingCallback = new XYZPlottingCallback();
274+
private PlottingCallback xyPlottingCallback = new XYPlottingCallback();
274275
private PlottingCallback intensityPlottingCallback = new IntensityPlottingCallback();
275276

276277
private abstract class PlottingCallback implements Callback {
@@ -376,6 +377,30 @@ public void point(double t, double x, double y, double z, double vx, double vy,
376377
}
377378
}
378379

380+
private class XYPlottingCallback extends PlottingCallback {
381+
382+
private ITrace2D coordTrace = new Trace2DSimple("x-y trajectory");
383+
384+
@Override
385+
public ZoomableChart createChart() {
386+
ZoomableChart c = new ZoomableChart();
387+
c.getAxisX().setAxisTitle(new AxisTitle("x"));
388+
c.getAxisY().setAxisTitle(new AxisTitle("y"));
389+
390+
c.addTrace(coordTrace);
391+
392+
return c;
393+
}
394+
395+
protected void clearTraces() {
396+
coordTrace.removeAllPoints();
397+
}
398+
399+
public void point(double t, double x, double y, double z, double vx, double vy, double vz) {
400+
coordTrace.addPoint(x, y);
401+
}
402+
}
403+
379404
private class OutputCallback implements Callback {
380405

381406
private PrintStream s;
@@ -470,6 +495,7 @@ public void fly(
470495
new Callback[] {energyPlottingCallback,
471496
coordPlottingCallback,
472497
intensityPlottingCallback,
498+
xyPlottingCallback,
473499
writer} :
474500
new Callback[] {writer};
475501
solve(dt, mass, charge,

0 commit comments

Comments
 (0)