Source Code Cross Referenced for ObjectViewerToolBar.java in  » GIS » GeOxygene-1.3 » fr » ign » cogit » geoxygene » util » viewer » 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 » GeOxygene 1.3 » fr.ign.cogit.geoxygene.util.viewer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the GeOxygene project source files. 
003:         * 
004:         * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for 
005:         * the development and deployment of geographic (GIS) applications. It is a open source 
006:         * contribution of the COGIT laboratory at the Institut Géographique National (the French 
007:         * National Mapping Agency).
008:         * 
009:         * See: http://oxygene-project.sourceforge.net 
010:         *  
011:         * Copyright (C) 2005 Institut Géographique National
012:         *
013:         * This library is free software; you can redistribute it and/or modify it under the terms
014:         * of the GNU Lesser General Public License as published by the Free Software Foundation; 
015:         * either version 2.1 of the License, or any later version.
016:         *
017:         * This library is distributed in the hope that it will be useful, but WITHOUT ANY 
018:         * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
019:         * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
020:         *
021:         * You should have received a copy of the GNU Lesser General Public License along with 
022:         * this library (see file LICENSE if present); if not, write to the Free Software 
023:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:         *  
025:         */
026:
027:        package fr.ign.cogit.geoxygene.util.viewer;
028:
029:        import java.awt.Component;
030:        import java.awt.event.ActionEvent;
031:        import java.awt.event.ActionListener;
032:        import java.net.URL;
033:        import java.util.ArrayList;
034:        import java.util.List;
035:        import java.util.Vector;
036:
037:        import javax.swing.Icon;
038:        import javax.swing.ImageIcon;
039:        import javax.swing.JComponent;
040:        import javax.swing.JToggleButton;
041:        import javax.swing.JToolBar;
042:
043:        import uk.ac.leeds.ccg.geotools.MultiPanTool;
044:        import uk.ac.leeds.ccg.geotools.OneClickZoomInTool;
045:        import uk.ac.leeds.ccg.geotools.OneClickZoomOutTool;
046:        import uk.ac.leeds.ccg.geotools.SelectTool;
047:        import uk.ac.leeds.ccg.geotools.ZoomTool;
048:        import fr.ign.cogit.geoxygene.datatools.Geodatabase;
049:        import fr.ign.cogit.geoxygene.feature.FT_Feature;
050:        import fr.ign.cogit.geoxygene.util.browser.ObjectBrowser;
051:
052:        /**
053:         * 
054:         * @author Thierry Badard & Arnaud Braun
055:         * @version 1.0
056:         * 
057:         */
058:
059:        class ObjectViewerToolBar extends JToolBar {
060:
061:            //Default selection of tools
062:            public static final boolean IS_OPENFILETOOL_SELECTED = true;
063:            public static final boolean IS_ZOOMINTOOL_SELECTED = true;
064:            public static final boolean IS_ZOOMOUTTOOL_SELECTED = true;
065:            public static final boolean IS_ZOOMEXTENTTOOL_SELECTED = true;
066:            public static final boolean IS_PANTOOL_SELECTED = true;
067:            public static final boolean IS_FULLEXTENTTOOL_SELECTED = true;
068:            public static final boolean IS_SELECTIONTOOL_SELECTED = true;
069:
070:            private ObjectViewerInterface objectViewerInterface;
071:
072:            public ObjectViewerToolBar(
073:                    ObjectViewerInterface objectViewerInterface,
074:                    boolean openFileTool, boolean zoomInTool,
075:                    boolean zoomOutTool, boolean zoomExtentTool,
076:                    boolean panTool, boolean fullExtentTool,
077:                    boolean selectionTool, Geodatabase db) {
078:
079:                this .objectViewerInterface = objectViewerInterface;
080:                URL imageUrl;
081:
082:                if (openFileTool) {
083:                    imageUrl = this .getClass().getResource("images/open.gif");
084:                    Icon openicon = new ImageIcon(imageUrl);
085:                    final JToggleButton opentbutton = new JToggleButton(
086:                            openicon, false);
087:                    opentbutton.setToolTipText("Open a file");
088:                    opentbutton
089:                            .addActionListener(new GeOxygeneViewerOpenFileAction(
090:                                    objectViewerInterface));
091:                    this .add(opentbutton);
092:                }
093:
094:                if (db != null) {
095:                    imageUrl = this .getClass()
096:                            .getResource("images/oxygene.gif");
097:                    Icon geOxygeneIcon = new ImageIcon(imageUrl);
098:                    final JToggleButton geOxygenetbutton = new JToggleButton(
099:                            geOxygeneIcon, false);
100:                    geOxygenetbutton
101:                            .setToolTipText("Access to GeOxygene mapping repository");
102:                    geOxygenetbutton
103:                            .addActionListener(new GeOxygeneViewerOpenGeOxygeneAction(
104:                                    objectViewerInterface, db));
105:                    this .add(geOxygenetbutton);
106:                }
107:
108:                if (openFileTool || db != null)
109:                    this .addSeparator();
110:
111:                if (zoomInTool) {
112:                    imageUrl = this .getClass().getResource("images/zoomin.gif");
113:                    Icon zoominicon = new ImageIcon(imageUrl);
114:                    final JToggleButton zoomintbutton = new JToggleButton(
115:                            zoominicon, false);
116:                    zoomintbutton.setToolTipText("Zoom in");
117:                    zoomintbutton.addActionListener(new ActionListener() {
118:                        public void actionPerformed(ActionEvent e) {
119:                            setToolBarButtonsUnselected(zoomintbutton);
120:
121:                            System.out.println("ZoomIn tool selected !!!");
122:
123:                            //ZoomTool zoomintool = new ZoomTool();
124:                            OneClickZoomInTool zoomintool = new OneClickZoomInTool();
125:                            System.out.println(zoomintool.getDescription());
126:                            getObjectViewerInterface().view.setTool(zoomintool);
127:                        }
128:                    });
129:                    this .add(zoomintbutton);
130:                }
131:
132:                if (zoomOutTool) {
133:                    imageUrl = this .getClass()
134:                            .getResource("images/zoomout.gif");
135:                    Icon zoomouticon = new ImageIcon(imageUrl);
136:                    final JToggleButton zoomouttbutton = new JToggleButton(
137:                            zoomouticon, false);
138:                    zoomouttbutton.setToolTipText("Zoom out");
139:                    zoomouttbutton.addActionListener(new ActionListener() {
140:                        public void actionPerformed(ActionEvent e) {
141:                            setToolBarButtonsUnselected(zoomouttbutton);
142:
143:                            System.out.println("ZoomOut tool selected !!!");
144:
145:                            //MultiZoomTool zoomouttool = new MultiZoomTool();
146:                            OneClickZoomOutTool zoomouttool = new OneClickZoomOutTool();
147:                            System.out.println(zoomouttool.getDescription());
148:                            getObjectViewerInterface().view
149:                                    .setTool(zoomouttool);
150:                        }
151:                    });
152:                    this .add(zoomouttbutton);
153:                }
154:
155:                if (zoomExtentTool) {
156:                    imageUrl = this .getClass().getResource(
157:                            "images/zoomextent.gif");
158:                    Icon zoomextenticon = new ImageIcon(imageUrl);
159:                    //final JToggleButton zoomextenttbutton = new JToggleButton(zoomextenticon,false);
160:                    final JToggleButton zoomextenttbutton = new JToggleButton(
161:                            zoomextenticon, true);
162:                    zoomextenttbutton.setToolTipText("Zoom in/out to extent");
163:                    zoomextenttbutton.addActionListener(new ActionListener() {
164:                        public void actionPerformed(ActionEvent e) {
165:                            setToolBarButtonsUnselected(zoomextenttbutton);
166:
167:                            System.out
168:                                    .println("Zoom In/Out to extent tool selected !!!");
169:
170:                            //System.out.println("Zoom: "+view.getZoomAsPercent());
171:                            ZoomTool zoomouttool = new ZoomTool();
172:                            System.out.println(zoomouttool.getDescription());
173:                            getObjectViewerInterface().view
174:                                    .setTool(zoomouttool);
175:                        }
176:                    });
177:                    this .add(zoomextenttbutton);
178:                }
179:
180:                if (panTool) {
181:                    imageUrl = this .getClass().getResource("images/pan.gif");
182:                    Icon panicon = new ImageIcon(imageUrl);
183:                    final JToggleButton pantbutton = new JToggleButton(panicon,
184:                            false);
185:                    pantbutton.setToolTipText("Pan");
186:                    pantbutton.addActionListener(new ActionListener() {
187:                        public void actionPerformed(ActionEvent e) {
188:                            setToolBarButtonsUnselected(pantbutton);
189:
190:                            System.out.println("Pan tool selected !!!");
191:
192:                            //PanTool pantool = new PanTool(true);
193:                            MultiPanTool pantool = new MultiPanTool(true);
194:                            System.out.println(pantool.getDescription());
195:                            getObjectViewerInterface().view.setTool(pantool);
196:                        }
197:                    });
198:                    this .add(pantbutton);
199:                }
200:
201:                if (fullExtentTool) {
202:                    imageUrl = this .getClass().getResource(
203:                            "images/fullextent.gif");
204:                    Icon reseticon = new ImageIcon(imageUrl);
205:                    final JToggleButton resettbutton = new JToggleButton(
206:                            reseticon, false);
207:                    resettbutton.setToolTipText("Zoom to full extent");
208:                    resettbutton.addActionListener(new ActionListener() {
209:                        public void actionPerformed(ActionEvent e) {
210:                            setToolBarButtonsUnselected(resettbutton);
211:
212:                            System.out.println("Reset tool selected !!!");
213:
214:                            getObjectViewerInterface().view.setMapExtentFull();
215:                        }
216:                    });
217:                    this .add(resettbutton);
218:                }
219:
220:                if (zoomInTool || zoomOutTool || zoomExtentTool || panTool
221:                        || fullExtentTool)
222:                    this .addSeparator();
223:
224:                if (selectionTool) {
225:                    imageUrl = this .getClass().getResource("images/select.gif");
226:                    Icon selecticon = new ImageIcon(imageUrl);
227:                    final JToggleButton selecttbutton = new JToggleButton(
228:                            selecticon, false);
229:                    selecttbutton.setToolTipText("Select feature");
230:                    selecttbutton.addActionListener(new ActionListener() {
231:                        public void actionPerformed(ActionEvent e) {
232:                            setToolBarButtonsUnselected(selecttbutton);
233:
234:                            System.out.println("Select tool selected !!!");
235:
236:                            SelectTool selecttool = new SelectTool();
237:                            System.out.println(selecttool.getDescription());
238:                            getObjectViewerInterface().view.setTool(selecttool);
239:                        }
240:                    });
241:                    this .add(selecttbutton);
242:                }
243:
244:                if (true) {
245:                    //Icon selectIDicon = new ImageIcon("../images/select.gif");
246:                    final JToggleButton selectIDtbutton = new JToggleButton(
247:                            "Id?", false);
248:                    selectIDtbutton.setToolTipText("Show attributes");
249:                    selectIDtbutton.addActionListener(new ActionListener() {
250:                        public void actionPerformed(ActionEvent e) {
251:                            setToolBarButtonsUnselected(selectIDtbutton);
252:
253:                            System.out.println("Show attributes selected !!!");
254:
255:                            List selectedFeatures = new ArrayList();
256:                            Vector selectedObjects = getObjectViewerInterface()
257:                                    .getSelectedObjects();
258:                            if (selectedObjects != null) {
259:                                for (int i = 0; i < selectedObjects.size(); i++) {
260:                                    ObjectViewerInterface.ObjectsIDAndSource aSelectedObjectAndSource = (ObjectViewerInterface.ObjectsIDAndSource) selectedObjects
261:                                            .get(i);
262:                                    if (aSelectedObjectAndSource
263:                                            .getDataSource() instanceof  GeOxygeneReader) {
264:                                        GeOxygeneReader geOxyRd = (GeOxygeneReader) aSelectedObjectAndSource
265:                                                .getDataSource();
266:                                        int[] selectedIDs = aSelectedObjectAndSource
267:                                                .getObjectsID();
268:                                        for (int j = 0; j < selectedIDs.length; j++) {
269:                                            FT_Feature feature = geOxyRd
270:                                                    .getFeatureById(selectedIDs[j]);
271:                                            if (feature != null)
272:                                                selectedFeatures.add(feature);
273:                                        }
274:                                    }
275:                                }
276:                                if (selectedFeatures.size() > 0) {
277:                                    if (selectedFeatures.size() == 1)
278:                                        ObjectBrowser.browse(selectedFeatures
279:                                                .get(0));
280:                                    else
281:                                        ObjectBrowser.browse(selectedFeatures);
282:                                }
283:                            }
284:                        }
285:                    });
286:                    this .add(selectIDtbutton);
287:                }
288:
289:            }
290:
291:            public ObjectViewerToolBar(
292:                    ObjectViewerInterface objectViewerInterface, Geodatabase db) {
293:                this (objectViewerInterface, IS_OPENFILETOOL_SELECTED,
294:                        IS_ZOOMINTOOL_SELECTED, IS_ZOOMOUTTOOL_SELECTED,
295:                        IS_ZOOMEXTENTTOOL_SELECTED, IS_PANTOOL_SELECTED,
296:                        IS_FULLEXTENTTOOL_SELECTED, IS_SELECTIONTOOL_SELECTED,
297:                        db);
298:            }
299:
300:            public void setToolBarButtonsUnselected(JComponent tb_button) {
301:                Component[] tbcomp = this .getComponents();
302:                int nbtbcomp = this .getComponentCount();
303:                String classname;
304:
305:                for (int i = 0; i < nbtbcomp; i++) {
306:                    classname = tbcomp[i].getClass().getName();
307:                    if ((classname == "javax.swing.JToggleButton")
308:                            && (tbcomp[i] != tb_button))
309:                        ((JToggleButton) tbcomp[i]).setSelected(false);
310:                }
311:            }
312:
313:            public ObjectViewerInterface getObjectViewerInterface() {
314:                return objectViewerInterface;
315:            }
316:
317:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.