public static void main(String[] args) {
   // TODO Auto-generated method stub
   ShapeFactory sf = new ShapeFactory();
   Shape circle = sf.getShape("CIRCLE");
   Shape rect = sf.getShape("RECTANGLE");
   circle.draw();
   rect.draw();
 }
  public static void main(String[] args) {
    Shape redCircle = new Circle(100, 100, 10, new RedCircle());
    Shape greenCircle = new Circle(100, 100, 10, new GreenCircle());

    redCircle.draw();
    greenCircle.draw();

    Shape redSquare = new Square(100, 100, 10, new RedSquare());
    Shape greenSquare = new Square(100, 100, 10, new GreenSquare());
    redSquare.draw();
    greenSquare.draw();
  }
Example #3
0
  public static void main(String[] args) {
    System.out.println("Creating shapes...");
    Shape s1 = new Circle();
    Shape s2 = new BorderDecorator(new Line(), "blue");
    Shape s3 = new BorderDecorator(new Rectangle(), "green");
    Shape s4 = new FillDecorator(s3, "yellow");
    System.out.println();

    System.out.println("Drawing shapes...");
    s1.draw();
    System.out.println();
    s2.draw();
    System.out.println();
    s3.draw();
    System.out.println();
    s4.draw();
  }
Example #4
0
  public static void main(String[] args) {
    Shape[] shapes = {
      new Circle(5, 10, 10, new LargeCircleDrawer()),
      new Circle(20, 30, 100, new SmallCircleDrawer())
    };

    for (Shape next : shapes) {
      next.draw();
    }
  }
  public static void main(String[] args) {
    // get shape factory
    AbstractFactory shapeFactory = FactoryProducer.getFactory("SHAPE");

    // get an object of Shape Circle
    Shape shape1 = shapeFactory.getShape("CIRCLE");

    // call draw method of Shape Circle
    shape1.draw();

    // get an object of Shape Rectangle
    Shape shape2 = shapeFactory.getShape("RECTANGLE");

    // call draw method of Shape Rectangle
    shape2.draw();

    // get an object of Shape Square
    Shape shape3 = shapeFactory.getShape("SQUARE");

    // call draw method of Shape Square
    shape3.draw();

    // get color factory
    AbstractFactory colorFactory = FactoryProducer.getFactory("COLOR");

    // get an object of Color Red
    Color color1 = colorFactory.getColor("RED");

    // call fill method of Red
    color1.fill();

    // get an object of Color Green
    Color color2 = colorFactory.getColor("Green");

    // call fill method of Green
    color2.fill();

    // get an object of Color Blue
    Color color3 = colorFactory.getColor("BLUE");

    // call fill method of Color Blue
    color3.fill();
  }
 public void paintComponent(Graphics g) {
   // In the paint method, all the shapes in ArrayList are
   // copied onto the canvas.
   g.setColor(getBackground());
   g.fillRect(0, 0, getSize().width, getSize().height);
   int top = shapes.size();
   for (int i = 0; i < top; i++) {
     Shape s = (Shape) shapes.get(i);
     s.draw(g);
   }
 }
  public static void main(String[] args) {

    AbstractFactoryI absFact = FactoryProducer.getFactory("color");

    Color color1 = absFact.getColor("green");
    color1.draw();

    AbstractFactoryI absFact2 = FactoryProducer.getFactory("shape");

    Shape shape1 = absFact2.getShape("rhombus");
    shape1.draw();
  }
Example #8
0
  // draw() : 이벤트 루프가 도는 함수
  public void draw() {
    /*
    noStroke();
    fill(random(150,255),random(150,255),random(150,255),30);

    float raduis = random(50,200);
    ellipse(mouseX,mouseY,raduis,raduis);
    */

    ArrayList<Shape> shape = new ArrayList<>();

    for (int i = 0; i < 20; i++) {
      shape.add(new Circle(i * 50, 100));
      shape.add(new Rect(i * 50, 100));
    }

    for (Shape each : shape) {
      each.draw();
    }
  }
Example #9
0
  @Override
  public void display(GLAutoDrawable drawable) {
    final GL2 gl = drawable.getGL().getGL2();

    gl.glClear(GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT);
    gl.glLoadIdentity();

    applyMovementAndRotation(gl);
    applyLight(gl);
    // enableTransparency(gl);

    for (Shape el : s) {
      el.draw(gl, glu);
    }

    for (ModelShape el : ms) {
      el.draw(gl);
    }

    gl.glFlush();
  }
 public void drawRectangle() {
   rectangle.draw();
 }
 public void drawCircle() {
   circle.draw();
 }
Example #12
0
 static void paintShapes(Graphics g, LinkedList<Shape> shapes) {
   for (Shape s : shapes) {
     s.draw(g);
   }
 }
Example #13
0
 public void drawSquare() {
   square.draw();
 }
 public void draw() {
   decoratedShape.draw();
 }
Example #15
0
 @Override
 public void draw() {
   decoratedShape.draw();
 }
 @Override
 protected void paintComponent(Graphics g) {
   for (Shape s : shapes) {
     s.draw(g);
   }
 }
Example #17
0
 public static void main(String[] args) {
   context = new ClassPathXmlApplicationContext("abc.xml");
   Shape shape = (Shape) context.getBean("triangle");
   shape.draw();
 }
 public void drawTriangle() {
   triangle.draw();
 }
Example #19
0
 // ========================================================= drawCurrentShape
 private void drawCurrentShape(Graphics2D g2) {
   g2.setColor(_color); // Set the color.
   _shape.draw(g2, _start, _end); // Draw the shape.
 }
Example #20
0
 public void draw(String color) {
   for (Shape shape : shapes) {
     shape.draw(color);
   }
 }
 public void drawShape(Shape s) {
   s.draw();
 }