001 //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/portal/context/General.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.awt.Rectangle; 039 040 import org.deegree.model.crs.CoordinateSystem; 041 import org.deegree.model.metadata.iso19115.CitedResponsibleParty; 042 import org.deegree.model.spatialschema.Envelope; 043 import org.deegree.model.spatialschema.GeometryFactory; 044 import org.deegree.model.spatialschema.Point; 045 import org.deegree.ogcbase.BaseURL; 046 import org.deegree.ogcbase.ImageURL; 047 048 /** 049 * The class encapsulates the general informations common to all types of contexts 050 * 051 * @version $Revision: 18195 $ 052 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a> 053 */ 054 public class General { 055 private CitedResponsibleParty contactInformation = null; 056 057 private Point[] boundingBox = null; 058 059 private GeneralExtension extension = null; 060 061 private String abstract_ = null; 062 063 private String title = null; 064 065 private BaseURL descriptionURL = null; 066 067 private ImageURL logoURL = null; 068 069 private String[] keywords = null; 070 071 private Rectangle window = null; 072 073 /** 074 * Creates a new General object. 075 * 076 * @param title 077 * title of the context 078 * @param abstract_ 079 * short description 080 * @param window 081 * @param contactInformation 082 * informations about creator of the context 083 * @param boundingBox 084 * bounding box of the map/data 085 * @param descriptionURL 086 * reference to a webpage which contains relevant information to the view. 087 * @param logoURL 088 * A reference to an image that might be attached to the context document. 089 * @param keywords 090 * @param extension 091 * The Extension element is a container tag in which arbitrary vendor specific information can be 092 * included without compromising the ability of other clients to enforce schema validation. 093 * 094 * @throws ContextException 095 */ 096 public General( String title, String abstract_, Rectangle window, CitedResponsibleParty contactInformation, 097 Point[] boundingBox, BaseURL descriptionURL, ImageURL logoURL, String[] keywords, 098 GeneralExtension extension ) throws ContextException { 099 setTitle( title ); 100 setAbstract( abstract_ ); 101 setWindow( window ); 102 setContactInformation( contactInformation ); 103 setBoundingBox( boundingBox ); 104 setDescriptionURL( descriptionURL ); 105 setLogoURL( logoURL ); 106 setKeywords( keywords ); 107 setExtension( extension ); 108 } 109 110 /** 111 * An element Window presenting the size in pixels of the map the Context document describes. Negotiation between 112 * Context defined aspect ratio and typical client aspect ratio (according to the client's vendor) is left to the 113 * client. 114 * 115 * @param window 116 */ 117 public void setWindow( Rectangle window ) { 118 this.window = window; 119 } 120 121 /** 122 * BoundingBox formatted as defined in the WMS 1.1.1 Specification. It represents the geographic extent that should 123 * be presented by the client1. 124 * 125 * @param boundingBox 126 * @throws ContextException 127 * if the bbox is <code>null</code> 128 */ 129 public void setBoundingBox( Point[] boundingBox ) 130 throws ContextException { 131 if ( boundingBox == null ) { 132 throw new ContextException( "A context's bounding box isn't allowed to be null" ); 133 } 134 135 this.boundingBox = boundingBox; 136 } 137 138 /** 139 * BoundingBox formatted as defined in the WMS 1.1.1 Specification. It represents the geographic extent that should 140 * be presented by the client1. 141 * 142 * @param boundingBox 143 * @throws ContextException 144 * if the bbox is <code>null</code> 145 */ 146 public void setBoundingBox( Envelope boundingBox ) 147 throws ContextException { 148 if ( boundingBox == null ) { 149 throw new ContextException( "A context's bounding box isn't allowed to be null" ); 150 } 151 152 CoordinateSystem cs = this.boundingBox[0].getCoordinateSystem(); 153 Point p0 = GeometryFactory.createPoint( boundingBox.getMin().getX(), boundingBox.getMin().getY(), cs ); 154 Point p1 = GeometryFactory.createPoint( boundingBox.getMax().getX(), boundingBox.getMax().getY(), cs ); 155 this.boundingBox = new Point[] { p0, p1 }; 156 } 157 158 /** 159 * An element KeywordList that contains one or more Keyword elements which allow search across context collections. 160 * 161 * @param keywords 162 */ 163 public void setKeywords( String[] keywords ) { 164 this.keywords = keywords; 165 } 166 167 /** 168 * An element Title that contains a human readable title of the Context. 169 * 170 * @param title 171 * @throws ContextException 172 * if the title is <code>null</code> 173 */ 174 public void setTitle( String title ) 175 throws ContextException { 176 if ( title == null ) { 177 throw new ContextException( "A context's title isn't allowed to be null" ); 178 } 179 180 this.title = title; 181 } 182 183 /** 184 * An element Abstract that contains a description for the Context document describing its content. 185 * 186 * @param abstract_ 187 */ 188 public void setAbstract( String abstract_ ) { 189 this.abstract_ = abstract_; 190 } 191 192 /** 193 * A reference to an image that might be attached to the Context document. It can be, for instance, the logo of the 194 * project for which the context has been setup, or an overview of the map the context describes. This element 195 * contains a link to the image as well as the dimension of the image (in pixels) and its format. 196 * 197 * @param logoURL 198 */ 199 public void setLogoURL( ImageURL logoURL ) { 200 this.logoURL = logoURL; 201 } 202 203 /** 204 * A URL reference to a webpage which contains relevant information to the view. 205 * 206 * @param descriptionURL 207 */ 208 public void setDescriptionURL( BaseURL descriptionURL ) { 209 this.descriptionURL = descriptionURL; 210 } 211 212 /** 213 * An element ContactInformation that presents contact information of the creator of the Context document. Contact 214 * is described as defined in WMS 1.1.1 Specification. 215 * 216 * @param contactInformation 217 */ 218 public void setContactInformation( CitedResponsibleParty contactInformation ) { 219 this.contactInformation = contactInformation; 220 } 221 222 /** 223 * The Extension element is a container tag in which arbitrary vendor specific information can be included without 224 * compromising the ability of other clients to enforce schema validation.<p/> This tag should not be used to 225 * introduce new candidate elements that are intended to promote interoperability. Content in an <Extension> element 226 * should not be expected to be preserved in transfers of ViewContext documents between different systems. 227 * 228 * @param extension 229 */ 230 public void setExtension( GeneralExtension extension ) { 231 this.extension = extension; 232 } 233 234 /** 235 * 236 * 237 * @return the window 238 */ 239 public Rectangle getWindow() { 240 return window; 241 } 242 243 /** 244 * 245 * @return the boundingbox 246 */ 247 public Point[] getBoundingBox() { 248 return boundingBox; 249 } 250 251 /** 252 * 253 * @return the keywords 254 */ 255 public String[] getKeywords() { 256 return keywords; 257 } 258 259 /** 260 * 261 * @return the titles 262 */ 263 public String getTitle() { 264 return title; 265 } 266 267 /** 268 * 269 * @return the abstract 270 */ 271 public String getAbstract() { 272 return abstract_; 273 } 274 275 /** 276 * 277 * @return the url to the logo 278 */ 279 public ImageURL getLogoURL() { 280 return logoURL; 281 } 282 283 /** 284 * 285 * @return the url to the description 286 */ 287 public BaseURL getDescriptionURL() { 288 return descriptionURL; 289 } 290 291 /** 292 * 293 * @return the contactinformation 294 */ 295 public CitedResponsibleParty getContactInformation() { 296 return contactInformation; 297 } 298 299 /** 300 * 301 * @return the extension. 302 */ 303 public GeneralExtension getExtension() { 304 return extension; 305 } 306 307 }