Package shapes.common

Examples of shapes.common.Rectangle


    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();
    f.setVisible(true);

    // now draw the same complex group of shapes.impl.composite by hand
View Full Code Here


    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();
    f.setVisible(true);

    // now draw the same complex group of shapes.impl.composite by hand
View Full Code Here

TOP

Related Classes of shapes.common.Rectangle

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.