Examples of Path2D


Examples of java.awt.geom.Path2D

                    return rect;
                }
            }
        }
        if (shape instanceof Path2D) {
            final Path2D path = (Path2D) shape;
            if (allowOverwrite) {
                path.transform(transform);
            } else {
                shape = path.createTransformedShape(transform);
            }
        } else if (shape instanceof Area) {
            final Area area = (Area) shape;
            if (allowOverwrite) {
                area.transform(transform);
View Full Code Here

Examples of java.awt.geom.Path2D

    Font originalFont = g.getFont();
    Stroke originalStroke = g.getStroke();
   
    g.setFont(ANNOTATION_FONT);
   
    Path2D path = new Path2D.Double();
    x += .5;
    int lineLength = 18;
    path.moveTo(x + lineLength, y);
    path.lineTo(x, y);
    path.lineTo(x, y + height);
    path.lineTo(x + lineLength, y + height);
   
    path.lineTo(x + lineLength, y + height -1);
    path.lineTo(x + 1, y + height -1);
    path.lineTo(x + 1, y + 1);
    path.lineTo(x + lineLength, y + 1);
    path.closePath();
   
    g.draw(path);
   
    int boxWidth = width - (2 * ANNOTATION_TEXT_PADDING);
    int boxHeight = height - (2 * ANNOTATION_TEXT_PADDING);
 
View Full Code Here

Examples of java.awt.geom.Path2D

     */
    private Shape buildStandardBarb() {
        int positionOnPath = -windBarbDefinition.vectorLength;

        // Base barb
        Path2D path = new Path2D.Double();

        // Initialize Barb
        if (knots < 5) {
            // let's use a circle for Calm
            return new Ellipse2D.Float(-windBarbDefinition.zeroWindRadius / 2.0f, // the X coordinate of the upper-left corner of the specified
                                                                                  // rectangular area
                    -windBarbDefinition.zeroWindRadius / 2.0f, // the Y coordinate of the upper-left corner of the specified rectangular area
                    windBarbDefinition.zeroWindRadius, windBarbDefinition.zeroWindRadius);
        } else {

            // draw wind barb line
            path.moveTo(0, 0);
            path.lineTo(0, positionOnPath);
        }
        // pennants management
        if (squares > 0) {
            positionOnPath = drawSquare(path, positionOnPath);
            positionOnPath += windBarbDefinition.elementsSpacing; // add spacing
        }

        // pennants management
        if (pennants > 0) {
            positionOnPath = drawPennants(path, positionOnPath);
            positionOnPath += windBarbDefinition.elementsSpacing; // add spacing
        }

        // long barbs management
        if (longBarbs > 0) {
            positionOnPath = drawLongBarbs(path, positionOnPath);
            positionOnPath += windBarbDefinition.elementsSpacing; // add spacing
        }

        // short barbs management
        if (shortBarbs > 0) {
            positionOnPath = drawShortBarb(path, positionOnPath);
        }

        // FLIP for geotools
        final Shape createTransformedShape = path.createTransformedShape(AffineTransform
                .getScaleInstance(1, -1));
        return createTransformedShape;

    }
View Full Code Here

Examples of java.awt.geom.Path2D

     * @return
     */
    Shape buildAbsentModule() {

        // Base barb
        Path2D path = new Path2D.Double();
        int positionOnPath = 0;

        // draw wind barb line
        path.moveTo(0, positionOnPath);
        positionOnPath -= windBarbDefinition.vectorLength;
        path.lineTo(0, positionOnPath);

        path.moveTo(windBarbDefinition.shortBarbLength / 2.0f, positionOnPath
                - windBarbDefinition.shortBarbLength / 2.0f);
        path.lineTo(-windBarbDefinition.shortBarbLength / 2.0f, positionOnPath
                + windBarbDefinition.shortBarbLength / 2.0f);

        path.moveTo(-windBarbDefinition.shortBarbLength / 2.0f, positionOnPath
                - windBarbDefinition.shortBarbLength / 2.0f);
        path.lineTo(windBarbDefinition.shortBarbLength / 2.0f, positionOnPath
                + windBarbDefinition.shortBarbLength / 2.0f);

        // FLIP for geotools
        final Shape createTransformedShape = path.createTransformedShape(AffineTransform
                .getScaleInstance(1, -1));
        return createTransformedShape;
    }
View Full Code Here

Examples of java.awt.geom.Path2D

      assertTrue(lastPoint.getY() < 513.0);
    }
  }

  private static Point2D getLastPointOfALane(Lane lane) throws IOException {
    Path2D shape = lane.queryReadShape().get();
    PathIterator it = shape.getPathIterator(null);
    double[] coords = new double[6];
    while (!it.isDone()) {
      it.currentSegment(coords);
      it.next();
    }
View Full Code Here

Examples of java.awt.geom.Path2D

            }
            else {
                outer = new Rectangle2D.Float(x, y, width, height);
                inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
            }
            Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
            path.append(outer, false);
            path.append(inner, false);
            g2d.fill(path);
            g2d.setColor(oldColor);
        }
    }
View Full Code Here

Examples of java.awt.geom.Path2D

        } else {
            rp = 0;
        }
       
       
        Path2D path = new Path2D.Float();
       
        // top left outside, check that theres a radius to be had
        if(leftRadius.getMaxRight(exteriorWidth) > 0) {
           
            Point2D [][] leftCurvePoints = getSubCurve(1-lp,
                new Point2D.Double(    leftRadius.getMaxRight(exteriorWidth) + lco,                     tco),
                new Point2D.Double(    curveConstant*(leftRadius.getMaxRight(exteriorWidth)) + lco,     tco),
                new Point2D.Double(    lco,                                                             tco+curveConstant*(leftRadius.getMaxLeft(exteriorHeight))),
                new Point2D.Double(    lco,                                                             tco+leftRadius.getMaxLeft(exteriorHeight)));
           
            path.moveTo(    (leftCurvePoints[0][3].getX()),         (leftCurvePoints[0][3].getY()));
            path.curveTo(    leftCurvePoints[0][2].getX(),         leftCurvePoints[0][2].getY(),
                            leftCurvePoints[0][1].getX(),        leftCurvePoints[0][1].getY(),
                            leftCurvePoints[0][0].getX(),        leftCurvePoints[0][0].getY());
        } else {
            path.moveTo(    lco,                 tco);
        }
       
        // top right outside
        if(rightRadius.getMaxLeft(exteriorWidth) > 0) {
           
            Point2D [][] rightCurvePoints = getSubCurve(1-rp,
                    new Point2D.Double(    sideWidth - rightRadius.getMaxLeft(exteriorWidth) - rco,                         tco),
                    new Point2D.Double(    sideWidth - curveConstant*(rightRadius.getMaxLeft(exteriorWidth)) - rco,         tco),
                    new Point2D.Double(    sideWidth - rco,                                                                 tco + curveConstant*(rightRadius.getMaxRight(exteriorHeight))),
                    new Point2D.Double(    sideWidth - rco,                                                                 tco + rightRadius.getMaxRight(exteriorHeight)));
           
            path.lineTo(     rightCurvePoints[0][0].getX(), rightCurvePoints[0][0].getY());
            path.curveTo(    rightCurvePoints[0][1].getX(), rightCurvePoints[0][1].getY(),
                            rightCurvePoints[0][2].getX(), rightCurvePoints[0][2].getY(),
                            (rightCurvePoints[0][3].getX()), (rightCurvePoints[0][3].getY()));
        } else {
            path.lineTo(sideWidth - rightRadius.getMaxLeft(exteriorWidth/2) - rco,         tco);
        }

       
        // check if we draw the interior
        if(drawInterior) {
            // start drawing interior
            tco = (1+scaledOffset)*topWidth;
            lco = (1+scaledOffset)*leftWidth;
            rco = (1+scaledOffset)*rightWidth;

            // top right interior, check we have a radius
            if(rightRadius.getMaxLeft(interiorWidth) > 0) {
               
                Point2D [][] rightCurvePoints = getSubCurve(1-rp,
                        new Point2D.Double(    sideWidth - rightRadius.getMaxLeft(interiorWidth) - rco,                             tco),
                        new Point2D.Double(    sideWidth - curveConstant*(rightRadius.getMaxLeft(interiorWidth)) - rco,             tco),
                        new Point2D.Double(    sideWidth - rco,                                                                     tco + curveConstant*(rightRadius.getMaxRight(interiorHeight))),
                        new Point2D.Double(    sideWidth - rco,                                                                     tco + rightRadius.getMaxRight(interiorHeight)));
               
                path.lineTo((rightCurvePoints[0][3].getX()), (rightCurvePoints[0][3].getY()));
                path.curveTo(    rightCurvePoints[0][2].getX(), rightCurvePoints[0][2].getY(),
                                rightCurvePoints[0][1].getX(), rightCurvePoints[0][1].getY(),
                                rightCurvePoints[0][0].getX(), rightCurvePoints[0][0].getY());
            } else {
                path.lineTo(sideWidth - rco,                 tco);
            }
           
            // top left interior, check we have a radius
            if(leftRadius.getMaxRight(interiorWidth) > 0) {
               
                Point2D [][] leftCurvePoints = getSubCurve(1-lp,
                    new Point2D.Double(    leftRadius.getMaxRight(interiorWidth) + lco,                         tco),
                    new Point2D.Double(    curveConstant*(leftRadius.getMaxRight(interiorWidth)) + lco,         tco),
                    new Point2D.Double(    lco,                                                                 tco + curveConstant*(leftRadius.getMaxLeft(interiorHeight))),
                    new Point2D.Double(    lco,                                                                 tco + leftRadius.getMaxLeft(interiorHeight)));
               
                path.lineTo(leftCurvePoints[0][0].getX(), leftCurvePoints[0][0].getY());
                path.curveTo(    leftCurvePoints[0][1].getX(), leftCurvePoints[0][1].getY(),
                        leftCurvePoints[0][2].getX(), leftCurvePoints[0][2].getY(),
                        (leftCurvePoints[0][3].getX()), (leftCurvePoints[0][3].getY()));
            } else {
                path.lineTo(leftRadius.getMaxRight(interiorHeight) +  lco,                 tco);
            }
           
            // only close the path if its a full 2d path. If its just the exterior line we leave it open
            path.closePath();
        }
       
        // rotate and translate our border to the correct side.
        path.transform(AffineTransform.getRotateInstance(rotation, 0, 0));
        path.transform(AffineTransform.getTranslateInstance(bounds.x + xOffset, bounds.y + yOffset));
       
        return path;
    }
View Full Code Here

Examples of java.awt.geom.Path2D

            final Rectangle bounds, final BorderPropertySet border,
            final BorderPropertySet color, final float[] pattern,
            final int sides, final int currentSide, int xOffset) {
        Stroke old_stroke = outputDevice.getStroke();

        Path2D path = generateBorderShape(bounds, currentSide, border, false, .5f, 1);
        Path2D clip = generateBorderShape(bounds, currentSide, border, true, 0, 1);
       
        Shape old_clip = outputDevice.getClip();
        outputDevice.setClip(clip);
               
        if (currentSide == BorderPainter.TOP) {
View Full Code Here

Examples of java.awt.geom.Path2D

      g.setStroke(HIGHLIGHT_FLOW_STROKE);
    }

    int radius = 15;
   
    Path2D path = new Path2D.Double();

    boolean isDefaultConditionAvailable = false;

    //Integer nextSrcX=null, nextSrcY=null;
    for(int i=0; i<xPoints.length; i++) {
      Integer anchorX = xPoints[i];
      Integer anchorY = yPoints[i];

      double targetX = anchorX, targetY = anchorY;

      double ax=0, ay=0, bx=0, by=0, zx=0, zy=0;

      if (i>0 && i < xPoints.length-1) {
        Integer cx = anchorX, cy = anchorY;

        // pivot point of prev line
        double  lineLengthY = yPoints[i] - yPoints[i-1],
                lineLengthX = xPoints[i] - xPoints[i-1];
        double  lineLength = Math.sqrt(Math.pow(lineLengthY, 2) + Math.pow(lineLengthX, 2)),
                dx = lineLengthX * radius / lineLength,
                dy = lineLengthY * radius / lineLength;
                targetX = targetX - dx;
                targetY = targetY - dy;

        isDefaultConditionAvailable = isDefault && i == 1 && lineLength > 10;

        if (lineLength < 2*radius && i>1) {
                targetX = xPoints[i] - lineLengthX/2;
                targetY = yPoints[i] - lineLengthY/2;
        }

        // pivot point of next line
                lineLengthY = yPoints[i+1] - yPoints[i];
                lineLengthX = xPoints[i+1] - xPoints[i];
                lineLength = Math.sqrt(Math.pow(lineLengthY, 2) + Math.pow(lineLengthX, 2));
        if (lineLength < radius) {
          lineLength = radius;
        }
        dx = lineLengthX * radius / lineLength;
        dy = lineLengthY * radius / lineLength;

        double  nextSrcX = xPoints[i] + dx,
                nextSrcY = yPoints[i] + dy;

        if (lineLength < 2*radius && i<xPoints.length-2) {
          nextSrcX = xPoints[i] + lineLengthX/2;
          nextSrcY = yPoints[i] + lineLengthY/2;
        }

        double dx0 = (cx - targetX) / 3,
               dy0 = (cy - targetY) / 3;
               ax = cx - dx0;
               ay = cy - dy0;

        double dx1 = (cx - nextSrcX) / 3,
               dy1 = (cy - nextSrcY) / 3;
               bx = cx - dx1;
               by = cy - dy1;

               zx=nextSrcX;
               zy=nextSrcY;
    }

    if (i==0) {
      path.moveTo(targetX, targetY);
    } else {
      path.lineTo(targetX, targetY);
    }

    if (i>0 && i < xPoints.length-1) {
      // add curve
      path.curveTo(ax, ay, bx, by, zx, zy);
    }

    if (i == xPoints.length-1) {
      Line2D.Double lineDouble = new Line2D.Double(xPoints[i-1], yPoints[i-1], xPoints[i], yPoints[i]);
      drawArrowHead(lineDouble);
View Full Code Here

Examples of java.awt.geom.Path2D

  protected void renderArrow(StyleGroup group, Graphics2D g, Camera camera,
      GraphicEdge edge) {
    if (edge.isDirected() && arrowWidth > 0 && arrowLength > 0) {
      if (group.getArrowShape() != ArrowShape.NONE) {
        Path2D shape = new Path2D.Double();
        GraphicNode node0 = (GraphicNode) edge.getNode0();
        GraphicNode node1 = (GraphicNode) edge.getNode1();
        double off = evalEllipseRadius(edge, node0, node1, camera);
        Vector2 theDirection = new Vector2(node1.getX() - node0.getX(),
            node1.getY() - node0.getY());

        theDirection.normalize();

        double x = node1.x - (theDirection.data[0] * off);
        double y = node1.y - (theDirection.data[1] * off);
        Vector2 perp = new Vector2(theDirection.data[1],
            -theDirection.data[0]);

        perp.normalize();
        theDirection.scalarMult(arrowLength);
        perp.scalarMult(arrowWidth);

        // Create a polygon.

        shape.reset();
        shape.moveTo(x, y);
        shape.lineTo(x - theDirection.data[0] + perp.data[0], y
            - theDirection.data[1] + perp.data[1]);
        shape.lineTo(x - theDirection.data[0] - perp.data[0], y
            - theDirection.data[1] - perp.data[1]);
        shape.closePath();

        g.fill(shape);
      }
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.