001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005: package org.vfny.geoserver.config;
006:
007: import org.vfny.geoserver.global.Config;
008: import org.vfny.geoserver.global.ConfigurationException;
009: import org.vfny.geoserver.global.WMS;
010: import org.vfny.geoserver.global.dto.ServiceDTO;
011: import org.vfny.geoserver.global.dto.WMSDTO;
012: import java.util.HashMap;
013: import java.util.Map;
014:
015: /**
016: * WMS purpose.
017: *
018: * <p>
019: * Description of WMS Used to store WMS data.
020: * </p>
021: *
022: * <p></p>
023: *
024: * @author dzwiers, Refractions Research, Inc.
025: * @version $Id: WMSConfig.java 7128 2007-06-29 15:17:56Z aaime $
026: */
027: public class WMSConfig extends ServiceConfig {
028: private static final String WMS_VERSION = "1.1.1";
029: public static final String CONFIG_KEY = "Config.WMS";
030:
031: /**
032: * SVG renderers.
033: */
034: public static final String SVG_SIMPLE = "Simple";
035: public static final String SVG_BATIK = "Batik";
036:
037: /**
038: * Interpolation Types
039: */
040: public static final String INT_NEAREST = "Nearest";
041: public static final String INT_BIlINEAR = "Bilinear";
042: public static final String INT_BICUBIC = "Bicubic";
043:
044: /** current svg renderer **/
045: private String svgRenderer;
046:
047: /** anti aliasing hint for svg renderer **/
048: private boolean svgAntiAlias;
049:
050: /** rendering interpolation **/
051: private Map baseMapLayers;
052: private Map baseMapStyles;
053: private Map baseMapEnvelopes;
054: private String allowInterpolation;
055:
056: /**
057: * WMS constructor.
058: *
059: * <p>
060: * Creates a WMS to represent an instance with default data.
061: * </p>
062: *
063: * @see defaultSettings()
064: */
065: public WMSConfig() {
066: super ();
067: svgRenderer = SVG_SIMPLE;
068: svgAntiAlias = true;
069: allowInterpolation = INT_NEAREST;
070: baseMapLayers = new HashMap();
071: baseMapStyles = new HashMap();
072: baseMapEnvelopes = new HashMap();
073: }
074:
075: /**
076: * WMS constructor.
077: *
078: * <p>
079: * Creates a copy of the WMSDTO provided. All the data structures are
080: * cloned.
081: * </p>
082: *
083: * @param w The WMSDTO to copy.
084: */
085: public WMSConfig(WMSDTO w) {
086: super (w.getService());
087: svgRenderer = w.getSvgRenderer();
088: svgAntiAlias = w.getSvgAntiAlias();
089: allowInterpolation = w.getAllowInterpolation();
090: baseMapLayers = w.getBaseMapLayers();
091: baseMapStyles = w.getBaseMapStyles();
092: baseMapEnvelopes = w.getBaseMapEnvelopes();
093: }
094:
095: /**
096: * Creates the WMSConfig.
097: *
098: * @param wms The wms module.
099: */
100: public WMSConfig(WMS wms) {
101: this ((WMSDTO) wms.toDTO());
102: }
103:
104: /**
105: * Implement loadDTO.
106: *
107: * <p>
108: * Takes a WMSDTO and loads it into this WMSConfig Object
109: * </p>
110: *
111: * @param dto an instance of WMSDTO
112: *
113: * @throws NullPointerException DOCUMENT ME!
114: *
115: * @see org.vfny.geoserver.config.DataStructure#loadDTO(java.lang.Object)
116: */
117: public void update(WMSDTO dto) {
118: if (dto == null) {
119: throw new NullPointerException(
120: "WMS Data Transfer Object required");
121: }
122:
123: super .update(dto.getService());
124: svgRenderer = dto.getSvgRenderer();
125: svgAntiAlias = dto.getSvgAntiAlias();
126: allowInterpolation = dto.getAllowInterpolation();
127: baseMapLayers = dto.getBaseMapLayers();
128: baseMapStyles = dto.getBaseMapStyles();
129: baseMapEnvelopes = dto.getBaseMapEnvelopes();
130: }
131:
132: /**
133: * Implement toDTO.
134: *
135: * <p>
136: * Returns a copy of the data in a ServiceDTO object
137: * </p>
138: *
139: * @return a copy of the data in a ServiceDTO object
140: *
141: * @see org.vfny.geoserver.config.DataStructure#toDTO()
142: */
143: public WMSDTO toDTO() {
144: WMSDTO wmsDto = new WMSDTO();
145: wmsDto.setService((ServiceDTO) super .toServDTO());
146: wmsDto.setSvgRenderer(svgRenderer);
147: wmsDto.setSvgAntiAlias(svgAntiAlias);
148: wmsDto.setAllowInterpolation(allowInterpolation);
149: wmsDto.setBaseMapLayers(baseMapLayers);
150: wmsDto.setBaseMapStyles(baseMapStyles);
151: wmsDto.setBaseMapEnvelopes(baseMapEnvelopes);
152:
153: return wmsDto;
154: }
155:
156: /**
157: * @return The constant identifying the current svg renderer.
158: * @see org.vfny.geoserver.config.WMSConfig#SVG_SIMPLE
159: * @see org.vfny.geoserver.config.WMSConfig#SVG_BATIK
160: */
161: public String getSvgRenderer() {
162: return svgRenderer;
163: }
164:
165: /**
166: * @param The constant identifying the current svg renderer.
167: * @see org.vfny.geoserver.config.WMSConfig#SVG_SIMPLE
168: * @see org.vfny.geoserver.config.WMSConfig#SVG_BATIK
169: */
170: public void setSvgRenderer(String svgRenderer) {
171: this .svgRenderer = svgRenderer;
172: }
173:
174: /**
175: * @param svgAntiAlias anti alias hint.
176: */
177: public void setSvgAntiAlias(boolean svgAntiAlias) {
178: this .svgAntiAlias = svgAntiAlias;
179: }
180:
181: /**
182: * @return The value of the anti aliasing rendering hint.
183: */
184: public boolean getSvgAntiAlias() {
185: return svgAntiAlias;
186: }
187:
188: /**
189: * @param allowInterpolation rendering interpolation hint.
190: */
191: public void setAllowInterpolation(String allowInterpolation) {
192: this .allowInterpolation = allowInterpolation;
193: }
194:
195: /**
196: * @return The value of the rendering interpolation rendering hint.
197: */
198: public String getAllowInterpolation() {
199: return allowInterpolation;
200: }
201:
202: /**
203: * The comma separated list of feature types that make up the
204: * base-map layer list.
205: * @return
206: */
207: public Map getBaseMapLayers() {
208: return baseMapLayers;
209: }
210:
211: public void setBaseMapLayers(Map layers) {
212: baseMapLayers = layers;
213: }
214:
215: /**
216: * The comma separated list of Styles that make up the
217: * base-map style list.
218: * @return
219: */
220: public Map getBaseMapStyles() {
221: return baseMapStyles;
222: }
223:
224: public void setBaseMapStyles(Map styles) {
225: baseMapStyles = styles;
226: }
227:
228: public Map getBaseMapEnvelopes() {
229: return baseMapEnvelopes;
230: }
231:
232: public void setBaseMapEnvelopes(Map envelopes) {
233: baseMapEnvelopes = envelopes;
234: }
235: }
|