001 //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/portal/context/Style.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 org.deegree.ogcbase.ImageURL; 039 040 /** 041 * this class encapsulates the style description as defined by the OGC Web Map Context specification 042 * 043 * @version $Revision: 18195 $ 044 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a> 045 */ 046 public class Style { 047 private ImageURL legendURL = null; 048 049 private SLD sld = null; 050 051 private String abstract_ = null; 052 053 private String name = null; 054 055 private String title = null; 056 057 private boolean current = false; 058 059 /** 060 * Creates a new Style object. 061 * 062 * @param name 063 * The name of the style 064 * @param title 065 * The human-readable title of the style 066 * @param abstract_ 067 * A narrative description of the current style 068 * @param legendURL 069 * location of an image of a map legend describing the current style 070 * @param current 071 * true the current style is selected. 072 * 073 * @throws ContextException 074 */ 075 public Style( String name, String title, String abstract_, ImageURL legendURL, boolean current ) 076 throws ContextException { 077 setName( name ); 078 setTitle( title ); 079 setAbstract( abstract_ ); 080 setLegendURL( legendURL ); 081 setCurrent( current ); 082 } 083 084 /** 085 * Creates a new Style object. 086 * 087 * @param sld 088 * define the style(s) of the layer with a <SLD> element. 089 * @param current 090 * true the current style is selected. 091 * 092 * @throws ContextException 093 */ 094 public Style( SLD sld, boolean current ) throws ContextException { 095 setSld( sld ); 096 setCurrent( current ); 097 } 098 099 /** 100 * The name of the style (extracted from Capabilities by the Context document creator). 101 * 102 * @return the name of the style (extracted from Capabilities by the Context document creator). 103 */ 104 public String getName() { 105 return name; 106 } 107 108 /** 109 * The human-readable title of the style (extracted from Capabilities by the Context document 110 * creator). 111 * 112 * @return The human-readable title 113 */ 114 public String getTitle() { 115 return title; 116 } 117 118 /** 119 * A narrative description of the current style (extracted from Capabilities by the Context 120 * document creator). 121 * 122 * @return A narrative description of the current style 123 */ 124 public String getAbstract() { 125 return abstract_; 126 } 127 128 /** 129 * The location of an image of a map legend describing the current style (extracted from 130 * Capabilities by the Context document creator). 131 * 132 * @return The location of an image of a map legend 133 */ 134 public ImageURL getLegendURL() { 135 return legendURL; 136 } 137 138 /** 139 * Each <Style> element may alternatively define the style(s) of the layer with a 140 * <SLD> element. 141 * 142 * @return a <SLD> element. 143 */ 144 public SLD getSld() { 145 return sld; 146 } 147 148 /** 149 * returns true the current style is selected. 150 * 151 * @return true if the current style is selected. 152 */ 153 public boolean isCurrent() { 154 return current; 155 } 156 157 /** 158 * @param name to set 159 * @throws ContextException if the name or the sld is null 160 */ 161 public void setName( String name ) 162 throws ContextException { 163 if ( ( name == null ) && ( sld == null ) ) { 164 throw new ContextException( "either name or sld must be different to null" ); 165 } 166 167 this.name = name; 168 } 169 170 /** 171 * @param title to set 172 * @throws ContextException if the name or the sld is null 173 */ 174 public void setTitle( String title ) 175 throws ContextException { 176 if ( ( title == null ) && ( sld == null ) ) { 177 throw new ContextException( "either title or sld must be different to null" ); 178 } 179 180 this.title = title; 181 } 182 183 /** 184 * 185 * @param abstract_ to set 186 */ 187 public void setAbstract( String abstract_ ) { 188 this.abstract_ = abstract_; 189 } 190 191 /** 192 * 193 * @param legendURL to set 194 */ 195 public void setLegendURL( ImageURL legendURL ) { 196 this.legendURL = legendURL; 197 } 198 199 /** 200 * 201 * @param sld to set 202 * @throws ContextException if the name or the sld is null 203 */ 204 public void setSld( SLD sld ) 205 throws ContextException { 206 if ( ( sld == null ) && ( title == null || name == null ) ) { 207 throw new ContextException( "either sld or name and tile must be different to null" ); 208 } 209 210 this.sld = sld; 211 } 212 213 /** 214 * 215 * @param current to set 216 */ 217 public void setCurrent( boolean current ) { 218 this.current = current; 219 } 220 221 }