@Override
  public final IVector2 scaleAndTranslate(final IVector2 point) {
    //      return point.sub(_viewport._lower).scale(_scale);

    final IVector2 scaled = point.sub(_viewport._lower).scale(_scale);
    return new GVector2D(scaled.x(), _renderExtent.y() - scaled.y());
  }
Пример #2
0
  private static List<IVector2> removeLastIfRepeated(final List<IVector2> points) {
    if (points.size() < 2) {
      return points;
    }

    final IVector2 first = points.get(0);
    final int lastIndex = points.size() - 1;
    final IVector2 last = points.get(lastIndex);
    if (first.closeTo(last)) {
      return points.subList(0, lastIndex - 1);
    }

    return points;
  }
Пример #3
0
  private static List<IVector2> removeConsecutiveEqualsPoints(final List<IVector2> points) {
    final int pointsCount = points.size();
    final ArrayList<IVector2> result = new ArrayList<IVector2>(pointsCount);

    for (int i = 0; i < pointsCount; i++) {
      final IVector2 current = points.get(i);
      final IVector2 next = points.get((i + 1) % pointsCount);
      if (!current.closeTo(next)) {
        result.add(current);
      }
    }

    result.trimToSize();
    return result;
  }
  @Override
  public final GAWTPoints toScaledAndTranslatedPoints(final IPointsContainer<IVector2> polygon) {
    final int nPoints = polygon.getPointsCount();
    final int[] xPoints = new int[nPoints];
    final int[] yPoints = new int[nPoints];

    for (int i = 0; i < nPoints; i++) {
      final IVector2 point = scaleAndTranslate(polygon.getPoint(i));

      xPoints[i] = Math.round((float) point.x());
      yPoints[i] = Math.round((float) point.y());
    }

    return new GAWTPoints(xPoints, yPoints);
  }
 @Override
 public final IVector2 scaleExtent(final IVector2 extent) {
   return extent.scale(_scale);
 }