Package shapes.common

Examples of shapes.common.Location


    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));
 
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);
    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));
 
View Full Code Here

TOP

Related Classes of shapes.common.Location

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.