Package java.awt.geom

Examples of java.awt.geom.GeneralPath


      int thresh = Math.max(Line.ON_LINE_THRESH, getStrokeWidth() / 2);
      PolyUtil.ClosestResult result = PolyUtil.getClosestPoint(loc,
          closed, handles);
      return result.getDistanceSq() < thresh * thresh;
    } else if (type == DrawAttr.PAINT_FILL) {
      GeneralPath path = getPath();
      return path.contains(loc.getX(), loc.getY());
    } else { // fill and stroke
      GeneralPath path = getPath();
      if (path.contains(loc.getX(), loc.getY())) return true;
      int width = getStrokeWidth();
      PolyUtil.ClosestResult result = PolyUtil.getClosestPoint(loc,
          closed, handles);
      return result.getDistanceSq() < (width * width) / 4;
    }
View Full Code Here


    int stroke = getStrokeWidth();
    bounds = stroke < 2 ? bds : bds.expand(stroke / 2);
  }

  private GeneralPath getPath() {
    GeneralPath p = path;
    if (p == null) {
      p = new GeneralPath();
      Handle[] hs = handles;
      if (hs.length > 0) {
        boolean first = true;
        for (Handle h : hs) {
          if (first) {
            p.moveTo(h.getX(), h.getY());
            first = false;
          } else {
            p.lineTo(h.getX(), h.getY());
          }
        }
      }
      path = p;
    }
View Full Code Here

      GraphicsUtil.drawCenteredArc(g, -7050, 85, 90, -53);
    }
    paintShield(g, -width, 0, width, height);
    */
   
    GeneralPath path;
    if (width < 40) {
      path = PATH_NARROW;
    } else if (width < 60) {
      path = PATH_MEDIUM;
    } else {
View Full Code Here

    }
    */
  }
 
  private static GeneralPath computeShield(int width, int height) {
    GeneralPath base;
    if (width < 40) {
      base = SHIELD_NARROW;
    } else if (width < 60) {
      base = SHIELD_MEDIUM;
    } else {
      base = SHIELD_WIDE;
    }

    if (height <= width) { // no wings
      return base;
    } else { // we need to add wings
      int wingHeight = (height - width) / 2;
      int dx = Math.min(20, wingHeight / 4);
     
      GeneralPath path = new GeneralPath();
      path.moveTo(-width, -height / 2);
      path.quadTo(-width + dx, -(width + height) / 4, -width, -width / 2);
      path.append(base, true);
      path.quadTo(-width + dx, (width + height) / 4, -width, height / 2);
      return path;
    }
  }
View Full Code Here

    Location loc0 = OrGate.FACTORY.getInputOffset(attrs, 0);
    Location locn = OrGate.FACTORY.getInputOffset(attrs, inputs - 1);
    int totalHeight = 10 + loc0.manhattanDistanceTo(locn);
    if (totalHeight < width) totalHeight = width;
   
    GeneralPath path = computeShield(width, totalHeight);
    for (int i = 0; i < inputs; i++) {
      Location loci = OrGate.FACTORY.getInputOffset(attrs, i);
      Point2D p = new Point2D.Float(loci.getX() + 1, loci.getY());
      int iters = 0;
      while (path.contains(p) && iters < 15) {
        iters++;
        p.setLocation(p.getX() + 1, p.getY());
      }
      if (iters >= 15) iters = 0;
      lengths[i] = iters;
View Full Code Here

  public Shape getShape()
  {
    if (polygon == null)
    {
      polygon = new GeneralPath();

      for (int i = 0; i < coordinates.length; i += 2)
      {
        float coordinateX = coordinates[i];
        float coordinateY = coordinates[i + 1];
View Full Code Here

    if (segments == null)
    {
      return null;
    }

    final GeneralPath path = new GeneralPath();
    path.setWindingRule(wRule);
    for (int i = 0; i < segments.length; i++)
    {
      final int segmentType = segments[i].getSegmentType();
      switch (segmentType)
      {
        case PathIterator.SEG_CLOSE:
        {
          path.closePath();
          break;
        }
        case PathIterator.SEG_CUBICTO:
        {
          path.curveTo(segments[i].getX1(), segments[i].getY1(),
              segments[i].getX2(), segments[i].getY2(),
              segments[i].getX3(), segments[i].getY3());
          break;
        }
        case PathIterator.SEG_LINETO:
        {
          path.lineTo(segments[i].getX1(), segments[i].getY1());
          break;
        }
        case PathIterator.SEG_MOVETO:
        {
          path.moveTo(segments[i].getX1(), segments[i].getY1());
          break;
        }
        case PathIterator.SEG_QUADTO:
        {
          path.quadTo(segments[i].getX1(), segments[i].getY1(),
              segments[i].getX2(), segments[i].getY2());
          break;
        }
        default:
          throw new IllegalStateException("Unexpected result from path iterator.");
View Full Code Here

          StrictGeomUtility.toExternalValue(w), StrictGeomUtility.toExternalValue(h));
      return borderShape;
    }


    final GeneralPath generalPath = new GeneralPath(GeneralPath.WIND_NON_ZERO, 200);
    generalPath.append(configureArc(x, y, 2 * topLeftWidth, 2 * topLeftHeight, -225, -45, Arc2D.OPEN), true);
    generalPath.lineTo((float) (x + w - topRightWidth), (float) y);//2
    generalPath.append(configureArc(x + w - 2 * topRightWidth, y, 2 * topRightWidth, 2 * topRightHeight, 90, -45,
        Arc2D.OPEN), true);

    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.append(configureArc(x + w - 2 * bottomRightWidth, y + h - 2 * bottomRightHeight, 2 * bottomRightWidth,
        2 * bottomRightHeight, -45, -45, Arc2D.OPEN), true);
    generalPath.lineTo((float) (x + bottomLeftWidth), (float) (y + h));//6
    generalPath.append(configureArc(x, y + h - 2 * bottomLeftHeight, 2 * bottomLeftWidth, 2 * bottomLeftHeight, -90,
        -45, Arc2D.OPEN), true);

    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.closePath();
    generalPath.transform(BorderRenderer.scaleInstance);
    borderShape = generalPath;
    return generalPath;
  }
View Full Code Here

      borderShapeTop = new Line2D.Double(lineX1, lineY, lineX2, lineY);
      return borderShapeTop;
    }

    // Make a rounded corner
    final GeneralPath generalPath = new GeneralPath(GeneralPath.WIND_NON_ZERO, 20);
    generalPath.append(configureArc(x, y, 2 * topLeftWidth, 2 * topLeftHeight, -225, -45, Arc2D.OPEN), true);
    generalPath.lineTo((float) (x + w - topRightWidth), (float) y);//2
    generalPath.append(configureArc(x + w - 2 * topRightWidth, y, 2 * topRightWidth, 2 * topRightHeight, 90, -45,
        Arc2D.OPEN), true);
    generalPath.transform(BorderRenderer.scaleInstance);
    borderShapeTop = generalPath;
    return generalPath;
  }
View Full Code Here

      borderShapeBottom = new Line2D.Double(lineX1, lineY, lineX2, lineY);
      return borderShapeBottom;
    }

    // Make a rounded corner
    final GeneralPath generalPath = new GeneralPath(GeneralPath.WIND_NON_ZERO, 20);
    generalPath.append(configureArc(x + w - 2 * bottomRightWidth, y + h - 2 * bottomRightHeight, 2 * bottomRightWidth,
        2 * bottomRightHeight, -45, -45, Arc2D.OPEN), true);
    generalPath.lineTo((float) (x + bottomLeftWidth), (float) (y + h));//6
    generalPath.append(configureArc(x, y + h - 2 * bottomLeftHeight, 2 * bottomLeftWidth, 2 * bottomLeftHeight, -90,
        -45, Arc2D.OPEN), true);
    generalPath.transform(BorderRenderer.scaleInstance);
    borderShapeBottom = generalPath;
    return generalPath;
  }
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.