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.wms;
006:
007: import java.awt.Color;
008: import java.awt.image.IndexColorModel;
009:
010: import org.geotools.map.GraphicEnhancedMapContext;
011: import org.geotools.map.MapLayer;
012: import org.vfny.geoserver.wms.requests.GetMapRequest;
013: import org.vfny.geoserver.wms.responses.palette.InverseColorMapOp;
014:
015: /**
016: * Extends DefaultMapContext to provide the whole set of request parameters a
017: * WMS GetMap request can have.
018: *
019: * <p>
020: * In particular, adds holding for the following parameter values:
021: *
022: * <ul>
023: * <li> WIDTH </li>
024: * <li> HEIGHT </li>
025: * <li> BGCOLOR </li>
026: * <li> TRANSPARENT </li>
027: * </ul>
028: * </p>
029: *
030: * @author Gabriel Roldan, Axios Engineering
031: * @author Simone Giannecchini - GeoSolutions SAS
032: * @version $Id: WMSMapContext.java 7467 2007-08-28 22:29:03Z afabiani $
033: */
034: public class WMSMapContext extends GraphicEnhancedMapContext {
035: /** requested map image width in output units (pixels) */
036: private int mapWidth;
037:
038: /** requested map image height in output units (pixels) */
039: private int mapHeight;
040:
041: /** Requested BGCOLOR, defaults to white according to WMS spec */
042: private Color bgColor = Color.white;
043:
044: /** true if background transparency is requested */
045: private boolean transparent;
046:
047: /**
048: * the rendering buffer used to avoid issues with tiled rendering and big
049: * strokes that may cross tile boundaries
050: */
051: private int buffer;
052:
053: /**
054: * The {@link InverseColorMapOp} that actually does the color inversion.
055: */
056: private InverseColorMapOp paletteInverter;
057:
058: private GetMapRequest request; // hold onto it so we can grab info from it
059:
060: // (request URL etc...)
061:
062: public WMSMapContext() {
063: super ();
064: }
065:
066: public WMSMapContext(GetMapRequest req) {
067: super ();
068: request = req;
069: }
070:
071: /**
072: * DOCUMENT ME!
073: *
074: * @param layers
075: */
076: public WMSMapContext(MapLayer[] layers) {
077: super (layers);
078: }
079:
080: /**
081: * DOCUMENT ME!
082: *
083: * @return DOCUMENT ME!
084: */
085: public Color getBgColor() {
086: return this .bgColor;
087: }
088:
089: /**
090: * DOCUMENT ME!
091: *
092: * @param bgColor
093: * DOCUMENT ME!
094: */
095: public void setBgColor(Color bgColor) {
096: this .bgColor = bgColor;
097: }
098:
099: /**
100: * DOCUMENT ME!
101: *
102: * @return DOCUMENT ME!
103: */
104: public int getMapHeight() {
105: return this .mapHeight;
106: }
107:
108: /**
109: * DOCUMENT ME!
110: *
111: * @param mapHeight
112: * DOCUMENT ME!
113: */
114: public void setMapHeight(int mapHeight) {
115: this .mapHeight = mapHeight;
116: }
117:
118: /**
119: * DOCUMENT ME!
120: *
121: * @return DOCUMENT ME!
122: */
123: public int getMapWidth() {
124: return this .mapWidth;
125: }
126:
127: /**
128: * DOCUMENT ME!
129: *
130: * @param mapWidth
131: * DOCUMENT ME!
132: */
133: public void setMapWidth(int mapWidth) {
134: this .mapWidth = mapWidth;
135: }
136:
137: /**
138: * DOCUMENT ME!
139: *
140: * @return DOCUMENT ME!
141: */
142: public boolean isTransparent() {
143: return this .transparent;
144: }
145:
146: /**
147: * DOCUMENT ME!
148: *
149: * @param transparent
150: * DOCUMENT ME!
151: */
152: public void setTransparent(boolean transparent) {
153: this .transparent = transparent;
154: }
155:
156: public GetMapRequest getRequest() {
157: return request;
158: }
159:
160: public void setRequest(GetMapRequest request) {
161: this .request = request;
162: }
163:
164: public int getBuffer() {
165: return buffer;
166: }
167:
168: public void setBuffer(int buffer) {
169: this .buffer = buffer;
170: }
171:
172: public InverseColorMapOp getPaletteInverter() {
173: return paletteInverter;
174: }
175:
176: public void setPaletteInverter(InverseColorMapOp paletteInverter) {
177: this.paletteInverter = paletteInverter;
178: }
179: }
|