/** {@inheritDoc} */
  public CPolyLine getRepresentative(String className) {
    int i = 0;
    Dollar1GestureClass gestureClass = null;
    for (; i < classes.size(); i++) {
      gestureClass = classes.get(i);
      if (className.compareTo(gestureClass.getName()) == 0) break;
    }

    Vector<Point2D> average = gestureClass.getAverage();
    CPolyLine representative = null;
    Vector<Point2D> next = null;
    double minValue = Double.MAX_VALUE;
    for (Iterator<Vector<Point2D>> gesturesIterator =
            gestureClass.getResampledGestures().iterator();
        gesturesIterator.hasNext(); ) {
      next = gesturesIterator.next();
      double value = GestureUtils.distanceAtBestAngle(next, average, -theta, theta, deltaTheta);
      if (value < minValue) {
        minValue = value;
        representative = GestureUtils.asPolyLine(next);
      }
    }

    if (representative != null) representative.setFilled(false);
    return representative;
  }
Exemple #2
0
 public void paintIcon(Component c, Graphics g, int x, int y) {
   Color color = c.getForeground();
   Color saveColor = g.getColor();
   CRectangle bg = new CRectangle(x, y, width, height);
   bg.setFilled(false);
   bg.paint(g);
   polyline
       .setReferencePoint(0, 0)
       .translateTo(x + sideStartingPoint / 2 + 1, y + sideStartingPoint / 2 + 1);
   polyline.setOutlinePaint(color).setAntialiased(true);
   polyline.paint(g);
   startPoint.paint(g);
   g.setColor(saveColor);
 }
Exemple #3
0
 public GestureIcon(int width, int height, AbstractClassifier classifier, String className) {
   this.width = width;
   this.height = height;
   polyline = classifier.getRepresentative(className).asPolyLine();
   double sx = (width - 6) / polyline.getWidth();
   double sy = (height - 6) / polyline.getHeight();
   sideStartingPoint = Math.min(width, height) / 5;
   startPoint =
       new CEllipse(
           polyline.getStartX() - (sideStartingPoint / 2) / sx,
           polyline.getStartY() - (sideStartingPoint / 2) / sy,
           sideStartingPoint / sx,
           sideStartingPoint / sy);
   startPoint.setFillPaint(Color.RED).setOutlinePaint(Color.RED).setPickable(false);
   polyline.addChild(startPoint);
   polyline.scaleBy(sx, sy);
   polyline.setFilled(false);
 }