Beispiel #1
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);
     }
   }
 }
Beispiel #2
0
  /**
   * Overrides Step getMark method.
   *
   * @param trackerPanel the tracker panel
   * @return the mark
   */
  protected Mark getMark(TrackerPanel trackerPanel) {
    Mark mark = marks.get(trackerPanel);
    TPoint selection = null;
    if (mark == null) {
      selection = trackerPanel.getSelectedPoint();
      Point p = null; // draws this step as "selected" shape if not null
      valid = true; // true if step is not NaN
      for (int n = 0; n < points.length; n++) {
        if (!valid) continue;
        // determine if point is valid (ie not NaN)
        valid = valid && !Double.isNaN(points[n].getX()) && !Double.isNaN(points[n].getY());
        screenPoints[n] = points[n].getScreenPosition(trackerPanel);
        // step is "selected" if trackerPanel selectedPoint is position or selectedSteps contains
        // this step
        if (valid && (selection == points[n] || trackerPanel.selectedSteps.contains(this))) {
          p = screenPoints[n];
        }
      }
      if (p == null) {
        if (footprint instanceof PositionVectorFootprint) {
          twoPoints[0] = screenPoints[0];
          twoPoints[1] = trackerPanel.getSnapPoint().getScreenPosition(trackerPanel);
          mark = footprint.getMark(twoPoints);
        } else mark = footprint.getMark(screenPoints);
      } else {
        transform.setToTranslation(p.x, p.y);
        int scale = FontSizer.getIntegerFactor();
        if (scale > 1) {
          transform.scale(scale, scale);
        }
        final Color color = footprint.getColor();
        final Shape selectedShape = transform.createTransformedShape(selectionShape);
        mark =
            new Mark() {
              public void draw(Graphics2D g, boolean highlighted) {
                g.setRenderingHint(
                    RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
                Paint gpaint = g.getPaint();
                g.setPaint(color);
                g.fill(selectedShape);
                g.setPaint(gpaint);
              }

              public Rectangle getBounds(boolean highlighted) {
                return selectedShape.getBounds();
              }
            };
      }
      final Mark theMark = mark;
      mark =
          new Mark() {
            public void draw(Graphics2D g, boolean highlighted) {
              if (!valid) {
                return;
              }
              theMark.draw(g, highlighted);
            }

            public Rectangle getBounds(boolean highlighted) {
              return theMark.getBounds(highlighted);
            }
          };
      marks.put(trackerPanel, mark);
      // get new text layout
      String s = ""; // $NON-NLS-1$
      VideoClip clip = trackerPanel.getPlayer().getVideoClip();
      if (clip.getStepCount() != 1) {
        s += clip.frameToStep(getFrameNumber());
      }
      if (s.length() == 0) s = " "; // $NON-NLS-1$
      TextLayout layout = new TextLayout(s, textLayoutFont, frc);
      textLayouts.put(trackerPanel, layout);
      // get layout position (bottom left corner of text)
      p = getLayoutPosition(trackerPanel);
      Rectangle bounds = layoutBounds.get(trackerPanel);
      if (bounds == null) {
        bounds = new Rectangle();
        layoutBounds.put(trackerPanel, bounds);
      }
      Rectangle2D rect = layout.getBounds();
      // set bounds (top left corner and size)
      bounds.setRect(p.x, p.y - rect.getHeight(), rect.getWidth(), rect.getHeight());
    }
    return mark;
  }