Пример #1
0
  /**
   * Gets the autoload manager, creating it the first time called.
   *
   * @return the autoload manageer
   */
  protected AutoloadManager getAutoloadManager() {
    if (autoloadManager == null) {
      autoloadManager = new AutoloadManager(this);

      // center on screen
      Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
      int x = (dim.width - autoloadManager.getBounds().width) / 2;
      int y = (dim.height - autoloadManager.getBounds().height) / 2;
      autoloadManager.setLocation(x, y);

      if (!Tracker.dataFunctionControlStrings.isEmpty()) {
        // convert and save in user platform-dependent default search directory
        ArrayList<String> searchPaths = OSPRuntime.getDefaultSearchPaths();
        final String directory = searchPaths.size() > 0 ? searchPaths.get(0) : null;
        if (directory != null) {
          Runnable runner =
              new Runnable() {
                public void run() {
                  int response =
                      JOptionPane.showConfirmDialog(
                          TrackDataBuilder.this,
                          TrackerRes.getString(
                                  "TrackDataBuilder.Dialog.ConvertAutoload.Message1") //$NON-NLS-1$
                              + "\n"
                              + TrackerRes.getString(
                                  "TrackDataBuilder.Dialog.ConvertAutoload.Message2") //$NON-NLS-1$
                                                                                      // //$NON-NLS-2$
                              + "\n\n"
                              + TrackerRes.getString(
                                  "TrackDataBuilder.Dialog.ConvertAutoload.Message3"), //$NON-NLS-1$
                                                                                       // //$NON-NLS-2$
                          TrackerRes.getString(
                              "TrackDataBuilder.Dialog.ConvertAutoload.Title"), //$NON-NLS-1$
                          JOptionPane.YES_NO_OPTION);
                  if (response == JOptionPane.YES_OPTION) {
                    TrackDataBuilder builder = new TrackDataBuilder(new TrackerPanel());
                    int i = 0;
                    for (String next : Tracker.dataFunctionControlStrings) {
                      XMLControl panelControl = new XMLControlElement(next);
                      DataFunctionPanel panel = new DataFunctionPanel(new DatasetManager());
                      panelControl.loadObject(panel);
                      builder.addPanelWithoutAutoloading("panel" + i, panel); // $NON-NLS-1$
                      i++;
                    }
                    File file =
                        new File(directory, "TrackerConvertedAutoloadFunctions.xml"); // $NON-NLS-1$
                    XMLControl control = new XMLControlElement(builder);
                    control.write(file.getAbsolutePath());
                    Tracker.dataFunctionControlStrings.clear();
                    autoloadManager.refreshAutoloadData();
                  }
                }
              };
          SwingUtilities.invokeLater(runner);
        }
      }
    }
    autoloadManager.setFontLevel(FontSizer.getLevel());
    return autoloadManager;
  }
Пример #2
0
 @Override
 public void setVisible(boolean vis) {
   if (vis) {
     setFontLevel(FontSizer.getLevel());
   }
   super.setVisible(vis);
 }
Пример #3
0
  /**
   * Gets the mark for the specified panel.
   *
   * @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;
      valid = true; // assume true
      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);
        if (valid && selection == points[n]) p = screenPoints[n];
      }
      mark = footprint.getMark(screenPoints);
      if (p != null) { // point is selected, so draw selection shape
        transform.setToTranslation(p.x, p.y);
        int scale = FontSizer.getIntegerFactor();
        if (scale > 1) {
          transform.scale(scale, scale);
        }
        final Color color = footprint.getColor();
        final Mark stepMark = mark;
        final Shape selectedShape = transform.createTransformedShape(selectionShape);
        mark =
            new Mark() {
              public void draw(Graphics2D g, boolean highlighted) {
                stepMark.draw(g, false);
                Paint gpaint = g.getPaint();
                g.setPaint(color);
                g.fill(selectedShape);
                g.setPaint(gpaint);
              }

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

            public Rectangle getBounds(boolean highlighted) {
              return theMark.getBounds(highlighted);
            }
          };
      marks.put(trackerPanel, mark);
    }
    return mark;
  }
  /**
   * Gets the shape of this footprint.
   *
   * @param points an array of Points
   * @return the shape
   */
  public Shape getShape(Point[] points) {
    Point p1 = points[0];
    Point p2 = points[1];

    // set up end shapes
    transform.setToTranslation(p1.x, p1.y);
    int scale = FontSizer.getIntegerFactor();
    if (scale > 1) {
      transform.scale(scale, scale);
    }
    Shape target1 = transform.createTransformedShape(targetShape);
    hitShapes[0] = transform.createTransformedShape(hitShape); // end1
    transform.setToTranslation(p2.x, p2.y);
    if (scale > 1) {
      transform.scale(scale, scale);
    }
    Shape target2 = transform.createTransformedShape(targetShape);
    hitShapes[1] = transform.createTransformedShape(hitShape); // end2

    // set up line shapes
    float d = (float) p1.distance(p2); // distance between ends
    float center = d / 2; // center point
    float l = d - scale * 2 * (size + 3); // line length
    float f = 0.45f; // hit shape is 90% of line length
    path.reset();
    path.moveTo(center - f * l, 0);
    path.lineTo(center + f * l, 0);
    double theta = Math.atan2(p1.y - p2.y, p1.x - p2.x);
    transform.setToRotation(theta, p2.x, p2.y);
    transform.translate(p2.x, p2.y);
    hitShapes[2] = transform.createTransformedShape(path); // line
    path.reset();
    path.moveTo(center - l / 2, 0);
    path.lineTo(center + l / 2, 0);
    Shape line = transform.createTransformedShape(path);

    // set up drawing area
    if (stroke == null || stroke.getLineWidth() != scale * baseStroke.getLineWidth()) {
      stroke = new BasicStroke(scale * baseStroke.getLineWidth());
    }
    Area area = new Area(stroke.createStrokedShape(target1));
    area.add(new Area(stroke.createStrokedShape(target2)));
    area.add(new Area(stroke.createStrokedShape(line)));
    return area;
  }
Пример #5
0
  @Override
  public void setFontLevel(int level) {
    if (autoloadButton == null) return;
    level = Math.max(0, level);
    Object[] toSize = new Object[] {loadButton, saveButton, autoloadButton};
    FontSizer.setFonts(toSize, level);
    for (String name : panels.keySet()) {
      TTrack track = trackerPanel.getTrack(name);
      FunctionPanel panel = panels.get(name);
      if (track == null || panel == null) continue;
      // get new footprint icon, automatically resized to current level
      panel.setIcon(track.getIcon(21, 16, "point")); // $NON-NLS-1$
    }

    super.setFontLevel(level);
    validate();
    autoloadButton.revalidate();
  }
 /**
  * Gets the icon.
  *
  * @param w width of the icon
  * @param h height of the icon
  * @return the icon
  */
 public Icon getIcon(int w, int h) {
   int scale = FontSizer.getIntegerFactor();
   w *= scale;
   h *= scale;
   if (stroke == null || stroke.getLineWidth() != scale * baseStroke.getLineWidth()) {
     stroke = new BasicStroke(scale * baseStroke.getLineWidth());
   }
   transform.setToScale(scale, scale);
   Shape target = stroke.createStrokedShape(transform.createTransformedShape(targetShape));
   Area area = new Area(target);
   double x0 = scale * (size + 2) - w;
   double y0 = h - scale * (size + 2);
   double d = Math.sqrt(x0 * x0 + y0 * y0);
   double x1 = x0 * scale * size / d;
   double y1 = y0 * scale * size / d;
   Line2D line = new Line2D.Double(x0, y0, x1, y1);
   area.add(new Area(stroke.createStrokedShape(line)));
   ShapeIcon icon = new ShapeIcon(area, w, h);
   icon.setColor(color);
   return icon;
 }
Пример #7
0
 /** Refreshes the GUI. */
 protected void refreshGUI() {
   super.refreshGUI();
   dropdown.setToolTipText(
       TrackerRes.getString("TrackerPanel.DataBuilder.Dropdown.Tooltip")); // $NON-NLS-1$
   setTitle(TrackerRes.getString("TrackerPanel.DataBuilder.Title")); // $NON-NLS-1$
   if (loadButton != null) {
     FunctionPanel panel = getSelectedPanel();
     loadButton.setEnabled(panel != null);
     saveButton.setEnabled(panel != null);
     loadButton.setToolTipText(
         TrackerRes.getString("TrackerPanel.DataBuilder.Button.Load.Tooltip")); // $NON-NLS-1$
     saveButton.setToolTipText(
         TrackerRes.getString("TrackerPanel.DataBuilder.Button.Save.Tooltip")); // $NON-NLS-1$
     autoloadButton.setText(
         TrackerRes.getString("TrackerPanel.DataBuilder.Button.Autoload")
             + "..."); //$NON-NLS-1$ //$NON-NLS-2$
     autoloadButton.setToolTipText(
         TrackerRes.getString("TrackerPanel.DataBuilder.Button.Autoload.Tooltip")); // $NON-NLS-1$
   }
   setFontLevel(FontSizer.getLevel());
   if (autoloadManager != null) {
     autoloadManager.refreshGUI();
   }
 }
Пример #8
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;
  }