// **********************************************************************
//
//
* Layers implement the ProjectionListener interface to listen for
* ProjectionEvents. When the projection changes, they may need to
* refetch, regenerate their graphics, and then repaint themselves
* into the new view.
*/
public class PuntitosLayer extends Layer {
class Nodo
{
int Referencia;
String Nombre;
Localizacion Local;
int Tipo;
AtributosNodo AtriNo;
String InfoAdicional;
}
class XY
{
boolean Val;
float X;
float Y;
}
class LatLon
{
boolean Val;
float Lat;
float Lon;
}
class utmXY
{
boolean Val;
float UtmX;
float UtmY;
char Letra;
int Num;
String Elipse;
}
class Localizacion
{
XY SysXY;
LatLon SysLatLon;
utmXY SysUtmXY;
}
class AtributosNodo
{
float Radio;
float Color;
}
protected OMGraphicList graphics;
/**
* Construct the layer.
*/
public PuntitosLayer () {
super();
graphics = new OMGraphicList(11);
createGraphics(graphics);
}
/**
* Sets the properties for the Layer. This allows
* Layers to get a richer set of parameters than the
* setArgs method.
* @param prefix the token to prefix the property names
* @param props the Properties object
*/
public void setProperties(String prefix, java.util.Properties props) {
super.setProperties(prefix, props);
}
/**
* Invoked when the projection has changed or this Layer has been
* added to the MapBean.
* @param e ProjectionEvent
*/
public void projectionChanged (ProjectionEvent e) {
graphics.generate(e.getProjection());
repaint();
}
/**
* Paints the layer.
* @param g the Graphics context for painting
*/
public void paint (Graphics g) {
graphics.render(g);
}
/**
* Create graphics.
*/
protected void createGraphics (OMGraphicList list) {
// NOTE: all this is very non-optimized...
//Declaracion de tipos
//Por municipio
String muni = null;
float utmMuniX;
float utmMuniY;
int radMuni;
int habitantes;
int numNodos;
int coda;
String ruta=null;
String s=null;
//lectura desde fichero Porti
try{
File miFichero;
miFichero = new File("c:\\gis\\ficheros\\f1.txt");
// miFichero = new File("c:\\gis\\ficheros\\fa.txt");
// miFichero = new File("c:\\gis\\porti\\Cantabria3\\Santander\\Santander_deploy.txt");
// miFichero = new File("c:\\gis\\porti\\Cantabria3\\Pielagos\\Pielagos_deploy.txt");
//Se crea canal de entrada para leer datos
FileInputStream canalentrada = new FileInputStream(miFichero);
byte bt[] = new byte[(int)miFichero.length()];
canalentrada.read(bt);
s = new String(bt);
canalentrada.close();
} catch(IOException e){
e.printStackTrace();}
StringTokenizer cortador;
cortador = new StringTokenizer(s);
//////Datos por Municipio
muni = cortador.nextToken().toString();
utmMuniX = (new Float(cortador.nextToken().toString())).floatValue();
utmMuniY = (new Float(cortador.nextToken().toString())).floatValue();
radMuni = Integer.parseInt(cortador.nextToken().toString());
habitantes = Integer.parseInt(cortador.nextToken().toString());
numNodos = Integer.parseInt(cortador.nextToken().toString());
coda = Integer.parseInt(cortador.nextToken().toString());
if (coda!=0)
ruta = cortador.nextToken().toString();
System.out.print(muni + "\t" + utmMuniX + "\t" +utmMuniY + "\t" + radMuni);
System.out.println("\t" + habitantes + "\t" + numNodos + "\t" + coda);
//////Datos por cada celula del municipio
//////Declaracion de tipos
Nodo[] Nodos= new Nodo[numNodos];
LatLonPoint[] latlonpt = new LatLonPoint[numNodos];
int nod=0;
while (cortador.hasMoreTokens())
{
System.out.println("gets till here");
Nodos[nod].Referencia = Integer.parseInt(cortador.nextToken().toString());
System.out.println("doesn´t let the assignation");
Nodos[nod].Nombre = cortador.nextToken().toString();
// Nodos[nod].Local.SysLatLon.Val = true;
// Nodos[nod].Local.SysLatLon.X = (new Float(cortador.nextToken().toString())).floatValue();
// Nodos[nod].Local.SysLatLon.Y = (new Float(cortador.nextToken().toString())).floatValue();
Nodos[nod].Local.SysUtmXY.Val = true;
Nodos[nod].Local.SysUtmXY.UtmX = (new Float(cortador.nextToken().toString())).floatValue();
Nodos[nod].Local.SysUtmXY.UtmY = (new Float(cortador.nextToken().toString())).floatValue();
Nodos[nod].Local.SysUtmXY.Letra = 'T';
Nodos[nod].Local.SysUtmXY.Num = 30;
Nodos[nod].Local.SysUtmXY.Elipse = "WGS_84";
Nodos[nod].Tipo = Integer.parseInt(cortador.nextToken().toString());
Nodos[nod].AtriNo.Radio = (new Float(cortador.nextToken().toString())).floatValue();
Nodos[nod].AtriNo.Color = (new Float(cortador.nextToken().toString())).floatValue();
Nodos[nod].InfoAdicional = "Este es un nodo";
// System.out.print(nombre[nod] + "\t" + utmx[nod] + "\t" +utmy[nod] + "\t" + nivel[nod]);
// System.out.println(radio[nod] + "\t" + trafErl[nod] + "\t" +trafKb[nod]);
nod++;
}
OMCircle circle;
UTMPoint utmpt;
for (int i=0; i