Package java.awt

Examples of java.awt.Polygon$PolygonPathIterator


          int y = child.getY() + child.getHeight() / 2;
          int x = 0;
          if (horizontal instanceof Leading) {
            x = ((Leading) horizontal).getLeading();
            g2d.drawLine(insets.left, y, insets.left + x, y);
            Polygon polygon = new Polygon();
            polygon.addPoint(insets.left, y - BOX + 1);
            polygon.addPoint(insets.left, y + BOX);
            polygon.addPoint(insets.left + BOX, y);
            g2d.fillPolygon(polygon);
          } else if (horizontal instanceof Trailing) {
            x = child.getX() + child.getWidth();
            g2d.drawLine(width - insets.right, y, x, y);
            Polygon polygon = new Polygon();
            polygon.addPoint(width - insets.right, y - BOX);
            polygon.addPoint(width - insets.right, y + BOX - 1);
            polygon.addPoint(width - BOX - insets.right, y);
            g2d.fillPolygon(polygon);
          } else if (horizontal instanceof Bilateral) {
            x = ((Bilateral) horizontal).getLeading();
            g2d.drawLine(insets.left, y, insets.left + x, y);
            Polygon polygon = new Polygon();
            polygon.addPoint(insets.left, y - BOX + 1);
            polygon.addPoint(insets.left, y + BOX);
            polygon.addPoint(insets.left + BOX, y);
            g2d.fillPolygon(polygon);
            x = child.getX() + child.getWidth();
            g2d.drawLine(width - insets.right, y, x, y);
            polygon = new Polygon();
            polygon.addPoint(width - insets.right, y - BOX);
            polygon.addPoint(width - insets.right, y + BOX - 1);
            polygon.addPoint(width - BOX - insets.right, y);
            g2d.fillPolygon(polygon);
          }
          Alignment vertical = constraints.getVertical();
          x = child.getX() + child.getWidth() / 2;
          if (vertical instanceof Leading) {
            y = ((Leading) vertical).getLeading();
            g2d.drawLine(x, insets.top, x, insets.top + y);
            Polygon polygon = new Polygon();
            polygon.addPoint(x - BOX + 1, insets.top);
            polygon.addPoint(x + BOX, insets.top);
            polygon.addPoint(x, BOX + insets.top);
            g2d.fillPolygon(polygon);
          } else if (vertical instanceof Trailing) {
            y = child.getY() + child.getHeight();
            g2d.drawLine(x, height - insets.bottom, x, y);
            Polygon polygon = new Polygon();
            polygon.addPoint(x - BOX, height - insets.bottom);
            polygon.addPoint(x + BOX - 1, height - insets.bottom);
            polygon.addPoint(x, height - BOX - insets.bottom);
            g2d.fillPolygon(polygon);
          } else if (vertical instanceof Bilateral) {
            y = ((Bilateral) vertical).getLeading();
            g2d.drawLine(x, insets.top, x, y + insets.top);
            Polygon polygon = new Polygon();
            polygon.addPoint(x - BOX + 1, insets.top);
            polygon.addPoint(x + BOX, insets.top);
            polygon.addPoint(x, BOX + insets.top);
            g2d.fillPolygon(polygon);
            y = child.getY() + child.getHeight();
            g2d.drawLine(x, height - insets.bottom, x, y);
            polygon = new Polygon();
            polygon.addPoint(x - BOX, height - insets.bottom);
            polygon.addPoint(x + BOX - 1, height - insets.bottom);
            polygon.addPoint(x, height - BOX - insets.bottom);
            g2d.fillPolygon(polygon);
          }
        }
      }
      g2d.setStroke(old);
View Full Code Here


      Point bottomLeft = new Point(0, 0);
      Point bottomRight = new Point(ARROW_WIDTH, 0);
     
      //This polygon is drawn on the left, but then gets rotated
      //so it actually appears on the right if North is up.
      Polygon left = new Polygon();
      left.addPoint(centerBase.x, centerBase.y);
      left.addPoint(tip.x, tip.y);
      left.addPoint(bottomLeft.x, bottomLeft.y);      
      g.setColor( Color.black );
      g.fill(left);
      g.draw(left);
     
      Polygon right = new Polygon();
      right.addPoint(centerBase.x, centerBase.y);
      right.addPoint(tip.x, tip.y);
      right.addPoint(bottomRight.x, bottomRight.y);
      g.setColor( Color.white );
      g.fill(right);
      g.setColor( Color.black );
      g.draw(right);
View Full Code Here

   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness)  
  {
    harness.checkPoint("Polygon 1");
    Polygon p = createTestPolygon1();
    harness.check(p.contains(0, 0));      // 1
    harness.check(!p.contains(0, 1));     // 2
    harness.check(p.contains(1, 0));      // 3
    harness.check(p.contains(1, 1));      // 4
    harness.check(!p.contains(1, 2));     // 5
    harness.check(!p.contains(2, 0));     // 6
    harness.check(!p.contains(2, 1));     // 7
   
    harness.checkPoint("Polygon 2");     
    p = createTestPolygon2();
    harness.check(p.contains(0, 0));      // 8
    harness.check(!p.contains(0, 5));     // 9
    harness.check(!p.contains(5, 5));     // 10
    harness.check(!p.contains(5, 1));     // 11
    harness.check(p.contains(2, 1));      // 12
    harness.check(!p.contains(2, 3));     // 13
    harness.check(!p.contains(3, 3));     // 14
    harness.check(!p.contains(3, 2));     // 15
    harness.check(p.contains(4, 2));      // 16
    harness.check(p.contains(4, 4));      // 17
    harness.check(p.contains(1, 4));      // 18
    harness.check(!p.contains(1, 0));     // 19
   
    harness.check(!p.contains(-0.5, 2.5))// 20
    harness.check(p.contains(0.5, 2.5));    // 21
    harness.check(!p.contains(1.5, 2.5));   // 22
    harness.check(p.contains(2.5, 2.5));    // 23
    harness.check(!p.contains(3.5, 2.5));   // 24
    harness.check(p.contains(4.5, 2.5));    // 25
    harness.check(!p.contains(5.5, 2.5));   // 26
   
    harness.checkPoint("Null argument checks");
    testNullArguments(harness);
  }
View Full Code Here

   * @param harness  the test harness (<code>null</code> not permitted).
   */
  private void testNullArguments(TestHarness harness)
  {
    boolean pass = false;
    Polygon p = new Polygon();
    try
    {
      p.contains((Point) null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    pass = false;
    try
    {
      p.contains((Point2D) null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
    harness.check(pass);
   
    pass = false;
    try
    {
      p.contains((Rectangle2D) null);
    }
    catch (NullPointerException e)
    {
      pass = true;
    }
View Full Code Here

   *
   * @return A test polygon.
   */
  private Polygon createTestPolygon1()
  {
    Polygon p = new Polygon();
    p.addPoint(0, 0);
    p.addPoint(1, 2);
    p.addPoint(2, 0);
    return p;
  }
View Full Code Here

   *
   * @return A test polygon.
   */
  private Polygon createTestPolygon2()
  {
    Polygon p = new Polygon();
    p.addPoint(0, 0);
    p.addPoint(0, 5);
    p.addPoint(5, 5);
    p.addPoint(5, 1);
    p.addPoint(2, 1);
    p.addPoint(2, 3);
    p.addPoint(3, 3);
    p.addPoint(3, 2);
    p.addPoint(4, 2);
    p.addPoint(4, 4);
    p.addPoint(1, 4);
    p.addPoint(1, 0);
    return p;
  }
View Full Code Here

  }
 
  public void test1(TestHarness harness)
  {
    harness.checkPoint("(AffineTransform)");
    Polygon p = new Polygon(new int[] {0, 1, 1, 0},
                            new int[] {0, 0, 1, 1}, 4);
   
    // test with no tranform...
    PathIterator pi = p.getPathIterator(null);
    harness.check(pi.getWindingRule(), PathIterator.WIND_EVEN_ODD);
    double[] coords = new double[6];
    int t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_MOVETO);
    harness.check(coords[0], 0.0);
    harness.check(coords[1], 0.0);
    harness.check(pi.isDone(), false);
    pi.next();
    t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_LINETO);
    harness.check(coords[0], 1.0);
    harness.check(coords[1], 0.0);
    harness.check(pi.isDone(), false);
    pi.next();
    t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_LINETO);
    harness.check(coords[0], 1.0);
    harness.check(coords[1], 1.0);
    harness.check(pi.isDone(), false);
    pi.next();
    t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_LINETO);
    harness.check(coords[0], 0.0);
    harness.check(coords[1], 1.0);
    harness.check(pi.isDone(), false);
    pi.next();
    t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_CLOSE);
    harness.check(pi.isDone(), false);
    pi.next();
    harness.check(pi.isDone(), true);

    // test with tranform...
    AffineTransform trans = AffineTransform.getTranslateInstance(10.0, 11.0);
    pi = p.getPathIterator(trans);
    harness.check(pi.getWindingRule(), PathIterator.WIND_EVEN_ODD);
    coords = new double[6];
    t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_MOVETO);
    harness.check(coords[0], 10.0);
View Full Code Here

  }
 
  public void test2(TestHarness harness)
  {
    harness.checkPoint("(AffineTransform, double)");
    Polygon p = new Polygon(new int[] {0, 1, 1, 0},
                            new int[] {0, 0, 1, 1}, 4);
   
    // test with no tranform...
    PathIterator pi = p.getPathIterator(null, 1.0);
    harness.check(pi.getWindingRule(), PathIterator.WIND_EVEN_ODD);
    double[] coords = new double[6];
    int t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_MOVETO);
    harness.check(coords[0], 0.0);
    harness.check(coords[1], 0.0);
    harness.check(pi.isDone(), false);
    pi.next();
    t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_LINETO);
    harness.check(coords[0], 1.0);
    harness.check(coords[1], 0.0);
    harness.check(pi.isDone(), false);
    pi.next();
    t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_LINETO);
    harness.check(coords[0], 1.0);
    harness.check(coords[1], 1.0);
    harness.check(pi.isDone(), false);
    pi.next();
    t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_LINETO);
    harness.check(coords[0], 0.0);
    harness.check(coords[1], 1.0);
    harness.check(pi.isDone(), false);
    pi.next();
    t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_CLOSE);
    harness.check(pi.isDone(), false);
    pi.next();
    harness.check(pi.isDone(), true);

    // test with tranform...
    AffineTransform trans = AffineTransform.getTranslateInstance(10.0, 11.0);
    pi = p.getPathIterator(trans, 1.0);
    harness.check(pi.getWindingRule(), PathIterator.WIND_EVEN_ODD);
    coords = new double[6];
    t = pi.currentSegment(coords);
    harness.check(t, PathIterator.SEG_MOVETO);
    harness.check(coords[0], 10.0);
View Full Code Here

        Rectangle rect=child.getBounds();
        g.setColor(Color.white);
        g.fillRect(rect.x+rect.width-18, rect.y-4, 10, 8);
        g.setColor(Color.black);
        g.drawRect(rect.x+rect.width-18, rect.y-4, 10, 8);
        Polygon p = new Polygon();
        p.addPoint(rect.x+rect.width-16, rect.y-1);
        p.addPoint(rect.x+rect.width-9, rect.y-1);
        p.addPoint(rect.x+rect.width-13, rect.y+3);
        g.setColor(Color.black);
        g.fillPolygon(p);
      }
    } 
  }
View Full Code Here

   * @see Graphics#drawPolyline
   */
  public void drawPolygon(final int[] xPoints, final int[] yPoints,
                          final int nPoints)
  {
    parent.draw(new Polygon(xPoints, yPoints, nPoints));
  }
View Full Code Here

TOP

Related Classes of java.awt.Polygon$PolygonPathIterator

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.