KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nightlabs > editor2d > DrawComponentContainer


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;
28
29 import java.util.Collection JavaDoc;
30 import java.util.List JavaDoc;
31
32 /**
33  * This is the base interface for all DrawComponents which
34  * are capable for holding children which are also of the type
35  * {@link DrawComponent}, e.g. Groups
36  *
37  * <p> Author: Daniel.Mazurek[AT]NightLabs[DOT]de </p>
38  */

39 public interface DrawComponentContainer
40 extends DrawComponent
41 {
42     /**
43      * The PropertyName which is fired when a child has been added
44      */

45     public static final String JavaDoc CHILD_ADDED = "Child Added";
46     
47     /**
48      * The PropertyName which is fired when a child has been removed
49      */

50     public static final String JavaDoc CHILD_REMOVED = "Child Removed";
51     
52     /**
53      * adds a DrawComponent to the container
54      * Implementations of this class should to the following:
55      *
56      * set the parent of the given DrawComponent to this,
57      * registers the DrawComponent in the MultiLayerDrawComponent,
58      * adds it to the drawComponent-List and fires a PropertyChange with the
59      * the propertyName CHILD_ADDED.
60      *
61      * always use this Method to add a DrawComponent, never add it directly
62      * to the drawComponents-List, because this skips the registration in the
63      * MultiLayerDrawComponent
64      *
65      * @param drawComponent the DrawComponent to add
66      * @see MultiLayerDrawComponent#registerDrawComponent(DrawComponent)
67      */

68     void addDrawComponent(DrawComponent drawComponent);
69     
70     /**
71      * removes the given DrawComponent from the container
72      * Implementations of this class should to the following:
73      *
74      * This Method unregisters the drawComponent from the MultiLayerDrawComponent
75      * and removes it from the drawComponents-List
76      *
77      * always use this Method to remove a DrawComponent, never remove it directly
78      * from the drawComponents-List, because this skips the registration in the
79      * MultiLayerDrawComponent
80      *
81      * @param drawComponent the DrawComponent to remove
82      * @see MultiLayerDrawComponent#unregisterDrawComponent(DrawComponent)
83      */

84     void removeDrawComponent(DrawComponent drawComponent);
85
86     /**
87      * adds a DrawComponent at the given index
88      * Implementations of this class should to the following:
89      *
90      * set the parent of the given DrawComponent to this,
91      * registers the DrawComponent in the MultiLayerDrawComponent,
92      * adds it to the drawComponent-List and fires a PropertyChange with the
93      * the propertyName CHILD_ADDED.
94      *
95      * always use this Method to add a DrawComponent, never add it directly
96      * to the drawComponents-List, because this skips the registration in the
97      * MultiLayerDrawComponent
98      *
99      * @param drawComponent the DrawComponent to add
100      * @param index the index in the DrawComponent-List
101      * @see addDrawComponent(DrawComponent drawComponent)
102      * @see MultiLayerDrawComponent#registerDrawComponent(DrawComponent)
103      */

104     void addDrawComponent(DrawComponent drawComponent, int index);
105     
106     /**
107      * removes the given DrawComponent at the given index from the container
108      * Implementations of this class should to the following:
109      *
110      * This Method unregisters the drawComponent from the MultiLayerDrawComponent
111      * and removes it from the drawComponents-List
112      *
113      * always use this Method to remove a DrawComponent, never remove it directly
114      * from the drawComponents-List, because this skips the registration in the
115      * MultiLayerDrawComponent
116      *
117      * @param drawComponent the DrawComponent to remove
118      * @see MultiLayerDrawComponent#unregisterDrawComponent(long)
119      */

120     void removeDrawComponent(int index);
121
122     /**
123      * This Method should be called from children of the container, when they were
124      * transformed, to notify the parent that a bounds change of the container
125      * might have occured
126      *
127      * @param child the Child-DrawComponent of this container which calls this Methods
128      */

129     void notifyChildTransform(DrawComponent child);
130
131     /**
132      *
133      * @return a List of all drawComponents for this DrawComponentContainer which have
134      * been added yet
135      * @see DrawComponentContainer#addDrawComponent(DrawComponent)
136      */

137     List JavaDoc getDrawComponents();
138     
139     /**
140      *
141      * @param drawComponents the List of DrawComponents to set for this DrawComponentContainer
142      */

143     void setDrawComponents(List JavaDoc drawComponents);
144
145     /**
146      * This method searches recursively in all child-{@link DrawComponent}s and collects
147      * all instances that either implement a given interface, are or extend a given class.
148      *
149      * @param type A class or an interface which the searched <tt>DrawComponent</tt>s must match.
150      * @param canSelfPackage If <tt>false</tt>, it is assumed that the given class does not contain
151      * itself and the search in this part of the tree is interrupted. If <tt>true</tt>, it will
152      * search in a found instance of the given type for the given type - means the whole tree will
153      * be scanned.
154      * @return A <tt>Collection</tt> with instances of the given <tt>type</tt>.
155      */

156     Collection JavaDoc findDrawComponents(Class JavaDoc type, boolean canSelfPackage);
157
158     /**
159      * Convenience method which calls {@link #findDrawComponents(Class, boolean)} with
160      * <tt>canSelfPackage == false</tt>.
161      */

162     Collection JavaDoc findDrawComponents(Class JavaDoc type);
163 } // DrawComponentContainer
164
Popular Tags