当前位置: 首页>>代码示例>>Java>>正文


Java PathIterator.currentSegment方法代码示例

本文整理汇总了Java中java.awt.geom.PathIterator.currentSegment方法的典型用法代码示例。如果您正苦于以下问题:Java PathIterator.currentSegment方法的具体用法?Java PathIterator.currentSegment怎么用?Java PathIterator.currentSegment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.geom.PathIterator的用法示例。


在下文中一共展示了PathIterator.currentSegment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: writeGeoPath

import java.awt.geom.PathIterator; //导入方法依赖的package包/类
private void writeGeoPath(PrintWriter writer, GeoPath geoPath) {
    writer.write("        { \"type\": \"LineString\", \"coordinates\":\n          [");

    DecimalFormat format = new DecimalFormat("#.###");
    PathIterator iterator = geoPath.getPathIterator(null, flatness);
    double[] coordinates = new double[6];
    while (!iterator.isDone()) {
        final int type = iterator.currentSegment(coordinates);
        switch (type) {
            case PathIterator.SEG_MOVETO:
            case PathIterator.SEG_LINETO:
                writer.print(" [ ");
                writer.print(format.format(coordinates[0]));
                writer.print(",");
                writer.print(format.format(coordinates[1]));
                writer.print(" ]");
                iterator.next();
                if (!iterator.isDone()) {
                    writer.print(",");
                }
                break;
        }
        
    }
    writer.println(" ] },");
}
 
开发者ID:berniejenny,项目名称:MapAnalyst,代码行数:27,代码来源:GeoJSONExporter.java

示例3: 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:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:Path2DCopyConstructor.java

示例4: 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

示例5: setCurrentSegment

import java.awt.geom.PathIterator; //导入方法依赖的package包/类
protected void setCurrentSegment(GeneralPath path) {
	if (currentSegment != null)
		trackLayer.removeRenderable( currentSegment );
	
	if (path == null)
	{
		currentSegment = null;
		return;
	}
	
	PathIterator pi =
		path.getPathIterator(new AffineTransform());
	List<LatLon> pos = new LinkedList<LatLon>();

	float [] coords = new float[6];
	int t = pi.currentSegment(coords);
	pos.add( LatLon.fromDegrees(coords[1], coords[0]));
	while (!pi.isDone())
	{
		t = pi.currentSegment(coords);
		if (t == PathIterator.SEG_LINETO && 
				!(coords[1] == 0 && coords[0]==0))
			pos.add( LatLon.fromDegrees(coords[1], coords[0]));
		
		pi.next();
	}
	
	Polyline line = new Polyline(pos, 0);
	line.setLineWidth(4);
	line.setFollowTerrain(true);
	line.setColor( Color.red );
	trackLayer.addRenderable(line);
	currentSegment = line;
	
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:36,代码来源:WWMGG.java

示例6: getPoints

import java.awt.geom.PathIterator; //导入方法依赖的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;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:15,代码来源:GeometricUtilities.java

示例7: getType

import java.awt.geom.PathIterator; //导入方法依赖的package包/类
public String getType() {
  final StringBuilder buffer = new StringBuilder();
  if (shape != null) {
    final PathIterator it = shape.getPathIterator(new AffineTransform());
    final float[] pts = new float[6];
    while (!it.isDone()) {
      switch (it.currentSegment(pts)) {
      case PathIterator.SEG_MOVETO:
        buffer.append('m')
              .append(',')
              .append(Math.round(pts[0]))
              .append(',')
              .append(Math.round(pts[1]));
        break;
      case PathIterator.SEG_LINETO:
      case PathIterator.SEG_CUBICTO:
      case PathIterator.SEG_QUADTO:
        buffer.append('l')
              .append(',')
              .append(Math.round(pts[0]))
              .append(',')
              .append(Math.round(pts[1]));
        break;
      case PathIterator.SEG_CLOSE:
        buffer.append('c');
        break;
      }
      it.next();
      if (!it.isDone()) {
        buffer.append(',');
      }
    }
  }
  return ID + buffer.toString();
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:36,代码来源:NonRectangular.java

示例8: 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

示例9: 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

示例10: addGeneralPath

import java.awt.geom.PathIterator; //导入方法依赖的package包/类
private void addGeneralPath(GeneralPath path) {
        PathIterator itr = path.getPathIterator(null, 0.1);
        ArrayList<Point2D.Float> pathList = new ArrayList();
        Point2D.Float pathStart = null, lastPoint = null;
        boolean closed = false;
        while (!itr.isDone()) {
            float[] coords = new float[6];
            int segtype = itr.currentSegment(coords);
            switch (segtype) {
                case PathIterator.SEG_MOVETO:
                    pathStart = new Point2D.Float(coords[0], coords[1]); // save start point
                case PathIterator.SEG_LINETO:
                case PathIterator.SEG_QUADTO:
                case PathIterator.SEG_CUBICTO:
                    pathList.add((lastPoint = new Point2D.Float(coords[0], coords[1]))); // TODO store quads/cubes as well as linesSVG
                    break;
                case PathIterator.SEG_CLOSE:
                    closed = true;
//                            if (pathStart != null) {
//                                pathList.add(pathStart);
//                            }
                    break;
                default:
                    log.info("found other element " + segtype);
            }
            itr.next();
        }
        if (closed && lastPoint != null) {
            pathList.remove(lastPoint);
        }
        if (pathList.size() > longestPath) {
            ballPathSVG = pathList;
            longestPath = ballPathSVG.size();
        }
        pathsSVG.add(pathList);
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:37,代码来源:LabyrinthMap.java

示例11: 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:SunburstApps,项目名称:OpenJSharp,代码行数:33,代码来源:RenderingEngine.java

示例12: 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:j-dong,项目名称:trashjam2017,代码行数:58,代码来源:OutlineZigzagEffect.java

示例13: 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

示例14: 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

示例15: 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


注:本文中的java.awt.geom.PathIterator.currentSegment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。