KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > nightlabs > editor2d > figures > ContainerDrawComponentFigure


1 /*
2  * Created on 06.06.2005
3  */

4 package com.nightlabs.editor2d.figures;
5
6 import java.awt.Graphics2D JavaDoc;
7 import java.util.Iterator JavaDoc;
8
9 import org.eclipse.draw2d.Figure;
10 import org.eclipse.draw2d.Graphics;
11
12 /**
13  * Overrides paint methods of DrawComponentFigures
14  * and paints only its children instead.
15  *
16  * @author Alexander Bieber <alex[AT]nightlabs[DOT]de>
17  *
18  */

19 public class ContainerDrawComponentFigure extends DrawComponentFigure {
20     
21     /**
22      * Overridden to paint only children
23      */

24     public void paint(Graphics2D JavaDoc graphics) {
25         for (Iterator JavaDoc iter = getChildren().iterator(); iter.hasNext();) {
26             Figure figure = (Figure) iter.next();
27             if (figure instanceof DrawComponentFigure) {
28                 ((DrawComponentFigure)figure).paint(graphics);
29             }
30         }
31     }
32     
33     /**
34      * Overridden to paint only children
35      */

36     public void paint(Graphics graphics) {
37         for (Iterator JavaDoc iter = getChildren().iterator(); iter.hasNext();) {
38             Figure figure = (Figure) iter.next();
39             figure.paint(graphics);
40         }
41     }
42     
43 }
44
Popular Tags