Source Code Cross Referenced for FeatureInfoWriter.java in  » GIS » openjump » com » vividsolutions » jump » workbench » ui » 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 » openjump » com.vividsolutions.jump.workbench.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003:         * for visualizing and manipulating spatial features with geometry and attributes.
004:         *
005:         * Copyright (C) 2003 Vivid Solutions
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         *
021:         * For more information, contact:
022:         *
023:         * Vivid Solutions
024:         * Suite #1A
025:         * 2328 Government Street
026:         * Victoria BC  V8T 5G5
027:         * Canada
028:         *
029:         * (250)385-6040
030:         * www.vividsolutions.com
031:         */
032:        package com.vividsolutions.jump.workbench.ui;
033:
034:        import java.awt.Color;
035:        import java.util.Collection;
036:        import java.util.Iterator;
037:        import java.util.Map;
038:
039:        import com.vividsolutions.jts.geom.Geometry;
040:        import com.vividsolutions.jump.I18N;
041:        import com.vividsolutions.jump.feature.Feature;
042:        import com.vividsolutions.jump.workbench.model.Layer;
043:
044:        public class FeatureInfoWriter {
045:            public static interface Writer {
046:                public String toHTML(Feature feature);
047:            }
048:
049:            public static Writer ATTRIBUTE_WRITER = new Writer() {
050:                public String toHTML(Feature feature) {
051:                    StringBuffer s = new StringBuffer();
052:                    for (int i = 0; i < feature.getSchema().getAttributeCount(); i++) {
053:                        if (feature.getAttribute(i) instanceof  Geometry) {
054:                            continue;
055:                        }
056:                        s.append("<br><b>"
057:                                + GUIUtil.escapeHTML(feature.getSchema()
058:                                        .getAttributeName(i), false, false)
059:                                + ":</b> ");
060:                        if (feature.getAttribute(i) == null) {
061:                            //do nothing
062:                        } else {
063:                            s.append(GUIUtil.escapeHTML(feature.getAttribute(i)
064:                                    .toString(), false, false));
065:                        }
066:                    }
067:                    return s.toString();
068:                }
069:            };
070:
071:            public static Writer EMPTY_WRITER = new Writer() {
072:                public String toHTML(Feature feature) {
073:                    return "";
074:                }
075:            };
076:
077:            //Row-stripe colour recommended in
078:            //Java Look and Feel Design Guidelines: Advanced Topics [Jon Aquino]
079:            private final static String BEIGE = "#E6E6E6";
080:            private final static String WHITE = "#FFFFFF";
081:            private final static String COLOR1 = BEIGE;
082:            private final static String COLOR2 = WHITE;
083:
084:            private boolean workingAroundJEditorPaneBug = true;
085:
086:            public Color sidebarColor(Layer layer) {
087:                Color basicColor = layer.getBasicStyle().isRenderingFill() ? layer
088:                        .getBasicStyle().getFillColor()
089:                        : layer.getBasicStyle().getLineColor();
090:                int alpha = layer.getBasicStyle().getAlpha();
091:                return GUIUtil.toSimulatedTransparency(GUIUtil.alphaColor(
092:                        basicColor, alpha));
093:            }
094:
095:            public String writeGeom(Map layerToFeaturesMap,
096:                    Writer featureWriter, Writer attributeWriter) {
097:                if (layerToFeaturesMap.isEmpty()) {
098:                    return "";
099:                }
100:                StringBuffer stringBuffer = new StringBuffer();
101:                for (Iterator i = layerToFeaturesMap.keySet().iterator(); i
102:                        .hasNext();) {
103:                    Layer layer = (Layer) i.next();
104:                    Collection features = (Collection) layerToFeaturesMap
105:                            .get(layer);
106:                    stringBuffer.append("<table width=100%>");
107:                    stringBuffer.append("  <tr>");
108:                    stringBuffer.append("    <td width=5 bgcolor="
109:                            + toHTML(sidebarColor(layer)) + ">");
110:                    stringBuffer.append("    </td>");
111:                    //I'm setting the column 1 width to 5 and the column 2 width to 100%.
112:                    //Theoretically column 2 should smush column 1, but this isn't happening.
113:                    //I hope this behaviour will continue in future Java versions.
114:                    //(See Dahm, Tom. "HTML Tip: Making a Wild Card Column Width." March 2000.
115:                    //Available from http://www.netmechanic.com/news/vol3/html_no3.htm.
116:                    //Internet; accessed 29 October 2002.)
117:                    //[Jon Aquino]
118:                    stringBuffer.append("    <td width=100%>");
119:                    stringBuffer.append("      <table width=100%>");
120:                    stringBuffer.append("        <tr>");
121:                    stringBuffer.append("          <td bgcolor=#FFFFCC>");
122:                    stringBuffer.append("            <B>" + layer.getName()
123:                            + "</B>");
124:                    stringBuffer.append("          </td>");
125:                    stringBuffer.append("        </tr>");
126:                    String bgcolor = COLOR1;
127:                    for (Iterator j = features.iterator(); j.hasNext();) {
128:                        Feature feature = (Feature) j.next();
129:                        if (!bgcolor.equals(COLOR1)) {
130:                            bgcolor = COLOR1;
131:                        } else {
132:                            bgcolor = COLOR2;
133:                        }
134:                        stringBuffer.append("        <tr bgcolor='" + bgcolor
135:                                + "'>");
136:                        stringBuffer.append("          <td>");
137:                        stringBuffer
138:                                .append("            FID <font color='#3300cc'><b>"
139:                                        + feature.getID() + "</b></font>");
140:                        if (featureWriter != EMPTY_WRITER) {
141:                            append(feature, stringBuffer, featureWriter);
142:                        }
143:                        if (attributeWriter != EMPTY_WRITER) {
144:                            stringBuffer.append("            "
145:                                    + attributeWriter.toHTML(feature));
146:                        }
147:                        stringBuffer.append("          </td>");
148:                        stringBuffer.append("        </tr>");
149:                    }
150:                    stringBuffer.append("      </table>");
151:                    stringBuffer.append("    </td>");
152:                    stringBuffer.append("  </tr>");
153:                    stringBuffer.append("</table>");
154:                }
155:                return stringBuffer.toString();
156:            }
157:
158:            private String pad(String s) {
159:                return (s.length() == 1) ? ("0" + s) : s;
160:            }
161:
162:            private String toHTML(Color color) {
163:                String colorString = "#";
164:                colorString += pad(Integer.toHexString(color.getRed()));
165:                colorString += pad(Integer.toHexString(color.getGreen()));
166:                colorString += pad(Integer.toHexString(color.getBlue()));
167:                return colorString;
168:            }
169:
170:            private void append(Feature feature, StringBuffer stringBuffer,
171:                    Writer featureWriter) {
172:                String text = featureWriter.toHTML(feature);
173:                if (workingAroundJEditorPaneBug
174:                        && ((stringBuffer.length() + featureWriter.toHTML(
175:                                feature).length()) > (32768 - 2000))) {
176:                    //See http://developer.java.sun.com/developer/bugParade/bugs/4775730.html. [Jon Aquino]
177:                    text = I18N
178:                            .get("ui.FeatureInfoWriter.text-representation-of-geometry-is-too-large");
179:                }
180:                stringBuffer.append(text);
181:            }
182:
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.