KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > render > RendererImpl


1 /* *****************************************************************************
2  * NightLabs Editor2D - Graphical editor framework *
3  * Copyright (C) 2004-2005 NightLabs - http://NightLabs.org *
4  * *
5  * This library is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or (at your option) any later version. *
9  * *
10  * This library is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13  * Lesser General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU Lesser General Public *
16  * License along with this library; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin St, Fifth Floor, *
19  * Boston, MA 02110-1301 USA *
20  * *
21  * Or get it online : *
22  * http://www.gnu.org/copyleft/lesser.html *
23  * *
24  * *
25  ******************************************************************************/

26
27 package org.nightlabs.editor2d.render;
28
29 import java.awt.Graphics2D JavaDoc;
30 import java.util.Iterator JavaDoc;
31
32 import org.nightlabs.editor2d.DrawComponent;
33 import org.nightlabs.editor2d.DrawComponentContainer;
34
35 /**
36  * The Standard Implementation of the Renderer-Interface
37  * does by default nothing.
38  * It only checks if the given DrawComponent is a DrawComponentContainer
39  * and if so, it paints all its children.
40  *
41  * @author Daniel.Mazurek [AT] NightLabs [DOT] com
42  */

43 public class RendererImpl
44 implements Renderer
45 {
46   public RendererImpl() {
47     super();
48     init();
49   }
50   
51   /**
52      * The Standard Implementation of the paint-Method
53      * does by default nothing.
54      * It only checks if the given DrawComponent is a DrawComponentContainer
55      * and if so, it paints all its children.
56    */

57   public void paint(DrawComponent dc, Graphics2D JavaDoc g2d)
58   {
59     if (dc instanceof DrawComponentContainer) {
60         DrawComponentContainer container = (DrawComponentContainer) dc;
61         if (container != null) {
62             for (Iterator JavaDoc it = container.getDrawComponents().iterator(); it.hasNext(); ) {
63                 DrawComponent d = (DrawComponent) it.next();
64                 Renderer r = d.getRenderer();
65                 if (r != null) {
66                     r.paint(dc, g2d);
67                 }
68             }
69         }
70     }
71   }
72
73   /**
74    * Inheritans of this class can override this Method
75    * in order to initialize things, needed for rendering.
76    *
77    * By Default this Method is empty.
78    * This Method will be called in the Constructor
79    */

80   protected void init()
81   {
82   };
83 }
84
Popular Tags