Source Code Cross Referenced for ZoomToScalePlugIn.java in  » GIS » openjump » org » openjump » core » ui » plugin » view » 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 » org.openjump.core.ui.plugin.view 
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:         * JUMP is Copyright (C) 2003 Vivid Solutions
006:         *
007:         * This program implements extensions to JUMP and is
008:         * Copyright (C) Stefan Steiniger.
009:         * 
010:         * This program is free software; you can redistribute it and/or
011:         * modify it under the terms of the GNU General Public License
012:         * as published by the Free Software Foundation; either version 2
013:         * of the License, or (at your option) any later version.
014:         * 
015:         * This program is distributed in the hope that it will be useful,
016:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
017:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
018:         * GNU General Public License for more details.
019:         * 
020:         * You should have received a copy of the GNU General Public License
021:         * along with this program; if not, write to the Free Software
022:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
023:         * 
024:         * For more information, contact:
025:         * Stefan Steiniger
026:         * perriger@gmx.de
027:         */
028:        /*****************************************************
029:         * created:  		04.01.2005
030:         * last modified:  	01.10.2005 [scale obtained now from other class 
031:         * 								and change in layout]
032:         * 
033:         * description:
034:         *   zooms to a given map scale, which is received from an input dialog 
035:         * 
036:         *****************************************************/package org.openjump.core.ui.plugin.view;
037:
038:        import org.openjump.core.ui.util.ScreenScale;
039:
040:        import com.vividsolutions.jts.geom.Coordinate;
041:        import com.vividsolutions.jts.geom.Envelope;
042:        import com.vividsolutions.jts.geom.Geometry;
043:        import com.vividsolutions.jts.geom.GeometryFactory;
044:        import com.vividsolutions.jump.I18N;
045:        import com.vividsolutions.jump.workbench.WorkbenchContext;
046:        import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
047:        import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
048:        import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
049:        import com.vividsolutions.jump.workbench.plugin.PlugInContext;
050:        import com.vividsolutions.jump.workbench.ui.GUIUtil;
051:        import com.vividsolutions.jump.workbench.ui.MenuNames;
052:        import com.vividsolutions.jump.workbench.ui.MultiInputDialog;
053:        import com.vividsolutions.jump.workbench.ui.Viewport;
054:
055:        /**
056:         * @description
057:         * 	zooms to a given map scale, received from a input dialog
058:         * 
059:         * @author sstein
060:         *
061:         */
062:        public class ZoomToScalePlugIn extends AbstractPlugIn {
063:
064:            private String T1 = "scale"; //[sstein] this string is not used anymore
065:            int scale = 0;
066:            double oldHorizontalScale = 0; // is calculated for panel-width (not heigth!!)
067:            double modelWidth = 0;
068:            double panelWidth = 0;
069:            String text = I18N
070:                    .get("org.openjump.core.ui.plugin.view.ZoomToScalePlugIn.set-new-scale-to-zoom")
071:                    + ":  1 : ";
072:
073:            public void initialize(PlugInContext context) throws Exception {
074:
075:                this .T1 = I18N
076:                        .get("org.openjump.core.ui.plugin.view.ZoomToScalePlugIn.scale")
077:                        + ": ";
078:                context
079:                        .getFeatureInstaller()
080:                        .addMainMenuItemWithJava14Fix(
081:                                this ,
082:                                new String[] { MenuNames.VIEW },
083:                                I18N
084:                                        .get("org.openjump.core.ui.plugin.view.ZoomToScalePlugIn.zoom-to-scale")
085:                                        + "{pos:9}",
086:                                false,
087:                                null,
088:                                createEnableCheck(context.getWorkbenchContext()));
089:            }
090:
091:            public static MultiEnableCheck createEnableCheck(
092:                    WorkbenchContext workbenchContext) {
093:                EnableCheckFactory checkFactory = new EnableCheckFactory(
094:                        workbenchContext);
095:
096:                return new MultiEnableCheck().add(checkFactory
097:                        .createAtLeastNLayersMustExistCheck(1));
098:            }
099:
100:            public boolean execute(PlugInContext context) throws Exception {
101:
102:                Viewport port = context.getLayerViewPanel().getViewport();
103:                this .oldHorizontalScale = ScreenScale
104:                        .getHorizontalMapScale(port);
105:
106:                MultiInputDialog dialog = new MultiInputDialog(
107:                        context.getWorkbenchFrame(),
108:                        I18N
109:                                .get("org.openjump.core.ui.plugin.view.ZoomToScalePlugIn.zoom-to-scale"),
110:                        true);
111:                setDialogValues(dialog, context);
112:                GUIUtil.centreOnWindow(dialog);
113:                dialog.setVisible(true);
114:                if (!dialog.wasOKPressed()) {
115:                    return false;
116:                }
117:                getDialogValues(dialog);
118:
119:                //-- get zoom factor
120:                double factor = this .scale / this .oldHorizontalScale;
121:
122:                //--calculating new screen using the envelope of the corner LineString 
123:                Envelope oldEnvelope = port.getEnvelopeInModelCoordinates();
124:
125:                double xc = 0.5 * (oldEnvelope.getMaxX() + oldEnvelope
126:                        .getMinX());
127:                double yc = 0.5 * (oldEnvelope.getMaxY() + oldEnvelope
128:                        .getMinY());
129:                double xmin = xc - 1 / 2.0 * factor * oldEnvelope.getWidth();
130:                double xmax = xc + 1 / 2.0 * factor * oldEnvelope.getWidth();
131:                double ymin = yc - 1 / 2.0 * factor * oldEnvelope.getHeight();
132:                double ymax = yc + 1 / 2.0 * factor * oldEnvelope.getHeight();
133:                Coordinate[] coords = new Coordinate[] {
134:                        new Coordinate(xmin, ymin), new Coordinate(xmax, ymax) };
135:                Geometry g1 = new GeometryFactory().createLineString(coords);
136:                port.zoom(g1.getEnvelopeInternal());
137:
138:                return true;
139:            }
140:
141:            private void setDialogValues(MultiInputDialog dialog,
142:                    PlugInContext context) {
143:                //dialog.addLabel("actual scale in horizontal direction: " + (int)this.oldHorizontalScale);
144:                dialog
145:                        .addLabel(I18N
146:                                .get("org.openjump.core.ui.plugin.view.ZoomToScalePlugIn.actual-scale-in-horizontal-direction")
147:                                + " 1 : " + (int) this .oldHorizontalScale);
148:                //dialog.addLabel("set new scale to zoom:");
149:                dialog.addIntegerField(text, 25000, 7, text);
150:            }
151:
152:            private void getDialogValues(MultiInputDialog dialog) {
153:                this.scale = dialog.getInteger(text);
154:            }
155:
156:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.