當前位置: 首頁>>代碼示例>>Java>>正文


Java PathIterator.next方法代碼示例

本文整理匯總了Java中java.awt.geom.PathIterator.next方法的典型用法代碼示例。如果您正苦於以下問題:Java PathIterator.next方法的具體用法?Java PathIterator.next怎麽用?Java PathIterator.next使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.awt.geom.PathIterator的用法示例。


在下文中一共展示了PathIterator.next方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testFlattening

import java.awt.geom.PathIterator; //導入方法依賴的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.");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:Path2DCopyConstructor.java

示例2: testIterator

import java.awt.geom.PathIterator; //導入方法依賴的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.");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:Path2DCopyConstructor.java

示例3: mapShape

import java.awt.geom.PathIterator; //導入方法依賴的package包/類
public Shape mapShape(Shape s) {
    if (LOGMAP) LOG.format("mapshape on path: %s\n", LayoutPathImpl.SegmentPath.this);
    PathIterator pi = s.getPathIterator(null, 1); // cheap way to handle curves.

    if (LOGMAP) LOG.format("start\n");
    init();

    final double[] coords = new double[2];
    while (!pi.isDone()) {
        switch (pi.currentSegment(coords)) {
        case SEG_CLOSE: close(); break;
        case SEG_MOVETO: moveTo(coords[0], coords[1]); break;
        case SEG_LINETO: lineTo(coords[0], coords[1]); break;
        default: break;
        }

        pi.next();
    }
    if (LOGMAP) LOG.format("finish\n\n");

    GeneralPath gp = new GeneralPath();
    for (Segment seg: segments) {
        gp.append(seg.gp, false);
    }
    return gp;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:27,代碼來源:LayoutPathImpl.java

示例4: feedConsumer

import java.awt.geom.PathIterator; //導入方法依賴的package包/類
/**
 * Utility method to feed a {@link PathConsumer2D} object from a
 * given {@link PathIterator}.
 * This method deals with the details of running the iterator and
 * feeding the consumer a segment at a time.
 */
public static void feedConsumer(PathIterator pi, PathConsumer2D consumer) {
    float coords[] = new float[6];
    while (!pi.isDone()) {
        switch (pi.currentSegment(coords)) {
        case PathIterator.SEG_MOVETO:
            consumer.moveTo(coords[0], coords[1]);
            break;
        case PathIterator.SEG_LINETO:
            consumer.lineTo(coords[0], coords[1]);
            break;
        case PathIterator.SEG_QUADTO:
            consumer.quadTo(coords[0], coords[1],
                            coords[2], coords[3]);
            break;
        case PathIterator.SEG_CUBICTO:
            consumer.curveTo(coords[0], coords[1],
                             coords[2], coords[3],
                             coords[4], coords[5]);
            break;
        case PathIterator.SEG_CLOSE:
            consumer.closePath();
            break;
        }
        pi.next();
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:33,代碼來源:RenderingEngine.java

示例5: appendPath

import java.awt.geom.PathIterator; //導入方法依賴的package包/類
private static StringBuilder appendPath(StringBuilder sb, int indent, PathIterator pathIterator) {
    double[] coords = new double[6];
    while (!pathIterator.isDone()) {
        int type = pathIterator.currentSegment(coords);
        String typeStr;
        int endIndex;
        switch (type) {
            case PathIterator.SEG_CLOSE:
                typeStr = "SEG_CLOSE";
                endIndex = 0;
                break;
            case PathIterator.SEG_CUBICTO:
                typeStr = "SEG_CUBICTO";
                endIndex = 6;
                break;
            case PathIterator.SEG_LINETO:
                typeStr = "SEG_LINETO";
                endIndex = 2;
                break;
            case PathIterator.SEG_MOVETO:
                typeStr = "SEG_MOVETO";
                endIndex = 2;
                break;
            case PathIterator.SEG_QUADTO:
                typeStr = "SEG_QUADTO";
                endIndex = 4;
                break;
            default:
                throw new IllegalStateException("Invalid type=" + type);
        }
        ArrayUtilities.appendSpaces(sb, indent);
        sb.append(typeStr).append(": ");
        for (int i = 0; i < endIndex;) {
            sb.append("[").append(coords[i++]).append(",").append(coords[i++]).append("] ");
        }
        sb.append('\n');
        pathIterator.next();
    }
    return sb;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:41,代碼來源:ViewUtils.java

示例6: testEqual

import java.awt.geom.PathIterator; //導入方法依賴的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.");
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:Path2DCopyConstructor.java

示例7: createStrokedShape

import java.awt.geom.PathIterator; //導入方法依賴的package包/類
public Shape createStrokedShape(Shape shape) {
    // We are flattening the path iterator to only get line segments.
    PathIterator path = shape.getPathIterator(null, 1);
    float points[] = new float[6];
    GeneralPath strokepath = new GeneralPath();
    float ix = 0, iy = 0;
    float px = 0, py = 0;

    while (!path.isDone()) {
        int type = path.currentSegment(points);
        switch (type) {
            case PathIterator.SEG_MOVETO:
                ix = px = points[0];
                iy = py = points[1];
                strokepath.moveTo(ix, iy);
                break;
            case PathIterator.SEG_LINETO:
                strokepath.append(createArrow(px, py, points[0], points[1]),
                        false);
                px = points[0];
                py = points[1];
                break;
            case PathIterator.SEG_CLOSE:
                if (px != ix && py != ix)
                    strokepath.append(createArrow(px, py, ix, iy), false);
                break;
            default:
                strokepath.append(createArrow(px, py, points[0], points[1]),
                        false);
                px = points[0];
                py = points[1];
                // never appear.
        }
        path.next();
    }
    return strokepath;
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:38,代碼來源:WayStroke.java

示例8: updateLayer

import java.awt.geom.PathIterator; //導入方法依賴的package包/類
public synchronized void updateLayer() {
	if (sceneGraph == null)
		return;

	boolean flat = false; 
	
	if (layerKey != -1) {
		flat = sceneGraph.isAFlatScene(layerKey);
		sceneGraph.disposeSubLayer(layerKey);
	}

	layerKey = sceneGraph.createSubLayer();

	if (flat)
		sceneGraph.makeFlatLayer(layerKey);

	Map<Integer, DetailedIcon> myIcons = this.getIconMap();
	int size = (int) (ICON_SIZE * symbolSize / 100f);

	if (iconRenderer == null)
		iconRenderer = new DetailedIconRenderer();

	int index = 0;
	for (UnknownData d : this.data) {
		boolean invalidStation = (Float.isNaN(d.y) || d.y > 90 || d.y < -90);
		invalidStation = invalidStation || (Float.isNaN(d.x) || d.x > 360 || d.y < -180);

		if (!invalidStation) {
			DetailedIcon icon = new DetailedIcon(ICON_PATH, Position.fromDegrees(d.y, d.x, 0));
			icon.setIconColor( this.getColor() );
			icon.setSize(new Dimension(size, size));
			icon.setHighlightScale(2);
			myIcons.put(index, icon);
			
			sceneGraph.addItem(
					new WWSceneGraph.SceneItemIcon(icon, iconRenderer),
					layerKey);
		}
		index++;
	}

	for (Polyline poly : getPolylineMap().values())
		renderableLayer.removeRenderable(poly);
	getPolylineMap().clear();

	for (int polyIndex : polylines) {
		UnknownData ud = data.get(polyIndex);
		if (ud.polyline == null) continue;

		List<Position> points = new LinkedList<Position>();

		PathIterator pi = ud.polyline.getPathIterator(new AffineTransform());
		float[] coords = new float[2];
		while (true) {
			pi.currentSegment(coords);
			if (pi.isDone()) break;
			points.add( Position.fromDegrees(coords[1] + ud.polyY0, coords[0] + ud.polyX0, 0) );
			pi.next();
		}

		Polyline pl = new Polyline(points);
		pl.setClosed(false);
		pl.setColor(Color.BLUE);
		pl.setFollowTerrain(true);
		pl.setLineWidth(2);
		getPolylineMap().put(polyIndex, pl);

		renderableLayer.addRenderable(pl);
	}
	processVisibility();
}
 
開發者ID:iedadata,項目名稱:geomapapp,代碼行數:72,代碼來源:WWUnknownDataSet.java

示例9: createStrokedShape

import java.awt.geom.PathIterator; //導入方法依賴的package包/類
/**
 * @see java.awt.Stroke#createStrokedShape(java.awt.Shape)
 */
public Shape createStrokedShape (Shape shape) {
	GeneralPath result = new GeneralPath();
	shape = new BasicStroke(getWidth(), BasicStroke.CAP_SQUARE, getJoin()).createStrokedShape(shape);
	PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS);
	float points[] = new float[6];
	float moveX = 0, moveY = 0;
	float lastX = 0, lastY = 0;
	float thisX = 0, thisY = 0;
	int type = 0;
	float next = 0;
	while (!it.isDone()) {
		type = it.currentSegment(points);
		switch (type) {
		case PathIterator.SEG_MOVETO:
			moveX = lastX = randomize(points[0]);
			moveY = lastY = randomize(points[1]);
			result.moveTo(moveX, moveY);
			next = 0;
			break;

		case PathIterator.SEG_CLOSE:
			points[0] = moveX;
			points[1] = moveY;
			// Fall into....

		case PathIterator.SEG_LINETO:
			thisX = randomize(points[0]);
			thisY = randomize(points[1]);
			float dx = thisX - lastX;
			float dy = thisY - lastY;
			float distance = (float)Math.sqrt(dx * dx + dy * dy);
			if (distance >= next) {
				float r = 1.0f / distance;
				while (distance >= next) {
					float x = lastX + next * dx * r;
					float y = lastY + next * dy * r;
					result.lineTo(randomize(x), randomize(y));
					next += detail;
				}
			}
			next -= distance;
			lastX = thisX;
			lastY = thisY;
			break;
		}
		it.next();
	}

	return result;
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:54,代碼來源:OutlineWobbleEffect.java

示例10: update

import java.awt.geom.PathIterator; //導入方法依賴的package包/類
@Override
public void update() {
  if (!this.isNavigating()) {
    return;
  }

  if (this.path == null) {
    return;
  }

  for (final Predicate<IMovableEntity> pred : this.cancelNavigationConditions) {
    if (pred.test(this.getEntity())) {
      this.stop();
      return;
    }
  }

  final PathIterator pi = this.path.getPath().getPathIterator(null);
  if (pi.isDone()) {
    this.stop();
    return;
  }

  // although at max 6 elements are returned, sometimes the path
  // implementation tries to access index 20 ... don't know why, but this
  // prevents it
  final double[] startCoordinates = new double[22];
  final double[] coordinates = new double[22];
  for (int i = 0; i <= this.currentSegment; i++) {
    if (pi.isDone()) {
      this.stop();
      return;
    }

    pi.currentSegment(startCoordinates);
    pi.next();
  }

  if (pi.isDone()) {
    this.stop();
    return;
  }

  pi.currentSegment(coordinates);

  final double distance = GeometricUtilities.distance(this.entity.getCollisionBox().getCenterX(), this.entity.getCollisionBox().getCenterY(), coordinates[0], coordinates[1]);
  if (distance < ACCEPTABLE_ERROR) {
    ++this.currentSegment;
    return;
  }

  final double angle = GeometricUtilities.calcRotationAngleInDegrees(this.entity.getCollisionBox().getCenterX(), this.entity.getCollisionBox().getCenterY(), coordinates[0], coordinates[1]);
  final float pixelsPerTick = Game.getLoop().getDeltaTime() * 0.001f * this.entity.getVelocity() * Game.getLoop().getTimeScale();
  Game.getPhysicsEngine().move(this.entity, (float) angle, (float) (distance < pixelsPerTick ? distance : pixelsPerTick));
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:56,代碼來源:EntityNavigator.java

示例11: createStrokedShape

import java.awt.geom.PathIterator; //導入方法依賴的package包/類
/** 
 * @see java.awt.Stroke#createStrokedShape(java.awt.Shape)
 */
public Shape createStrokedShape (Shape shape) {
	GeneralPath result = new GeneralPath();
	PathIterator it = new FlatteningPathIterator(shape.getPathIterator(null), FLATNESS);
	float points[] = new float[6];
	float moveX = 0, moveY = 0;
	float lastX = 0, lastY = 0;
	float thisX = 0, thisY = 0;
	int type = 0;
	float next = 0;
	int phase = 0;
	while (!it.isDone()) {
		type = it.currentSegment(points);
		switch (type) {
		case PathIterator.SEG_MOVETO:
			moveX = lastX = points[0];
			moveY = lastY = points[1];
			result.moveTo(moveX, moveY);
			next = wavelength / 2;
			break;

		case PathIterator.SEG_CLOSE:
			points[0] = moveX;
			points[1] = moveY;
			// Fall into....

		case PathIterator.SEG_LINETO:
			thisX = points[0];
			thisY = points[1];
			float dx = thisX - lastX;
			float dy = thisY - lastY;
			float distance = (float)Math.sqrt(dx * dx + dy * dy);
			if (distance >= next) {
				float r = 1.0f / distance;
				while (distance >= next) {
					float x = lastX + next * dx * r;
					float y = lastY + next * dy * r;
					if ((phase & 1) == 0)
						result.lineTo(x + amplitude * dy * r, y - amplitude * dx * r);
					else
						result.lineTo(x - amplitude * dy * r, y + amplitude * dx * r);
					next += wavelength;
					phase++;
				}
			}
			next -= distance;
			lastX = thisX;
			lastY = thisY;
			if (type == PathIterator.SEG_CLOSE) result.closePath();
			break;
		}
		it.next();
	}
	return new BasicStroke(getWidth(), BasicStroke.CAP_SQUARE, getJoin()).createStrokedShape(result);
}
 
開發者ID:IngSW-unipv,項目名稱:Progetto-C,代碼行數:58,代碼來源:OutlineZigzagEffect.java

示例12: convertToWPath

import java.awt.geom.PathIterator; //導入方法依賴的package包/類
/**
 * Given a Java2D <code>PathIterator</code> instance,
 * this method translates that into a Window's path
 * in the printer device context.
 */
private void convertToWPath(PathIterator pathIter) {

    float[] segment = new float[6];
    int segmentType;

    WPrinterJob wPrinterJob = (WPrinterJob) getPrinterJob();

    /* Map the PathIterator's fill rule into the Window's
     * polygon fill rule.
     */
    int polyFillRule;
    if (pathIter.getWindingRule() == PathIterator.WIND_EVEN_ODD) {
        polyFillRule = WPrinterJob.POLYFILL_ALTERNATE;
    } else {
        polyFillRule = WPrinterJob.POLYFILL_WINDING;
    }
    wPrinterJob.setPolyFillMode(polyFillRule);

    wPrinterJob.beginPath();

    while (pathIter.isDone() == false) {
        segmentType = pathIter.currentSegment(segment);

        switch (segmentType) {
         case PathIterator.SEG_MOVETO:
            wPrinterJob.moveTo(segment[0], segment[1]);
            break;

         case PathIterator.SEG_LINETO:
            wPrinterJob.lineTo(segment[0], segment[1]);
            break;

        /* Convert the quad path to a bezier.
         */
         case PathIterator.SEG_QUADTO:
            int lastX = wPrinterJob.getPenX();
            int lastY = wPrinterJob.getPenY();
            float c1x = lastX + (segment[0] - lastX) * 2 / 3;
            float c1y = lastY + (segment[1] - lastY) * 2 / 3;
            float c2x = segment[2] - (segment[2] - segment[0]) * 2/ 3;
            float c2y = segment[3] - (segment[3] - segment[1]) * 2/ 3;
            wPrinterJob.polyBezierTo(c1x, c1y,
                                     c2x, c2y,
                                     segment[2], segment[3]);
            break;

         case PathIterator.SEG_CUBICTO:
            wPrinterJob.polyBezierTo(segment[0], segment[1],
                                     segment[2], segment[3],
                                     segment[4], segment[5]);
            break;

         case PathIterator.SEG_CLOSE:
            wPrinterJob.closeFigure();
            break;
        }


        pathIter.next();
    }

    wPrinterJob.endPath();

}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:70,代碼來源:WPathGraphics.java

示例13: feedConsumer

import java.awt.geom.PathIterator; //導入方法依賴的package包/類
private void feedConsumer(PathConsumer consumer, PathIterator pi) {
    try {
        consumer.beginPath();
        boolean pathClosed = false;
        float mx = 0.0f;
        float my = 0.0f;
        float point[]  = new float[6];

        while (!pi.isDone()) {
            int type = pi.currentSegment(point);
            if (pathClosed == true) {
                pathClosed = false;
                if (type != PathIterator.SEG_MOVETO) {
                    // Force current point back to last moveto point
                    consumer.beginSubpath(mx, my);
                }
            }
            switch (type) {
            case PathIterator.SEG_MOVETO:
                mx = point[0];
                my = point[1];
                consumer.beginSubpath(point[0], point[1]);
                break;
            case PathIterator.SEG_LINETO:
                consumer.appendLine(point[0], point[1]);
                break;
            case PathIterator.SEG_QUADTO:
                consumer.appendQuadratic(point[0], point[1],
                                         point[2], point[3]);
                break;
            case PathIterator.SEG_CUBICTO:
                consumer.appendCubic(point[0], point[1],
                                     point[2], point[3],
                                     point[4], point[5]);
                break;
            case PathIterator.SEG_CLOSE:
                consumer.closedSubpath();
                pathClosed = true;
                break;
            }
            pi.next();
        }

        consumer.endPath();
    } catch (PathException e) {
        throw new InternalError("Unable to Stroke shape ("+
                                e.getMessage()+")", e);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:50,代碼來源:DuctusRenderingEngine.java


注:本文中的java.awt.geom.PathIterator.next方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。