Example #1
0
 /**
  * Sets the name. Overrides TTrack method.
  *
  * @param name the name
  */
 public void setName(String name) {
   String prevName = getName();
   super.setName(name);
   if (inspector != null) {
     inspector.renamePanel(prevName, name);
   }
 }
Example #2
0
 /**
  * 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();
   }
 }
Example #3
0
 /** Removes this particle from all panels that draw it. Overrides TTrack method. */
 public void delete() {
   FunctionTool modelBuilder = null;
   if (trackerPanel != null && trackerPanel.modelBuilder != null) {
     ArrayList<ParticleModel> list = trackerPanel.getDrawables(ParticleModel.class);
     if (list.size() == 1) modelBuilder = trackerPanel.modelBuilder;
   }
   super.delete();
   if (modelBuilder != null) {
     modelBuilder.setVisible(false);
   }
 }
Example #4
0
 /** Cleans up associated resources when this track is deleted or cleared. */
 protected void cleanup() {
   super.cleanup();
   if (inspector != null) {
     trackerPanel.removePropertyChangeListener("data", this); // $NON-NLS-1$
     inspector.removePanel(getName());
     inspector.removePropertyChangeListener(this);
     if (trackerPanel.getTFrame() != null) {
       trackerPanel.getTFrame().removePropertyChangeListener("tab", this); // $NON-NLS-1$
     }
     if (inspector.isEmpty()) inspector.setVisible(false);
   }
 }
Example #5
0
 /**
  * Identifies the controlling TrackerPanel for this track (by default, the first TrackerPanel that
  * adds this track to its drawables).
  *
  * @param panel the TrackerPanel
  */
 protected void setTrackerPanel(TrackerPanel panel) {
   super.setTrackerPanel(panel);
   if (panel != null) {
     if (startFrameUndefined) {
       int n = panel.getPlayer().getVideoClip().getStartFrameNumber();
       setStartFrame(n);
       startFrameUndefined = false;
     }
     if (panel.getTFrame() != null) {
       boolean radians = panel.getTFrame().anglesInRadians;
       functionPanel.initEditor.setAnglesInDegrees(!radians);
     }
   }
 }
Example #6
0
 /**
  * Draws this without refreshing steps.
  *
  * @param panel the drawing panel requesting the drawing
  * @param _g the graphics context on which to draw
  */
 public void drawMe(DrawingPanel panel, Graphics _g) {
   // position and show inspector if requested during loading
   if (inspectorX != Integer.MIN_VALUE
       && trackerPanel != null
       && trackerPanel.getTFrame() != null) {
     positionInspector();
     Runnable runner =
         new Runnable() {
           public void run() {
             showInspector = false;
             inspector.setVisible(true);
           }
         };
     if (showInspector) SwingUtilities.invokeLater(runner);
   }
   if (isVisible() && isTraceVisible()) {
     // draw trace only if fixed coords & (non-worldview or no ref frame)
     TrackerPanel tPanel = (TrackerPanel) panel;
     ImageCoordSystem coords = tPanel.getCoords(); // get active coords
     boolean isRefFrame = coords instanceof ReferenceFrame;
     if (isRefFrame) {
       coords = ((ReferenceFrame) coords).getCoords();
     }
     boolean fixed = coords.isFixedAngle() && coords.isFixedOrigin() && coords.isFixedScale();
     if (fixed && (!(tPanel instanceof WorldTView) || !isRefFrame)) {
       trace.reset();
       for (int i = 0; i < traceX.length; i++) {
         if (Double.isNaN(traceX[i])) continue;
         tracePt.setLocation(traceX[i], traceY[i]);
         java.awt.Point p = tracePt.getScreenPosition(tPanel);
         if (trace.getCurrentPoint() == null) trace.moveTo((float) p.getX(), (float) p.getY());
         else trace.lineTo((float) p.getX(), (float) p.getY());
       }
       Graphics2D g2 = (Graphics2D) _g;
       Color color = g2.getColor();
       Stroke stroke = g2.getStroke();
       g2.setColor(getFootprint().getColor());
       g2.setStroke(traceStroke);
       g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
       g2.draw(trace);
       // restore original color and stroke
       g2.setColor(color);
       g2.setStroke(stroke);
     }
   }
   super.draw(panel, _g);
 }
Example #7
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);
 }
Example #8
0
  /**
   * Responds to property change events.
   *
   * @param e the property change event
   */
  public void propertyChange(PropertyChangeEvent e) {
    super.propertyChange(e);
    if (trackerPanel == null) return;
    String name = e.getPropertyName();
    //		System.out.println(name);
    if (name.equals("function") && !loading) { // $NON-NLS-1$
      trackerPanel.changed = true;
    } else if (name.equals("tab") && inspector != null) { // $NON-NLS-1$
      if (trackerPanel != null
          && e.getNewValue() == trackerPanel
          && trackerPanel.isModelBuilderVisible) {
        inspector.setVisible(true);
      } else if (inspector.isVisible()) {
        inspector.setVisible(false);
        trackerPanel.isModelBuilderVisible = true;
      }

    } else if (name.equals("selectedtrack") // $NON-NLS-1$
        && e.getNewValue() == this
        && inspector != null
        && !inspector.getSelectedName().equals(getName())) {
      inspector.setSelectedPanel(getName());
    }
    if (name.equals("function") // $NON-NLS-1$
        || name.equals("starttime") // $NON-NLS-1$
        || name.equals("frameduration") // $NON-NLS-1$
        || name.equals("startframe") // $NON-NLS-1$
        || name.equals("stepsize")) { // $NON-NLS-1$
      lastValidFrame = -1;
    }
    if (name.equals("transform")) { // $NON-NLS-1$
      // workaround to prevent infinite loop
      ImageCoordSystem coords = trackerPanel.getCoords();
      if (!(coords instanceof ReferenceFrame
          && ((ReferenceFrame) coords).getOriginTrack() == this)) {
        lastValidFrame = -1;
      }
    }
    if (!refreshing && isModelsVisible()) {
      if (name.equals("function")) { // $NON-NLS-1$
        repaint();
      } else if (name.equals("adjusting")) { // $NON-NLS-1$
        refreshStepsLater = (Boolean) e.getNewValue();
        if (!refreshStepsLater) { // stopped adjusting, so refresh steps
          refreshSteps();
        }
      }
      if (name.equals("transform")) { // $NON-NLS-1$
        // workaround to prevent infinite loop
        ImageCoordSystem coords = trackerPanel.getCoords();
        if (!(coords instanceof ReferenceFrame
            && ((ReferenceFrame) coords).getOriginTrack() == this)) {
          refreshSteps();
        }
      } else if (name.equals("starttime") // $NON-NLS-1$
          || name.equals("frameduration") // $NON-NLS-1$
          || name.equals("startframe")) { // $NON-NLS-1$
        refreshInitialTime();
        refreshSteps();
      } else if (name.equals("stepsize")) { // $NON-NLS-1$
        refreshSteps();
      }
    }
  }