[Gvsig_desarrolladores] fichas automatizadas
Cesar Escribano
cescriba en gmail.com
Mar Sep 15 09:21:47 CEST 2009
Hola Robert.
Yo he resuelto el problema de fichas automatizadas en la versión 1.1.2 de
gvSIG.
Yo tengo un objeto cuyas propiedades almacenan la información que se va a
mostrar en la ficha (fichagrafica).
este objeto se lo paso a mi ficha gráfica.
La extensión hace una instancia a un objeto MuestraFichaGrafica. el método
mostrar se encarga de mostrar la ficha gráfica. El fichero .gvt ha de
existir previamente. Lo generas desde gvSIG como usuario.
/**
* *Muestra* *la* *Ficha* *Gráfica* *del* *tipo* *solicitado* *en* *función*
*de* *la* *selección* *del* *usuario
*
* *Si* *tipo*=1 --> El *usuario* *quiere* *sacar* *ficha* *gráfica* General
* *Si* *tipo*=2 --> El *usuario* *quiere* *sacar* *ficha* *gráfica* *De* *
Parcela
*
* *Si* *tipo*=3 --> El *usuario* *quiere* *sacer* *ficha* *gráfica* *De* *
Capas* o *de* DosCapas
*
* *@author* *César* *Escribano* *Hernández
*
*/
*
public* *class* MuestraFichaGrafica {
File directorioRelativo = *null*;
String rutaPlantilla="";
File xmlFile =*null*;
FileReader reader=*null*;
*public* MuestraFichaGrafica(String nombrePlantilla) {
directorioRelativo = *new* File("");
rutaPlantilla=directorioRelativo.getAbsolutePath()+"\\"+nombrePlantilla;
xmlFile = *new* File(rutaPlantilla);
// try {
// reader = new FileReader(xmlFile);
// } catch (FileNotFoundException e) {
// *TODO* Auto-generated catch block
// e.printStackTrace();
// }
}//Fin *del* constructor
*public* *void* mostrar(FichaGrafica fg,*int* tipo){
*try* {
reader = *new* FileReader(xmlFile);
XmlTag tag;
tag = (XmlTag) XmlTag.*unmarshal*(reader);
Project p =((ProjectExtension)PluginServices.*getExtension*
(ProjectExtension.*class*)).getProject();
Layout layout;
layout = Layout.*createLayout*(*new* XMLEntity(tag),p);
//*Recorremos* *los* frames *del* layout y *los* *cargamos* *en* *un* array
IFFrame[] frames=layout.getLayoutContext().getFFrames();
//*Dar* valor *al* tag *provinciatag
*
IFFrame texto=getFFrameByTag("provinciatag",layout, frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText("PROVINCIA :"+fg.getProvincia());
//*Dar* valor *al* tag *operadortag
*
texto = getFFrameByTag("operadortag",layout, frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText("OPERADOR :"+fg.getOperador());
//*Dar* valor *al* tag *projcstag
*
texto = getFFrameByTag("projcstag",layout, frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText("SIST. REF.:"+fg.getProjcs());
//*Dar* valor *al* tag *datumtag
*
texto = getFFrameByTag("datumtag",layout, frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText("DATUM :"+fg.getDatum());
//*Dar* valor *al* tag *spheroidtag
*
texto = getFFrameByTag("spheroidtag",layout, frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText("ELIPSOIDE :"+fg.getSpheroid());
//*Dar* valor *al* tag *projectiontag
*
texto = getFFrameByTag("projectiontag",layout, frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText("PROYECCIÓN:"+fg.getProjection());
//*Dar* valor *al* tag *escalatag
*
texto = getFFrameByTag("escalatag",layout, frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText("ESCALA : 1 / "+fg.getEscalaV1());
//*Dar* valor *al* tag *vistatag* e *imponer* *la* *escala* anterior
IFFrame vista=getFFrameByTag("vistatag",layout, frames);
ProjectView pv=(ProjectView)p.getDocumentsByType(ProjectViewFactory.*
registerName*).get(0);
((FFrameView)vista).setView(pv);
((FFrameView)vista).setTypeScale(FFrameView.*MANUAL*);
((FFrameView)vista).setScale(Double.*valueOf*
(fg.getEscalaV1()).doubleValue());//*Transformamos* el String *escala* a *
tipo* double
((FFrameView)vista).refresh();
//*Dar* valor *al* tag *fechatag
*
IFFrame fecha = getFFrameByTag("fechatag",layout, frames);
((FFrameText)fecha).clearText();
// Date date=new Date();
// ((FFrameText)*fecha*).addText("FECHA
:"+DateFormat.getDateInstance().format(date));
((FFrameText)fecha).addText("FECHA :"+fg.getFecha());
//*Dar* valor *al* tag *logotag
*
String rutaEscudo = directorioRelativo.getAbsolutePath()+
"\\images\\logo_indra.png";
IFFrame escudo=getFFrameByTag("logotag",layout,frames);
((FFramePicture)escudo).load(rutaEscudo);
// ********** //*Si* *se* *quiere* *sacar* *una* *ficha* *gráfica* *De* *
Parcela* (*Tipo* 2) // *********
*if* (tipo==2){
//*Dar* valor *al* tag escalatag
texto = getFFrameByTag("escalaparcelatag",layout, frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText("ESCALA : 1 / "+fg.getEscalaV2());
//Dar valor al tag vistaparcelatag
vista=getFFrameByTag("vistaparcelatag",layout, frames);
pv=(ProjectView)p.getDocumentsByType(ProjectViewFactory.*registerName*
).get(1);
((FFrameView)vista).setView(pv);
//((FFrameView)vista).setTypeScale(FFrameView.AUTOMATICO);
((FFrameView)vista).setTypeScale(FFrameView.*MANUAL*);
((FFrameView)vista).setScale(Double.*valueOf*
(fg.getEscalaV2()).doubleValue());//Transformamos el String escala a tipo
double
((FFrameView)vista).refresh();
//Dar valor al tag codparcelatag
texto = getFFrameByTag("codparcelatag",layout,frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText(fg.getCodParcela());
//Dar valor al tag areaparcelatag
texto = getFFrameByTag("areaparcelatag",layout,frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText(fg.getAreaParcela());
//Dar valor al tag perimetro
texto = getFFrameByTag("perimetroparcelatag",layout,frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText(fg.getPerimetroParcela());
}//Fin del if de Tipo = 2.
*if* (tipo==3){
//Dar valor al tag escalatag
texto = getFFrameByTag("escalatag",layout, frames);
((FFrameText)texto).clearText();
((FFrameText)texto).addText("ESCALA : 1 / "+fg.getEscalaV2());
//Dar valor al tag vistatag e imponer la escala anterior
vista=getFFrameByTag("vistatag",layout, frames);
pv=(ProjectView)p.getDocumentsByType(ProjectViewFactory.*registerName*
).get(1);
((FFrameView)vista).setView(pv);
((FFrameView)vista).setTypeScale(FFrameView.*MANUAL*);
((FFrameView)vista).setScale(Double.*valueOf*
(fg.getEscalaV2()).doubleValue());//Transformamos el String escala a tipo
double
((FFrameView)vista).refresh();
IFFrame leyenda = getFFrameByTag("leyendatag",layout,frames);
((FFrameLegend)leyenda).setViewing(1);
//Añadir el código necesario específico para fichas gráficas tipo 3
(plantillacapas.gvt)
}
ProjectMap pmap = ProjectFactory.*createMap*("Ficha");
layout.setProjectMap(pmap);
PluginServices.*getMDIManager*().addWindow(layout);
} *catch* (OpenException e) {
// *TODO* Auto-generated catch block
e.printStackTrace();
} *catch* (ValidationException e1) {
e1.printStackTrace();
} *catch* (FileNotFoundException e) {
e.printStackTrace();
} *catch* (org.exolab.castor.xml.MarshalException e) {
e.printStackTrace();
}
}//Fin de la funcion mostrar
*private* IFFrame getFFrameByTag(String string,Layout layout,IFFrame[]
frames) {
*for* (*int* i = 0; i < frames.length; i++) {
*if*(frames[i].getTag()!=*null* && frames[i].getTag().equals(string)){
*return* frames[i];
}
}
*return* *null*;
}//Fin del método getFFrameByTag
}
El 15 de septiembre de 2009 00:23, Elder Robert Zavaleta Veneros <
erobert_zv en hotmail.com> escribió:
>
> Hola nuevamente:
> alguien me puede ayudar o decirme como crear fichas automatizadas se que se
> crea con el documento MAPAS
> pero quisiera crearme una plantilla y pasarle datos desde una extencion que
> estoy desarrollando
>
> gracias de ante mano:
>
> atte.
> Robert Zavaleta
>
>
>
> ------------------------------
> From: erobert_zv en hotmail.com
> To: gvsig_desarrolladores en listserv.gva.es;
> gvsig_desarrolladores en runas.cap.gva.es
> Subject: fichas automatizadas
> Date: Thu, 10 Sep 2009 13:37:56 -0500
>
>
> Hola nuevamente:
> una consulta revisando la docuemntacion del portal, he visto que se puden
> crear fichas automatizadas(reportes),
> me podrian ayudar con este nuevo reto.
>
> gracias de ante mano:
>
> atte.
> Robert Zavaleta
>
> ------------------------------
> From: erobert_zv en hotmail.com
> To: gvsig_desarrolladores en runas.cap.gva.es
> Subject: RE: imprimir mapas
> Date: Wed, 9 Sep 2009 13:56:47 -0500
>
> hola a todos:
> favor ayuden con lo expuesto
>
> atte.
> Robert Zavaleta
>
>
> ------------------------------
> From: erobert_zv en hotmail.com
> To: gvsig_desarrolladores en runas.cap.gva.es
> Subject: imprimir mapas
> Date: Tue, 8 Sep 2009 17:15:10 -0500
>
> hola a todos:
> una consulta estoy intentando desarrollar una extencion en gvSIG que va ha
> permir
> imprimir un mapa, lo estoy desarrollando con la clase FFRAME, pero no se
> como configurar
> la plantilla(.gvt) para que reciba para los parametros por codigo.
>
> agradezco de ante mano su ayuda
>
> Robert Zavaleta
>
>
> ------------------------------
> See all the ways you can stay connected to friends and family<http://www.microsoft.com/windows/windowslive/default.aspx>
> ------------------------------
> check out the rest of the Windows Live™. More than mail–Windows Live™ goes
> way beyond your inbox. More than messages<http://www.microsoft.com/windows/windowslive/>
> ------------------------------
> Share your memories online with anyone you want anyone you want.<http://www.microsoft.com/middleeast/windows/windowslive/products/photos-share.aspx?tab=1>
> ------------------------------
> See all the ways you can stay connected to friends and family<http://www.microsoft.com/windows/windowslive/default.aspx>
>
> _______________________________________________
> gvSIG_desarrolladores mailing list
> gvSIG_desarrolladores en listserv.gva.es
> http://listserv.gva.es/cgi-bin/mailman/listinfo/gvsig_desarrolladores
>
>
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: http://listserv.gva.es/pipermail/gvsig_desarrolladores/attachments/20090915/3444e8b1/attachment.htm
More information about the gvSIG_desarrolladores
mailing list