/** {@inheritDoc} */
  public Vector<Score> sortedClasses(Gesture g) {
    Vector<Score> sortedClasses = new Vector<Score>();

    Vector<Point2D> inputPointsResampled = new Vector<Point2D>();
    GestureUtils.resample(g.getPoints(), nbPoints, inputPointsResampled);
    GestureUtils.rotateToZero(inputPointsResampled, inputPointsResampled);
    GestureUtils.scaleToSquare(inputPointsResampled, sizeScaleToSquare, inputPointsResampled);
    GestureUtils.translateToOrigin(inputPointsResampled, inputPointsResampled);

    double score;
    double minClassScore = 0;
    for (int nc = 0; nc < classes.size(); nc++) {
      minClassScore = Integer.MAX_VALUE;
      for (Iterator<Vector<Point2D>> gesturesIterator =
              classes.get(nc).getResampledGestures().iterator();
          gesturesIterator.hasNext(); ) {
        Vector<Point2D> gesturePoints = gesturesIterator.next();
        score =
            GestureUtils.distanceAtBestAngle(
                inputPointsResampled, gesturePoints, -theta, theta, deltaTheta);
        if (score < minClassScore) minClassScore = score;
      }
      if (nc == 0) {
        sortedClasses.add(new Score(classes.get(nc).getName(), minClassScore));
      } else {
        int i = 0;
        while (i < sortedClasses.size() && sortedClasses.get(i).getScore() < minClassScore) i++;
        sortedClasses.add(i, new Score(classes.get(nc).getName(), minClassScore));
      }
    }

    return sortedClasses;
  }
  /** {@inheritDoc} */
  public String classify(Gesture g) {
    double minScore = Double.MAX_VALUE;
    double currentScore;
    GestureClass recognized = null;

    Vector<Point2D> inputPointsResampled = new Vector<Point2D>();
    GestureUtils.resample(g.getPoints(), nbPoints, inputPointsResampled);
    GestureUtils.rotateToZero(inputPointsResampled, inputPointsResampled);
    GestureUtils.scaleToSquare(inputPointsResampled, sizeScaleToSquare, inputPointsResampled);
    GestureUtils.translateToOrigin(inputPointsResampled, inputPointsResampled);

    for (Iterator<Dollar1GestureClass> classesIterator = classes.iterator();
        classesIterator.hasNext(); ) {
      Dollar1GestureClass nextClass = classesIterator.next();
      for (Iterator<Vector<Point2D>> gesturesIterator = nextClass.getResampledGestures().iterator();
          gesturesIterator.hasNext(); ) {
        Vector<Point2D> gesturePoints = gesturesIterator.next();
        currentScore =
            GestureUtils.distanceAtBestAngle(
                inputPointsResampled, gesturePoints, -theta, theta, deltaTheta);
        if (currentScore < minScore) {
          minScore = currentScore;
          recognized = nextClass;
        }
      }
    }
    currentDistance = minScore;
    if (currentDistance > maximumDistance) return null;
    return recognized.getName();
  }
 /**
  * {@inheritDoc} Each time a gesture is added, a vector of points corresponding to this gesture
  * as resampled, rotated and scaled is computed and stored in <code>resampledGestures</code>.
  */
 public void addExample(Gesture gesture) {
   super.addExample(gesture);
   Vector<Point2D> newPoints = new Vector<Point2D>();
   GestureUtils.resample(gesture.getPoints(), Dollar1Classifier.this.getNbPoints(), newPoints);
   GestureUtils.rotateToZero(newPoints, newPoints);
   GestureUtils.scaleToSquare(
       newPoints, Dollar1Classifier.this.getSizeScaleToSquare(), newPoints);
   GestureUtils.translateToOrigin(newPoints, newPoints);
   resampledGestures.add(newPoints);
 }