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.event.WindowAdapter;
030: import java.awt.event.WindowEvent;
031:
032: import java.net.URL;
033:
034: import java.util.Observable;
035:
036: import fr.ign.cogit.geoxygene.datatools.Geodatabase;
037: import fr.ign.cogit.geoxygene.feature.FT_Feature;
038: import fr.ign.cogit.geoxygene.feature.FT_FeatureCollection;
039:
040: /**
041: * 2007 : amélioration de la gestion de la fermeture - grosso
042: *
043: * @author Thierry Badard & Arnaud Braun
044: * @version 1.1
045: *
046: */
047:
048: public class ObjectViewer extends Observable {
049:
050: private static final String OBJECTVIEWER_TITLE = "GeOxygene Object Viewer";
051:
052: public static boolean flagWindowClosing = true;
053:
054: public ObjectViewerInterface objectViewerInterface;
055:
056: /** Creates a new ObjectViewer without connection to a Geodatabase.*/
057: public ObjectViewer() {
058: this (null);
059: }
060:
061: /** Creates a new ObjectViewer with a connection to a Geodatabase. */
062: public ObjectViewer(Geodatabase db) {
063: objectViewerInterface = new ObjectViewerInterface(
064: OBJECTVIEWER_TITLE, db);
065: addObserver(objectViewerInterface);
066: objectViewerInterface.pack();
067: objectViewerInterface.setSize(600, 400);
068: objectViewerInterface.show();
069: objectViewerInterface.addWindowListener(new WindowAdapter() {
070: public void windowClosing(WindowEvent e) {
071: if (flagWindowClosing)
072: System.exit(0);
073: else
074: objectViewerInterface.dispose();
075: }
076: });
077:
078: }
079:
080: /** Display objects stored in the FeatureCollection as a Theme with the given name. */
081:
082: public void addFeatureCollection(FT_FeatureCollection fColl,
083: String themeName) {
084:
085: objectViewerInterface.addAFeatureCollectionTheme(fColl,
086: themeName);
087:
088: }
089:
090: /** Refresh fully the FeatureCollection displayed in the viewer with this given name. */
091:
092: public void refreshFeatureCollection(FT_FeatureCollection fColl,
093: String themeName) {
094:
095: objectViewerInterface.refreshAFeatureCollectionTheme(fColl,
096: themeName);
097:
098: }
099:
100: /** Refresh the FeatureCollection displayed in the viewer with this given name with this feature.
101:
102: * The feature must already belong to the collection. */
103:
104: public void refreshFeatureCollection(FT_Feature feature,
105: String themeName) {
106:
107: objectViewerInterface.refreshAFeatureCollectionTheme(feature,
108: themeName);
109:
110: }
111:
112: /** Display objects stored in the shapefile given by url (without .shp) in an ObjectViewer. */
113:
114: public void addAShapefile(URL url) {
115:
116: objectViewerInterface.addAShapefileTheme(url);
117:
118: }
119:
120: /** Display an image (.jpg or .gif) in an ObjectViewer. */
121:
122: public void addAnImage(URL url, int x, int y, int width, int height) {
123:
124: objectViewerInterface.addAnImageTheme(url.getFile(), x, y,
125: width, height);
126:
127: }
128:
129: }
|