[Gvsig_desarrolladores] Visualizar el mapOverview

Sergio Piñón Campañó sergiopinhon en gmail.com
Lun Ago 11 22:51:15 CEST 2008


Hola, estoy desarrollando una extensión para la gestíon de empresas y no soy 
capaz de hacer que se dibuje el mapOverview en la vista. Al iniciar la 
extensión creo la vista y cargo las capas desde la BD y se muestran 
correctamente en la vista pero en la ventanita del mapOverview no se muestra 
nada. Depurando vi que en el mapContext si que aparece un mapOverview 
asociado al correspondiente MapControl.
¿Alguien me puede ayudar?
Muchas gracias.
Este es el código donde creo el Proyecto:


/****************************************************************************
 *   Copyright (C) 2008 by Sergio Piñón Campañó  						*
 *   sergiopinhon en gmail.com   										*
 *                                                                         														   	
*
 *   This program is free software; you can redistribute it and/or modify  		   	
*
 *   it under the terms of the GNU General Public License as published by  	   	
*
 *   the Free Software Foundation; either version 2 of the License, or     		   	
*
 *   (at your option) any later version.                                   									
*
 *                                                                         															
*
 *   This program 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 General Public License for more details.                          						
*
 *                                                                         															
*
 *   You should have received a copy of the GNU General Public License     		*
 *   along with this program; if not, write to the                         								
*
 *   Free Software Foundation, Inc.,                                       									
*
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             			
*
 ***************************************************************************/
package proyecto;

import java.awt.Component;
import java.util.ArrayList;

import javax.swing.JOptionPane;

import com.iver.andami.PluginServices;
import com.iver.andami.ui.mdiManager.IWindow;
import com.iver.cit.gvsig.fmap.MapContext;
import com.iver.cit.gvsig.fmap.MapControl;
import com.iver.cit.gvsig.project.Project;
import com.iver.cit.gvsig.project.documents.ProjectDocument;
import com.iver.cit.gvsig.project.documents.view.MapOverview;
import com.iver.cit.gvsig.project.documents.view.ProjectView;
import com.iver.cit.gvsig.project.documents.view.ProjectViewFactory;
import com.iver.cit.gvsig.project.documents.view.gui.View;
import 
com.iver.cit.gvsig.project.documents.view.toolListeners.MapOverviewChangeZoomListener;
import com.iver.utiles.extensionPoints.ExtensionPoint;
import com.iver.utiles.extensionPoints.ExtensionPoints;
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;

import controlador.Controlador;

/**
 * @author Sergio Piñón Campañó
 *
 */

/**
 * Clase singleton utilizada para la creación de un proyecto al iniciar la 
guia de empresas
 */
public class ProyectoEmpresas extends Project{
	/**
	 * 
	 */
	private static final long serialVersionUID = 7951655722940671380L;
	//referencia a la instancia del proyecto
	private static ProyectoEmpresas instancia;
	
	/*la vista asociada con este proyecto*/
	private View vista;
	
	/**
	 * 	Devuelve una instancia del proyecto, si éste todavía no fue creado
	 * se crea uno.
	 * Las tablas a cargar se obtienen de la clase Configuracion
	 * 
	 * @return el proyecto de empresas
	 */ 
	public static synchronized ProyectoEmpresas getProyecto() {
		if(instancia == null)
			instancia = new ProyectoEmpresas();
		return instancia;
	}
	
	
	private ProyectoEmpresas() {
		super();
		try {
			this.setName("empreSIX");
			//creamos un documento de tipo vista para añadir a nuestro proyecto
			ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
			ExtensionPoint extensionPoint 
=(ExtensionPoint)extensionPoints.get("Documents");
			ProjectViewFactory projectViewFactory = (ProjectViewFactory) 
extensionPoint.create("ProjectView");
			ProjectDocument documento = projectViewFactory.create(this);
			documento.setProjectDocumentFactory(projectViewFactory);
			this.addDocument(documento);
			this.abrir();
			
			//cargamos las capas desde las  tablas de la BD
			CargadorCapas cargador = new CargadorCapas();			
			for(String nombreTabla : Controlador.getConfiguracion().getTablas() )
				cargador.cargarTabla( nombreTabla, vista.getMapControl(), vista);
			
			//creamos el mapOverView para añadir a la vista
			//MapOverview mapOverview = new MapOverview(vista.getMapControl());
			//mapOverview.setModel(vista.getMapControl().getMapContext());
			//mapOverview.setVisible(true);
			//y lo añadimos al ProjectView
			
			System.out.println("");
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	
	public View getVista() {
		return vista;
	}
	
	
	
	
	/**
	 * Crea la ventana de un nuevo project view
	 * @todo: modificarlo y ponerlo "bien bien"
	 */
	private void abrir() {

		String s=this.getName();

		ProjectDocument doc=(ProjectDocument)this.getDocuments().get(0);
		doc.setName(s);
		IWindow window=doc.createWindow();
		
		if (window == null){
			JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), 
PluginServices.getText(this, "error_opening_the_document"));
			return;
		}
		vista =(View) window;
	}
	
}
-- 
Un saludo,
	Sergio.



Más información sobre la lista de distribución gvSIG_desarrolladores