    001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.4_testing/src/org/deegree/graphics/AbstractLayer.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.graphics;
    037
    038    import java.util.ArrayList;
    039    import java.util.Collections;
    040    import java.util.List;
    041
    042    import org.deegree.model.crs.CRSFactory;
    043    import org.deegree.model.crs.CoordinateSystem;
    044    import org.deegree.model.spatialschema.Envelope;
    045    import org.deegree.model.spatialschema.GeometryFactory;
    046
    047    /**
    048     * A Layer is a collection of <tt>Feature</tt>s or rasters building a thematic 'unit' waterways or country borders for
    049     * example. <tt>Feature</tt>s or raster can be added or removed from the layer. A <tt>Feature</tt> or raster can e
    050     * changed by a modul of the application using the layer because only references to <tt>Feature</tt>s or rasters are
    051     * stored within a layer.
    052     *
    053     *
    054     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
    055     * @version $Revision: 19800 $ $Date: 2009-09-26 12:33:09 +0200 (Sa, 26. Sep 2009) $
    056     */
    057
    058    abstract class AbstractLayer implements Layer {
    059
    060        /**
    061         * Of the layer
    062         */
    063        protected CoordinateSystem cs = null;
    064
    065        /**
    066         * bbox of the layer
    067         */
    068        protected Envelope boundingbox = null;
    069
    070        /**
    071         * List of controllers.
    072         */
    073        protected List<EventController> eventController = Collections.synchronizedList( new ArrayList<EventController>() );
    074
    075        private String name = null;
    076
    077        /**
    078         * creates a layer with EPSG:4326 as default coordinate system
    079         *
    080         * @param name
    081         * @throws Exception
    082         */
    083        AbstractLayer( String name ) throws Exception {
    084            this.name = name;
    085            cs = CRSFactory.create( "EPSG:4326" );
    086
    087        }
    088
    089        /**
    090         * Creates a new AbstractLayer object.
    091         *
    092         * @param name
    093         * @param crs
    094         *
    095         * @throws Exception
    096         */
    097        AbstractLayer( String name, CoordinateSystem crs ) throws Exception {
    098            this.name = name;
    099
    100            cs = crs;
    101
    102            boundingbox = GeometryFactory.createEnvelope( 9E99, 9E99, -9E99, -9E99, null );
    103        }
    104
    105        /**
    106         * returns the name of the layer
    107         *
    108         * @return the name of the layer
    109         */
    110        public String getName() {
    111            return name;
    112        }
    113
    114        /**
    115         * returns the BoundingBox (Envelope) of Layer. This is the BoundingBox of the layers data. The BoundingBox of the
    116         * View maybe larger or smaller
    117         *
    118         * @return the BoundingBox (Envelope) of Layer
    119         */
    120        public Envelope getBoundingBox() {
    121            return boundingbox;
    122        }
    123
    124        /**
    125         * returns the coordinate reference system of the MapView
    126         *
    127         * @return the coordinate reference system of the MapView
    128         */
    129        public CoordinateSystem getCoordinatesSystem() {
    130            return cs;
    131        }
    132
    133        /**
    134         * adds an eventcontroller to the MapView that's reponsible for handling events that targets the map. E.g.: zooming,
    135         * panning, selecting a feature etc.
    136         *
    137         * @param obj
    138         */
    139        public void addEventController( LayerEventController obj ) {
    140            eventController.add( obj );
    141            obj.addLayer( this );
    142        }
    143
    144        /**
    145         * @see org.deegree.graphics.AbstractLayer#addEventController(LayerEventController)
    146         * @param obj
    147         */
    148        public void removeEventController( LayerEventController obj ) {
    149            eventController.remove( obj );
    150            obj.removeLayer( this );
    151        }
    152
    153        /**
    154         * As default the method returns <code>true</code>, but it may be overwritten by extending classes
    155         *
    156         * @return <code>true</code> if a layer is valid and should be rendered
    157         */
    158        public boolean isValid() {
    159            return true;
    160        }
    161    }