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();
  }
示例#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();
  }
示例#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();
  }
示例#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();
    }
  }
示例#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();
  }
示例#10
0
 public void drawRectangle() {
   rectangle.draw();
 }
示例#11
0
 public void drawCircle() {
   circle.draw();
 }
示例#12
0
 static void paintShapes(Graphics g, LinkedList<Shape> shapes) {
   for (Shape s : shapes) {
     s.draw(g);
   }
 }
示例#13
0
 public void drawSquare() {
   square.draw();
 }
 public void draw() {
   decoratedShape.draw();
 }
示例#15
0
 @Override
 public void draw() {
   decoratedShape.draw();
 }
 @Override
 protected void paintComponent(Graphics g) {
   for (Shape s : shapes) {
     s.draw(g);
   }
 }
示例#17
0
文件: Test.java 项目: feisuo/Spring
 public static void main(String[] args) {
   context = new ClassPathXmlApplicationContext("abc.xml");
   Shape shape = (Shape) context.getBean("triangle");
   shape.draw();
 }
示例#18
0
 public void drawTriangle() {
   triangle.draw();
 }
示例#19
0
 // ========================================================= drawCurrentShape
 private void drawCurrentShape(Graphics2D g2) {
   g2.setColor(_color); // Set the color.
   _shape.draw(g2, _start, _end); // Draw the shape.
 }
示例#20
0
 public void draw(String color) {
   for (Shape shape : shapes) {
     shape.draw(color);
   }
 }
 public void drawShape(Shape s) {
   s.draw();
 }