private int checkPointSide(Point filteredPoint, Point clipLineBeg, Point clipLineEnd) { double x1, x2, y1, y2; x1 = filteredPoint.getX() - clipLineBeg.getX(); y2 = clipLineEnd.getY() - clipLineBeg.getY(); x2 = clipLineEnd.getX() - clipLineBeg.getX(); y1 = filteredPoint.getY() - clipLineBeg.getY(); double sgn = x1 * y2 - x2 * y1; if (Math.abs(sgn) < 0.001) return 0; if (sgn > 0) return 1; if (sgn < 0) return -1; return 0; }
/** * Constructs a new subpath starting at the given point. */ public Subpath(Point startPoint) { this((float) startPoint.getX(), (float) startPoint.getY()); }
private int checkPointSide(Point filteredPoint, Point clipLineBeg, Point clipLineEnd) { double x1, x2, y1, y2; x1 = filteredPoint.getX() - clipLineBeg.getX(); y2 = clipLineEnd.getY() - clipLineBeg.getY(); x2 = clipLineEnd.getX() - clipLineBeg.getX(); y1 = filteredPoint.getY() - clipLineBeg.getY(); double sgn = x1 * y2 - x2 * y1; if (Math.abs(sgn) < 0.001) return 0; if (sgn > 0) return 1; if (sgn < 0) return -1; return 0; }
private Point getIntersectionPoint(Point lineBeg, Point lineEnd, Point clipLineBeg, Point clipLineEnd) { double A1 = lineBeg.getY() - lineEnd.getY(), A2 = clipLineBeg.getY() - clipLineEnd.getY(); double B1 = lineEnd.getX() - lineBeg.getX(), B2 = clipLineEnd.getX() - clipLineBeg.getX(); double C1 = lineBeg.getX() * lineEnd.getY() - lineBeg.getY() * lineEnd.getX(); double C2 = clipLineBeg.getX() * clipLineEnd.getY() - clipLineBeg.getY() * clipLineEnd.getX(); double M = B1 * A2 - B2 * A1; return new Point((B2 * C1 - B1 * C2) / M, (C2 * A1 - C1 * A2) / M); } }
protected Point getIntersectionPoint(Point lineBeg, Point lineEnd, Point clipLineBeg, Point clipLineEnd) { double A1 = lineBeg.getY() - lineEnd.getY(), A2 = clipLineBeg.getY() - clipLineEnd.getY(); double B1 = lineEnd.getX() - lineBeg.getX(), B2 = clipLineEnd.getX() - clipLineBeg.getX(); double C1 = lineBeg.getX() * lineEnd.getY() - lineBeg.getY() * lineEnd.getX(); double C2 = clipLineBeg.getX() * clipLineEnd.getY() - clipLineBeg.getY() * clipLineEnd.getX(); double M = B1 * A2 - B2 * A1; return new Point((B2 * C1 - B1 * C2) / M, (C2 * A1 - C1 * A2) / M); } }
protected Point getIntersectionPoint(Point lineBeg, Point lineEnd, Point clipLineBeg, Point clipLineEnd) { double A1 = lineBeg.getY() - lineEnd.getY(), A2 = clipLineBeg.getY() - clipLineEnd.getY(); double B1 = lineEnd.getX() - lineBeg.getX(), B2 = clipLineEnd.getX() - clipLineBeg.getX(); double C1 = lineBeg.getX() * lineEnd.getY() - lineBeg.getY() * lineEnd.getX(); double C2 = clipLineBeg.getX() * clipLineEnd.getY() - clipLineBeg.getY() * clipLineEnd.getX(); double M = B1 * A2 - B2 * A1; return new Point((B2 * C1 - B1 * C2) / M, (C2 * A1 - C1 * A2) / M); } }
private Point getIntersectionPoint(Point lineBeg, Point lineEnd, Point clipLineBeg, Point clipLineEnd) { double A1 = lineBeg.getY() - lineEnd.getY(), A2 = clipLineBeg.getY() - clipLineEnd.getY(); double B1 = lineEnd.getX() - lineBeg.getX(), B2 = clipLineEnd.getX() - clipLineBeg.getX(); double C1 = lineBeg.getX() * lineEnd.getY() - lineBeg.getY() * lineEnd.getX(); double C2 = clipLineBeg.getX() * clipLineEnd.getY() - clipLineBeg.getY() * clipLineEnd.getX(); double M = B1 * A2 - B2 * A1; return new Point((B2 * C1 - B1 * C2) / M, (C2 * A1 - C1 * A2) / M); } }
/** * Converts list of {@link com.itextpdf.kernel.geom.Point} objects into list of * {@link Point.LongPoint} objects. */ public static List<Point.LongPoint> convertToLongPoints(List<com.itextpdf.kernel.geom.Point> points) { List<Point.LongPoint> convertedPoints = new ArrayList<>(points.size()); for (com.itextpdf.kernel.geom.Point point : points) { convertedPoints.add(new Point.LongPoint( floatMultiplier * point.getX(), floatMultiplier * point.getY() )); } return convertedPoints; }
/** * Appends a cubic Bezier curve to the current path. The curve shall extend from * the current point to the point <CODE>(x3, y3)</CODE> with the note that the current * point represents two control points. */ public void curveTo(float x2, float y2, float x3, float y3) { if (currentPoint == null) { throw new RuntimeException(START_PATH_ERR_MSG); } curveTo((float) currentPoint.getX(), (float) currentPoint.getY(), x2, y2, x3, y3); }
/** * Sets the start point of the subpath. * @param startPoint */ public void setStartPoint(Point startPoint) { setStartPoint((float) startPoint.getX(), (float) startPoint.getY()); }
static void addContour(com.itextpdf.kernel.geom.Path path, List<Point.LongPoint> contour, boolean close) { List<com.itextpdf.kernel.geom.Point> floatContour = convertToFloatPoints(contour); com.itextpdf.kernel.geom.Point point = floatContour.get(0); path.moveTo((float) point.getX(), (float) point.getY()); for (int i = 1; i < floatContour.size(); i++) { point = floatContour.get(i); path.lineTo((float) point.getX(), (float) point.getY()); } if (close) { path.closeSubpath(); } }
public double distanceSq(double px, double py) { return distanceSq(getX(), getY(), px, py); }
public Point deltaTransform(Point src, Point dst) { if (dst == null) { dst = new Point(); } double x = src.getX(); double y = src.getY(); dst.setLocation(x * m00 + y * m01, x * m10 + y * m11); return dst; }
public Point transform(Point src, Point dst) { if (dst == null) { dst = new Point(); } double x = src.getX(); double y = src.getY(); dst.setLocation(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12); return dst; }
@Override public void setCoordinates(String[] coordinates, Point startPoint) { String[] normalizedCoords = new String[coordinates.length * 2]; // An H or h command is equivalent to an L or l command with 0 specified for the y coordinate. for (int i = 0; i < coordinates.length; i++) { normalizedCoords[i * 2] = coordinates[i]; normalizedCoords[i * 2 + 1] = isRelative() ? "0" : SvgCssUtils.convertDoubleToString(startPoint.getY()); } super.setCoordinates(normalizedCoords, startPoint); } }
public void transform(Point[] src, int srcOff, Point[] dst, int dstOff, int length) { while (--length >= 0) { Point srcPoint = src[srcOff++]; double x = srcPoint.getX(); double y = srcPoint.getY(); Point dstPoint = dst[dstOff]; if (dstPoint == null) { dstPoint = new Point(); } dstPoint.setLocation(x * m00 + y * m01 + m02, x * m10 + y * m11 + m12); dst[dstOff++] = dstPoint; } }
public Point inverseTransform(Point src, Point dst) throws NoninvertibleTransformException { double det = getDeterminant(); if (Math.abs(det) < ZERO) { // awt.204=Determinant is zero throw new NoninvertibleTransformException("Determinant is zero. Cannot invert transformation"); //$NON-NLS-1$ } if (dst == null) { dst = new Point(); } double x = src.getX() - m02; double y = src.getY() - m12; dst.setLocation((x * m11 - y * m01) / det, (y * m00 - x * m10) / det); return dst; }
@Override public int hashCode() { HashCode hash = new HashCode(); hash.append(getX()); hash.append(getY()); return hash.hashCode(); }
/** * Closes the current subpath. */ public void closeSubpath() { if (!isEmpty()) { Subpath lastSubpath = getLastSubpath(); lastSubpath.setClosed(true); Point startPoint = lastSubpath.getStartPoint(); moveTo((float) startPoint.getX(), (float) startPoint.getY()); } }