示例#1
0
 /**
  * Draws a Circle object on the GrapherPanel as a series of 1 pixel wide lines contained in the
  * Circle's sides variable.
  *
  * @param The Circle to paint.
  */
 private void paintCircle(Circle c) {
   g.setColor(Color.GREEN);
   g.drawOval(
       (int) (c.getCenter().getX() - c.getRadius()),
       (int) (c.getCenter().getY() - c.getRadius()),
       (int) (c.getRadius() * 2),
       (int) (c.getRadius() * 2));
 }
示例#2
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();
  }