Package shapes.common

Examples of shapes.common.Shape


      builder.endGroup();
      builder.setStroke(Color.RED);
      builder.setLocation(150, 50);
    builder.endGroup();
    builder.setLocation(50, 100);
    final Shape s1 = builder.getProduct();
   
    final Shape s2 = new Location(50, 100,
        new Group(
          new Circle(20),
          new Rectangle(100, 200),
          new Location(150, 50,
            new Stroke(Color.RED,
View Full Code Here


      builder.setFilled(true);
      builder.setStroke(Color.RED);
      builder.setLocation(150, 50);
    builder.endGroup();
    builder.setLocation(50, 100);
    final Shape s1 = builder.getProduct();
   
    final Shape s2 = new Location(50, 100,
        new Group(
          new Circle(20),
          new Rectangle(100, 200),
          new Location(150, 50,
            new Stroke(Color.RED,
View Full Code Here

    assertEquals(120, r.getHeight());
  }
 
  @Test
  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

    assertEquals(300, r.getHeight());
  }
 
  @Test
  public void testGroupComplex() {
    final Shape s = new Location(50, 100,
      new Group(
        new Circle(20),
        new Rectangle(100, 200),
        new Location(150, 50,
          new Stroke(Color.RED,
            new Filled(
              new Group(
                new Rectangle(50, 30),
                new Outline(new Rectangle(300, 60)),
                new Stroke(Color.CYAN,
                  new Polygon(
                    new DefaultPoint(50, 50),
                    new DefaultPoint(60, 100),
                    new DefaultPoint(100, 110),
                    new DefaultPoint(120, 60)
                  )
                ),
                new Location(100, 200,
                  new Stroke(Color.ORANGE,
                    new Outline(new Circle(50))
                  )
                )
              )
            )
          )
        )
      )
    );
    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

    assertEquals(120, r.getHeight());
  }
 
  @Test
  public void testPolygon() {
    Shape s = new Polygon(
      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

    assertEquals(1, s);
  }
 
  @Test
  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);
  }
View Full Code Here

    assertEquals(2, r);
  }
 
  @Test
  public void testGroupComplex() {
    final Shape s = new Location(50, 100,
      new Group(
        new Circle(20),
        new Rectangle(100, 200),
        new Location(150, 50,
          new Stroke(Color.RED,
            new Filled(
              new Group(
                new Rectangle(50, 30),
                new Outline(new Rectangle(300, 60)),
                new Stroke(Color.CYAN,
                  new Polygon(
                    new DefaultPoint(50, 50),
                    new DefaultPoint(60, 100),
                    new DefaultPoint(100, 110),
                    new DefaultPoint(120, 60)
                  )
                ),
                new Location(100, 200,
                  new Stroke(Color.ORANGE,
                    new Outline(new Circle(50))
                  )
                )
              )
            )
          )
        )
      )
    );
    int r = s.accept(v);
    assertEquals(6, r);
  }
View Full Code Here

    assertEquals(1, s);
  }
 
  @Test
  public void testPolygon() {
    Shape s = new Polygon(
      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.endGroup();
      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();

    // draw it in a frame centered around the bounding box
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final int padding = 20;
    @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);
    f.pack();
 
View Full Code Here

      builder.setFilled(true);
      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();

    // draw it in a frame centered around the bounding box
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    final int padding = 20;
    @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);
    f.pack();
 
View Full Code Here

TOP

Related Classes of shapes.common.Shape

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.