MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / createParticle

Method createParticle

src/davidson/gr/ClassicalApp.java:237–270  ·  view source on GitHub ↗

Adds a particle to the plot.

()

Source from the content-addressed store, hash-verified

235 * Adds a particle to the plot.
236 */
237 public void createParticle() {
238 final ClassicalTrajectory particle = new ClassicalTrajectory();
239 particle.setStepSize(dt);
240 particle.M = control.getDouble("M");
241 OSPTableInspector editor = particle.edit();
242 editor.setLocationRelativeTo(plottingPanel);
243 final Control control = editor.getControl();
244 editor.addWindowListener(new java.awt.event.WindowAdapter() {
245
246 @Override
247 public void windowClosed(WindowEvent e) {
248 particle.setEnabled(control.getBoolean("draggable state"));
249 particle.trackPoints = control.getInt("track points");
250 particle.label = control.getString("label");
251 double[] state = particle.getState();
252 state[0] = control.getDouble("r");
253 state[1] = control.getDouble("dr/dt");
254 state[2] = control.getDouble(Trajectory.PHI);
255 state[3] = control.getDouble(Trajectory.PHIRATE);
256 state[4] = 0; // time
257 particle.initialize(state);
258 defaultTrajectory = particle;
259 defaultTrajectory.color = Color.MAGENTA;
260 trajectories.add(defaultTrajectory);
261 plottingPanel.addDrawable(defaultTrajectory);
262 if (inspector != null) {
263 inspector.updateDataAndScale(defaultTrajectory);
264 }
265 support.firePropertyChange("trajectoryChange", null, defaultTrajectory);
266 plottingPanel.repaint();
267 }
268 });
269 editor.setVisible(true);
270 }
271
272 /**
273 * Returns an XML.ObjectLoader to save and load data for this program.

Callers

nothing calls this directly

Calls 5

getDoubleMethod · 0.95
editMethod · 0.95
getControlMethod · 0.95
setStepSizeMethod · 0.65
setVisibleMethod · 0.65

Tested by

no test coverage detected