java.awt.geom.Path2D#Double ( )源码实例Demo

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

源代码1 项目: diirt   文件: Graph2DRenderer.java
private static Path2D.Double nearestNeighbour(ScaledData scaledData) {
    double[] scaledX = scaledData.scaledX;
    double[] scaledY = scaledData.scaledY;
    int start = scaledData.start;
    int end = scaledData.end;
    Path2D.Double line = new Path2D.Double();
    line.moveTo(scaledX[start], scaledY[start]);
    for (int i = 1; i < end; i++) {
        double halfX = scaledX[i - 1] + (scaledX[i] - scaledX[i - 1]) / 2;
        if (!java.lang.Double.isNaN(scaledY[i-1])) {
            line.lineTo(halfX, scaledY[i - 1]);
            if (!java.lang.Double.isNaN(scaledY[i]))
                line.lineTo(halfX, scaledY[i]);
        } else {
            line.moveTo(halfX, scaledY[i]);
        }
    }
    line.lineTo(scaledX[end - 1], scaledY[end - 1]);
    return line;
}
 
源代码2 项目: consulo   文件: DividerPolygon.java
private void paint(Graphics2D g, int width) {
  GraphicsUtil.setupAntialiasing(g);


  if (!myApplied) {
    Shape upperCurve = makeCurve(width, myStart1, myStart2, true);
    Shape lowerCurve = makeCurve(width, myEnd1, myEnd2, false);

    Path2D path = new Path2D.Double();
    path.append(upperCurve, true);
    path.append(lowerCurve, true);
    g.setColor(myColor);
    g.fill(path);

    g.setColor(DiffUtil.getFramingColor(myColor));
    g.draw(upperCurve);
    g.draw(lowerCurve);
  }
  else {
    g.setColor(myColor);
    g.draw(makeCurve(width, myStart1 + 1, myStart2 + 1, true));
    g.draw(makeCurve(width, myStart1 + 2, myStart2 + 2, true));
    g.draw(makeCurve(width, myEnd1 + 1, myEnd2 + 1, false));
    g.draw(makeCurve(width, myEnd1 + 2, myEnd2 + 2, false));
  }
}
 
源代码3 项目: workcraft   文件: VisualQueueComponent.java
@Override
public Shape getShape() {
    Path2D shape = new Path2D.Double();
    QueueComponent ref = getReferencedComponent();
    if (ref != null) {
        int capacity = ref.getCapacity();
        double contactOffset = 0.5 * capacity * SLOT_WIDTH;

        shape.moveTo(+contactOffset, 0.0);
        shape.lineTo(+contactOffset + CONTACT_LENGTH, 0.0);

        shape.moveTo(-contactOffset, 0.0);
        shape.lineTo(-contactOffset - CONTACT_LENGTH, 0.0);

        for (int i = 0; i < capacity; i++) {
            shape.append(getSlotShape(i), false);
        }
    }
    return shape;
}
 
源代码4 项目: rcrs-server   文件: TrafficSimulatorGUI.java
private void drawAreas(Graphics2D g) {
	areas.clear();
	for (TrafficArea area : manager.getAreas()) {
		Path2D shape = new Path2D.Double();
		List<Edge> edges = area.getArea().getEdges();
		Edge e = edges.get(0);
		shape.moveTo(transform.xToScreen(e.getStartX()), transform.yToScreen(e.getStartY()));
		for (Edge edge : edges) {
			shape.lineTo(transform.xToScreen(edge.getEndX()), transform.yToScreen(edge.getEndY()));
		}
		if (area == selectedArea) {
			g.setColor(SELECTED_AREA_COLOUR);
			g.fill(shape);
			g.setColor(AREA_OUTLINE_COLOUR);
			paintEdges(edges, g);
			int[][] graph = area.getGraph();
			List<Line2D> oLines = area.getOpenLines();
			g.setColor(Color.green);
			paintLines(oLines, g);
			g.setColor(Color.yellow);
			for (int i = 0; i < graph.length; i++) {
				for (int j = 0; j < graph.length; j++) {
					if (graph[i][j] > 10000)
						continue;
					Line2D line = new Line2D(TrafficSimulator.getMidPoint(oLines.get(i).getOrigin(), oLines.get(i).getEndPoint()),
							TrafficSimulator.getMidPoint(oLines.get(j).getOrigin(), oLines.get(j).getEndPoint()));
					paintLine(line, g);
				}
			}
		} else {
			g.setColor(AREA_OUTLINE_COLOUR);
			paintEdges(edges, g);
		}
		areas.put(shape, area);
	}
}
 
源代码5 项目: audiveris   文件: StemsBuilder.java
/**
 * Define the lookup area on given corner, knowing the reference point of the
 * entity (head).
 * Global slope is used (plus and minus slopeMargin).
 *
 * @return the lookup area
 */
private Area getLuArea ()
{
    final double slope = skew.getSlope();
    final double dSlope = -xDir * yDir * params.slopeMargin;

    final Point2D outPt = getOutPoint();
    final Point2D inPt = getInPoint();

    // Look Up path, start by head horizontal segment
    final Path2D lu = new Path2D.Double();
    lu.moveTo(outPt.getX(), outPt.getY());
    lu.lineTo(inPt.getX(), inPt.getY());

    // Then segment away from head (system limit)
    final Rectangle systemBox = system.getBounds();
    final double yLimit = (yDir > 0) ? systemBox.getMaxY() : systemBox.getMinY();
    final double dy = yLimit - outPt.getY();
    lu.lineTo(inPt.getX() + ((slope + dSlope) * dy), yLimit);
    lu.lineTo(outPt.getX() + ((slope - dSlope) * dy), yLimit);
    lu.closePath();

    // Attachment
    StringBuilder sb = new StringBuilder();
    sb.append((corner.vSide == TOP) ? "T" : "B");
    sb.append((corner.hSide == LEFT) ? "L" : "R");
    head.addAttachment(sb.toString(), lu);

    return new Area(lu);
}
 
源代码6 项目: dragonwell8_jdk   文件: EmptyCapacity.java
public static void main(final String[] args) {
    final Path2D path1 = new Path2D.Double(Path2D.WIND_EVEN_ODD, 0);
    path1.moveTo(10, 10);
    path1.lineTo(20, 20);
    final Path2D path2 = new Path2D.Float(Path2D.WIND_EVEN_ODD, 0);
    path2.moveTo(10, 10);
    path2.lineTo(20, 20);
}
 
源代码7 项目: workcraft   文件: VisualQueueComponent.java
public Shape getSlotShape(int index) {
    Path2D shape = new Path2D.Double();
    if (isInitialised()) {
        double w2 = 0.5 * SLOT_WIDTH;
        double h2 = 0.5 * SLOT_HEIGHT;
        double slotOffset = getSlotOffset(index);
        shape.moveTo(slotOffset - w2, -h2);
        shape.lineTo(slotOffset - w2, +h2);
        shape.lineTo(slotOffset + w2, +h2);
        shape.lineTo(slotOffset + w2, -h2);
        shape.closePath();
    }
    return shape;
}
 
源代码8 项目: Geom_Kisrhombille   文件: DocGraphics.java
void fillPolygon(DPolygon polygon,Color c){
Path2D path=new Path2D.Double();
int s=polygon.size();
DPoint p=polygon.get(0);
path.moveTo(p.x,p.y);
for(int i=1;i<s;i++){
  p=polygon.get(i);
  path.lineTo(p.x,p.y);}
path.closePath();
graphics.setPaint(c);
graphics.fill(path); }
 
源代码9 项目: Forsythia   文件: EMGridOverlayPainter.java
private void strokeGraphEdges_EditGeometry(Graphics2D graphics){
graphics.setStroke(UI.GRID_DRAWINGSTROKE);
graphics.setPaint(UI.EDITJIG_EDITGEOMETRY_STROKECOLOR);
Iterator<GEdge> i=GE.ge.editor_metagon.editedmetagon.getGraph().edges.iterator();
GEdge e;
double[] p0,p1;
Path2D path=new Path2D.Double();
while(i.hasNext()){
  e=i.next();
  p0=GE.ge.editor_metagon.editedmetagon.getMetagonEditorGeometryCache().getPoint(e.v0.kvertex);
  p1=GE.ge.editor_metagon.editedmetagon.getMetagonEditorGeometryCache().getPoint(e.v1.kvertex);
  path.reset();
  path.moveTo(p0[0],p0[1]);
  path.lineTo(p1[0],p1[1]);
  graphics.draw(path);}}
 
源代码10 项目: Geom_Kisrhombille   文件: DocGraphics.java
void fillPolygon(KPolygon polygon,Color c){
Path2D path=new Path2D.Double();
int s=polygon.size();
DPoint p=polygon.get(0).getBasicPoint2D();
path.moveTo(p.x,p.y);
for(int i=1;i<s;i++){
  p=polygon.get(i).getBasicPoint2D();
  path.lineTo(p.x,p.y);}
path.closePath();
graphics.setPaint(c);
graphics.fill(path); }
 
源代码11 项目: htmlunit   文件: AwtRenderingBackend.java
/**
 * {@inheritDoc}
 */
@Override
public void moveTo(final double x, final double y) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("[" + id_ + "] moveTo(" + x + ", " + y + ")");
    }

    final Path2D subPath = new Path2D.Double();
    final Point2D p = transformation_.transform(new Point2D.Double(x, y), null);
    subPath.moveTo(p.getX(), p.getY());
    subPaths_.add(subPath);
}
 
源代码12 项目: jdk8u-dev-jdk   文件: EmptyCapacity.java
public static void main(final String[] args) {
    final Path2D path1 = new Path2D.Double(Path2D.WIND_EVEN_ODD, 0);
    path1.moveTo(10, 10);
    path1.lineTo(20, 20);
    final Path2D path2 = new Path2D.Float(Path2D.WIND_EVEN_ODD, 0);
    path2.moveTo(10, 10);
    path2.lineTo(20, 20);
}
 
源代码13 项目: java-swing-tips   文件: MainPanel.java
private static Area getOuterShape(Shape shape) {
  Area area = new Area();
  Path2D path = new Path2D.Double();
  PathIterator pi = shape.getPathIterator(null);
  double[] coords = new double[6];
  while (!pi.isDone()) {
    int pathSegmentType = pi.currentSegment(coords);
    switch (pathSegmentType) {
      case PathIterator.SEG_MOVETO:
        path.moveTo(coords[0], coords[1]);
        break;
      case PathIterator.SEG_LINETO:
        path.lineTo(coords[0], coords[1]);
        break;
      case PathIterator.SEG_QUADTO:
        path.quadTo(coords[0], coords[1], coords[2], coords[3]);
        break;
      case PathIterator.SEG_CUBICTO:
        path.curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
        break;
      case PathIterator.SEG_CLOSE:
        path.closePath();
        area.add(createArea(path));
        path.reset();
        break;
      default:
        System.err.println("Unexpected value! " + pathSegmentType);
        break;
    }
    pi.next();
  }
  return area;
}
 
源代码14 项目: workcraft   文件: ConnectionTool.java
@Override
public void drawInUserSpace(GraphEditor editor, Graphics2D g) {
    if ((firstNode != null) && (currentPoint != null)) {
        g.setStroke(new BasicStroke((float) editor.getViewport().pixelSizeInUserSpace().getX()));
        Path2D path = new Path2D.Double();
        path.moveTo(firstPoint.getX(), firstPoint.getY());
        for (Point2D point : controlPoints) {
            path.lineTo(point.getX(), point.getY());
        }
        path.lineTo(currentPoint.getX(), currentPoint.getY());
        if (currentNode == null) {
            g.setColor(incompleteConnectionColor);
            g.draw(path);
        } else {
            try {
                VisualModel model = editor.getModel();
                if (directedArcs) {
                    model.validateConnection(firstNode, currentNode);
                } else {
                    model.validateUndirectedConnection(firstNode, currentNode);
                }
                g.setColor(validConnectionColor);
                g.draw(path);
            } catch (InvalidConnectionException e) {
                showIssue(editor, e.getMessage());
                g.setColor(invalidConnectionColor);
                g.draw(path);
            }
        }
    }
}
 
源代码15 项目: snap-desktop   文件: WorldMapPanelWrapper.java
public void highlightPolygons(Path2D.Double[] polygonPaths) {
    this.polygonsLayerModel.highlightPolygons(polygonPaths);
    if (this.currentWorldMap != null) {
        this.currentWorldMap.refresh();
    }
}
 
/**
 *
 * @param g2d
 */
@Override
public void paint(Graphics2D g2d) {
    super.paint(g2d);

    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);

    }
}
 
源代码17 项目: snap-desktop   文件: ProductLibraryToolViewV2.java
private void leftMouseButtonClicked(List<Path2D.Double> polygonPaths) {
    this.repositoryOutputProductListPanel.getProductListPanel().selectProductsByPolygonPath(polygonPaths);
}
 
源代码18 项目: sis   文件: Java2D.java
/**
     * Merges a sequence of points or paths if the first instance is an implementation of this library.
     *
     * @throws ClassCastException if an element in the iterator is not a {@link Shape} or a {@link Point2D}.
     */
    @Override
    final Shape tryMergePolylines(Object next, final Iterator<?> polylines) {
        if (!(next instanceof Shape || next instanceof Point2D)) {
            return null;
        }
        boolean isFloat = ShapeUtilities.isFloat(next);
        Path2D path = isFloat ? new Path2D.Float() : new Path2D.Double();
        boolean lineTo = false;
add:    for (;;) {
            if (next instanceof Point2D) {
                final double x = ((Point2D) next).getX();
                final double y = ((Point2D) next).getY();
                if (Double.isNaN(x) || Double.isNaN(y)) {
                    lineTo = false;
                } else if (lineTo) {
                    path.lineTo(x, y);
                } else {
                    path.moveTo(x, y);
                    lineTo = true;
                }
            } else {
                path.append((Shape) next, false);
                lineTo = false;
            }
            /*
             * 'polylines.hasNext()' check is conceptually part of 'for' instruction,
             * except that we need to skip this condition during the first iteration.
             */
            do if (!polylines.hasNext()) break add;
            while ((next = polylines.next()) == null);
            /*
             * Convert the path from single-precision to double-precision if needed.
             */
            if (isFloat && !ShapeUtilities.isFloat(next)) {
                path = new Path2D.Double(path);
                isFloat = false;
            }
        }
        return ShapeUtilities.toPrimitive(path);
    }
 
源代码19 项目: ET_Redux   文件: ConcordiaLine.java
/**
 * 
 * @param aspectRatio
 * @param minX
 * @param minY
 * @param maxX
 * @param maxY
 */
public void calcLowerUnctEnvelopeC(double aspectRatio, double minX, double minY, double maxX, double maxY) {

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

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

    // start at top right of concordia
    lowerUnctEnvelope.moveTo(
            (float) mapX(endSeg.maxX()),
            (float) mapY(endSeg.maxY()));

    ParametricCurveSegmentI myWorkingSeg = startLowerUncertSeg;

    // decide whether to include upper right corner of viewport
    if (myWorkingSeg != null) {
        if (myWorkingSeg.maxPlusSigmaY(aspectRatio) < endSeg.maxY()) {
            lowerUnctEnvelope.lineTo(
                    (float) mapX(maxX),
                    (float) mapY(maxY));
        }
    } else {
        // paint the lower right corner
        lowerUnctEnvelope.lineTo(
                (float) mapX(maxX),
                (float) mapY(minY));
    }

    while (myWorkingSeg != null) {
        // check for out of bounds
        double tempX = myWorkingSeg.maxPlusSigmaX(aspectRatio);
        double tempY = myWorkingSeg.maxPlusSigmaY(aspectRatio);
        double tempXc = myWorkingSeg.controlLowerX(aspectRatio);
        double tempYc = myWorkingSeg.controlLowerY(aspectRatio);
        double tempXl = myWorkingSeg.minPlusSigmaX(aspectRatio);
        double tempYl = myWorkingSeg.minPlusSigmaY(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 < maxY) && !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(minY));
            // get rid of the rest
            while (myWorkingSeg.getLeftSeg() != null) {
                myWorkingSeg = myWorkingSeg.getLeftSeg();
            }
        }
        myWorkingSeg = myWorkingSeg.getLeftSeg();
    }
}
 
源代码20 项目: lams   文件: SLGraphics.java
/**
 * Fills the interior of a <code>Shape</code> using the settings of the
 * <code>Graphics2D</code> context. The rendering attributes applied
 * include the <code>Clip</code>, <code>Transform</code>,
 * <code>Paint</code>, and <code>Composite</code>.
 * @param shape the <code>Shape</code> to be filled
 * @see #setPaint
 * @see java.awt.Graphics#setColor
 * @see #_transform
 * @see #setTransform
 * @see #setComposite
 * @see #clip
 * @see #setClip
 */
public void fill(Shape shape){
    Path2D.Double path = new Path2D.Double(_transform.createTransformedShape(shape));
    FreeformShape<?,?> p = _group.createFreeform();
    p.setPath(path);
    applyPaint(p);
    p.setStrokeStyle();   //Fills must be "No Line"
}