Package java.awt

Examples of java.awt.Polygon


  /**
   * @see Graphics#drawPolygon(int[], int[], int)
   */
  public void drawPolygon(final int[] xPoints, final int[] yPoints, final int nPoints)
  {
    final Polygon poly = new Polygon();
    for (int i = 0; i < nPoints; i++)
    {
      poly.addPoint(xPoints[i], yPoints[i]);
    }
    draw(poly);
  }
View Full Code Here


  /**
   * @see Graphics#fillPolygon(int[], int[], int)
   */
  public void fillPolygon(final int[] xPoints, final int[] yPoints, final int nPoints)
  {
    final Polygon poly = new Polygon();
    for (int i = 0; i < nPoints; i++)
    {
      poly.addPoint(xPoints[i], yPoints[i]);
    }
    fill(poly);
  }
View Full Code Here

      // Add in the triangle piece for the balloon.
      if (vpos == VPOS_BELOW) {
        if (hpos == HPOS_LEFT) {
          int[] xPts = {16, 16, 32};
          int[] yPts = {-1, 16, 16};
          area.add(new Area(new Polygon(xPts, yPts, 3)));
        }
        else {
          int[] xPts = {width - 15, width - 15, width - 32};
          int[] yPts = {-1, 16, 16};
          area.add(new Area(new Polygon(xPts, yPts, 3)));
        }
      }
      else {
        if (hpos == HPOS_LEFT) {
          int[] xPts = {16, 16, 31};
          int[] yPts = {height, height + 16, height};
          area.add(new Area(new Polygon(xPts, yPts, 3)));
        }
        else {
          int[] xPts = {width - 15, width - 15, width - 32};
          int[] yPts = {height, height + 16, height};
          area.add(new Area(new Polygon(xPts, yPts, 3)));
        }
      }
      return area;
    }
View Full Code Here

    }
  }

  public void drawArrowHead(Line2D.Double line) {
    int doubleArrowWidth = 2 * ARROW_WIDTH;
    Polygon arrowHead = new Polygon();
    arrowHead.addPoint(0, 0);
    arrowHead.addPoint(-ARROW_WIDTH, -doubleArrowWidth);
    arrowHead.addPoint(ARROW_WIDTH, -doubleArrowWidth);

    AffineTransform transformation = new AffineTransform();
    transformation.setToIdentity();
    double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
    transformation.translate(line.x2, line.y2);
View Full Code Here

  public void drawConditionalSequenceFlowIndicator(Line2D.Double line) {
    int horizontal = (int) (CONDITIONAL_INDICATOR_WIDTH * 0.7);
    int halfOfHorizontal = horizontal / 2;
    int halfOfVertical = CONDITIONAL_INDICATOR_WIDTH / 2;

    Polygon conditionalIndicator = new Polygon();
    conditionalIndicator.addPoint(0, 0);
    conditionalIndicator.addPoint(-halfOfHorizontal, halfOfVertical);
    conditionalIndicator.addPoint(0, CONDITIONAL_INDICATOR_WIDTH);
    conditionalIndicator.addPoint(halfOfHorizontal, halfOfVertical);

    AffineTransform transformation = new AffineTransform();
    transformation.setToIdentity();
    double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
    transformation.translate(line.x1, line.y1);
View Full Code Here

      }
    }
  }

  public void drawGateway(int x, int y, int width, int height) {
    Polygon rhombus = new Polygon();
    rhombus.addPoint(x, y + (height / 2));
    rhombus.addPoint(x + (width / 2), y + height);
    rhombus.addPoint(x + width, y + (height / 2));
    rhombus.addPoint(x + (width / 2), y);
    g.draw(rhombus);
  }
View Full Code Here

                }
                break;
            } else if ("ellipse".equalsIgnoreCase(child.getNodeName())) {
                obj.setShape(new Ellipse2D.Double(x, y, width, height));
            } else if ("polygon".equalsIgnoreCase(child.getNodeName()) || "polyline".equalsIgnoreCase(child.getNodeName())) {
                Polygon shape = new Polygon();
                final String pointsAttribute = getAttributeValue(child, "points");
                StringTokenizer st = new StringTokenizer(pointsAttribute, ", ");
                while (st.hasMoreElements()) {
                    shape.addPoint(x + Integer.parseInt(st.nextToken()), y + Integer.parseInt(st.nextToken()));
                }
                obj.setShape(shape);
                obj.setBounds(shape.getBounds());
            }
        }

        Properties props = new Properties();
        readProperties(children, props);
View Full Code Here

        for (int i = 0; i < points; i++) {
            xPoints[i] = x + (int) (width / 2.0) + (int) (width / 2.0 * Math.cos(radians));
            yPoints[i] = y + (int) (height / 2.0) + (int) (height / 2.0 * Math.sin(radians));
            radians += (2.0 * Math.PI) / points;
        }
        final Polygon p = new Polygon(xPoints, yPoints, points);
        return p;
    }
View Full Code Here

    }

    @Override
    public void drawOval(final int x, final int y, final int width, final int height, final Color color) {
        useColor(color);
        final Polygon p = createOval(x, y, width - 1, height - 1);
        graphics.drawPolygon(p);
    }
View Full Code Here

    }

    @Override
    public void drawSolidOval(final int x, final int y, final int width, final int height, final Color color) {
        useColor(color);
        final Polygon p = createOval(x, y, width, height);
        graphics.fillPolygon(p);
    }
View Full Code Here

TOP

Related Classes of java.awt.Polygon

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.