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


Java PathIterator.SEG_MOVETO屬性代碼示例

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


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

示例1: checkMoveTo

/**
 * 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:ModelWriter,項目名稱:Tarski,代碼行數:27,代碼來源:ExtendedGeneralPath.java

示例2: writeGeoPath

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,代碼行數:26,代碼來源:GeoJSONExporter.java

示例3: drawShape

/** Draws a shape. */
public OurPDFWriter drawShape(Shape shape, boolean fillOrNot) {
   if (shape instanceof Polygon) {
      Polygon obj = (Polygon)shape;
      for(int i = 0; i < obj.npoints; i++) buf.writes(obj.xpoints[i]).writes(obj.ypoints[i]).write(i==0 ? "m\n" : "l\n");
      buf.write("h\n");
   } else {
      double moveX = 0, moveY = 0, nowX = 0, nowY = 0, pt[] = new double[6];
      for(PathIterator it = shape.getPathIterator(null); !it.isDone(); it.next()) switch(it.currentSegment(pt)) {
         case PathIterator.SEG_MOVETO:
            nowX = moveX = pt[0]; nowY = moveY = pt[1]; buf.writes(nowX).writes(nowY).write("m\n"); break;
         case PathIterator.SEG_CLOSE:
            nowX = moveX; nowY = moveY; buf.write("h\n"); break;
         case PathIterator.SEG_LINETO:
            nowX = pt[0]; nowY = pt[1]; buf.writes(nowX).writes(nowY).write("l\n"); break;
         case PathIterator.SEG_CUBICTO:
            nowX = pt[4]; nowY = pt[5];
            buf.writes(pt[0]).writes(pt[1]).writes(pt[2]).writes(pt[3]).writes(nowX).writes(nowY).write("c\n"); break;
         case PathIterator.SEG_QUADTO: // Convert quadratic bezier into cubic bezier using de Casteljau algorithm
            double px = nowX + (pt[0] - nowX)*(2.0/3.0), qx = px + (pt[2] - nowX)/3.0;
            double py = nowY + (pt[1] - nowY)*(2.0/3.0), qy = py + (pt[3] - nowY)/3.0;
            nowX = pt[2]; nowY = pt[3];
            buf.writes(px).writes(py).writes(qx).writes(qy).writes(nowX).writes(nowY).write("c\n"); break;
      }
   }
   buf.write(fillOrNot ? "f\n" : "S\n");
   return this;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:28,代碼來源:OurPDFWriter.java

示例4: moveTo

/**
 * Delegates to the enclosed <code>GeneralPath</code>.
 */
public synchronized void moveTo(float x, float y)
{
	// Don't add moveto to general path unless there is a reason.
	makeRoom(2);
	types[numSeg++] = PathIterator.SEG_MOVETO;
	cx = mx = values[numVals++] = x;
	cy = my = values[numVals++] = y;

}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:12,代碼來源:ExtendedGeneralPath.java

示例5: shapeToSVG

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,代碼行數:38,代碼來源:SVGExporter.java

示例6: createStrokedShape

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,代碼行數:37,代碼來源:ArrowedStroke.java

示例7: addGeneralPath

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,代碼行數:36,代碼來源:LabyrinthMap.java

示例8: getLength

static int getLength(int type) {
    switch(type) {
        case PathIterator.SEG_CUBICTO:
            return 6;
        case PathIterator.SEG_QUADTO:
            return 4;
        case PathIterator.SEG_LINETO:
        case PathIterator.SEG_MOVETO:
            return 2;
        case PathIterator.SEG_CLOSE:
            return 0;
        default:
            throw new IllegalStateException("Invalid type: " + type);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:15,代碼來源:Path2DCopyConstructor.java

示例9: convertToWPath

/**
 * Given a Java2D {@code PathIterator} 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:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:69,代碼來源:WPathGraphics.java

示例10: getConstrainingLines

public static List<Line2D.Double> getConstrainingLines(final Area area) {
  final ArrayList<double[]> areaPoints = new ArrayList<>();
  final ArrayList<Line2D.Double> areaSegments = new ArrayList<>();
  final double[] coords = new double[6];

  for (final PathIterator pi = area.getPathIterator(null); !pi.isDone(); pi.next()) {
    // The type will be SEG_LINETO, SEG_MOVETO, or SEG_CLOSE
    // Because the Area is composed of straight lines
    final int type = pi.currentSegment(coords);

    // We record a double array of x coord and y coord
    final double[] pathIteratorCoords = { type, coords[0], coords[1] };
    areaPoints.add(pathIteratorCoords);
  }

  double[] start = new double[3]; // To record where each polygon starts

  for (int i = 0; i < areaPoints.size(); i++) {
    // If we're not on the last point, return a line from this point to the
    // next
    final double[] currentElement = areaPoints.get(i);

    // We need a default value in case we've reached the end of the ArrayList
    double[] nextElement = { -1, -1, -1 };
    if (i < areaPoints.size() - 1) {
      nextElement = areaPoints.get(i + 1);
    }

    // Make the lines
    if (currentElement[0] == PathIterator.SEG_MOVETO) {
      start = currentElement; // Record where the polygon started to close it
                              // later
    }

    if (nextElement[0] == PathIterator.SEG_LINETO) {
      areaSegments.add(new Line2D.Double(currentElement[1], currentElement[2], nextElement[1], nextElement[2]));
    } else if (nextElement[0] == PathIterator.SEG_CLOSE) {
      areaSegments.add(new Line2D.Double(currentElement[1], currentElement[2], start[1], start[2]));
    }
  }
  return areaSegments;
}
 
開發者ID:gurkenlabs,項目名稱:litiengine,代碼行數:42,代碼來源:GeometricUtilities.java

示例11: getSegment

public int getSegment(double coords[]) {
    coords[0] = x;
    coords[1] = y;
    return PathIterator.SEG_MOVETO;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:5,代碼來源:Order0.java

示例12: convertToWPath

/**
 * 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,代碼行數:69,代碼來源:WPathGraphics.java

示例13: render

@Override
public BufferedImage render(BufferedImage image) {

    final int width = image.getWidth();
    final int height = image.getHeight();

    final PathIterator pi = new CubicCurve2D.Float(factor1 * width, height
            * RandomUtil.nextFloat(), factor2 * width, height
            * RandomUtil.nextFloat(), factor3 * width, height
            * RandomUtil.nextFloat(), factor4 * width, height
            * RandomUtil.nextFloat())
            .getPathIterator(null, 2);

    final int[] pts = new int[200];
    int i = 0;

    float[] coords = new float[6];
    while (!pi.isDone() && i < 200) {
        int seg = pi.currentSegment(coords);
        if (seg == PathIterator.SEG_MOVETO || seg == PathIterator.SEG_LINETO) {
            pts[i++] = (int) coords[0];
            pts[i++] = (int) coords[1];
        }
        pi.next();
    }

    final Graphics2D graph = (Graphics2D) image.getGraphics();
    graph.setRenderingHints(new RenderingHints(
            RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON));

    graph.setColor(color);

    i -= 2;
    int j = 0;
    while (j < i) {
        graph.drawLine(pts[j++], pts[j++], pts[j], pts[j + 1]);
    }

    graph.dispose();
    return image;
}
 
開發者ID:febit,項目名稱:febit,代碼行數:42,代碼來源:CubicCurveNoiseFilter.java

示例14: currentSegment

@Override
public final int currentSegment(final float[] coords) {
    int lastCoord;
    final int type = src.currentSegment(coords);

    switch(type) {
        case PathIterator.SEG_MOVETO:
        case PathIterator.SEG_LINETO:
            lastCoord = 0;
            break;
        case PathIterator.SEG_QUADTO:
            lastCoord = 2;
            break;
        case PathIterator.SEG_CUBICTO:
            lastCoord = 4;
            break;
        case PathIterator.SEG_CLOSE:
            // we don't want to deal with this case later. We just exit now
            curx_adjust = movx_adjust;
            cury_adjust = movy_adjust;
            return type;
        default:
            throw new InternalError("Unrecognized curve type");
    }

    // normalize endpoint
    float coord, x_adjust, y_adjust;

    coord = coords[lastCoord];
    x_adjust = normCoord(coord); // new coord
    coords[lastCoord] = x_adjust;
    x_adjust -= coord;

    coord = coords[lastCoord + 1];
    y_adjust = normCoord(coord); // new coord
    coords[lastCoord + 1] = y_adjust;
    y_adjust -= coord;

    // now that the end points are done, normalize the control points
    switch(type) {
        case PathIterator.SEG_MOVETO:
            movx_adjust = x_adjust;
            movy_adjust = y_adjust;
            break;
        case PathIterator.SEG_LINETO:
            break;
        case PathIterator.SEG_QUADTO:
            coords[0] += (curx_adjust + x_adjust) / 2.0f;
            coords[1] += (cury_adjust + y_adjust) / 2.0f;
            break;
        case PathIterator.SEG_CUBICTO:
            coords[0] += curx_adjust;
            coords[1] += cury_adjust;
            coords[2] += x_adjust;
            coords[3] += y_adjust;
            break;
        case PathIterator.SEG_CLOSE:
            // handled earlier
        default:
    }
    curx_adjust = x_adjust;
    cury_adjust = y_adjust;
    return type;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:64,代碼來源:MarlinRenderingEngine.java

示例15: currentSegment

public int currentSegment(float[] coords) {
    int type = src.currentSegment(coords);

    int lastCoord;
    switch(type) {
    case PathIterator.SEG_CUBICTO:
        lastCoord = 4;
        break;
    case PathIterator.SEG_QUADTO:
        lastCoord = 2;
        break;
    case PathIterator.SEG_LINETO:
    case PathIterator.SEG_MOVETO:
        lastCoord = 0;
        break;
    case PathIterator.SEG_CLOSE:
        // we don't want to deal with this case later. We just exit now
        curx_adjust = movx_adjust;
        cury_adjust = movy_adjust;
        return type;
    default:
        throw new InternalError("Unrecognized curve type");
    }

    // normalize endpoint
    float x_adjust = (float)Math.floor(coords[lastCoord] + lval) +
                 rval - coords[lastCoord];
    float y_adjust = (float)Math.floor(coords[lastCoord+1] + lval) +
                 rval - coords[lastCoord + 1];

    coords[lastCoord    ] += x_adjust;
    coords[lastCoord + 1] += y_adjust;

    // now that the end points are done, normalize the control points
    switch(type) {
    case PathIterator.SEG_CUBICTO:
        coords[0] += curx_adjust;
        coords[1] += cury_adjust;
        coords[2] += x_adjust;
        coords[3] += y_adjust;
        break;
    case PathIterator.SEG_QUADTO:
        coords[0] += (curx_adjust + x_adjust) / 2;
        coords[1] += (cury_adjust + y_adjust) / 2;
        break;
    case PathIterator.SEG_LINETO:
        break;
    case PathIterator.SEG_MOVETO:
        movx_adjust = x_adjust;
        movy_adjust = y_adjust;
        break;
    case PathIterator.SEG_CLOSE:
        throw new InternalError("This should be handled earlier.");
    }
    curx_adjust = x_adjust;
    cury_adjust = y_adjust;
    return type;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:58,代碼來源:PiscesRenderingEngine.java


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