本文整理汇总了Java中java.awt.geom.Path2D.getPathIterator方法的典型用法代码示例。如果您正苦于以下问题:Java Path2D.getPathIterator方法的具体用法?Java Path2D.getPathIterator怎么用?Java Path2D.getPathIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.Path2D
的用法示例。
在下文中一共展示了Path2D.getPathIterator方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFlattening
import java.awt.geom.Path2D; //导入方法依赖的package包/类
static void testFlattening(Path2D pathA, Path2D pathB) {
final PathIterator itA = pathA.getPathIterator(at, FLATNESS);
final PathIterator itB = pathB.getPathIterator(at, FLATNESS);
float[] coordsA = new float[6];
float[] coordsB = new float[6];
int n = 0;
for (; !itA.isDone() && !itB.isDone(); itA.next(), itB.next(), n++) {
int typeA = itA.currentSegment(coordsA);
int typeB = itB.currentSegment(coordsB);
if (typeA != typeB) {
throw new IllegalStateException("Path-segment[" + n + "] "
+ "type are not equals [" + typeA + "|" + typeB + "] !");
}
// Take care of floating-point precision:
if (!equalsArrayEps(coordsA, coordsB, getLength(typeA))) {
throw new IllegalStateException("Path-segment[" + n + "] coords"
+ " are not equals [" + Arrays.toString(coordsA) + "|"
+ Arrays.toString(coordsB) + "] !");
}
}
if (!itA.isDone() || !itB.isDone()) {
throw new IllegalStateException("Paths do not have same lengths !");
}
log("testFlattening: " + n + " segments.");
}
示例2: testIterator
import java.awt.geom.Path2D; //导入方法依赖的package包/类
static void testIterator(Path2D pathA, Path2D pathB) {
final PathIterator itA = pathA.getPathIterator(at);
final PathIterator itB = pathB.getPathIterator(at);
float[] coordsA = new float[6];
float[] coordsB = new float[6];
int n = 0;
for (; !itA.isDone() && !itB.isDone(); itA.next(), itB.next(), n++) {
int typeA = itA.currentSegment(coordsA);
int typeB = itB.currentSegment(coordsB);
if (typeA != typeB) {
throw new IllegalStateException("Path-segment[" + n + "] "
+ "type are not equals [" + typeA + "|" + typeB + "] !");
}
// Take care of floating-point precision:
if (!equalsArrayEps(coordsA, coordsB, getLength(typeA))) {
throw new IllegalStateException("Path-segment[" + n + "] coords"
+ " are not equals [" + Arrays.toString(coordsA) + "|"
+ Arrays.toString(coordsB) + "] !");
}
}
if (!itA.isDone() || !itB.isDone()) {
throw new IllegalStateException("Paths do not have same lengths !");
}
log("testIterator: " + n + " segments.");
}
示例3: getPoints
import java.awt.geom.Path2D; //导入方法依赖的package包/类
public static List<Point2D> getPoints(final Path2D path) {
final PathIterator pi = path.getPathIterator(null);
final double[] coordinates = new double[22];
final List<Point2D> points = new ArrayList<>();
while (!pi.isDone()) {
pi.next();
pi.currentSegment(coordinates);
final Point2D currentPoint = new Point2D.Double(coordinates[0], coordinates[1]);
points.add(currentPoint);
}
return points;
}
示例4: testEqual
import java.awt.geom.Path2D; //导入方法依赖的package包/类
static void testEqual(Path2D pathA, Path2D pathB) {
final PathIterator itA = pathA.getPathIterator(null);
final PathIterator itB = pathB.getPathIterator(null);
float[] coordsA = new float[6];
float[] coordsB = new float[6];
int n = 0;
for (; !itA.isDone() && !itB.isDone(); itA.next(), itB.next(), n++) {
int typeA = itA.currentSegment(coordsA);
int typeB = itB.currentSegment(coordsB);
if (typeA != typeB) {
throw new IllegalStateException("Path-segment[" + n + "] "
+ " type are not equals [" + typeA + "|" + typeB + "] !");
}
if (!equalsArray(coordsA, coordsB, getLength(typeA))) {
throw new IllegalStateException("Path-segment[" + n + "] coords"
+ " are not equals [" + Arrays.toString(coordsA) + "|"
+ Arrays.toString(coordsB) + "] !");
}
}
if (!itA.isDone() || !itB.isDone()) {
throw new IllegalStateException("Paths do not have same lengths !");
}
log("testEqual: " + n + " segments.");
}