Source Code Cross Referenced for MapGraphicResource.java in  » GIS » udig-1.1 » net » refractions » udig » mapgraphic » internal » 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 » udig 1.1 » net.refractions.udig.mapgraphic.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.refractions.udig.mapgraphic.internal;
002:
003:        import java.io.IOException;
004:        import java.net.MalformedURLException;
005:        import java.net.URL;
006:        import java.text.MessageFormat;
007:
008:        import net.refractions.udig.catalog.IGeoResource;
009:        import net.refractions.udig.catalog.IGeoResourceInfo;
010:        import net.refractions.udig.catalog.IService;
011:        import net.refractions.udig.mapgraphic.MapGraphic;
012:        import net.refractions.udig.mapgraphic.MapGraphicFactory;
013:
014:        import org.eclipse.core.runtime.IConfigurationElement;
015:        import org.eclipse.core.runtime.IProgressMonitor;
016:        import org.eclipse.ui.plugin.AbstractUIPlugin;
017:        import org.geotools.geometry.jts.ReferencedEnvelope;
018:        import org.geotools.referencing.crs.DefaultEngineeringCRS;
019:        import org.geotools.referencing.crs.DefaultGeographicCRS;
020:
021:        import com.vividsolutions.jts.geom.Envelope;
022:
023:        public class MapGraphicResource extends IGeoResource {
024:
025:            /** the service which contains all decorator resources **/
026:            private final MapGraphicService parent;
027:
028:            /** the info for the map graphic resource **/
029:            private volatile MapGraphicResourceInfo info;
030:
031:            /** the map graphic itself **/
032:            private volatile MapGraphic mapGraphic;
033:
034:            /** the map graphic name **/
035:            private String name;
036:
037:            /** the map graphic id **/
038:            private final String id;
039:
040:            private IConfigurationElement element;
041:
042:            MapGraphicResource(MapGraphicService service,
043:                    IConfigurationElement element) {
044:                parent = service;
045:                this .name = element.getAttribute("name"); //$NON-NLS-1$
046:                this .id = element.getAttribute("id"); //$NON-NLS-1$
047:                this .element = element;
048:                mapGraphic = MapGraphicFactory.getInstance().createMapGraphic(
049:                        id);
050:            }
051:
052:            /*
053:             * @see net.refractions.udig.catalog.IGeoResource#resolve(java.lang.Class, org.eclipse.core.runtime.IProgressMonitor)
054:             */
055:            public <T> T resolve(Class<T> adaptee, IProgressMonitor monitor)
056:                    throws IOException {
057:                if (adaptee == null)
058:                    return null;
059:
060:                //        if (adaptee.isAssignableFrom(IService.class)) {
061:                //            return adaptee.cast(parent);
062:                //        }
063:                if (adaptee.isAssignableFrom(IGeoResourceInfo.class)) {
064:                    return adaptee.cast(getInfo(monitor));
065:                }
066:                //TODO: this is not safe, the caller of this method might not have
067:                // the MapGraphicClasses on their classpath
068:                if (adaptee.isAssignableFrom(MapGraphic.class)) {
069:                    return adaptee.cast(mapGraphic);
070:                }
071:                if (adaptee.isAssignableFrom(MapGraphicFactory.class)) {
072:                    return adaptee.cast(MapGraphicFactory.getInstance());
073:                }
074:
075:                return super .resolve(adaptee, monitor);
076:            }
077:
078:            public IService service(IProgressMonitor monitor)
079:                    throws IOException {
080:                return parent;
081:            }
082:
083:            public IGeoResourceInfo getInfo(IProgressMonitor monitor)
084:                    throws IOException {
085:                if (info == null) {
086:                    info = new MapGraphicResourceInfo(element);
087:                }
088:                return info;
089:            }
090:
091:            /*
092:             * @see net.refractions.udig.catalog.IResolve#canResolve(java.lang.Class)
093:             */
094:            public <T> boolean canResolve(Class<T> adaptee) {
095:
096:                return adaptee != null
097:                        && (adaptee.isAssignableFrom(element.getClass())
098:                                || adaptee.isAssignableFrom(IService.class)
099:                                || adaptee.isAssignableFrom(IGeoResource.class)
100:                                ||
101:                                //TODO: this is not safe, the caller of this method might not have
102:                                // the MapGraphicClasses on their classpath
103:                                adaptee.isAssignableFrom(MapGraphic.class)
104:                                || adaptee
105:                                        .isAssignableFrom(MapGraphicFactory.class) || (mapGraphic != null && adaptee
106:                                .isAssignableFrom(mapGraphic.getClass())))
107:                        || super .canResolve(adaptee);
108:            }
109:
110:            /*
111:             * @see net.refractions.udig.catalog.IResolve#getStatus()
112:             */
113:            public Status getStatus() {
114:                return parent.getStatus();
115:            }
116:
117:            /*
118:             * @see net.refractions.udig.catalog.IResolve#getMessage()
119:             */
120:            public Throwable getMessage() {
121:                return parent.getMessage();
122:            }
123:
124:            /*
125:             * @see net.refractions.udig.catalog.IResolve#getIdentifier()
126:             */
127:            public URL getIdentifier() {
128:                try {
129:                    return new URL(parent.getIdentifier().toString() + "#" + id); //$NON-NLS-1$
130:                } catch (MalformedURLException e) {
131:                    e.printStackTrace();
132:                }
133:
134:                return null;
135:            }
136:
137:            class MapGraphicResourceInfo extends IGeoResourceInfo {
138:
139:                public MapGraphicResourceInfo(IConfigurationElement element) {
140:                    String iconPath = element.getAttribute("icon"); //$NON-NLS-1$
141:                    if (iconPath != null && iconPath.length() > 0)
142:                        this .icon = AbstractUIPlugin.imageDescriptorFromPlugin(
143:                                element.getNamespaceIdentifier(), iconPath);
144:                }
145:
146:                /*
147:                 * @see net.refractions.udig.catalog.IGeoResourceInfo#getName()
148:                 */
149:                @Override
150:                public String getName() {
151:                    return MapGraphicResource.this .name;
152:                }
153:
154:                @Override
155:                public String getTitle() {
156:                    return getName();
157:                }
158:
159:                @Override
160:                public String getDescription() {
161:                    MessageFormat formatter = new MessageFormat(
162:                            Messages.MapGraphicResource_description);
163:                    return formatter.format(name);
164:                }
165:
166:                @Override
167:                public ReferencedEnvelope getBounds() {
168:                    if (bounds == null) {
169:                        Envelope e = new Envelope();
170:                        e.setToNull();
171:
172:                        bounds = new ReferencedEnvelope(e,
173:                                DefaultGeographicCRS.WGS84);
174:                    }
175:                    return bounds;
176:                }
177:            }
178:
179:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.