/** * 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()); } }
/** * Sets the start point of the subpath. * @param startPoint */ public void setStartPoint(Point startPoint) { setStartPoint((float) startPoint.getX(), (float) startPoint.getY()); }
/** * @param width the width, in text space * @return the width in user space */ private float convertWidthFromTextSpaceToUserSpace(float width) { LineSegment textSpace = new LineSegment(new Vector(0, 0, 1), new Vector(width, 0, 1)); LineSegment userSpace = textSpace.transformBy(textToUserSpaceTransformMatrix); return userSpace.getLength(); }
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; }
/** * Gets the copy of this rectangle. * * @return the copied rectangle. */ public Rectangle clone() { return new Rectangle(x, y, width, height); }
/** * Appends a straight line segment from the current point to the point <CODE>(x, y)</CODE>. * @param x x-coordinate of the new point * @param y y-coordinate of the new point */ public void lineTo(float x, float y) { if (currentPoint == null) { throw new RuntimeException(START_PATH_ERR_MSG); } Point targetPoint = new Point(x, y); getLastSubpath().addSegment(new Line(currentPoint, targetPoint)); currentPoint = targetPoint; }
/** * Add a counter-clockwise rotation to this transformation, * using the passed point as the center of rotation * @param angle angle in radians to rotate over * @param px x-coordinate of center of rotation * @param py y-coordinate of center of rotation */ public void rotate(double angle, double px, double py) { concatenate(AffineTransform.getRotateInstance(angle, px, py)); }
public static AffineTransform getShearInstance(double shx, double shy) { AffineTransform m = new AffineTransform(); m.setToShear(shx, shy); return m; }
/** * Get an affine transformation representing a counter-clockwise rotation over the passed angle * * @param angle angle in radians to rotate over * @return {@link AffineTransform} representing the rotation */ public static AffineTransform getRotateInstance(double angle) { AffineTransform t = new AffineTransform(); t.setToRotation(angle); return t; }
/** * Rotates PageSize clockwise. */ public PageSize rotate() { return new PageSize(height, width); }
/** * Computes the cross product of this vector and the specified matrix * * @param by the matrix to cross this vector with * @return the result of the cross product */ public Vector cross(Matrix by) { float x = vals[I1] * by.get(Matrix.I11) + vals[I2] * by.get(Matrix.I21) + vals[I3] * by.get(Matrix.I31); float y = vals[I1] * by.get(Matrix.I12) + vals[I2] * by.get(Matrix.I22) + vals[I3] * by.get(Matrix.I32); float z = vals[I1] * by.get(Matrix.I13) + vals[I2] * by.get(Matrix.I23) + vals[I3] * by.get(Matrix.I33); return new Vector(x, y, z); }
/** * Sets the start point of the subpath. * @param x * @param y */ public void setStartPoint(float x, float y) { this.startPoint = new Point(x, y); }
/** * Transforms the segment by the specified matrix * @param m the matrix for the transformation * @return the transformed segment */ public LineSegment transformBy(Matrix m){ Vector newStart = startPoint.cross(m); Vector newEnd = endPoint.cross(m); return new LineSegment(newStart, newEnd); }
/** * Sets the current clipping path to the specified path. * * <strong>Note:</strong>This method doesn't modify existing clipping path, * it simply replaces it with the new one instead. * @param clippingPath New clipping path. */ public void setClippingPath(Path clippingPath) { Path pathCopy = new Path(clippingPath); pathCopy.closeAllSubpaths(); this.clippingPath = pathCopy; }
/** * Checks if a segment contains another segment in itself * @param other a segment to be checked * @return true if this segment contains other one, false otherwise */ public boolean containsSegment(LineSegment other) { return other != null && containsPoint(other.startPoint) && containsPoint(other.endPoint); }
/** * @return the size of the image, in User space units */ public float getArea() { // the image space area is 1, so we multiply that by the determinant of the CTM to get the transformed area return ctm.getDeterminant(); }
/** * @param height the height, in text space * @return the height in user space */ private float convertHeightFromTextSpaceToUserSpace(float height) { LineSegment textSpace = new LineSegment(new Vector(0, 0, 1), new Vector(0, height, 1)); LineSegment userSpace = textSpace.transformBy(textToUserSpaceTransformMatrix); return userSpace.getLength(); }
@Override public Rectangle clone() { return new PageSize(this); } }