    001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.4_testing/src/org/deegree/portal/context/LayerExtension.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.HashMap;
    039    import java.util.Iterator;
    040    import java.util.Map;
    041
    042    /**
    043     * provides additional information about a layer described in a web map context document. Additional description is not
    044     * requiered so an instance of <tt>org.deegree_impl.clients.context.Layer</tt> may doesn't provide an instance of this
    045     * class.
    046     *
    047     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
    048     * @author last edited by: $Author: jmays $
    049     *
    050     * @version $Revision: 20705 $, $Date: 2009-11-11 09:05:38 +0100 (Mi, 11. Nov 2009) $
    051     */
    052    public class LayerExtension {
    053
    054        /**
    055         * No authentication type
    056         */
    057        public static final int NONE = -1;
    058
    059        /**
    060         * The session id authentication type
    061         */
    062        public static final int SESSIONID = 0;
    063
    064        /**
    065         * The user password authentication type
    066         */
    067        public static final int USERPASSWORD = 1;
    068
    069        private DataService dataService = null;
    070
    071        private boolean masterLayer = false;
    072
    073        private double minScaleHint = 0;
    074
    075        private double maxScaleHint = 9E99;
    076
    077        private boolean selectedForQuery = false;
    078
    079        private int authentication = NONE;
    080
    081        private int parentNodeId = NONE;
    082
    083        private boolean showLegendGraphic = false;
    084
    085        private String identifier;
    086
    087        private Map<String, String> vendorspecificParams = new HashMap<String, String>();
    088
    089        /**
    090         * default constructor
    091         *
    092         */
    093        public LayerExtension() {
    094            // default constructor.
    095        }
    096
    097        /**
    098         * This constructor is deprecated. Please use other constructor (with identifier) instead.
    099         *
    100         * @param dataService
    101         * @param masterLayer
    102         * @param minScaleHint
    103         * @param maxScaleHint
    104         * @param selectedForQuery
    105         * @param authentication
    106         * @param parentNodeId
    107         * @param showLegendGraphic
    108         */
    109        @Deprecated
    110        public LayerExtension( DataService dataService, boolean masterLayer, double minScaleHint, double maxScaleHint,
    111                               boolean selectedForQuery, int authentication, int parentNodeId, boolean showLegendGraphic ) {
    112           this( dataService, masterLayer, minScaleHint, maxScaleHint, selectedForQuery, authentication, parentNodeId, showLegendGraphic, null);
    113        }
    114
    115        /**
    116         * Creates a new LayerExtension object.
    117         *
    118         * @param dataService
    119         *            description of the service/server behind a WMS layer
    120         * @param masterLayer
    121         *            true if a layer is one of the main layers of an application; false if it just provides background or
    122         *            additional informations.
    123         * @param minScaleHint
    124         * @param maxScaleHint
    125         * @param selectedForQuery
    126         * @param authentication
    127         * @param parentNodeId
    128         * @param showLegendGraphic
    129         * @param identifier
    130         */
    131        public LayerExtension( DataService dataService, boolean masterLayer, double minScaleHint, double maxScaleHint,
    132                               boolean selectedForQuery, int authentication, int parentNodeId, boolean showLegendGraphic,
    133                               String identifier) {
    134            setDataService( dataService );
    135            setMasterLayer( masterLayer );
    136            setMinScaleHint( minScaleHint );
    137            setMaxScaleHint( maxScaleHint );
    138            setSelectedForQuery( selectedForQuery );
    139            setAuthentication( authentication );
    140            setParentNodeId( parentNodeId );
    141            setShowLegendGraphic( showLegendGraphic );
    142            setIdentifier( identifier );
    143        }
    144
    145        /**
    146         * @return the identifier
    147         */
    148        public String getIdentifier() {
    149            return identifier;
    150        }
    151
    152        /**
    153         * @param identifier the identifier to set
    154         */
    155        public void setIdentifier( String identifier ) {
    156            this.identifier = identifier;
    157        }
    158
    159        /**
    160         * returns a description of the service/server behind a WMS layer. The returned value will be <tt>null</tt> if the
    161         * WMS uses an internal mechanism to access a layers data.
    162         *
    163         * @return instance of <tt>DataService</tt>
    164         */
    165        public DataService getDataService() {
    166            return this.dataService;
    167            // return null;
    168        }
    169
    170        /**
    171         * sets a description of the service/server behind a WMS layer. The returned value will be <tt>null</tt> if the
    172         * WMS uses an internal mechanism to access a layers data.
    173         *
    174         * @param dataService
    175         */
    176        public void setDataService( DataService dataService ) {
    177            this.dataService = dataService;
    178        }
    179
    180        /**
    181         * @return true if a layer is one of the main layers of an application; returns false if it just provides background
    182         *         or additional informations.
    183         *
    184         */
    185        public boolean isMasterLayer() {
    186            return masterLayer;
    187        }
    188
    189        /**
    190         * set to true if a layer is one of the main layers of an application; set to false if it just provides background
    191         * or additional informations.
    192         *
    193         * @param masterLayer
    194         */
    195        public void setMasterLayer( boolean masterLayer ) {
    196            this.masterLayer = masterLayer;
    197        }
    198
    199        /**
    200         * returns the maximum sclae the layer is valid
    201         *
    202         * @return maximum scale hint
    203         */
    204        public double getMaxScaleHint() {
    205            return maxScaleHint;
    206        }
    207
    208        /**
    209         * sets the maximum scale the layer is valid for
    210         *
    211         * @param maxScaleHint
    212         */
    213        public void setMaxScaleHint( double maxScaleHint ) {
    214            this.maxScaleHint = maxScaleHint;
    215        }
    216
    217        /**
    218         * returns the minimum sclae the layer is valid
    219         *
    220         * @return minimum scale hint
    221         */
    222        public double getMinScaleHint() {
    223            return minScaleHint;
    224        }
    225
    226        /**
    227         * sets the minimum scale the layer is valid for
    228         *
    229         * @param minScaleHint
    230         */
    231        public void setMinScaleHint( double minScaleHint ) {
    232            this.minScaleHint = minScaleHint;
    233        }
    234
    235        /**
    236         * returns true if a layer is currently selected for being active for feature info requests
    237         *
    238         * @return <code>true</code> if a layer is currently selected for being active for feature info requests
    239         */
    240        public boolean isSelectedForQuery() {
    241            return selectedForQuery;
    242        }
    243
    244        /**
    245         * sets a layer to active for feature info requests
    246         *
    247         * @param selectedForFI
    248         */
    249        public void setSelectedForQuery( boolean selectedForFI ) {
    250            this.selectedForQuery = selectedForFI;
    251        }
    252
    253        /**
    254         * returns a code for authentication to be used for service requests
    255         *
    256         * @return a code for authentication to be used for service requests
    257         */
    258        public int getAuthentication() {
    259            return authentication;
    260        }
    261
    262        /**
    263         * @see #getAuthentication()
    264         * @param authentication
    265         */
    266        public void setAuthentication( int authentication ) {
    267            this.authentication = authentication;
    268        }
    269
    270        /**
    271         * returns true if the legendGraphic of the layer should be drawn in the layerlistview
    272         *
    273         * @return <code>true</code> if the legendGraphic of the layer should be drawn in the layerlistview
    274         */
    275        public boolean getShowLegendGraphic() {
    276            return showLegendGraphic;
    277        }
    278
    279        /**
    280         * returns true the id of the node to which the layer belongs in the layertree
    281         *
    282         * @return <code>true</code> the id of the node to which the layer belongs in the layertree
    283         */
    284        public int getParentNodeId() {
    285            return parentNodeId;
    286        }
    287
    288        /**
    289         *
    290         * @param showLegendGraphic
    291         */
    292        public void setShowLegendGraphic( boolean showLegendGraphic ) {
    293            this.showLegendGraphic = showLegendGraphic;
    294        }
    295
    296        /**
    297         *
    298         * @param parentNodeId
    299         */
    300        public void setParentNodeId( int parentNodeId ) {
    301            this.parentNodeId = parentNodeId;
    302        }
    303
    304        /**
    305         *
    306         * @param name
    307         * @param value
    308         */
    309        public void addVendorspecificParameter( String name, String value ) {
    310            vendorspecificParams.put( name, value );
    311        }
    312
    313        /**
    314         *
    315         * @param name
    316         * @return the vendorspecific parameter by given name or <code>null</code> if no such parameter exists.
    317         */
    318        public String getVendorspecificParameter( String name ) {
    319            return vendorspecificParams.get( name );
    320        }
    321
    322        /**
    323         *
    324         * @return an iterator over all vendor specific keys.
    325         */
    326        public Iterator<String> getVendorspecificParameterNames() {
    327            return vendorspecificParams.keySet().iterator();
    328        }
    329
    330    }