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); } }
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; }
public double distanceSq(double px, double py) { return distanceSq(getX(), getY(), px, py); }
/** * Sets the start point of the subpath. * @param x * @param y */ public void setStartPoint(float x, float y) { this.startPoint = new Point(x, y); }
point.setLocation(point.getX() + shift[0], point.getY() + shift[1]);
public void setLocation(int x, int y) { setLocation((double)x, (double)y); }
@Override public void setCoordinates(String[] coordinates, Point startPoint) { String[] normalizedCoords = new String[coordinates.length * 2]; // A V or v command is equivalent to an L or l command with 0 specified for the x coordinate. for (int i = 0; i < coordinates.length; i++) { normalizedCoords[i * 2] = isRelative() ? "0" : SvgCssUtils.convertDoubleToString(startPoint.getX()); normalizedCoords[i * 2 + 1] = coordinates[i]; } super.setCoordinates(normalizedCoords, startPoint); } }
@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 double distance(Point p) { return Math.sqrt(distanceSq(p)); }
@SuppressWarnings("CloneDoesntCallSuperClone") @Override public Object clone() { return new Point(x, y); } }
point.setLocation(point.getX() + shift[0], point.getY() + shift[1]);
public Point(double x, double y) { setLocation(x, y); }
public double distance(double px, double py) { return Math.sqrt(distanceSq(px, py)); }
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 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; }
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; }
/** * Constructs a new subpath starting at the given point. */ public Subpath(float startPointX, float startPointY) { this.startPoint = new Point(startPointX, startPointY); }
public double distanceSq(Point p) { return distanceSq(getX(), getY(), p.getX(), p.getY()); }