/** * Sets the mass. Overrides PointMass method. * * @param mass the mass */ public void setMass(double mass) { super.setMass(mass); mass = super.getMass(); massField.setValue(mass); // refresh mass parameter in paramPanel if changed Parameter massParam = (Parameter) getParamEditor().getObject("m"); // $NON-NLS-1$ if (massParam != null && massParam.getValue() != mass) { functionPanel.getParamEditor().setExpression("m", String.valueOf(mass), false); // $NON-NLS-1$ refreshSteps(); } }
/** This adds the mass and initial time parameters to the function panel. */ protected void createMassAndTimeParameters() { Parameter param = new Parameter("m", String.valueOf(getMass())); // $NON-NLS-1$ param.setNameEditable(false); param.setDescription( TrackerRes.getString("ParticleModel.Parameter.Mass.Description")); // $NON-NLS-1$ getParamEditor().addObject(param, false); param = new Parameter("t", "0"); // $NON-NLS-1$ //$NON-NLS-2$ param.setNameEditable(false); param.setDescription( TrackerRes.getString("ParticleModel.Parameter.InitialTime.Description")); // $NON-NLS-1$ functionPanel.getInitEditor().addObject(param, false); getParamEditor() .addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if ("m".equals(e.getOldValue())) { // $NON-NLS-1$ Parameter param = (Parameter) getParamEditor().getObject("m"); // $NON-NLS-1$ if (ParticleModel.super.getMass() != param.getValue()) { setMass(param.getValue()); } } } }); getInitEditor() .addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (refreshing) return; if ("t".equals(e.getOldValue()) && trackerPanel != null) { // $NON-NLS-1$ Parameter param = (Parameter) getInitEditor().getObject("t"); // $NON-NLS-1$ VideoClip clip = trackerPanel.getPlayer().getVideoClip(); double timeOffset = param.getValue() * 1000 - clip.getStartTime(); double dt = trackerPanel.getPlayer().getMeanStepDuration(); int n = clip.getStartFrameNumber(); boolean mustRound = timeOffset % dt > 0; n += clip.getStepSize() * (int) Math.round(timeOffset / dt); setStartFrame(n); if (getStartFrame() != n || mustRound) Toolkit.getDefaultToolkit().beep(); } } }); }
/** * Gets the function editor. * * @return UserFunctionEditor */ public UserFunctionEditor getFunctionEditor() { return functionPanel.getUserFunctionEditor(); }
/** * Gets the initial value editor. * * @return the editor */ public InitialValueEditor getInitEditor() { return functionPanel.getInitEditor(); }
/** * Gets the parameter editor. * * @return ParamEditor */ public ParamEditor getParamEditor() { return functionPanel.getParamEditor(); }
/** * Gets the initial values. * * @return initial values */ public double[] getInitialValues() { return functionPanel.getInitEditor().getValues(); }