/** * Constructs a TextPath based on the specified path. * * @param path The general path along which text is to be laid. */ public TextPath(GeneralPath path) { pathLength = new PathLength(path); startOffset = 0; }
/** * Returns the total length of the path. * * @return The lenght of the path. */ public float lengthOfPath() { return pathLength.lengthOfPath(); }
/** * Returns the point that is at the specified length * along the path. * * @param length The length along the path. * @return The point. */ public Point2D pointAtLength(float length) { return pathLength.pointAtLength(length); } }
PathLength pl = new PathLength(path); float pathLength = pl.lengthOfPath(); pl.lengthOfPath() == 0f || glyphsLength == 0f) { return newPath; Point2D charMidPoint = pl.pointAtLength(charMidPos); float angle = pl.angleAtLength(charMidPos);
(keyPoints[keyTimeIndex + 1] - keyPoints[keyTimeIndex]); point *= pathLength.lengthOfPath(); Point2D p = pathLength.pointAtLength(point); float ang; if (rotateAuto) { ang = pathLength.angleAtLength(point); if (rotateAutoReverse) { ang += Math.PI; (float) p.getY(), ang); } else { Point2D p = pathLength.pointAtLength(pathLength.lengthOfPath()); float ang; if (rotateAuto) { ang = pathLength.angleAtLength(pathLength.lengthOfPath()); if (rotateAutoReverse) { ang += Math.PI; Point2D p = pathLength.pointAtLength(pathLength.lengthOfPath()); float ang; if (rotateAuto) { ang = pathLength.angleAtLength(pathLength.lengthOfPath()); if (rotateAutoReverse) { ang += Math.PI;
pathLength = new PathLength(path); int segments = 0; ExtendedPathIterator epi = path.getExtendedPathIterator(); float totalLength = pathLength.lengthOfPath(); if (this.keyTimes != null && calcMode != CALC_MODE_PACED) { if (this.keyTimes.length != count) { pathLength.getLengthAtSegment(j) / totalLength; j++; epi.next(); epi.next(); keyPoints[i] = pathLength.getLengthAtSegment(j) / totalLength; j++; epi.next();
/** * Returns the point that is the given proportion along the path segment * given by the specified index. */ public Point2D pointAtLength(int index, float proportion) { if (!initialised) { initialise(); } if (index < 0 || index >= segmentIndexes.length) { return null; } PathSegment seg = (PathSegment) segments.get(segmentIndexes[index]); float start = seg.getLength(); float end; if (index == segmentIndexes.length - 1) { end = pathLength; } else { seg = (PathSegment) segments.get(segmentIndexes[index + 1]); end = seg.getLength(); } return pointAtLength(start + (end - start) * proportion); }
/** * Returns the slope of the path at the specified length. * @param index The segment number * @param proportion The proportion along the given segment * @return the angle in radians, in the range [-{@link Math#PI}, * {@link Math#PI}]. */ public float angleAtLength(int index, float proportion) { if (!initialised) { initialise(); } if (index < 0 || index >= segmentIndexes.length) { return 0f; } PathSegment seg = (PathSegment) segments.get(segmentIndexes[index]); float start = seg.getLength(); float end; if (index == segmentIndexes.length - 1) { end = pathLength; } else { seg = (PathSegment) segments.get(segmentIndexes[index + 1]); end = seg.getLength(); } return angleAtLength(start + (end - start) * proportion); }
/** * Returns the length of the path used by this PathLength object. * @return The length of the path. */ public float lengthOfPath() { if (!initialised) { initialise(); } return pathLength; }
/** * Returns the angle at the specified length * along the path. * * @param length The length along the path. * @return The angle. */ public float angleAtLength(float length) { return pathLength.angleAtLength(length); }
/** * Returns the index of the segment at the given distance along the path. */ public int segmentAtLength(float length) { int upperIndex = findUpperIndex(length); if (upperIndex == -1) { // Length is off the end of the path. return -1; } if (upperIndex == 0) { // Length was probably zero, so return the upper segment. PathSegment upper = (PathSegment) segments.get(upperIndex); return upper.getIndex(); } PathSegment lower = (PathSegment) segments.get(upperIndex - 1); return lower.getIndex(); }
/** * Returns the index of the path segment at the given distance along the * path. */ public int getPathSegAtLength(float distance) { PathLength pl = getPathLengthObj(); return pl.segmentAtLength(distance); } }
/** * Creates a new PathLength object for the specified {@link Shape}. * @param path The Path (or Shape) to use. */ public PathLength(Shape path) { setPath(path); }
PathLength pl = new PathLength(path); float pathLength = pl.lengthOfPath(); pl.lengthOfPath() == 0f || glyphsLength == 0f) { return newPath; Point2D charMidPoint = pl.pointAtLength(charMidPos); float angle = pl.angleAtLength(charMidPos);
(keyPoints[keyTimeIndex + 1] - keyPoints[keyTimeIndex]); point *= pathLength.lengthOfPath(); Point2D p = pathLength.pointAtLength(point); float ang; if (rotateAuto) { ang = pathLength.angleAtLength(point); if (rotateAutoReverse) { ang += Math.PI; (float) p.getY(), ang); } else { Point2D p = pathLength.pointAtLength(pathLength.lengthOfPath()); float ang; if (rotateAuto) { ang = pathLength.angleAtLength(pathLength.lengthOfPath()); if (rotateAutoReverse) { ang += Math.PI; Point2D p = pathLength.pointAtLength(pathLength.lengthOfPath()); float ang; if (rotateAuto) { ang = pathLength.angleAtLength(pathLength.lengthOfPath()); if (rotateAutoReverse) { ang += Math.PI;
pathLength = new PathLength(path); int segments = 0; ExtendedPathIterator epi = path.getExtendedPathIterator(); float totalLength = pathLength.lengthOfPath(); if (this.keyTimes != null && calcMode != CALC_MODE_PACED) { if (this.keyTimes.length != count) { pathLength.getLengthAtSegment(j) / totalLength; j++; epi.next(); epi.next(); keyPoints[i] = pathLength.getLengthAtSegment(j) / totalLength; j++; epi.next();
/** * Returns the point that is the given proportion along the path segment * given by the specified index. */ public Point2D pointAtLength(int index, float proportion) { if (!initialised) { initialise(); } if (index < 0 || index >= segmentIndexes.length) { return null; } PathSegment seg = (PathSegment) segments.get(segmentIndexes[index]); float start = seg.getLength(); float end; if (index == segmentIndexes.length - 1) { end = pathLength; } else { seg = (PathSegment) segments.get(segmentIndexes[index + 1]); end = seg.getLength(); } return pointAtLength(start + (end - start) * proportion); }
/** * Returns the slope of the path at the specified length. * @param index The segment number * @param proportion The proportion along the given segment * @return the angle in radians, in the range [-{@link Math#PI}, * {@link Math#PI}]. */ public float angleAtLength(int index, float proportion) { if (!initialised) { initialise(); } if (index < 0 || index >= segmentIndexes.length) { return 0f; } PathSegment seg = (PathSegment) segments.get(segmentIndexes[index]); float start = seg.getLength(); float end; if (index == segmentIndexes.length - 1) { end = pathLength; } else { seg = (PathSegment) segments.get(segmentIndexes[index + 1]); end = seg.getLength(); } return angleAtLength(start + (end - start) * proportion); }
/** * Returns the length of the path used by this PathLength object. * @return The length of the path. */ public float lengthOfPath() { if (!initialised) { initialise(); } return pathLength; }
/** * Returns the angle at the specified length * along the path. * * @param length The length along the path. * @return The angle. */ public float angleAtLength(float length) { return pathLength.angleAtLength(length); }