001    //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/portal/context/GUIArea.java $
002    /*----------------------------------------------------------------------------
003     This file is part of deegree, http://deegree.org/
004     Copyright (C) 2001-2009 by:
005       Department of Geography, University of Bonn
006     and
007       lat/lon GmbH
008    
009     This library is free software; you can redistribute it and/or modify it under
010     the terms of the GNU Lesser General Public License as published by the Free
011     Software Foundation; either version 2.1 of the License, or (at your option)
012     any later version.
013     This library is distributed in the hope that it will be useful, but WITHOUT
014     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015     FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016     details.
017     You should have received a copy of the GNU Lesser General Public License
018     along with this library; if not, write to the Free Software Foundation, Inc.,
019     59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020    
021     Contact information:
022    
023     lat/lon GmbH
024     Aennchenstr. 19, 53177 Bonn
025     Germany
026     http://lat-lon.de/
027    
028     Department of Geography, University of Bonn
029     Prof. Dr. Klaus Greve
030     Postfach 1147, 53001 Bonn
031     Germany
032     http://www.geographie.uni-bonn.de/deegree/
033    
034     e-mail: info@deegree.org
035    ----------------------------------------------------------------------------*/
036    package org.deegree.portal.context;
037    
038    import java.util.ArrayList;
039    import java.util.HashMap;
040    import java.util.List;
041    
042    /**
043     * this interface describes the content of an area of a GUI. a GUI area contains zero ... n modules
044     * described by the <tt>Module</tt> interface. A GUI area may be can be switched to be invisible.
045     * indicated by the hidden attribute.
046     *
047     * @version $Revision: 18195 $
048     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
049     */
050    public class GUIArea {
051    
052        /**
053         * A constant defining a 'west' direction.
054         */
055        public static final int WEST = 0;
056    
057        /**
058         * A constant defining a 'EAST' direction.
059         */
060        public static final int EAST = 1;
061    
062        /**
063         * A constant defining a 'SOUTH' direction.
064         */
065        public static final int SOUTH = 2;
066    
067        /**
068         * A constant defining a 'NORTH' direction.
069         */
070        public static final int NORTH = 3;
071    
072        /**
073         * A constant defining a 'CENTER' direction.
074         */
075        public static final int CENTER = 4;
076    
077        private HashMap<String, Module> modules = new HashMap<String, Module>();
078    
079        private boolean hidden = false;
080    
081        private int area = 0;
082    
083        private int width;
084    
085        private int height;
086    
087        private int left;
088    
089        private int top;
090    
091        private int right;
092    
093        private int bottom;
094    
095        private boolean overlay;
096    
097        private boolean header;
098    
099        private boolean closable;
100    
101        private List<Module> list = new ArrayList<Module>();
102    
103        /**
104         * Creates a new GUIArea instance
105         *
106         * @param area
107         * @param hidden
108         * @param width
109         * @param height
110         * @param left
111         * @param top
112         * @param right
113         * @param bottom
114         * @param overlay
115         * @param header
116         * @param closable
117         * @param modules
118         */
119        public GUIArea( int area, boolean hidden, int width, int height, int left, int top, int right, int bottom,
120                        boolean overlay, boolean header, boolean closable, Module[] modules ) {
121            setArea( area );
122            setHidden( hidden );
123            setWidth( width );
124            setHeight( height );
125            setLeft( left );
126            setTop( top );
127            setRight( right );
128            setBottom( bottom );
129            setOverlay( overlay );
130            setHeader( header );
131            setClosable( closable );
132            setModules( modules );
133        }
134    
135        /**
136         * returns area (north, west, east ...) assigned to an instance
137         *
138         * @return area
139         */
140        public int getArea() {
141            return area;
142        }
143    
144        /**
145         * sets the name of a module
146         *
147         * @param area
148         */
149        public void setArea( int area ) {
150            this.area = area;
151        }
152    
153        /**
154         * returns true if the GUIArea is hidden.
155         *
156         * @return true if area is hidden
157         */
158        public boolean isHidden() {
159            return hidden;
160        }
161    
162        /**
163         * sets the GUIArea to be hidden or visible.
164         *
165         * @param hidden
166         */
167        public void setHidden( boolean hidden ) {
168            this.hidden = hidden;
169        }
170    
171        /**
172         * @return the bottom
173         */
174        public int getBottom() {
175            return bottom;
176        }
177    
178        /**
179         * @param bottom
180         *            the bottom to set
181         */
182        public void setBottom( int bottom ) {
183            this.bottom = bottom;
184        }
185    
186        /**
187         * @return the left
188         */
189        public int getLeft() {
190            return left;
191        }
192    
193        /**
194         * @param left
195         *            the left to set
196         */
197        public void setLeft( int left ) {
198            this.left = left;
199        }
200    
201        /**
202         * @return the right
203         */
204        public int getRight() {
205            return right;
206        }
207    
208        /**
209         * @param right
210         *            the right to set
211         */
212        public void setRight( int right ) {
213            this.right = right;
214        }
215    
216        /**
217         * @return the top
218         */
219        public int getTop() {
220            return top;
221        }
222    
223        /**
224         * @param top
225         *            the top to set
226         */
227        public void setTop( int top ) {
228            this.top = top;
229        }
230    
231        /**
232         * @return the overlay
233         */
234        public boolean isOverlay() {
235            return overlay;
236        }
237    
238        /**
239         * @param overlay
240         *            the overlay to set
241         */
242        public void setOverlay( boolean overlay ) {
243            this.overlay = overlay;
244        }
245    
246        /**
247         * @return the closable
248         */
249        public boolean isClosable() {
250            return closable;
251        }
252    
253        /**
254         * @param closable
255         *            the closable to set
256         */
257        public void setClosable( boolean closable ) {
258            this.closable = closable;
259        }
260    
261        /**
262         * @return the header
263         */
264        public boolean hasHeader() {
265            return header;
266        }
267    
268        /**
269         * @param header
270         *            the header to set
271         */
272        public void setHeader( boolean header ) {
273            this.header = header;
274        }
275    
276        /**
277         * @return the height
278         */
279        public int getHeight() {
280            return height;
281        }
282    
283        /**
284         * @param height
285         *            the height to set
286         */
287        public void setHeight( int height ) {
288            this.height = height;
289        }
290    
291        /**
292         * @return the width
293         */
294        public int getWidth() {
295            return width;
296        }
297    
298        /**
299         * @param width
300         *            the width to set
301         */
302        public void setWidth( int width ) {
303            this.width = width;
304        }
305    
306        /**
307         * returns a module identified by its name
308         *
309         * @param name
310         *
311         * @return named module
312         */
313        public Module getModule( String name ) {
314            return modules.get( name );
315        }
316    
317        /**
318         * returns all modules of a GUIArea
319         *
320         * @return all modules
321         */
322        public Module[] getModules() {
323            Module[] cl = new Module[list.size()];
324            return list.toArray( cl );
325    
326        }
327    
328        /**
329         * sets the modules of a GUIArea
330         *
331         * @param modules
332         */
333        public void setModules( Module[] modules ) {
334            this.modules.clear();
335            this.list.clear();
336    
337            if ( modules != null ) {
338                for ( int i = 0; i < modules.length; i++ ) {
339                    this.modules.put( modules[i].getName(), modules[i] );
340                    list.add( modules[i] );
341                }
342            }
343        }
344    
345        /**
346         * adds a module to a GUIArea
347         *
348         * @param module
349         */
350        public void addModul( Module module ) {
351            modules.put( module.getName(), module );
352            list.add( module );
353        }
354    
355        /**
356         * reomes a module identified by its name from the GUIArea
357         *
358         * @param name
359         *
360         * @return removed module
361         */
362        public Module removeModule( String name ) {
363            Module module = modules.remove( name );
364            list.remove( module );
365            return module;
366        }
367    
368    }