Package java.awt.geom

Examples of java.awt.geom.GeneralPath


      borderShapeLeft = new Line2D.Double(lineX, lineY1, lineX, lineY2);
      return borderShapeLeft;
    }

    // Make a rounded corner
    final GeneralPath generalPath = new GeneralPath(GeneralPath.WIND_NON_ZERO, 20);
    generalPath.append(configureArc(x, y + h - 2 * bottomLeftHeight, 2 * bottomLeftWidth, 2 * bottomLeftHeight, -135,
        -45, Arc2D.OPEN), true);
    generalPath.lineTo((float) x, (float) (y + topLeftHeight));//8
    generalPath.append(configureArc(x, y, 2 * topLeftWidth, 2 * topLeftHeight, -180, -45, Arc2D.OPEN), true);
    generalPath.transform(BorderRenderer.scaleInstance);
    borderShapeLeft = generalPath;
    return generalPath;
  }
View Full Code Here


      borderShapeRight = new Line2D.Double(lineX, lineY1, lineX, lineY2);
      return borderShapeRight;
    }

    // Make a rounded corner
    final GeneralPath generalPath = new GeneralPath(GeneralPath.WIND_NON_ZERO, 20);
    generalPath.append(configureArc(x + w - 2 * topRightWidth, y, 2 * topRightWidth, 2 * topRightHeight, 45, -45,
        Arc2D.OPEN), true);
    generalPath.lineTo((float) (x + w), (float) (y + h - bottomRightHeight));//4
    generalPath.append(configureArc(x + w - 2 * bottomRightWidth, y + h - 2 * bottomRightHeight, 2 * bottomRightWidth,
        2 * bottomRightHeight, 0, -45, Arc2D.OPEN), true);
    generalPath.transform(BorderRenderer.scaleInstance);
    borderShapeRight = generalPath;
    return generalPath;
  }
View Full Code Here

          (line.getX1(), line.getY1(), line.getX2(), line.getY2(),
              -DELTA, DELTA + bounds.getWidth(),
              -DELTA, DELTA + bounds.getHeight());
      if (clipped == null)
      {
        return new GeneralPath();
      }
      return new Line2D.Float(clipped[0], clipped[1]);
    }

    final Rectangle2D boundsCorrected = bounds.getBounds2D();
    boundsCorrected.setRect(-DELTA, -DELTA,
        DELTA + boundsCorrected.getWidth(), DELTA + boundsCorrected.getHeight());
    final Area a = new Area(boundsCorrected);
    if (a.isEmpty())
    {
      // don't clip  ... Area does not like lines
      // operations with lines always result in an empty Bounds:(0,0,0,0) area
      return new GeneralPath();
    }

    final Area clipArea = new Area(s);
    a.intersect(clipArea);
    return a;
View Full Code Here

        final float transY1;

        final RectangleEdge edge1 = plot.getRangeAxisEdge();

        final GeneralPath left = new GeneralPath();
        final GeneralPath right = new GeneralPath();
        if (y1 >= 0.0) {  // handle positive value
            transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[1], dataArea,
                    edge1);
            final float transStack1 = (float) rangeAxis.valueToJava2D(stack1[1],
                    dataArea, edge1);
            final float transStackLeft = (float) rangeAxis.valueToJava2D(
                    adjStackLeft[1], dataArea, edge1);

            // LEFT POLYGON
            if (y0 >= 0.0) {
                final double yleft = (y0 + y1) / 2.0 + stackLeft[1];
                final float transYLeft
                    = (float) rangeAxis.valueToJava2D(yleft, dataArea, edge1);
                left.moveTo((float) xx1, transY1);
                left.lineTo((float) xx1, transStack1);
                left.lineTo((float) xxLeft, transStackLeft);
                left.lineTo((float) xxLeft, transYLeft);
                left.closePath();
            }
            else {
                left.moveTo((float) xx1, transStack1);
                left.lineTo((float) xx1, transY1);
                left.lineTo((float) xxLeft, transStackLeft);
                left.closePath();
            }

            final float transStackRight = (float) rangeAxis.valueToJava2D(
                    adjStackRight[1], dataArea, edge1);
            // RIGHT POLYGON
            if (y2 >= 0.0) {
                final double yright = (y1 + y2) / 2.0 + stackRight[1];
                final float transYRight
                    = (float) rangeAxis.valueToJava2D(yright, dataArea, edge1);
                right.moveTo((float) xx1, transStack1);
                right.lineTo((float) xx1, transY1);
                right.lineTo((float) xxRight, transYRight);
                right.lineTo((float) xxRight, transStackRight);
                right.closePath();
            }
            else {
                right.moveTo((float) xx1, transStack1);
                right.lineTo((float) xx1, transY1);
                right.lineTo((float) xxRight, transStackRight);
                right.closePath();
            }
        }
        else // handle negative value
            transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[0], dataArea,
                    edge1);
            final float transStack1 = (float) rangeAxis.valueToJava2D(stack1[0],
                    dataArea, edge1);
            final float transStackLeft = (float) rangeAxis.valueToJava2D(
                    adjStackLeft[0], dataArea, edge1);

            // LEFT POLYGON
            if (y0 >= 0.0) {
                left.moveTo((float) xx1, transStack1);
                left.lineTo((float) xx1, transY1);
                left.lineTo((float) xxLeft, transStackLeft);
                left.clone();
            }
            else {
                final double yleft = (y0 + y1) / 2.0 + stackLeft[0];
                final float transYLeft = (float) rangeAxis.valueToJava2D(yleft,
                        dataArea, edge1);
                left.moveTo((float) xx1, transY1);
                left.lineTo((float) xx1, transStack1);
                left.lineTo((float) xxLeft, transStackLeft);
                left.lineTo((float) xxLeft, transYLeft);
                left.closePath();
            }
            final float transStackRight = (float) rangeAxis.valueToJava2D(
                    adjStackRight[0], dataArea, edge1);

            // RIGHT POLYGON
            if (y2 >= 0.0) {
                right.moveTo((float) xx1, transStack1);
                right.lineTo((float) xx1, transY1);
                right.lineTo((float) xxRight, transStackRight);
                right.closePath();
            }
            else {
                final double yright = (y1 + y2) / 2.0 + stackRight[0];
                final float transYRight = (float) rangeAxis.valueToJava2D(yright,
                        dataArea, edge1);
                right.moveTo((float) xx1, transStack1);
                right.lineTo((float) xx1, transY1);
                right.lineTo((float) xxRight, transYRight);
                right.lineTo((float) xxRight, transStackRight);
                right.closePath();
            }
        }

        if (pass == 0) {
            final Paint itemPaint = getItemPaint(row, column);
            g2.setPaint(itemPaint);
            g2.fill(left);
            g2.fill(right);

            // add an entity for the item...
            if (entities != null) {
                final GeneralPath gp = new GeneralPath(left);
                gp.append(right, false);
                entityArea = gp;
                addItemEntity(entities, dataset, row, column, entityArea);
            }
        }
        else if (pass == 1) {
View Full Code Here

                    int[] yps = (int[]) lines.get(i + 1);

                    xpoints[j] = xps;
                    ypoints[j] = yps;

                    GeneralPath gp = createShape(xps, yps, false);
                    if (shape == null) {
                        shape = gp;
                    } else {
                        ((GeneralPath) shape).append(gp, false);
                    }
View Full Code Here

            System.err.println("OMPoint.generate(): invalid RenderType");
            return false;
        }

        if (oval) {
            shape = new GeneralPath(new Ellipse2D.Float((float) Math.min(x2, x1), (float) Math.min(y2,
                    y1), (float) Math.abs(x2 - x1), (float) Math.abs(y2 - y1)));
        } else {
            shape = createBoxShape((int) Math.min(x2, x1), (int) Math.min(y2,
                    y1), (int) Math.abs(x2 - x1), (int) Math.abs(y2 - y1));
        }
View Full Code Here

        if (proj == null) {
            Debug.message("omgraphic", "OMArc: null projection in generate!");
            return false;
        }

        GeneralPath gp, gp1, gp2;
        PathIterator pi;
        AffineTransform af = null;

        switch (renderType) {
        case RENDERTYPE_OFFSET:
            if (!proj.isPlotable(center)) {
                setNeedToRegenerate(true);//HMMM not the best flag
                return false;
            }
            Point p1 = proj.forward(center.radlat_,
                    center.radlon_,
                    new Point(),
                    true);
            x1 = p1.x + off_x;
            y1 = p1.y + off_y;

        case RENDERTYPE_XY:
            float fwidth = (float) width;
            float fheight = (float) height;
            float transx = (float) x1;
            float transy = (float) y1;
            float x = transx - fwidth / 2f;
            float y = transy - fheight / 2f;

            Shape arcShape = createArcShape(x, y, fwidth, fheight);

            if (rotationAngle != DEFAULT_ROTATIONANGLE) {
                af = new AffineTransform();
                af.rotate(rotationAngle, transx, transy);
            }
            pi = arcShape.getPathIterator(af);
            gp = new GeneralPath();
            gp.append(pi, false);
            // In X/Y or Offset RenderType, there is only one shape.
            setShape(gp);

            break;

        case RENDERTYPE_LATLON:
            ArrayList coordLists = getCoordLists(proj, center, radius, nverts);

            Point p = proj.forward(center.radlat_,
                    center.radlon_,
                    new Point(),
                    true);
            x1 = p.x;
            y1 = p.y;

            int size = coordLists.size();
            GeneralPath tempShape = null;

            for (int i = 0; i < size; i += 2) {
                int[] xpoints = (int[]) coordLists.get(i);
                int[] ypoints = (int[]) coordLists.get(i + 1);

                gp = createShape(xpoints,
                        ypoints,
                        (arcType != Arc2D.OPEN || (arcType == Arc2D.OPEN && !isClear(fillPaint))));

                if (shape == null) {
                    setShape(gp);
                } else {
                    ((GeneralPath) shape).append(gp, false);
                }

                correctFill = proj instanceof Cylindrical
                        && ((shouldCenterBeInShape() && shape != null && !shape.contains(x1, y1)) || correctPolar);

                if (correctFill) {
                    int[][] alts = doPolarFillCorrection(xpoints,
                            ypoints,
                            (center.radlat_ > 0f) ? -1 : proj.getWidth() + 1);

                    int gp2length = alts[0].length - 2;

                    gp1 = createShape(alts[0], alts[1], true);
                    gp2 = createShape(alts[0], alts[1], 0, gp2length, false);

                    if (tempShape == null || polarShapeLine == null) {
                        tempShape = gp1;
                        polarShapeLine = gp2;
                    } else {
                        tempShape.append(gp1, false);
                        polarShapeLine.append(gp2, false);
                    }
                }
            }
View Full Code Here

            break;
        case RENDERTYPE_LATLON:
            int size = xpoints.length;

            for (int i = 0; i < size; i++) {
                GeneralPath gp = createShape(xpoints[i], ypoints[i], isPolygon);

                if (shape == null) {
                    shape = gp;
                } else {
                    ((GeneralPath) shape).append(gp, false);
View Full Code Here

        int size = vector.size();

        // We could call create shape, but this is more efficient.
        int i, j;
        for (i = 0, j = 0; i < size; i += 2, j++) {
            GeneralPath gp = createShape((int[]) vector.get(i),
                    (int[]) vector.get(i + 1),
                    true);

            if (shape == null) {
                setShape(gp);
View Full Code Here

     * attributes from the individual parts will be ignored. The
     * contributions will be kept geometrically separate
     * (disconnected) and their clipping areas will be ignored.
     */
    public Shape getGeometry() {
        GeneralPath geometry = null;
        Iterator it = iterator();
        while (it.hasNext()) {
            IconPart part = (IconPart) it.next();

            Shape shp = part.getGeometry();

            if (shp == null) {
                continue;
            }

            if (geometry == null) {
                geometry = new GeneralPath(shp);
            } else {
                geometry.append(shp, false);
            }
        }
        return geometry;
    }
View Full Code Here

TOP

Related Classes of java.awt.geom.GeneralPath

Copyright © 2018 www.massapicom. 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.