@Override public Document convert(Polygon source) { if (source == null) { return null; } List<Point> points = source.getPoints(); List<Document> pointTuples = new ArrayList<>(points.size()); for (Point point : points) { pointTuples.add(PointToDocumentConverter.INSTANCE.convert(point)); } Document result = new Document(); result.put("points", pointTuples); return result; } }
@Override @SuppressWarnings({ "unchecked" }) public Polygon convert(Document source) { if (source == null) { return null; } List<Document> points = (List<Document>) source.get("points"); List<Point> newPoints = new ArrayList<>(points.size()); for (Document element : points) { Assert.notNull(element, "Point elements of polygon must not be null!"); newPoints.add(DocumentToPointConverter.INSTANCE.convert(element)); } return new Polygon(newPoints); } }
public int bindPolygon(final Object value, final boolean shouldIgnoreCase, final int startIndex) { int index = startIndex; final Polygon polygon = (Polygon) ignoreArgumentCase(value, shouldIgnoreCase); final List<List<Double>> points = new LinkedList<>(); polygon.forEach(p -> { final List<Double> point = new LinkedList<>(); point.add(p.getY()); point.add(p.getX()); points.add(point); }); bind(index++, points); return index; }
public int bindPolygon(final Object value, final boolean shouldIgnoreCase, final int startIndex) { int index = startIndex; final Polygon polygon = (Polygon) ignoreArgumentCase(value, shouldIgnoreCase); final List<List<Double>> points = new LinkedList<>(); polygon.forEach(p -> { final List<Double> point = new LinkedList<>(); point.add(p.getY()); point.add(p.getX()); points.add(point); }); bind(index++, points); return index; }
for (Point point : ((Polygon) shape).getPoints()) { argument.add(toList(point));
@Override @SuppressWarnings({ "unchecked" }) public Polygon convert(Document source) { if (source == null) { return null; } List<Document> points = (List<Document>) source.get("points"); List<Point> newPoints = new ArrayList<>(points.size()); for (Document element : points) { Assert.notNull(element, "Point elements of polygon must not be null!"); newPoints.add(DocumentToPointConverter.INSTANCE.convert(element)); } return new Polygon(newPoints); } }
@Override public Document convert(Polygon source) { if (source == null) { return null; } List<Point> points = source.getPoints(); List<Document> pointTuples = new ArrayList<>(points.size()); for (Point point : points) { pointTuples.add(PointToDocumentConverter.INSTANCE.convert(point)); } Document result = new Document(); result.put("points", pointTuples); return result; } }
for (Point point : ((Polygon) shape).getPoints()) { argument.add(toList(point));
@Override public boolean pointInPolygon(Point p, Polygon polygon) { final List<Point> points = polygon.getPoints(); Path2D awtPolygon = new Path2D.Double(Path2D.WIND_EVEN_ODD, points.size()); boolean first = true; for (Point point : points) { if (first) { first = false; awtPolygon.moveTo(point.getX(), point.getY()); } else { awtPolygon.lineTo(point.getX(), point.getY()); } } awtPolygon.closePath(); return pointInPolygon(p, awtPolygon); }
@Override public boolean pointInPolygon(Point p, Polygon polygon) { final List<Point> points = polygon.getPoints(); Path2D awtPolygon = new Path2D.Double(Path2D.WIND_EVEN_ODD, points.size()); boolean first = true; for (Point point : points) { if (first) { first = false; awtPolygon.moveTo(point.getX(), point.getY()); } else { awtPolygon.lineTo(point.getX(), point.getY()); } } awtPolygon.closePath(); return pointInPolygon(p, awtPolygon); }