예제 #1
0
 /** RedŽfinition de la mŽthode paintComponent() de JComponent */
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   for (Shape s : shapes) {
     s.paint(g);
   }
   notifyObservers();
 }
예제 #2
0
 /** Redefinition de la methode paintComponent() de JComponent */
 public void paintComponent(Graphics g) {
   super.paintComponent(g);
   for (Shape s : shapes) {
     s.paint(g);
   }
   for (Shape s : shapesCloneList) {
     s.paint(g);
   }
 }
예제 #3
0
 public void duplication() {
   if (shapes.size() != 0) {
     for (Shape shape : shapes) {
       Shape clone = shape.duplicateShape();
       Point point = new Point(shape.origin());
       point.y += 120;
       clone.setOrigin(point);
       shapesCloneList.add(clone);
       System.out.println("shape is duplicated");
     }
     this.repaint();
   }
 }
예제 #4
0
  public void textShape(String name) {
    if (shapes.size() != 0) {
      for (Shape shape : shapes) {
        shape.setText(name);
      }
      this.repaint();
    }

    if (shapesCloneList.size() != 0) {
      for (Shape shapeClone : shapes) {
        shapeClone.setText(name);
      }
      this.repaint();
    }
  }
예제 #5
0
  public void dupliquer() {
    for (Shape s : shapeSelect) {
      Point p = new Point(s.getOrigin());
      p.y += 100;

      if (s instanceof Rectangle) {
        Rectangle r = (Rectangle) s;
        shapes.add(new Rectangle(p, r.getWidth(), r.getHeight(), r.getColor()));
        cpt++;
        notifyObservers();
      }

      if (s instanceof Circle) {
        Circle c = (Circle) s;
        shapes.add(new Circle(p, c.getRadius(), c.getColor()));
        cpt++;
        notifyObservers();
      }
    }

    shapeSelect.clear();
    this.repaint();
  }