java.awt.geom.Path2D#WIND_NON_ZERO源码实例Demo

下面列出了java.awt.geom.Path2D#WIND_NON_ZERO 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pumpernickel   文件: AccuracyTest.java
private GeneralPath getShape(int index) {
	Random r = new Random(index * 100000);
	GeneralPath path = new GeneralPath(
			r.nextBoolean() ? Path2D.WIND_EVEN_ODD : Path2D.WIND_NON_ZERO);
	path.moveTo(r.nextFloat() * 100, r.nextFloat() * 100);
	for (int a = 0; a < 3; a++) {
		int k;
		if (type.getSelectedIndex() == 0) {
			k = r.nextInt(3);
		} else {
			k = type.getSelectedIndex() - 1;
		}

		if (k == 0) {
			path.lineTo(r.nextFloat() * 100, r.nextFloat() * 100);
		} else if (k == 1) {
			path.quadTo(r.nextFloat() * 100, r.nextFloat() * 100,
					r.nextFloat() * 100, r.nextFloat() * 100);
		} else {
			path.curveTo(r.nextFloat() * 100, r.nextFloat() * 100,
					r.nextFloat() * 100, r.nextFloat() * 100,
					r.nextFloat() * 100, r.nextFloat() * 100);
		}
	}
	return path;
}
 
源代码2 项目: Pixelitor   文件: DiamondsTransition2D.java
@Override
public Transition2DInstruction[] getInstructions(float progress,
                                                 Dimension size) {

    GeneralPath clipping = new GeneralPath(Path2D.WIND_NON_ZERO);

    float dx = size.width / 2.0f;
    float dy = size.height / 2.0f;
    while (dx > 0 + diamondSize) {
        dx -= diamondSize;
    }
    while (dy > 0 + diamondSize) {
        dy -= diamondSize;
    }

    int ctr = 0;
    progress = progress / 2.0f;
    for (float y = -dy; y < size.height + diamondSize; y += diamondSize / 2) {
        float z = 0;
        if (ctr % 2 == 0) {
            z = diamondSize / 2.0f;
        }

        for (float x = -dx; x < size.width + diamondSize; x += diamondSize) {
            clipping.moveTo(x + z, y - diamondSize * progress);
            clipping.lineTo(x + diamondSize * progress + z, y);
            clipping.lineTo(x + z, y + diamondSize * progress);
            clipping.lineTo(x - diamondSize * progress + z, y);
            clipping.lineTo(x + z, y - diamondSize * progress);
            clipping.closePath();
        }
        ctr++;
    }

    return new Transition2DInstruction[]{
            new ImageInstruction(true),
            new ImageInstruction(false, null, clipping)
    };
}
 
源代码3 项目: flowable-engine   文件: BpmnJsonConverter.java
private Path2D.Double createGatewayShape(double x, double y, double width, double height) {
    double middleX = x + (width / 2);
    double middleY = y + (height / 2);

    Path2D.Double gatewayShape = new Path2D.Double(Path2D.WIND_NON_ZERO, 4);
    gatewayShape.moveTo(x, middleY);
    gatewayShape.lineTo(middleX, y);
    gatewayShape.lineTo(x + width, middleY);
    gatewayShape.lineTo(middleX, y + height);
    gatewayShape.closePath();
    return gatewayShape;
}
 
源代码4 项目: flowable-engine   文件: DmnJsonConverterUtil.java
public static Shape getLineShape(java.awt.geom.Line2D line2D) {
    Path2D line = new Path2D.Double(Path2D.WIND_NON_ZERO, 4);
    line.moveTo(line2D.getX1(), line2D.getY1());
    line.lineTo(line2D.getX2(), line2D.getY2());
    line.lineTo(line2D.getX2() + lineWidth, line2D.getY2() + lineWidth);
    line.closePath();
    return line;
}
 
源代码5 项目: flowable-engine   文件: BpmnJsonConverter.java
protected Shape getLineShape(java.awt.geom.Line2D line2D) {
    Path2D line = new Path2D.Double(Path2D.WIND_NON_ZERO, 4);
    line.moveTo(line2D.getX1(), line2D.getY1());
    line.lineTo(line2D.getX2(), line2D.getY2());
    line.lineTo(line2D.getX2() + lineWidth, line2D.getY2() + lineWidth);
    line.closePath();
    return line;
}
 
源代码6 项目: pumpernickel   文件: DiamondsTransition2D.java
@Override
public Transition2DInstruction[] getInstructions(float progress,
		Dimension size) {

	GeneralPath clipping = new GeneralPath(Path2D.WIND_NON_ZERO);

	float dx = size.width / 2f;
	float dy = size.height / 2f;
	while (dx > 0 + diamondSize)
		dx -= diamondSize;
	while (dy > 0 + diamondSize)
		dy -= diamondSize;

	int ctr = 0;
	progress = progress / 2f;
	for (float y = -dy; y < size.height + diamondSize; y += diamondSize / 2) {
		float z = 0;
		if (ctr % 2 == 0)
			z = diamondSize / 2f;

		for (float x = -dx; x < size.width + diamondSize; x += diamondSize) {
			clipping.moveTo(x + z, y - diamondSize * progress);
			clipping.lineTo(x + diamondSize * progress + z, y);
			clipping.lineTo(x + z, y + diamondSize * progress);
			clipping.lineTo(x - diamondSize * progress + z, y);
			clipping.lineTo(x + z, y - diamondSize * progress);
			clipping.closePath();
		}
		ctr++;
	}

	return new Transition2DInstruction[] { new ImageInstruction(true),
			new ImageInstruction(false, null, clipping) };
}
 
源代码7 项目: RipplePower   文件: Path.java
private static int getWindingRule(FillRule fillRule) {
	switch (fillRule) {
	case EVEN_ODD:
		return Path2D.WIND_EVEN_ODD;
	case NON_ZERO:
		return Path2D.WIND_NON_ZERO;
	}

	throw new IllegalArgumentException("unknown fill rule:" + fillRule);
}
 
源代码8 项目: jdk8u-dev-jdk   文件: DuctusRenderingEngine.java
public FillAdapter() {
    // Ductus only supplies float coordinates so
    // Path2D.Double is not necessary here.
    path = new Path2D.Float(Path2D.WIND_NON_ZERO);
}
 
源代码9 项目: TencentKona-8   文件: DuctusRenderingEngine.java
public FillAdapter() {
    // Ductus only supplies float coordinates so
    // Path2D.Double is not necessary here.
    path = new Path2D.Float(Path2D.WIND_NON_ZERO);
}
 
源代码10 项目: jdk8u60   文件: DuctusRenderingEngine.java
public FillAdapter() {
    // Ductus only supplies float coordinates so
    // Path2D.Double is not necessary here.
    path = new Path2D.Float(Path2D.WIND_NON_ZERO);
}
 
源代码11 项目: ET_Redux   文件: ConcordiaLine.java
/**
 * 
 * @param aspectRatio
 * @param minX
 * @param minY
 * @param maxX
 * @param maxY
 */
public void calcLowerUnctEnvelopeTW(double aspectRatio, double minX, double minY, double maxX, double maxY) {

    // parameters represent viewport
    constructLowerEnvelopeAtRightEnd(startSeg, aspectRatio, minX, minY, maxX, maxY);
    constructLowerEnvelopeAtLeftEnd(endSeg, aspectRatio, minX, minY, maxX, maxY);

    lowerUnctEnvelope = new Path2D.Double (Path2D.WIND_NON_ZERO);

    // start at top right of concordia
    lowerUnctEnvelope.moveTo(
            (float) mapX(startSeg.minX()),
            (float) mapY(startSeg.minY()));

    ParametricCurveSegmentI myWorkingSeg = startLowerUncertSeg;

    // decide whether to include lower right corner of viewport
    if (myWorkingSeg != null) {
        if (myWorkingSeg.minPlusSigmaY(aspectRatio) > startSeg.minY()) {
            lowerUnctEnvelope.lineTo(
                    (float) mapX(maxX),
                    (float) mapY(minY));
        }
    }

    while (myWorkingSeg != null) {
        // check for out of bounds
        double tempX = myWorkingSeg.minPlusSigmaX(aspectRatio);
        double tempY = myWorkingSeg.minPlusSigmaY(aspectRatio);
        double tempXc = myWorkingSeg.controlLowerX(aspectRatio);
        double tempYc = myWorkingSeg.controlLowerY(aspectRatio);
        double tempXl = myWorkingSeg.maxPlusSigmaX(aspectRatio);
        double tempYl = myWorkingSeg.maxPlusSigmaY(aspectRatio);

        lowerUnctEnvelope.lineTo(
                (float) mapX(tempX),
                (float) mapY(tempY));

        if (pointInViewPort(tempX, tempY, minX, minY, maxX, maxY) //
                ||//
                ((determineAxisIntersectedByLowerEnvelopeRight(maxX, maxY, tempXl, tempYl, tempX, tempY) == 1) //
                && pointInViewPort(tempXl, tempYl, minX, minY, maxX, maxY))) {

            lowerUnctEnvelope.curveTo(//
                    (float) mapX(tempX),
                    (float) mapY(tempY),
                    (float) mapX(tempXc),
                    (float) mapY(tempYc),
                    (float) mapX(tempXl),
                    (float) mapY(tempYl));
        } else if ((tempX < maxX) && (tempY > minY) && !pointInViewPort(tempX, tempY, minX, minY, maxX, maxY)//
                && (!pointInViewPort(tempXl, tempYl, minX, minY, maxX, maxY))) { //
            if (determineAxisIntersectedByConcordiaLeft(minX, minY) == -1) {
                lowerUnctEnvelope.lineTo(
                        (float) mapX(tempXl),
                        (float) mapY(tempYl));
            }
            lowerUnctEnvelope.lineTo(
                    (float) mapX(minX),
                    (float) mapY(maxY));
            // get rid of the rest
            while (myWorkingSeg.getRightSeg() != null) {
                myWorkingSeg = myWorkingSeg.getRightSeg();
            }

        }
        myWorkingSeg = myWorkingSeg.getRightSeg();
    }
}
 
源代码12 项目: openjdk-jdk8u   文件: DuctusRenderingEngine.java
public FillAdapter() {
    // Ductus only supplies float coordinates so
    // Path2D.Double is not necessary here.
    path = new Path2D.Float(Path2D.WIND_NON_ZERO);
}
 
源代码13 项目: jdk8u-jdk   文件: DuctusRenderingEngine.java
public FillAdapter() {
    // Ductus only supplies float coordinates so
    // Path2D.Double is not necessary here.
    path = new Path2D.Float(Path2D.WIND_NON_ZERO);
}
 
源代码14 项目: openjdk-8-source   文件: DuctusRenderingEngine.java
public FillAdapter() {
    // Ductus only supplies float coordinates so
    // Path2D.Double is not necessary here.
    path = new Path2D.Float(Path2D.WIND_NON_ZERO);
}
 
源代码15 项目: openjdk-8   文件: DuctusRenderingEngine.java
public FillAdapter() {
    // Ductus only supplies float coordinates so
    // Path2D.Double is not necessary here.
    path = new Path2D.Float(Path2D.WIND_NON_ZERO);
}
 
源代码16 项目: pumpernickel   文件: BrushStroke.java
public Shape createStrokedShape(Shape p) {
	if (thinStrokes == null) {
		thinStrokes = new BasicStroke[100];
		for (int a = 0; a < thinStrokes.length; a++) {
			float f = .15f + (2.05f - .15f) * (a) / (thinStrokes.length);
			thinStrokes[a] = new BasicStroke(f, BasicStroke.CAP_BUTT,
					BasicStroke.JOIN_BEVEL, 10);
		}
	}

	GeneralPath path = new GeneralPath();

	Random r = new Random(randomSeed);

	float h = thickness * thickness;
	int thicknessMax = Math.min(thinStrokes.length,
			(int) (thinStrokes.length * h + thinStrokes.length * .2f));
	int thicknessMin = (int) (thinStrokes.length * h / 2f);

	GeneralPath thisLayer = new GeneralPath(Path2D.WIND_NON_ZERO);
	GeneralPathWriter writer = new GeneralPathWriter(thisLayer);
	for (int a = 0; a < layers; a++) {
		writer.reset();
		float k1 = a * width / (layers - 1f);
		float k2 = k1 - width / 2;
		InsetPathWriter insetWriter;
		if (k2 > 0) {
			insetWriter = new InsetPathWriter(writer, Math.abs(k2), theta);
		} else {
			insetWriter = new InsetPathWriter(writer, Math.abs(k2),
					(float) (Math.PI + theta));
		}
		insetWriter.write(p);
		MeasuredShape[] measuredLayers = MeasuredShape
				.getSubpaths(thisLayer);

		float minStreakDistance = (4 + 10 * thickness) / 1f;
		float maxStreakDistance = (40 + 10 * thickness) / 1f;
		float k3 = Math.abs(k2);
		float minGapDistance = (4 + 10 * k3) / 1f;
		float maxGapDistance = (40 + 10 * k3) / 1f;

		for (int b = 0; b < measuredLayers.length; b++) {
			r.setSeed(randomSeed + 1000 * a + 10000 * b);

			float x = 0;
			if (a != layers / 2) {
				float k4 = Math.abs(k2 / width);
				x = (maxGapDistance - minGapDistance) * r.nextFloat()
						+ k4 * (.3f * r.nextFloat() + .7f) * minGapDistance;
			}

			boolean first = true;
			while (x < measuredLayers[b].getOriginalDistance()) {
				float streakDistance = minStreakDistance
						+ (maxStreakDistance - minStreakDistance)
								* r.nextFloat();
				float gapDistance;
				if (first) {
					first = false;
					gapDistance = (.2f + .8f * r.nextFloat())
							* minGapDistance
							+ (maxGapDistance - minGapDistance)
									* r.nextFloat();
				} else {
					gapDistance = minGapDistance
							+ (maxGapDistance - minGapDistance)
									* r.nextFloat();
				}

				if (x + streakDistance > measuredLayers[b]
						.getOriginalDistance()) {
					float z = 0;
					if (a != layers / 2)
						z = (maxGapDistance - minGapDistance)
								* r.nextFloat();
					streakDistance = measuredLayers[b].getOriginalDistance()
							- x - z;
				}
				if (streakDistance > 0) {
					GeneralPath p2 = measuredLayers[b].getShape(
							x / measuredLayers[b].getClosedDistance(),
							streakDistance / measuredLayers[b]
									.getClosedDistance());
					path.append(
							thinStrokes[r
									.nextInt(thicknessMax - thicknessMin)
									+ thicknessMin].createStrokedShape(p2),
							false);
				}

				x = x + (streakDistance + gapDistance);
			}
		}
	}
	return path;
}
 
源代码17 项目: jdk8u_jdk   文件: DuctusRenderingEngine.java
public FillAdapter() {
    // Ductus only supplies float coordinates so
    // Path2D.Double is not necessary here.
    path = new Path2D.Float(Path2D.WIND_NON_ZERO);
}
 
源代码18 项目: ET_Redux   文件: RawRatioDataViewForShrimp.java
/**
     *
     * @param g2d
     */
    @Override
    public void paint(Graphics2D g2d) {
        super.paint(g2d);

//        if (isNotShownDueToBelowDetectionFlag()) {
//            setBackground(ReduxConstants.palePinkBelowDetection);
//            g2d.drawString("BELOW DETECTION", 25, 25);
//        }
//
//        if (!isNotShownDueToBelowDetectionFlag()) {
//            for (int i = 0; i < myOnPeakData.length; i++) {
//                Shape rawRatioPoint = new java.awt.geom.Ellipse2D.Double( //
//                        mapX(myOnPeakNormalizedAquireTimes[i]), mapY(myOnPeakData[i]), 1, 1);
//                g2d.setPaint(determineDataColor(i, Color.black));
//
//                g2d.draw(rawRatioPoint);
//            }
//        }
        Path2D pointTrace = new Path2D.Double(Path2D.WIND_NON_ZERO);
        pointTrace.moveTo(mapX(myOnPeakNormalizedAquireTimes[0]), mapY(myOnPeakData[0]));
        for (int i = 0; i < myOnPeakData.length; i++) {
            // line tracing through points
            pointTrace.lineTo(mapX(myOnPeakNormalizedAquireTimes[i]), mapY(myOnPeakData[i]));
            g2d.setStroke(new BasicStroke(0.5f));
            g2d.setPaint(determineDataColor(i, Color.GRAY));
            g2d.draw(pointTrace);

            Shape intensity = new java.awt.geom.Ellipse2D.Double( //
                    mapX(myOnPeakNormalizedAquireTimes[i]) - 1, mapY(myOnPeakData[i]) - 1, 2, 2);
            g2d.setStroke(new BasicStroke(1.5f));
            g2d.setPaint(determineDataColor(i, Color.black));
            g2d.draw(intensity);

            // uncertainty
            Shape plusMinusOneSigma = new Line2D.Double(//
                    mapX(myOnPeakNormalizedAquireTimes[i]),// 
                    mapY(myOnPeakData[i] - myOnPeakOneSigmas[i]),//
                    mapX(myOnPeakNormalizedAquireTimes[i]),// 
                    mapY(myOnPeakData[i] + myOnPeakOneSigmas[i]));
            g2d.setStroke(new BasicStroke(1.0f));
            g2d.draw(plusMinusOneSigma);

            // tips of uncertainty
            Shape plusOneSigmaTip = new Line2D.Double(//
                    mapX(myOnPeakNormalizedAquireTimes[i]) - 1,// 
                    mapY(myOnPeakData[i] + myOnPeakOneSigmas[i]),//
                    mapX(myOnPeakNormalizedAquireTimes[i]) + 1,// 
                    mapY(myOnPeakData[i] + myOnPeakOneSigmas[i]));

            Shape minusOneSigmaTip = new Line2D.Double(//
                    mapX(myOnPeakNormalizedAquireTimes[i]) - 1,// 
                    mapY(myOnPeakData[i] - myOnPeakOneSigmas[i]),//
                    mapX(myOnPeakNormalizedAquireTimes[i]) + 1,// 
                    mapY(myOnPeakData[i] - myOnPeakOneSigmas[i]));

            g2d.setStroke(new BasicStroke(1.0f));
            g2d.draw(plusOneSigmaTip);
            g2d.draw(minusOneSigmaTip);

        }
    }
 
源代码19 项目: gef   文件: SWT2AWT.java
/**
 * Converts an SWT {@link PathData} into an equivalent AWT
 * {@link PathIterator}.
 * 
 * @param pathData
 *            the {@link PathData} to convert.
 * @param windingRule
 *            the winding rule to use when constructing the
 *            {@link PathIterator}, i.e. one of {@link SWT#FILL_WINDING} or
 *            {@link SWT#FILL_EVEN_ODD}.
 * @return a new {@link PathIterator} representing the same path
 */
public static PathIterator toAWTPathIterator(PathData pathData, int windingRule) {
	if (windingRule != SWT.FILL_WINDING && windingRule != SWT.FILL_EVEN_ODD) {
		throw new IllegalArgumentException(
				"Unsupported winding rule. Must be one of SWT.FILL_WINDING or SWT.FILL_EVEN_ODD");
	}
	Path2D.Double path = new Path2D.Double(
			windingRule == SWT.FILL_EVEN_ODD ? Path2D.WIND_EVEN_ODD : Path2D.WIND_NON_ZERO);
	int j = 0;
	byte[] types = pathData.types;
	float[] points = pathData.points;
	double x, y, x2, y2, x3, y3;
	for (int i = 0; i < types.length; i++) {

		switch (types[i]) {
		case SWT.PATH_MOVE_TO:
			x = points[j++];
			y = points[j++];
			path.moveTo(x, y);
			break;
		case SWT.PATH_LINE_TO:
			x = points[j++];
			y = points[j++];
			path.lineTo(x, y);
			break;
		case SWT.PATH_QUAD_TO:
			x = points[j++];
			y = points[j++];
			x2 = points[j++];
			y2 = points[j++];
			path.quadTo(x, y, x2, y2);
			break;
		case SWT.PATH_CUBIC_TO:
			x = points[j++];
			y = points[j++];
			x2 = points[j++];
			y2 = points[j++];
			x3 = points[j++];
			y3 = points[j++];
			path.curveTo(x, y, x2, y2, x3, y3);
			break;
		case SWT.PATH_CLOSE:
			path.closePath();
			break;
		default:
			break;
		}
	}
	return path.getPathIterator(null);
}
 
源代码20 项目: pumpernickel   文件: MeasuredShape.java
/**
 * Trace the shape.
 * 
 * @param position
 *            a fraction from zero to one indicating where to start tracing
 * @param length
 *            a fraction from negative one to one indicating how much to
 *            trace. If this value is negative then the shape will be traced
 *            backwards.
 * @return a new path
 */
public GeneralPath getShape(float position, float length) {
	GeneralPath dest = new GeneralPath(Path2D.WIND_NON_ZERO);
	PathWriter w = new GeneralPathWriter(dest);
	writeShape(position, length, w, true);
	return dest;
}