Source Code Cross Referenced for DiffSegmentsPlugIn.java in  » GIS » openjump » com » vividsolutions » jump » plugin » qa » 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.plugin.qa 
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.plugin.qa;
033:
034:        import java.awt.Color;
035:        import javax.swing.*;
036:
037:        import com.vividsolutions.jump.I18N;
038:        import com.vividsolutions.jump.qa.diff.*;
039:        import com.vividsolutions.jump.feature.*;
040:        import com.vividsolutions.jump.workbench.*;
041:        import com.vividsolutions.jump.workbench.model.*;
042:        import com.vividsolutions.jump.workbench.plugin.*;
043:        import com.vividsolutions.jump.workbench.ui.*;
044:        import com.vividsolutions.jump.workbench.ui.plugin.*;
045:        import com.vividsolutions.jump.task.*;
046:
047:        public class DiffSegmentsPlugIn extends ThreadedBasePlugIn {
048:
049:            private String sLayer = I18N
050:                    .get("jump.plugin.qa.DiffGeometryPlugIn.Layer");
051:            private String LAYER1 = sLayer + " 1";
052:            private String LAYER2 = sLayer + " 2";
053:            private String USE_TOLERANCE = I18N
054:                    .get("jump.plugin.qa.DiffSegmentsPlugIn.Use-Distance-Tolerance");
055:            private String DISTANCE_TOL = I18N
056:                    .get("jump.plugin.qa.DiffGeometryPlugIn.Distance-Tolerance");
057:
058:            private String sSegmentDiffs = I18N
059:                    .get("jump.plugin.qa.DiffGeometryPlugIn.Segment-Diffs");
060:            private String sUnmSegm = I18N
061:                    .get("jump.plugin.qa.DiffSegmentsPlugIn.Unmatched-Segments-in-Layer");
062:            // further strings are below
063:
064:            private Layer layer1, layer2;
065:            private boolean useTolerance = false;
066:            private double distanceTolerance = 0.0;
067:
068:            public DiffSegmentsPlugIn() {
069:            }
070:
071:            /*
072:             public void initialize(PlugInContext context) throws Exception {
073:             context.getFeatureInstaller().addMainMenuItem(this, new String[] {"QA"},
074:             getName() + "...", false, null, new MultiEnableCheck()
075:             .add(context.getCheckFactory().createWindowWithLayerViewPanelMustBeActiveCheck())
076:             .add(context.getCheckFactory().createAtLeastNLayersMustExistCheck(2)));
077:             }
078:             */
079:
080:            public String getName() {
081:                return I18N
082:                        .get("jump.plugin.qa.DiffSegmentsPlugIn.Calculate-Segment-Differences");
083:            }
084:
085:            public boolean execute(PlugInContext context) throws Exception {
086:
087:                //[sstein, 16.07.2006] set again to obtain correct language
088:                sLayer = I18N.get("jump.plugin.qa.DiffGeometryPlugIn.Layer");
089:                LAYER1 = sLayer + " 1";
090:                LAYER2 = sLayer + " 2";
091:                USE_TOLERANCE = I18N
092:                        .get("jump.plugin.qa.DiffSegmentsPlugIn.Use-Distance-Tolerance");
093:                DISTANCE_TOL = I18N
094:                        .get("jump.plugin.qa.DiffGeometryPlugIn.Distance-Tolerance");
095:
096:                sSegmentDiffs = I18N
097:                        .get("jump.plugin.qa.DiffGeometryPlugIn.Segment-Diffs");
098:                sUnmSegm = I18N
099:                        .get("jump.plugin.qa.DiffSegmentsPlugIn.Unmatched-Segments-in-Layer");
100:
101:                MultiInputDialog dialog = new MultiInputDialog(
102:                        context.getWorkbenchFrame(),
103:                        I18N
104:                                .get("jump.plugin.qa.DiffSegmentsPlugIn.Diff-Segments"),
105:                        true);
106:                setDialogValues(dialog, context);
107:                GUIUtil.centreOnWindow(dialog);
108:                dialog.setVisible(true);
109:                if (!dialog.wasOKPressed()) {
110:                    return false;
111:                }
112:                getDialogValues(dialog);
113:                return true;
114:            }
115:
116:            public void run(TaskMonitor monitor, PlugInContext context)
117:                    throws Exception {
118:                FeatureCollection[] diffFC;
119:                if (!useTolerance) {
120:                    DiffSegments diff = new DiffSegments(monitor);
121:                    diff.setSegments(0, layer1.getFeatureCollectionWrapper());
122:                    diff.setSegments(1, layer2.getFeatureCollectionWrapper());
123:
124:                    diffFC = new FeatureCollection[2];
125:                    diffFC[0] = diff.computeDiffEdges(0);
126:                    diffFC[1] = diff.computeDiffEdges(1);
127:                } else {
128:                    DiffSegmentsWithTolerance diff = new DiffSegmentsWithTolerance(
129:                            layer1.getFeatureCollectionWrapper(), layer2
130:                                    .getFeatureCollectionWrapper(),
131:                            distanceTolerance);
132:
133:                    diffFC = diff.diff();
134:                }
135:                createLayers(context, diffFC);
136:                createOutput(context, diffFC);
137:            }
138:
139:            private void createLayers(PlugInContext context,
140:                    FeatureCollection[] diffFC) {
141:                Layer lyr = context.addLayer(StandardCategoryNames.QA,
142:                        sSegmentDiffs + " - " + layer1.getName(), diffFC[0]);
143:                LayerStyleUtil.setLinearStyle(lyr, Color.red, 2, 4);
144:                lyr.fireAppearanceChanged();
145:
146:                Layer lyr2 = context.addLayer(StandardCategoryNames.QA,
147:                        sSegmentDiffs + " - " + layer2.getName(), diffFC[1]);
148:                LayerStyleUtil.setLinearStyle(lyr2, Color.blue, 2, 4);
149:                lyr2.fireAppearanceChanged();
150:            }
151:
152:            private void createOutput(PlugInContext context,
153:                    FeatureCollection[] diffFC) {
154:                context.getOutputFrame().createNewDocument();
155:                context
156:                        .getOutputFrame()
157:                        .addHeader(
158:                                1,
159:                                I18N
160:                                        .get("jump.plugin.qa.DiffSegmentsPlugIn.Diff-Segments"));
161:                context.getOutputFrame().addField(sLayer + " 1: ",
162:                        layer1.getName());
163:                context.getOutputFrame().addField(sLayer + " 2: ",
164:                        layer2.getName());
165:                context.getOutputFrame().addText(" ");
166:                if (useTolerance) {
167:                    context.getOutputFrame().addField(DISTANCE_TOL + ": ",
168:                            "" + distanceTolerance);
169:                }
170:                context.getOutputFrame().addField("# " + sUnmSegm + " 1: ",
171:                        "" + diffFC[0].size());
172:                context.getOutputFrame().addField("# " + sUnmSegm + " 2: ",
173:                        "" + diffFC[1].size());
174:            }
175:
176:            private void setDialogValues(MultiInputDialog dialog,
177:                    PlugInContext context) {
178:                dialog.setSideBarImage(new ImageIcon(getClass().getResource(
179:                        "DiffSegments.png")));
180:                dialog
181:                        .setSideBarDescription(I18N
182:                                .get("jump.plugin.qa.DiffSegmentsPlugIn.Finds-line-segments-which-occur-in-Layer-1-or-Layer-2-but-not-both"));
183:                //Set initial layer values to the first and second layers in the layer list.
184:                //In #initialize we've already checked that the number of layers >= 2. [Jon Aquino]
185:                dialog.addLayerComboBox(LAYER1, context.getLayerManager()
186:                        .getLayer(0), context.getLayerManager());
187:                dialog.addLayerComboBox(LAYER2, context.getLayerManager()
188:                        .getLayer(1), context.getLayerManager());
189:                dialog
190:                        .addCheckBox(
191:                                USE_TOLERANCE,
192:                                useTolerance,
193:                                I18N
194:                                        .get("jump.plugin.qa.DiffSegmentsPlugIn.Match-segments-if-all-points-are-within-a-Distance-Tolerance"));
195:                dialog
196:                        .addDoubleField(
197:                                DISTANCE_TOL,
198:                                distanceTolerance,
199:                                8,
200:                                I18N
201:                                        .get("jump.plugin.qa.DiffSegmentsPlugIn.The-Distance-Tolerance-specifies-how-close-segments-must-be-to-match"));
202:            }
203:
204:            private void getDialogValues(MultiInputDialog dialog) {
205:                layer1 = dialog.getLayer(LAYER1);
206:                layer2 = dialog.getLayer(LAYER2);
207:                useTolerance = dialog.getBoolean(USE_TOLERANCE);
208:                distanceTolerance = dialog.getDouble(DISTANCE_TOL);
209:            }
210:
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.