Source Code Cross Referenced for DrawCircleWithGivenRadiusPlugIn.java in  » GIS » openjump » org » openjump » core » ui » plugin » edittoolbox » 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.edittoolbox 
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:  		03.11.2005
030:         * last modified:  	
031:         * 
032:         * description:
033:         *    draw a circle for a given radius and a specified 
034:         *    number of vertices per circle quarter<p>
035:         * 
036:         *****************************************************/package org.openjump.core.ui.plugin.edittoolbox;
037:
038:        import java.awt.event.ComponentAdapter;
039:        import java.awt.event.ComponentEvent;
040:
041:        import org.openjump.core.ui.plugin.edittoolbox.cursortools.DrawCircleWithGivenRadiusTool;
042:
043:        import com.vividsolutions.jump.workbench.WorkbenchContext;
044:        import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
045:        import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
046:        import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
047:        import com.vividsolutions.jump.workbench.plugin.PlugInContext;
048:        import com.vividsolutions.jump.workbench.ui.GUIUtil;
049:        import com.vividsolutions.jump.workbench.ui.LayerNamePanelProxy;
050:        import com.vividsolutions.jump.workbench.ui.MultiInputDialog;
051:        import com.vividsolutions.jump.workbench.ui.cursortool.CursorTool;
052:        import com.vividsolutions.jump.workbench.ui.cursortool.QuasimodeTool;
053:        import com.vividsolutions.jump.workbench.ui.cursortool.editing.EditingPlugIn;
054:        import com.vividsolutions.jump.workbench.ui.toolbox.ToolboxDialog;
055:
056:        /**
057:         * @description:
058:         *    selects items of the actual layer
059:         *    and informs about the number of selected items
060:         * 
061:         * @author sstein
062:         *
063:         */
064:        public class DrawCircleWithGivenRadiusPlugIn extends AbstractPlugIn {
065:
066:            private boolean circleButtonAdded = false;
067:            private String T1 = "diameter";
068:            private String T2 = "Points";
069:            private String sidebarstring = "";
070:            private double diameter = 50;
071:            private int points = 8; //points per cirlce quarter
072:
073:            public void initialize(final PlugInContext context)
074:                    throws Exception {
075:
076:                //this.T1 = I18N.get("org.openjump.core.ui.plugin.edit.SelectItemsByCirlceFromSelectedLayersPlugIn.cirlce-diameter") + ":";
077:                this .T1 = "Circle Diameter";
078:                this .T2 = "Number of segments per circle quarter";
079:                this .sidebarstring = "Draw a circle by specifiying the radius, the number of points per circle quarter and the center position by mouse click";
080:                /**
081:                context.getFeatureInstaller().addMainMenuItemWithJava14Fix(this,
082:                        new String[] {MenuNames.TOOLS, MenuNames.TOOLS_GENERATE},
083:                		"Draw Cirlce for Given Radius", 
084:                		false, //icon
085:                		null, //icon
086:                        createEnableCheck(context.getWorkbenchContext())); //enable check
087:                 **/
088:                //add a listener so that when the toolbox dialog opens the constrained tools will be added
089:                //we can't just add the tools directly at this point since the toolbox isn't ready yet
090:                context.getWorkbenchContext().getWorkbench().getFrame()
091:                        .addComponentListener(new ComponentAdapter() {
092:                            public void componentShown(ComponentEvent e) {
093:                                final ToolboxDialog toolBox = ((EditingPlugIn) context
094:                                        .getWorkbenchContext().getBlackboard()
095:                                        .get(EditingPlugIn.KEY))
096:                                        .getToolbox(context
097:                                                .getWorkbenchContext());
098:                                toolBox
099:                                        .addComponentListener(new ComponentAdapter() {
100:
101:                                            public void componentShown(
102:                                                    ComponentEvent e) {
103:                                                addButton(context);
104:                                            }
105:
106:                                            public void componentHidden(
107:                                                    ComponentEvent e) {
108:                                            }
109:                                        });
110:                            }
111:                        });
112:            }
113:
114:            public static MultiEnableCheck createEnableCheck(
115:                    WorkbenchContext workbenchContext) {
116:                EnableCheckFactory checkFactory = new EnableCheckFactory(
117:                        workbenchContext);
118:                return new MultiEnableCheck().add(checkFactory
119:                        .createSelectedLayersMustBeEditableCheck());
120:            }
121:
122:            public boolean makeDialogThings(PlugInContext context)
123:                    throws Exception {
124:                this .reportNothingToUndoYet(context);
125:                MultiInputDialog dialog = new MultiInputDialog(context
126:                        .getWorkbenchFrame(), getName(), true);
127:                setDialogValues(dialog, context);
128:                GUIUtil.centreOnWindow(dialog);
129:                dialog.setVisible(true);
130:                if (!dialog.wasOKPressed()) {
131:                    return false;
132:                }
133:                getDialogValues(dialog);
134:                return true;
135:            }
136:
137:            private void setDialogValues(MultiInputDialog dialog,
138:                    PlugInContext context) {
139:                dialog.setSideBarDescription(this .sidebarstring);
140:                dialog.addDoubleField(T1, this .diameter, 7, T1);
141:                dialog.addIntegerField(T2, this .points, 8, T2);
142:            }
143:
144:            private void getDialogValues(MultiInputDialog dialog) {
145:                this .diameter = dialog.getDouble(T1);
146:                this .points = dialog.getInteger(T2);
147:            }
148:
149:            public boolean execute(PlugInContext context) throws Exception {
150:                try {
151:                    /**
152:                    this.makeDialogThings(context);
153:                    Envelope viewportEnvelope = context.getLayerViewPanel().getViewport().getEnvelopeInModelCoordinates();
154:                    double x = viewportEnvelope.getMinX() + viewportEnvelope.getWidth()/2;
155:                    double y = viewportEnvelope.getMinY() + viewportEnvelope.getHeight()/2;
156:                    Coordinate initCoords = new Coordinate(x,y);
157:                    TestDrawCircleByRadiusTool circleTool = new TestDrawCircleByRadiusTool(context, Math.abs(this.diameter), 
158:                    									Math.abs(this.points), initCoords);
159:                    
160:                    context.getLayerViewPanel().setCurrentCursorTool(circleTool);
161:                     **/
162:                    CursorTool circleTool = DrawCircleWithGivenRadiusTool
163:                            .create((LayerNamePanelProxy) context
164:                                    .getActiveInternalFrame());
165:                    context.getLayerViewPanel()
166:                            .setCurrentCursorTool(circleTool);
167:
168:                    //-- if an toolbar item should be added use the following? 
169:                    /**
170:                    QuasimodeTool tool = new QuasimodeTool(sit).add(
171:                            new QuasimodeTool.ModifierKeySpec(true, false, false), null);
172:                    WorkbenchContext wbcontext = context.getWorkbenchContext();
173:                    wbcontext.getWorkbench().getFrame().getToolBar().addCursorTool(tool).getQuasimodeTool();
174:                     **/
175:                } catch (Exception e) {
176:                    context.getWorkbenchFrame().warnUser(
177:                            "SelecItemsByCircleTool Exception:" + e.toString());
178:                    return false;
179:                }
180:
181:                System.gc();
182:                return true;
183:            }
184:
185:            public void addButton(final PlugInContext pcontext) {
186:                if (!circleButtonAdded) {
187:                    final ToolboxDialog toolbox = ((EditingPlugIn) pcontext
188:                            .getWorkbenchContext().getBlackboard().get(
189:                                    EditingPlugIn.KEY)).getToolbox(pcontext
190:                            .getWorkbenchContext());
191:                    QuasimodeTool quasimodeTool = new QuasimodeTool(
192:                            DrawCircleWithGivenRadiusTool.create(toolbox
193:                                    .getContext()));
194:                    quasimodeTool.add(new QuasimodeTool.ModifierKeySpec(true,
195:                            false, false), null);
196:                    quasimodeTool.add(new QuasimodeTool.ModifierKeySpec(true,
197:                            true, false), null);
198:                    toolbox.add(quasimodeTool, null);
199:                    toolbox.finishAddingComponents();
200:                    toolbox.validate();
201:                    circleButtonAdded = true;
202:                }
203:            }
204:
205:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.