001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/graphics/MapFactory.java $
002    /*----------------    FILE HEADER  ------------------------------------------
003    
004     This file is part of deegree.
005     Copyright (C) 2001-2008 by:
006     EXSE, Department of Geography, University of Bonn
007     http://www.giub.uni-bonn.de/deegree/
008     lat/lon GmbH
009     http://www.lat-lon.de
010    
011     This library is free software; you can redistribute it and/or
012     modify it under the terms of the GNU Lesser General Public
013     License as published by the Free Software Foundation; either
014     version 2.1 of the License, or (at your option) any later version.
015    
016     This library is distributed in the hope that it will be useful,
017     but WITHOUT ANY WARRANTY; without even the implied warranty of
018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019     Lesser General Public License for more details.
020    
021     You should have received a copy of the GNU Lesser General Public
022     License along with this library; if not, write to the Free Software
023     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024    
025     Contact:
026    
027     Andreas Poth
028     lat/lon GmbH
029     Aennchenstr. 19
030     53115 Bonn
031     Germany
032     E-Mail: poth@lat-lon.de
033    
034     Prof. Dr. Klaus Greve
035     Department of Geography
036     University of Bonn
037     Meckenheimer Allee 166
038     53115 Bonn
039     Germany
040     E-Mail: greve@giub.uni-bonn.de
041    
042     
043     ---------------------------------------------------------------------------*/
044    package org.deegree.graphics;
045    
046    import org.deegree.graphics.sld.UserStyle;
047    import org.deegree.model.coverage.grid.GridCoverage;
048    import org.deegree.model.crs.CoordinateSystem;
049    import org.deegree.model.feature.FeatureCollection;
050    import org.deegree.model.spatialschema.Envelope;
051    
052    /**
053     * Factory class for creating <tt>MapView</tt>s, <tt>Layer</tt>s and <tt>Theme</tt>s.
054     * 
055     * <p>
056     * ------------------------------------------------------------------------
057     * </p>
058     * 
059     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
060     * @version $Revision: 9340 $ $Date: 2007-12-27 13:32:12 +0100 (Do, 27 Dez 2007) $
061     */
062    public class MapFactory {
063        /**
064         * creates an empty feature layer with EPSG:4326 as default coordinate reference system. All
065         * data that will be added to the layer will be converted to the EPSG:4326 coordinate reference
066         * system if no other CRS is set.
067         */
068        public static synchronized Layer createFeatureLayer( String name )
069                                throws Exception {
070            return new FeatureLayer( name );
071        }
072    
073        /**
074         * creates an empty feature layer. All data that will be added to the layer will be converted to
075         * the submitted coordinate reference system if no other CRS is set.
076         */
077        public static synchronized Layer createFeatureLayer( String name, CoordinateSystem crs )
078                                throws Exception {
079            return new FeatureLayer( name, crs );
080        }
081    
082        /**
083         * creates a complete feature layer. If the CRS of the geometries contained within the submitted
084         * feature collection are not the same as the submitted CRS all geometries will be converted to
085         * the submitted CRS.
086         */
087        public static synchronized Layer createFeatureLayer( String name, CoordinateSystem crs, FeatureCollection fc )
088                                throws Exception {
089            return new FeatureLayer( name, crs, fc );
090        }
091    
092        /**
093         * creates a raster layer. The required CRS is contained within the <tt>GC_GridCoverage</tt>
094         * object
095         */
096        public static synchronized Layer createRasterLayer( String name, GridCoverage raster )
097                                throws Exception {
098            return new RasterLayer( name, raster );
099        }
100    
101        /**
102         * creates a theme with a name, a Layer containing the themes data and an array of styles to be
103         * known by the <tt>Theme</tt>
104         */
105        public static synchronized Theme createTheme( String name, Layer layer, UserStyle[] styles ) {
106            return new Theme( name, layer, styles );
107        }
108    
109        /**
110         * creates a theme with a name, a Layer containing the themes data and an array of styles to be
111         * known by the <tt>Theme</tt>
112         */
113        public static synchronized Theme createTheme( String name, Layer layer ) {
114            return new Theme( name, layer, new UserStyle[] { null } );
115        }
116    
117        /**
118         * creates a <tt>MapView</tt> with a name, a boundingbox describing the area coverd by the
119         * <tt>MapView</tt>, a CRS and n <tt>Theme</tt>s.
120         */
121        public static synchronized MapView createMapView( String name, Envelope boundingbox, CoordinateSystem crs,
122                                                          Theme[] themes, double pixelsize )
123                                throws Exception {
124            MapView mv = new MapView( name, boundingbox, crs, pixelsize );
125            for ( int i = 0; i < themes.length; i++ ) {
126                mv.addTheme( themes[i] );
127            }
128    
129            return mv;
130        }
131    
132    }