Package shapes.common

Examples of shapes.common.Shape.accept()


  public void testGroupSimple() {
    Shape s = new Group(
      new Location(200, 100, new Circle(50)),
      new Location(400, 300, new Rectangle(100, 50))
    );
    shapes.common.Location b = s.accept(v);
    shapes.common.Rectangle r = (shapes.common.Rectangle) b.getChild();
    assertEquals(150, b.getX());
    assertEquals(50, b.getY());
    assertEquals(350, r.getWidth());
    assertEquals(300, r.getHeight());
View Full Code Here


            )
          )
        )
      )
    );
    shapes.common.Location b = s.accept(v);
    shapes.common.Rectangle r = (shapes.common.Rectangle) b.getChild();
    assertEquals(30, b.getX());
    assertEquals(80, b.getY());
    assertEquals(470, r.getWidth());
    assertEquals(320, r.getHeight());
View Full Code Here

      new DefaultPoint(50, 50),
      new DefaultPoint(60, 100),
      new DefaultPoint(100, 110),
      new DefaultPoint(120, 60)
    );
    shapes.common.Location b = s.accept(v);
    shapes.common.Rectangle r = (shapes.common.Rectangle) b.getChild();
    assertEquals(50, b.getX());
    assertEquals(50, b.getY());
    assertEquals(70, r.getWidth());
    assertEquals(60, r.getHeight());
View Full Code Here

  public void testGroupSimple() {
    Shape s = new Group(
      new Location(200, 100, new Circle(50)),
      new Location(400, 300, new Rectangle(100, 50))
    );
    int r = s.accept(v);
    assertEquals(2, r);
  }
 
  @Test
  public void testGroupComplex() {
View Full Code Here

            )
          )
        )
      )
    );
    int r = s.accept(v);
    assertEquals(6, r);
  }
 
  @Test
  public void testOutline() {
View Full Code Here

      new DefaultPoint(50, 50),
      new DefaultPoint(60, 100),
      new DefaultPoint(100, 110),
      new DefaultPoint(120, 60)
    );
    int r = s.accept(v);
    assertEquals(1, r);
  }
}
View Full Code Here

      builder.setStroke(Color.RED);
      builder.setLocation(150, 50);
    builder.endGroup();
    builder.setLocation(50, 100);
    final Shape s = builder.getProduct();
    System.out.println(s.accept(new Size()) + " basic shapes");

    // calculate the bounding box
    final Location b = s.accept(new BoundingBox());
    final Rectangle r = (Rectangle) b.getChild();
View Full Code Here

    builder.setLocation(50, 100);
    final Shape s = builder.getProduct();
    System.out.println(s.accept(new Size()) + " basic shapes");

    // calculate the bounding box
    final Location b = s.accept(new BoundingBox());
    final Rectangle r = (Rectangle) b.getChild();

    // draw it in a frame centered around the bounding box
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
View Full Code Here

    @SuppressWarnings("serial")
    JPanel p = new JPanel() {
      @Override
      public void paintComponent(Graphics g) {
        g.translate(-b.getX() + padding, -b.getY() + padding);
        s.accept(new Draw(g));
        s.accept(new BoundingBox()).accept(new Draw(g));
      }
    };
    p.setPreferredSize(new Dimension(r.getWidth() + 2 * padding, r.getHeight() + 2 * padding));
    f.setContentPane(p);
 
View Full Code Here

    JPanel p = new JPanel() {
      @Override
      public void paintComponent(Graphics g) {
        g.translate(-b.getX() + padding, -b.getY() + padding);
        s.accept(new Draw(g));
        s.accept(new BoundingBox()).accept(new Draw(g));
      }
    };
    p.setPreferredSize(new Dimension(r.getWidth() + 2 * padding, r.getHeight() + 2 * padding));
    f.setContentPane(p);
    f.pack();
 
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.