Esempio n. 1
0
 /**
  * Overrides PointMass findInteractive method.
  *
  * @param panel the drawing panel
  * @param xpix the x pixel position on the panel
  * @param ypix the y pixel position on the panel
  * @return the first step or motion vector that is hit
  */
 public Interactive findInteractive(DrawingPanel panel, int xpix, int ypix) {
   Interactive ia = super.findInteractive(panel, xpix, ypix);
   if (ia instanceof PositionStep.Position) {
     hint = TrackerRes.getString("PointMass.Position.Locked.Hint"); // $NON-NLS-1$
   } else if (ia == null) hint = TrackerRes.getString("ParticleModel.Hint"); // $NON-NLS-1$
   return ia;
 }
Esempio n. 2
0
 /** Constructs a ParticleModel. */
 public ParticleModel() {
   Footprint[] footprints = super.getFootprints();
   Footprint[] newprints = new Footprint[footprints.length + 1];
   newprints[0] = CircleFootprint.getFootprint("CircleFootprint.FilledCircle"); // $NON-NLS-1$
   for (int i = 0; i < footprints.length; i++) {
     newprints[i + 1] = footprints[i];
   }
   setFootprints(newprints);
   defaultFootprint = newprints[0];
   setFootprint(defaultFootprint.getName());
   // assign a meaningful initial name
   setName(TrackerRes.getString("ParticleModel.New.Name")); // $NON-NLS-1$
   initializeFunctionPanel();
   // set initial hint
   hint = TrackerRes.getString("ParticleModel.Hint"); // $NON-NLS-1$
 }
Esempio n. 3
0
 /** 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();
               }
             }
           });
 }
Esempio n. 4
0
 /**
  * Sets the display format for angles.
  *
  * @param radians <code>true</code> for radians, false for degrees
  */
 protected void setAnglesInRadians(boolean radians) {
   super.setAnglesInRadians(radians);
   functionPanel.initEditor.setAnglesInDegrees(!radians);
   String s =
       TrackerRes.getString("DynamicParticle.Parameter.InitialTheta.Description")
           + " "; //$NON-NLS-1$ //$NON-NLS-2$
   s +=
       radians
           ? TrackerRes.getString("TableTrackView.Radians.Tooltip")
           : //$NON-NLS-1$
           TrackerRes.getString("TableTrackView.Degrees.Tooltip"); // $NON-NLS-1$
   functionPanel.initEditor.setDescription(FunctionEditor.THETA, s);
   s =
       TrackerRes.getString("DynamicParticle.Parameter.InitialOmega.Description")
           + " "; //$NON-NLS-1$ //$NON-NLS-2$
   s +=
       radians
           ? TrackerRes.getString("TableTrackView.RadiansPerSecond.Tooltip")
           : //$NON-NLS-1$
           TrackerRes.getString("TableTrackView.DegreesPerSecond.Tooltip"); // $NON-NLS-1$
   functionPanel.initEditor.setDescription(FunctionEditor.OMEGA, s);
 }
Esempio n. 5
0
  /**
   * Returns a menu with items that control this track.
   *
   * @param trackerPanel the tracker panel
   * @return a menu
   */
  public JMenu getMenu(TrackerPanel trackerPanel) {
    if (inspectorItem == null) {
      // create the model inspector item
      inspectorItem = new JMenuItem();
      inspectorItem.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              positionInspector();
              getInspector().setVisible(true);
            }
          });
      // create the useDefaultRefFrameItem item
      useDefaultRefFrameItem = new JCheckBoxMenuItem();
      useDefaultRefFrameItem.setSelected(!useDefaultReferenceFrame);
      useDefaultRefFrameItem.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent e) {
              setUseDefaultReferenceFrame(!useDefaultRefFrameItem.isSelected());
              if (ParticleModel.this.trackerPanel.getCoords() instanceof ReferenceFrame) {
                lastValidFrame = -1;
                refreshSteps();
              }
            }
          });
    }
    inspectorItem.setText(
        TrackerRes.getString("ParticleModel.MenuItem.InspectModel")); // $NON-NLS-1$
    useDefaultRefFrameItem.setText(
        TrackerRes.getString("ParticleModel.MenuItem.UseDefaultReferenceFrame")); // $NON-NLS-1$
    // assemble the menu
    JMenu menu = super.getMenu(trackerPanel);

    // remove unwanted menu items and separators
    menu.remove(autotrackItem);
    menu.remove(deleteStepItem);
    menu.remove(clearStepsItem);
    menu.remove(lockedItem);
    menu.remove(autoAdvanceItem);
    menu.remove(markByDefaultItem);
    menu.insert(inspectorItem, 0);
    if (menu.getItemCount() > 1) menu.insertSeparator(1);

    //		// find visible item and insert useDefaultRefFrameItem after it
    //		for (int i=0; i<menu.getMenuComponentCount(); i++) {
    //			if (menu.getMenuComponent(i)==visibleItem) {
    //				menu.insert(useDefaultRefFrameItem, i+1);
    //				break;
    //			}
    //		}

    // eliminate any double separators
    Object prevItem = inspectorItem;
    int n = menu.getItemCount();
    for (int j = 1; j < n; j++) {
      Object item = menu.getItem(j);
      if (item == null && prevItem == null) { // found extra separator
        menu.remove(j - 1);
        j = j - 1;
        n = n - 1;
      }
      prevItem = item;
    }
    return menu;
  }