⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 objectviewerinterface.java

📁 用于GIS(全球地理系统)的分析和处理的代码。
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * This file is part of the GeOxygene project source files. 
 * 
 * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for 
 * the development and deployment of geographic (GIS) applications. It is a open source 
 * contribution of the COGIT laboratory at the Institut G閛graphique National (the French 
 * National Mapping Agency).
 * 
 * See: http://oxygene-project.sourceforge.net 
 *  
 * Copyright (C) 2005 Institut G閛graphique National
 *
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation; 
 * either version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY 
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with 
 * this library (see file LICENSE if present); if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *  
 */

package fr.ign.cogit.geoxygene.util.viewer;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.io.File;
import java.io.FileInputStream;
import java.net.URL;
import java.util.Observable;
import java.util.Observer;
import java.util.Vector;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;

import uk.ac.leeds.ccg.geotools.DataSource;
import uk.ac.leeds.ccg.geotools.GeoData;
import uk.ac.leeds.ccg.geotools.GeoRectangle;
import uk.ac.leeds.ccg.geotools.HighlightManager;
import uk.ac.leeds.ccg.geotools.MonoShader;
import uk.ac.leeds.ccg.geotools.SelectionChangedEvent;
import uk.ac.leeds.ccg.geotools.SelectionChangedListener;
import uk.ac.leeds.ccg.geotools.SelectionManager;
import uk.ac.leeds.ccg.geotools.ShadeStyle;
import uk.ac.leeds.ccg.geotools.ShapefileReader;
import uk.ac.leeds.ccg.geotools.Theme;
import uk.ac.leeds.ccg.geotools.Viewer;
import uk.ac.leeds.ccg.raster.ImageLayer;
import fr.ign.cogit.geoxygene.datatools.Geodatabase;
import fr.ign.cogit.geoxygene.feature.FT_Feature;
import fr.ign.cogit.geoxygene.feature.FT_FeatureCollection;

/**
  * This class instanciates the GUI of the (Geo)Object Viewer.
  *
  * @author Thierry Badard & Arnaud Braun
  * @version 1.0
  * 
  */

class ObjectViewerInterface extends JFrame implements Observer {
	
	/** This constant defines if themes can be selected when they are loaded or added (default = true), or not (false). */
	private static final boolean THEME_SELECTION = true;
	
	/** This constant defines if themes are displayed when they are loaded or added (default = true), or not (false). */
	private static final boolean THEME_VISIBILITY = true;

	/** It is a reference to the Geotools viewer. */
	protected Viewer view = new Viewer();
	
	/** It is a reference to the status bar of the ObjectViewer's GUI. */
	private ObjectViewerStatusBar statusbar;

	/** It is a reference to the tool bar of the GUI of the ObjectViewer. */
	private ObjectViewerToolBar jtb;

	/** It is a reference to the menu bar of the GUI of the ObjectViewer. */
	private ObjectViewerMenuBar jmb;

	/** List of themes properties */
	//private Vector themesList;
	
	/** List of properties of themes. */
	private Vector themesPropertiesList;
	
	/** List of actives themes (button is pressed) */
	private Vector activeThemes;

	/** JPanel for themes. */
	protected JPanel panel_themes = new JPanel();
	
	/** JScrollPane. */
	private JScrollPane scrolling_panel_themes ;
	
	/** Selected ID objects */
	private Vector selectedObjects ;
	


	protected ObjectViewerInterface(String titre, Geodatabase db) {
		super(titre);
		InterfaceInit(db);
	}


	public void update(Observable o, Object rect) {

	}


	private void InterfaceInit(Geodatabase db) {

		// Init the lists		
		themesPropertiesList = new Vector();
		activeThemes = new Vector();

		// Init GUI
		this.getContentPane().setLayout( new BorderLayout() );
		panel_themes.setLayout( new BoxLayout(panel_themes, BoxLayout.Y_AXIS) );
		scrolling_panel_themes = new JScrollPane(panel_themes);
		scrolling_panel_themes.setMinimumSize(new Dimension(180, 200));
		JPanel view_panel = new JPanel();
		view_panel.setLayout( new BorderLayout());
		view.setSize(300,200);
		view.setBackground(Color.white);
		view_panel.add(view);
		JSplitPane jsp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, scrolling_panel_themes,	view_panel);
		jsp.setDividerLocation(0.4);
		this.getContentPane().add(jsp);		

		// Definition of the ToolBar.
		jtb = new ObjectViewerToolBar(this,db);
		this.getContentPane().add(jtb, BorderLayout.NORTH);

		// Definition of the MenuBar.
		jmb = new ObjectViewerMenuBar(this, db);
		this.setJMenuBar(jmb);

		// Definition of the StatusBar
		statusbar = new ObjectViewerStatusBar(this);
		this.getContentPane().add(statusbar, BorderLayout.SOUTH);

		// Mouse listener for view
		view.addMouseMotionListener(new MouseMotionListener() {
			public void mouseDragged(MouseEvent e) {
				
			}
			
			public void mouseMoved(MouseEvent e) {
			  double x = view.getMapGeoPoint().getX();
			  double y = view.getMapGeoPoint().getY();
			  statusbar.setText("X="+(int)x+"  Y="+(int)y);		  
			}
		});
	}
	
	
	/** Add a new Theme with the given name to the viewer, and the kind of DataSource. */
	private void addTheme (Theme t, String sourcetype, DataSource source) {
		
		// init theme properties
		 ObjectViewerThemeProperties objectViewerThemeProperties =
			new ObjectViewerThemeProperties(this, t, sourcetype, source, THEME_SELECTION, THEME_VISIBILITY);

		// fill vectors of themes and theme properties
		themesPropertiesList.add(objectViewerThemeProperties);
		activeThemes.add(t);

		// Init
		initTheme(t,objectViewerThemeProperties );
		
		// Init "theme button"
		setThemeButton(themesPropertiesList.size()-1, objectViewerThemeProperties);

		// Add theme to geotools viewer
		view.addTheme(t);
		view.setThemeIsVisible(t, THEME_VISIBILITY, true);
		panel_themes.revalidate();
		panel_themes.repaint();
		
		// Gestion de l'ordre d'affichage
		for (int i=0; i<themesPropertiesList.size(); i++) {
			Theme th = ((ObjectViewerThemeProperties)themesPropertiesList.get(i)).getObjectViewerTheme();
			view.setThemeWaighting(th,-i);
		}		
	}
	
	
	/** Refresh theme at the given index. */
	private void setTheme (Theme t, String sourcetype, DataSource source, int index, boolean active, boolean visible) {

		// init theme properties
		 ObjectViewerThemeProperties objectViewerThemeProperties =
			new ObjectViewerThemeProperties(this, t, sourcetype, source, active, visible);
					
		// fill vectors of themes and theme properties
		themesPropertiesList.set(index,objectViewerThemeProperties);

		// Init
		initTheme(t,objectViewerThemeProperties );
		
		// Remove "theme button" and init new one
		panel_themes.remove(index);
		setThemeButton(index, objectViewerThemeProperties);

		// Add theme to geotools viewer
		view.addTheme(t);
		view.setThemeIsVisible(t, visible, true);
		panel_themes.revalidate();
		panel_themes.repaint();
	}
	
	
	private void initTheme(Theme t, ObjectViewerThemeProperties objectViewerThemeProperties ) {
		
		// Add a Shader	
		t.setShader(new MonoShader(objectViewerThemeProperties.getFillInThemeColor()));
			
		// Add a HighlightManager
		t.setHighlightManager(new HighlightManager());		
		ShadeStyle themeHighlightShadeStyle = new ShadeStyle();
		themeHighlightShadeStyle.setFillColor(
			objectViewerThemeProperties.getFillInHighlightColor());
		themeHighlightShadeStyle.setLineColor(
			objectViewerThemeProperties.getOutlineHighlightColor());
		t.setHighlightStyle(themeHighlightShadeStyle);
		objectViewerThemeProperties.setThemeHighlightManager(t.getHighlightManager());
				
		// Add a SelectionManager
		SelectionManager themeSelectMgr = new SelectionManager();
		ShadeStyle themeSelectShadeStyle = new ShadeStyle();
		themeSelectShadeStyle.setFillColor(

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -