Source Code Cross Referenced for WMSContentForm.java in  » GIS » GeoServer » org » vfny » geoserver » form » wms » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoServer » org.vfny.geoserver.form.wms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.form.wms;
006:
007:        import java.net.MalformedURLException;
008:        import java.net.URL;
009:        import java.util.ArrayList;
010:        import java.util.HashMap;
011:        import java.util.Iterator;
012:        import java.util.List;
013:
014:        import javax.servlet.ServletContext;
015:        import javax.servlet.http.HttpServletRequest;
016:
017:        import org.apache.struts.action.ActionError;
018:        import org.apache.struts.action.ActionErrors;
019:        import org.apache.struts.action.ActionForm;
020:        import org.apache.struts.action.ActionMapping;
021:        import org.geotools.geometry.GeneralEnvelope;
022:        import org.geotools.referencing.CRS;
023:        import org.opengis.referencing.FactoryException;
024:        import org.opengis.referencing.NoSuchAuthorityCodeException;
025:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
026:        import org.vfny.geoserver.config.WMSConfig;
027:
028:        /**
029:         * DOCUMENT ME!
030:         *
031:         * @author User To change the template for this generated type comment go to
032:         *         Window>Preferences>Java>Code Generation>Code and Comments
033:         */
034:        public class WMSContentForm extends ActionForm {
035:            private boolean enabled;
036:            private String onlineResource;
037:            private List baseMapLayers = new ArrayList();
038:            private List baseMapStyles = new ArrayList();
039:            private List baseMapTitles = new ArrayList();
040:            private List baseMapEnvelopes = new ArrayList();
041:            private int envIndex = -1;
042:            private HashMap minCPs = new HashMap();
043:            private HashMap maxCPs = new HashMap();
044:            private CoordinateReferenceSystem targetCRS = null;
045:
046:            private int selectedLayer;
047:
048:            /*
049:             * Because of the way that STRUTS works, if the user does not check the enabled box,
050:             * or unchecks it, setEnabled() is never called, thus we must monitor setEnabled()
051:             * to see if it doesn't get called. This must be accessible, as ActionForms need to
052:             * know about it -- there is no way we can tell whether we are about to be passed to
053:             * an ActionForm or not.
054:             *
055:             * Probably a better way to do this, but I can't think of one.
056:             * -rgould
057:             */
058:            private boolean enabledChecked = false;
059:
060:            /**
061:             * DOCUMENT ME!
062:             *
063:             * @return
064:             */
065:            public boolean isEnabled() {
066:                return enabled;
067:            }
068:
069:            /**
070:             * DOCUMENT ME!
071:             *
072:             * @return
073:             */
074:            public String getOnlineResource() {
075:                return onlineResource;
076:            }
077:
078:            // ---------------------------------------------------------------
079:            public void setBaseMapTitles(List titles) {
080:                baseMapTitles = titles;
081:            }
082:
083:            public void setBaseMapTitle(int index, String value) {
084:                baseMapTitles.set(index, value);
085:            }
086:
087:            public List getBaseMapTitles() {
088:                return baseMapTitles;
089:            }
090:
091:            public String getBaseMapTitle(int index) {
092:                return (String) baseMapTitles.get(index);
093:            }
094:
095:            // ---------------------------------------------------------------
096:            public List getBaseMapLayers() {
097:                return baseMapLayers;
098:            }
099:
100:            public String getBaseMapLayers(int index) {
101:                return (String) baseMapLayers.get(index);
102:            }
103:
104:            public void setBaseMapLayers(int index, String value) {
105:                baseMapLayers.set(index, value);
106:            }
107:
108:            public void setBaseMapLayers(List layers) {
109:                baseMapLayers = layers;
110:            }
111:
112:            // ---------------------------------------------------------------
113:            public List getBaseMapStyles() {
114:                return baseMapStyles;
115:            }
116:
117:            public String getBaseMapStyles(int index) {
118:                return (String) baseMapStyles.get(index);
119:            }
120:
121:            public void setBaseMapStyles(int index, String value) {
122:                baseMapStyles.set(index, value);
123:            }
124:
125:            public void setBaseMapStyles(List styles) {
126:                baseMapStyles = styles;
127:            }
128:
129:            // ---------------------------------------------------------------
130:
131:            // ---------------------------------------------------------------
132:            public void setBaseMapEnvelopes(List envelopes) {
133:                baseMapEnvelopes = envelopes;
134:            }
135:
136:            public void setBaseMapEnvelope(int index, GeneralEnvelope value) {
137:                baseMapEnvelopes.set(index, value);
138:            }
139:
140:            public List getBaseMapEnvelopes() {
141:                return baseMapEnvelopes;
142:            }
143:
144:            public GeneralEnvelope getBaseMapEnvelope(int index) {
145:                return (GeneralEnvelope) baseMapEnvelopes.get(index);
146:            }
147:
148:            public double getMinX(int index) {
149:                GeneralEnvelope envelope = getBaseMapEnvelope(index);
150:
151:                return envelope.getLowerCorner().getOrdinate(0);
152:            }
153:
154:            public double getMinY(int index) {
155:                GeneralEnvelope envelope = getBaseMapEnvelope(index);
156:
157:                return envelope.getLowerCorner().getOrdinate(1);
158:            }
159:
160:            public double getMaxX(int index) {
161:                GeneralEnvelope envelope = getBaseMapEnvelope(index);
162:
163:                return envelope.getUpperCorner().getOrdinate(0);
164:            }
165:
166:            public double getMaxY(int index) {
167:                GeneralEnvelope envelope = getBaseMapEnvelope(index);
168:
169:                return envelope.getUpperCorner().getOrdinate(1);
170:            }
171:
172:            public void setMinX(int index, double value) {
173:                /*GeneralEnvelope oldEnvelope = getBaseMapEnvelope(index);
174:                GeneralEnvelope newEnvelope = null;
175:                double[] minCP = new double[] { value, oldEnvelope.getLowerCorner().getOrdinate(1) };
176:                double[] maxCP = new double[] {
177:                        oldEnvelope.getUpperCorner().getOrdinate(0),
178:                        oldEnvelope.getUpperCorner().getOrdinate(1)
179:                    };
180:                newEnvelope = new GeneralEnvelope(minCP, maxCP);
181:                newEnvelope.setCoordinateReferenceSystem(oldEnvelope.getCoordinateReferenceSystem());
182:                setBaseMapEnvelope(index, newEnvelope);*/
183:                double[] minCP = (double[]) minCPs.get(new Integer(index));
184:
185:                if (minCP == null) {
186:                    minCP = new double[2];
187:                }
188:
189:                minCP[0] = value;
190:                minCPs.put(new Integer(index), minCP);
191:            }
192:
193:            public void setMinY(int index, double value) {
194:                /*GeneralEnvelope oldEnvelope = getBaseMapEnvelope(index);
195:                GeneralEnvelope newEnvelope = null;
196:                double[] minCP = new double[] { oldEnvelope.getLowerCorner().getOrdinate(0), value };
197:                double[] maxCP = new double[] {
198:                        oldEnvelope.getUpperCorner().getOrdinate(0),
199:                        oldEnvelope.getUpperCorner().getOrdinate(1)
200:                    };
201:                newEnvelope = new GeneralEnvelope(minCP, maxCP);
202:                newEnvelope.setCoordinateReferenceSystem(oldEnvelope.getCoordinateReferenceSystem());
203:                setBaseMapEnvelope(index, newEnvelope);*/
204:                double[] minCP = (double[]) minCPs.get(new Integer(index));
205:
206:                if (minCP == null) {
207:                    minCP = new double[2];
208:                }
209:
210:                minCP[1] = value;
211:                minCPs.put(new Integer(index), minCP);
212:            }
213:
214:            public void setMaxX(int index, double value) {
215:                /*GeneralEnvelope oldEnvelope = getBaseMapEnvelope(index);
216:                GeneralEnvelope newEnvelope = null;
217:                double[] minCP = new double[] {
218:                        oldEnvelope.getLowerCorner().getOrdinate(0),
219:                        oldEnvelope.getLowerCorner().getOrdinate(1)
220:                    };
221:                double[] maxCP = new double[] { value, oldEnvelope.getUpperCorner().getOrdinate(1) };
222:                newEnvelope = new GeneralEnvelope(minCP, maxCP);
223:                newEnvelope.setCoordinateReferenceSystem(oldEnvelope.getCoordinateReferenceSystem());
224:                setBaseMapEnvelope(index, newEnvelope);*/
225:                double[] maxCP = (double[]) maxCPs.get(new Integer(index));
226:
227:                if (maxCP == null) {
228:                    maxCP = new double[2];
229:                }
230:
231:                maxCP[0] = value;
232:                maxCPs.put(new Integer(index), maxCP);
233:            }
234:
235:            public void setMaxY(int index, double value) {
236:                /*GeneralEnvelope oldEnvelope = getBaseMapEnvelope(index);
237:                GeneralEnvelope newEnvelope = null;
238:                double[] minCP = new double[] {
239:                        oldEnvelope.getLowerCorner().getOrdinate(0),
240:                        oldEnvelope.getLowerCorner().getOrdinate(1)
241:                    };
242:                double[] maxCP = new double[] { oldEnvelope.getUpperCorner().getOrdinate(0), value };
243:                newEnvelope = new GeneralEnvelope(minCP, maxCP);
244:                newEnvelope.setCoordinateReferenceSystem(oldEnvelope.getCoordinateReferenceSystem());
245:                setBaseMapEnvelope(index, newEnvelope);*/
246:                double[] maxCP = (double[]) maxCPs.get(new Integer(index));
247:
248:                if (maxCP == null) {
249:                    maxCP = new double[2];
250:                }
251:
252:                maxCP[1] = value;
253:                maxCPs.put(new Integer(index), maxCP);
254:            }
255:
256:            public String getSrsName(int index) {
257:                GeneralEnvelope envelope = getBaseMapEnvelope(index);
258:
259:                if (envelope.getCoordinateReferenceSystem().getName()
260:                        .toString().equalsIgnoreCase("EPSG:WGS 84")) {
261:                    return "EPSG:4326";
262:                } else if (envelope.getCoordinateReferenceSystem()
263:                        .getIdentifiers().toArray().length > 0) {
264:                    return envelope.getCoordinateReferenceSystem()
265:                            .getIdentifiers().toArray()[0].toString();
266:                } else {
267:                    return "EPSG:4326";
268:                }
269:            }
270:
271:            public void setSrsName(int index, String value)
272:                    throws NoSuchAuthorityCodeException, FactoryException {
273:                envIndex = index;
274:                try {
275:                    targetCRS = CRS.decode(value);
276:                } catch (Exception e) {
277:                    targetCRS = null;
278:                }
279:            }
280:
281:            /**
282:             * DOCUMENT ME!
283:             *
284:             * @param b
285:             */
286:            public void setEnabled(boolean b) {
287:                enabledChecked = true;
288:                enabled = b;
289:            }
290:
291:            /**
292:             * DOCUMENT ME!
293:             *
294:             * @param string
295:             */
296:            public void setOnlineResource(String string) {
297:                onlineResource = string;
298:            }
299:
300:            /**
301:             * Action requested by user
302:             */
303:            private String action;
304:
305:            public void reset(ActionMapping arg0, HttpServletRequest arg1) {
306:                super .reset(arg0, arg1);
307:
308:                enabledChecked = false;
309:
310:                ServletContext context = getServlet().getServletContext();
311:                WMSConfig config = (WMSConfig) context
312:                        .getAttribute(WMSConfig.CONFIG_KEY);
313:
314:                this .enabled = config.isEnabled();
315:
316:                URL url = config.getOnlineResource();
317:
318:                if (url != null) {
319:                    this .onlineResource = url.toString();
320:                } else {
321:                    this .onlineResource = "";
322:                }
323:
324:                if (config.getBaseMapLayers() != null) {
325:                    Iterator it = config.getBaseMapLayers().keySet().iterator();
326:                    String baseMapTitle;
327:                    String baseMapLayerValues;
328:                    String baseMapStyleValues;
329:                    GeneralEnvelope baseMapEnvelopeValues;
330:
331:                    List baseMapTitles = new ArrayList();
332:                    List baseMapLayers = new ArrayList();
333:                    List baseMapStyles = new ArrayList();
334:                    List baseMapEnvelopes = new ArrayList();
335:
336:                    while (it.hasNext()) {
337:                        baseMapTitle = (String) it.next();
338:                        baseMapLayerValues = (String) config.getBaseMapLayers()
339:                                .get(baseMapTitle);
340:                        baseMapStyleValues = (String) config.getBaseMapStyles()
341:                                .get(baseMapTitle);
342:                        baseMapEnvelopeValues = (GeneralEnvelope) config
343:                                .getBaseMapEnvelopes().get(baseMapTitle);
344:
345:                        baseMapTitles.add(baseMapTitle);
346:                        baseMapLayers.add(baseMapLayerValues);
347:                        baseMapStyles.add(baseMapStyleValues);
348:                        baseMapEnvelopes.add(baseMapEnvelopeValues);
349:                    }
350:
351:                    this .baseMapTitles = baseMapTitles;
352:                    this .baseMapLayers = baseMapLayers;
353:                    this .baseMapStyles = baseMapStyles;
354:                    this .baseMapEnvelopes = baseMapEnvelopes;
355:                }
356:            }
357:
358:            public ActionErrors validate(ActionMapping mapping,
359:                    HttpServletRequest request) {
360:                ActionErrors errors = new ActionErrors();
361:
362:                if ((targetCRS == null) && (envIndex >= 0)) {
363:                    errors.add("onlineResource",
364:                            new ActionError(
365:                                    "error.wms.onlineResource.required",
366:                                    onlineResource));
367:                } else if (envIndex >= 0) {
368:                    GeneralEnvelope envelope = getBaseMapEnvelope(envIndex);
369:
370:                    //CoordinateReferenceSystem sourceCRS  = envelope.getCoordinateReferenceSystem();
371:                    /*final MathTransform srcCRSTodestCRS = CRS.findMathTransform(sourceCRS, targetCRS, true);
372:                                envelope = CRSUtilities.transform(srcCRSTodestCRS, envelope);*/
373:
374:                    //GeneralEnvelope newEnvelope = new GeneralEnvelope(minCP, maxCP);
375:                    //newEnvelope.setCoordinateReferenceSystem(sourceCRS);
376:                    envelope.setEnvelope(new GeneralEnvelope((double[]) minCPs
377:                            .get(new Integer(envIndex)), (double[]) maxCPs
378:                            .get(new Integer(envIndex))));
379:                    envelope.setCoordinateReferenceSystem(targetCRS);
380:                    setBaseMapEnvelope(envIndex, envelope);
381:                }
382:
383:                if ((onlineResource == null) || "".equals(onlineResource)) {
384:                    errors.add("onlineResource",
385:                            new ActionError(
386:                                    "error.wms.onlineResource.required",
387:                                    onlineResource));
388:                } else {
389:                    try {
390:                        URL url = new URL(onlineResource);
391:                    } catch (MalformedURLException badURL) {
392:                        errors.add("onlineResource", new ActionError(
393:                                "error.wms.onlineResource.malformed", badURL));
394:                    }
395:                }
396:
397:                return errors;
398:            }
399:
400:            /**
401:             * DOCUMENT ME!
402:             *
403:             * @return
404:             */
405:            public boolean isEnabledChecked() {
406:                return enabledChecked;
407:            }
408:
409:            /**
410:             * DOCUMENT ME!
411:             *
412:             * @param b
413:             */
414:            public void setEnabledChecked(boolean b) {
415:                enabledChecked = b;
416:            }
417:
418:            public String getAction() {
419:                return action;
420:            }
421:
422:            public void setAction(String action) {
423:                this .action = action;
424:            }
425:
426:            public HashMap getMaxCPs() {
427:                return maxCPs;
428:            }
429:
430:            public HashMap getMinCPs() {
431:                return minCPs;
432:            }
433:
434:            /**
435:             * @return the selectedLayer
436:             */
437:            public int getSelectedLayer() {
438:                return selectedLayer;
439:            }
440:
441:            /**
442:             * @param selectedLayer the selectedLayer to set
443:             */
444:            public void setSelectedLayer(int selectedLayer) {
445:                this.selectedLayer = selectedLayer;
446:            }
447:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.