/** * 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)); }
// ----------------------------------------------------------------- // 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); }
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); }
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(); }