Exemplo n.º 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));
 }
Exemplo n.º 2
0
  // -----------------------------------------------------------------
  //  Draws this panel by requesting that each circle draw itself.
  // -----------------------------------------------------------------
  public void paintComponent(Graphics page) {
    super.paintComponent(page);

    circle1.draw(page);
    circle2.draw(page);
    circle3.draw(page);
    circle4.draw(page);
    circle5.draw(page);
  }
Exemplo n.º 3
0
  public void update(Graphics g) {
    if (offimage == null) {
      offimage = createImage(getWidth(), getHeight());
      offg = offimage.getGraphics();
    }
    Graphics2D g2d = (Graphics2D) offg;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    circleList.add(new Circle(getWidth(), getHeight()));
    for (Circle circle : circleList) {
      circle.grow();
      g2d.setColor(circle.color);
      g2d.fillOval(
          circle.x - circle.radius, circle.y - circle.radius, circle.radius * 2, circle.radius * 2);
      if (circle.radius > 100) {
        circleList.remove(circle);
      }
    }

    g.drawImage(offimage, 0, 0, this);
  }
Exemplo n.º 4
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();
  }