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


Java PathIterator类代码示例

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


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

示例1: NormalizingPathIterator

import java.awt.geom.PathIterator; //导入依赖的package包/类
NormalizingPathIterator(PathIterator src, NormMode mode) {
    this.src = src;
    switch (mode) {
    case ON_NO_AA:
        // round to nearest (0.25, 0.25) pixel
        lval = rval = 0.25f;
        break;
    case ON_WITH_AA:
        // round to nearest pixel center
        lval = 0f;
        rval = 0.5f;
        break;
    case OFF:
        throw new InternalError("A NormalizingPathIterator should " +
                 "not be created if no normalization is being done");
    default:
        throw new InternalError("Unrecognized normalization mode");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:PiscesRenderingEngine.java

示例2: checkEmptyPath

import java.awt.geom.PathIterator; //导入依赖的package包/类
private static void checkEmptyPath(final Shape s) {
    final float[] coords = new float[6];
    final PathIterator it = s.getPathIterator(null);

    int n = 0;
    for (; !it.isDone(); it.next()) {
        int type = it.currentSegment(coords);
        System.out.println("unexpected segment type= " + type
             + " with coords: " + Arrays.toString(coords));
        n++;
    }
    if (n != 0) {
        System.out.println("path elements = " + n);
        throw new IllegalStateException("Not empty path: "
                      + n + " path elements !");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:CrashNaNTest.java

示例3: getStrokeSpans

import java.awt.geom.PathIterator; //导入依赖的package包/类
public static ShapeSpanIterator getStrokeSpans(SunGraphics2D sg2d,
                                               Shape s)
{
    ShapeSpanIterator sr = new ShapeSpanIterator(false);

    try {
        sr.setOutputArea(sg2d.getCompClip());
        sr.setRule(PathIterator.WIND_NON_ZERO);

        BasicStroke bs = (BasicStroke) sg2d.stroke;
        boolean thin = (sg2d.strokeState <= SunGraphics2D.STROKE_THINDASHED);
        boolean normalize =
            (sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE);

        RenderEngine.strokeTo(s,
                              sg2d.transform, bs,
                              thin, normalize, false, sr);
    } catch (Throwable t) {
        sr.dispose();
        sr = null;
        throw new InternalError("Unable to Stroke shape ("+
                                t.getMessage()+")", t);
    }
    return sr;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:LoopPipe.java

示例4: deviceFill

import java.awt.geom.PathIterator; //导入依赖的package包/类
protected void deviceFill(PathIterator pathIter, Color color,
                          AffineTransform tx, Shape clip) {

    setTransform(tx);
    setClip(clip);
    setColor(color);
    convertToPSPath(pathIter);
    /* Specify the path to fill as the clip, this ensures that only
     * pixels which are inside the path will be filled, which is
     * what the Java 2D APIs specify
     */
    mPSStream.println(GSAVE_STR);
    selectClipPath();
    fillPath();
    mPSStream.println(GRESTORE_STR + " " + NEWPATH_STR);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:PSPrinterJob.java

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

示例6: getSegment

import java.awt.geom.PathIterator; //导入依赖的package包/类
public int getSegment(double coords[]) {
    if (direction == INCREASING) {
        coords[0] = cx0;
        coords[1] = cy0;
        coords[2] = cx1;
        coords[3] = cy1;
        coords[4] = x1;
        coords[5] = y1;
    } else {
        coords[0] = cx1;
        coords[1] = cy1;
        coords[2] = cx0;
        coords[3] = cy0;
        coords[4] = x0;
        coords[5] = y0;
    }
    return PathIterator.SEG_CUBICTO;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Order3.java

示例7: checkMoveTo

import java.awt.geom.PathIterator; //导入依赖的package包/类
/**
 * Checks if previous command was a moveto command,
 * skipping a close command (if present).
 */
protected void checkMoveTo()
{
	if (numSeg == 0)
		return;

	switch (types[numSeg - 1])
	{

		case PathIterator.SEG_MOVETO:
			path.moveTo(values[numVals - 2], values[numVals - 1]);
			break;

		case PathIterator.SEG_CLOSE:
			if (numSeg == 1)
				return;
			if (types[numSeg - 2] == PathIterator.SEG_MOVETO)
				path.moveTo(values[numVals - 2], values[numVals - 1]);
			break;

		default:
			break;
	}
}
 
开发者ID:GDSRS,项目名称:TrabalhoFinalEDA2,代码行数:28,代码来源:ExtendedGeneralPath.java

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

示例9: getPolyCoords

import java.awt.geom.PathIterator; //导入依赖的package包/类
/**
 * Returns a string containing the coordinates for a given shape.  This
 * string is intended for use in an image map.
 *
 * @param shape  the shape (<code>null</code> not permitted).
 *
 * @return The coordinates for a given shape as string.
 */
private String getPolyCoords(Shape shape) {
    if (shape == null) {
        throw new IllegalArgumentException("Null 'shape' argument.");   
    }
    StringBuffer result = new StringBuffer();
    boolean first = true;
    float[] coords = new float[6];
    PathIterator pi = shape.getPathIterator(null, 1.0);
    while (!pi.isDone()) {
        pi.currentSegment(coords);
        if (first) {
            first = false;
            result.append((int) coords[0]);
            result.append(",").append((int) coords[1]);
        }
        else {
            result.append(",");
            result.append((int) coords[0]);
            result.append(",");
            result.append((int) coords[1]);
        }
        pi.next();
    }
    return result.toString();
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:34,代码来源:ChartEntity.java

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

示例11: closePath

import java.awt.geom.PathIterator; //导入依赖的package包/类
/**
 * Delegates to the enclosed <code>GeneralPath</code>.
 */
public synchronized void closePath()
{
	// Don't double close path.
	if ((numSeg != 0) && (types[numSeg - 1] == PathIterator.SEG_CLOSE))
		return;

	// Only close path if the previous command wasn't a moveto
	if ((numSeg != 0) && (types[numSeg - 1] != PathIterator.SEG_MOVETO))
		path.closePath();

	makeRoom(0);
	types[numSeg++] = PathIterator.SEG_CLOSE;
	cx = mx;
	cy = my;
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:19,代码来源:ExtendedGeneralPath.java

示例12: validateCompClip

import java.awt.geom.PathIterator; //导入依赖的package包/类
protected void validateCompClip() {
    int origClipState = clipState;
    if (usrClip == null) {
        clipState = CLIP_DEVICE;
        clipRegion = devClip;
    } else if (usrClip instanceof Rectangle2D) {
        clipState = CLIP_RECTANGULAR;
        clipRegion = devClip.getIntersection((Rectangle2D) usrClip);
    } else {
        PathIterator cpi = usrClip.getPathIterator(null);
        int box[] = new int[4];
        ShapeSpanIterator sr = LoopPipe.getFillSSI(this);
        try {
            sr.setOutputArea(devClip);
            sr.appendPath(cpi);
            sr.getPathBox(box);
            Region r = Region.getInstance(box, sr);
            clipRegion = r;
            clipState =
                r.isRectangular() ? CLIP_RECTANGULAR : CLIP_SHAPE;
        } finally {
            sr.dispose();
        }
    }
    if (origClipState != clipState &&
        (clipState == CLIP_SHAPE || origClipState == CLIP_SHAPE))
    {
        validFontInfo = false;
        invalidatePipe();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:32,代码来源:SunGraphics2D.java

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

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

示例15: shapeToSVG

import java.awt.geom.PathIterator; //导入依赖的package包/类
private static String shapeToSVG(Shape sh) {
	StringBuffer s = new StringBuffer();
	double[] pts = new double[6];
	for (PathIterator p = sh.getPathIterator(null); !p.isDone(); p.next()) {
		switch (p.currentSegment(pts)) {
		case PathIterator.SEG_MOVETO:
			s.append('M'); s.append(' ');
			s.append(svgRound(pts[0])); s.append(' ');
			s.append(svgRound(pts[1])); s.append(' ');
			break;
		case PathIterator.SEG_LINETO:
			s.append('L'); s.append(' ');
			s.append(svgRound(pts[0])); s.append(' ');
			s.append(svgRound(pts[1])); s.append(' ');
			break;
		case PathIterator.SEG_QUADTO:
			s.append('Q'); s.append(' ');
			s.append(svgRound(pts[0])); s.append(' ');
			s.append(svgRound(pts[1])); s.append(' ');
			s.append(svgRound(pts[2])); s.append(' ');
			s.append(svgRound(pts[3])); s.append(' ');
			break;
		case PathIterator.SEG_CUBICTO:
			s.append('C'); s.append(' ');
			s.append(svgRound(pts[0])); s.append(' ');
			s.append(svgRound(pts[1])); s.append(' ');
			s.append(svgRound(pts[2])); s.append(' ');
			s.append(svgRound(pts[3])); s.append(' ');
			s.append(svgRound(pts[4])); s.append(' ');
			s.append(svgRound(pts[5])); s.append(' ');
			break;
		case PathIterator.SEG_CLOSE:
			s.append('Z'); s.append(' ');
			break;
		}
	}
	return s.toString().trim();
}
 
开发者ID:kreativekorp,项目名称:vexillo,代码行数:39,代码来源:SVGExporter.java


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