From 052bd643008431b447e60ebc05b11b3776c7dc16 Mon Sep 17 00:00:00 2001 From: Stefano Date: Sun, 14 Mar 2010 22:59:19 +0100 Subject: [PATCH] Suddivided into DataSource Layer and MainLayer. Correct bugs with the fetch of js files. Added some features. --- src/data/latlon.js | 54 +- src/data/log.txt | 2 +- src/freimapgsoc/DataSource.java | 6 +- src/freimapgsoc/LatLonJsDataSource.java | 437 ++++++----- src/freimapgsoc/Layer.java | 81 +- src/freimapgsoc/MainLayer.form | 504 +++++++++---- src/freimapgsoc/MainLayer.java | 830 +++++++++++---------- src/freimapgsoc/MysqlDataSource.java | 7 +- src/freimapgsoc/NodeLayer.java | 3 +- src/freimapgsoc/OlsrdDataSource.java | 6 +- src/freimapgsoc/Start.form | 27 +- src/freimapgsoc/Start.java | 96 ++- src/freimapgsoc/YamlDataSource.java | 7 +- src/freimapgsoc/log.java | 2 +- src/freimapgsoc/resources/Start.properties | 5 +- src/freimapgsoc/xmlDataSource.java | 7 +- {src => test}/freimapgsoc/LayerForm.form | 0 {src => test}/freimapgsoc/LayerForm.java | 9 - {src => test}/freimapgsoc/addNode.form | 0 {src => test}/freimapgsoc/addNode.java | 0 20 files changed, 1222 insertions(+), 861 deletions(-) rename {src => test}/freimapgsoc/LayerForm.form (100%) rename {src => test}/freimapgsoc/LayerForm.java (99%) rename {src => test}/freimapgsoc/addNode.form (100%) rename {src => test}/freimapgsoc/addNode.java (100%) diff --git a/src/data/latlon.js b/src/data/latlon.js index d932eff..71e2676 100755 --- a/src/data/latlon.js +++ b/src/data/latlon.js @@ -10,52 +10,50 @@ Mid('104.128.30.8','104.128.30.7'); Mid('77.87.50.66','77.87.50.81'); Mid('77.87.50.82','77.87.50.67'); Node('77.87.48.35',52.863804,12.553408,0,'0.0.0.0','StefanoGSoC'); -Node('77.87.50.72',52.546024,13.314249,0,'0.0.0.0','FhGrbaussen'); +Node('77.87.50.72',52.546024,13.314249,1,'0.0.0.0','FhGrbaussen'); Node('77.87.50.70',52.516031,13.314318,0,'0.0.0.0','wrap-roof'); Node('77.87.50.125',52.592260,13.327054,0,'0.0.0.0','tu-fokus'); Node('77.87.50.71',52.576024,13.314549,0,'0.0.0.0','FhGrbmittig'); Node('104.128.30.21',52.525982,13.314444,0,'0.0.0.0','relet'); Node('77.87.50.121',52.544476,13.352702,0,'0.0.0.0','tfh-test'); Node('77.87.50.66',52.525986,13.314315,0,'0.0.0.0','fokus-3009'); -Node('77.87.50.82',52.525986,13.314317,0,'0.0.0.0','hertz'); -Node('104.128.30.22',52.525923,13.314374,0,'0.0.0.0','104-128-30-22'); -Node('104.128.30.23',52.533921,13.314374,0,'0.0.0.0','Prova1'); +Node('77.87.50.82',52.525986,13.314317,1,'0.0.0.0','hertz'); +Node('104.128.30.21',52.525923,13.314374,0,'0.0.0.0','PincoPallino'); +Node('104.128.30.8',52.533921,13.314374,1,'77.87.50.121','Prova1'); Node('104.128.30.24',52.545525,13.314374,0,'0.0.0.0','Prova2'); -Node('104.128.30.25',52.55925,13.324374,0,'0.0.0.0','Prova3'); -Node('104.128.30.26',52.521925,13.374374,0,'0.0.0.0','Prova4'); - +Node('77.87.48.78',52.55925,13.324374,0,'0.0.0.0','Prova3'); +Node('104.128.30.51',52.521925,13.374374,0,'0.0.0.0','Prova4'); Link('77.87.50.121','104.128.30.8',1.000,1.000,1.000); -PLink('104.128.30.22','104.128.30.21',1.000,0.408,2.452,52.525982,13.314444,0,52.525925,13.314374,0); Link('104.128.30.51','104.128.30.21',1.000,0.420,2.383); -PLink('104.128.30.21','104.128.30.22',0.431,1.000,2.318,52.525925,13.314374,0,52.525982,13.314444,0); -Link('104.128.30.51','104.128.30.22',0.851,0.918,1.281); -PLink('77.87.50.66','104.128.30.22',0.655,0.929,1.643,52.525925,13.314374,0,52.525986,13.314315,0); +Link('104.128.30.51','104.128.30.21',0.851,0.918,1.281); Link('77.87.48.78','77.87.48.35',0.165,0.596,10.186); Link('104.128.30.21','104.128.30.51',0.420,1.000,2.383); -Link('104.128.30.22','104.128.30.51',0.910,0.839,1.310); -PLink('104.128.30.22','77.87.50.66',0.933,0.675,1.588,52.525986,13.314315,0,52.525925,13.314374,0); -PLink('77.87.50.70','77.87.50.66',0.984,1.000,1.016,52.525986,13.314315,0,52.526031,13.314318,0); -PLink('77.87.50.71','77.87.50.66',1.000,1.000,1.000,52.525986,13.314315,0,52.526024,13.314249,0); -PLink('77.87.50.72','77.87.50.66',1.000,1.000,1.000,52.525986,13.314315,0,52.526024,13.314249,0); +Link('104.128.30.21','104.128.30.51',0.910,0.839,1.310); Link('77.87.48.78','77.87.50.66',1.000,1.000,1.000); -PLink('77.87.50.82','77.87.50.66',1.000,1.000,1.000,52.525986,13.314315,0,52.525986,13.314317,0); -PLink('77.87.50.66','77.87.50.72',1.000,1.000,1.000,52.526024,13.314249,0,52.525986,13.314315,0); -PLink('77.87.50.70','77.87.50.72',0.984,1.000,1.016,52.526024,13.314249,0,52.526031,13.314318,0); -PLink('77.87.50.71','77.87.50.72',1.000,1.000,1.000,52.526024,13.314249,0,52.526024,13.314249,0); Link('77.87.48.78','77.87.50.72',1.000,1.000,1.000); -PLink('77.87.50.82','77.87.50.72',1.000,1.000,1.000,52.526024,13.314249,0,52.525986,13.314317,0); -PLink('77.87.50.125','77.87.50.72',0.973,0.969,1.062,52.526024,13.314249,0,52.512260,13.327054,0); Link('77.87.48.35','77.87.48.78',0.596,0.945,1.775); Link('77.87.50.66','77.87.48.78',1.000,1.000,1.000); Link('77.87.50.70','77.87.48.78',1.000,1.000,1.000); Link('77.87.50.71','77.87.48.78',1.000,1.000,1.000); Link('77.87.50.72','77.87.48.78',1.000,1.000,1.000); Link('77.87.50.82','77.87.48.78',1.000,1.000,1.000); -PLink('77.87.50.66','77.87.50.82',1.000,1.000,1.000,52.525986,13.314317,0,52.525986,13.314315,0); -PLink('77.87.50.70','77.87.50.82',0.988,1.000,1.012,52.525986,13.314317,0,52.526031,13.314318,0); -PLink('77.87.50.71','77.87.50.82',1.000,1.000,1.000,52.525986,13.314317,0,52.526024,13.314249,0); -PLink('77.87.50.72','77.87.50.82',1.000,1.000,1.000,52.525986,13.314317,0,52.526024,13.314249,0); +Link('104.128.30.21','104.128.30.21',1.000,0.408,2.452); +Link('77.87.50.66','104.128.30.21',0.655,0.929,1.643); +Link('104.128.30.21','104.128.30.21',0.431,1.000,2.318); +Link('77.87.50.66','77.87.50.82',1.000,1.000,1.000); +Link('77.87.50.70','77.87.50.82',0.988,1.000,1.012); +Link('77.87.50.71','77.87.50.82',1.000,1.000,1.000); +Link('77.87.50.72','77.87.50.82',1.000,1.000,1.000); +Link('77.87.50.82','77.87.50.72',1.000,1.000,1.000); +Link('77.87.50.125','77.87.50.72',0.973,0.969,1.062); +Link('77.87.50.82','77.87.50.66',1.000,1.000,1.000); +Link('77.87.50.66','77.87.50.72',1.000,1.000,1.000); +Link('77.87.50.70','77.87.50.72',0.984,1.000,1.016); +Link('77.87.50.71','77.87.50.72',1.000,1.000,1.000); +Link('104.128.30.21','77.87.50.66',0.933,0.675,1.588); +Link('77.87.50.70','77.87.50.66',0.984,1.000,1.016); +Link('77.87.50.71','77.87.50.66',1.000,1.000,1.000); +Link('77.87.50.72','77.87.50.66',1.000,1.000,1.000); Link('77.87.48.78','77.87.50.82',1.000,1.000,1.000); Link('104.128.30.8','77.87.50.121',1.000,1.000,1.000); -PLink('77.87.50.71','77.87.50.121',0.922,0.937,1.158,52.544476,13.352702,0,52.526024,13.314249,0); -PLink('77.87.50.72','77.87.50.125',0.969,0.976,1.057,52.512260,13.327054,0,52.526024,13.314249,0); + diff --git a/src/data/log.txt b/src/data/log.txt index 5439380..17d52b3 100644 --- a/src/data/log.txt +++ b/src/data/log.txt @@ -1 +1 @@ -XML Broken. Not Valid. \ No newline at end of file +Problem with loading components in MainLayer.java: e.getmessage() \ No newline at end of file diff --git a/src/freimapgsoc/DataSource.java b/src/freimapgsoc/DataSource.java index 96ee171..34c70e2 100755 --- a/src/freimapgsoc/DataSource.java +++ b/src/freimapgsoc/DataSource.java @@ -51,10 +51,6 @@ public interface DataSource { /** Initialize this data source with its configuration parameters. **/ public HashMap read_conf(HashMap configuration); - public String getId(); - - public String getCurrentID(); - /** Initialize this data source with path file. **/ //public void init(String path); /** @return A Vector of Nodes to be displayed. */ @@ -98,7 +94,7 @@ public interface DataSource { public MapNode getNodeByIp(String ip); - public Vector getLinks(long time); + public Vector getLinks(); /** @param dsl A DataSourceListener listening on events from this DataSource */ public Vector getLinksFromSource(String id); diff --git a/src/freimapgsoc/LatLonJsDataSource.java b/src/freimapgsoc/LatLonJsDataSource.java index e5b1ef8..657d889 100755 --- a/src/freimapgsoc/LatLonJsDataSource.java +++ b/src/freimapgsoc/LatLonJsDataSource.java @@ -21,15 +21,14 @@ */ public class LatLonJsDataSource implements DataSource { - public LatLonJsDataSource(){ - + public LatLonJsDataSource() { } - public LatLonJsDataSource(String path){ + public LatLonJsDataSource(String path) { this.init(path); } - public HashMap, Vector> init(String path) { + public void init(String path) { HashMap, Vector> config = new HashMap, Vector>(); String sServerURL = null; try { @@ -37,220 +36,262 @@ public HashMap, Vector> init(String path) { System.out.println("Fetching data from URL: " + sServerURL); System.out.println("This may take a while ... "); BufferedReader in = new BufferedReader(new InputStreamReader(new URL(sServerURL).openStream())); - while (true) { - line = in.readLine(); - //System.out.println("Line: " + line); - if (line == null) { - break;//if there aren't string in a file - } - //if substring is Node then add a node - if ((line.length() > 4) && (line.substring(0, 4).equals("Node"))) { - parseNode(); - } //if substring is Link then add a link - else if ((line.length() > 4) && (line.substring(0, 4).equals("Link"))) { - parseLink(); - //if substring is a PLink then add a PLink - } else if ((line.length() > 5) && (line.substring(0, 5).equals("PLink"))) { - parsePLink(); - } - //at the end add others interfaces - addInterfaces(path); + parseNode(sServerURL); + try { + Thread.sleep(500); // do nothing for 1000 miliseconds (1 second) + } catch (InterruptedException e) { + e.printStackTrace(); + } + //at the end add others interfaces + addInterfaces(path); + try { + Thread.sleep(500); // do nothing for 1000 miliseconds (1 second) + } catch (InterruptedException e) { + e.printStackTrace(); + } + parseLink(sServerURL); + try { + Thread.sleep(500); // do nothing for 1000 miliseconds (1 second) + } catch (InterruptedException e) { + e.printStackTrace(); } + // parsePLink(sServerURL); I nedd to know what Plink is! } catch (MalformedURLException mue) { System.out.println("failed! Invalid server URL: " + sServerURL); + mue.printStackTrace(); } catch (IOException ioe) { System.out.println("failed! IOException in LatLonJSDataSource"); ioe.printStackTrace(); } - addInterfaces(path); config.put(nodes, links); - Layer l=new Layer(this); - l.createLayer(); - return config; + Layer l = new Layer(config, this); } - public void parseNode() { - //PARSE NODE - StringTokenizer st = new StringTokenizer(line.substring(5, line.length() - 2), ",", false); - String ip = st.nextToken(); - double lat = Double.parseDouble(st.nextToken()); - double lon = Double.parseDouble(st.nextToken()); - int isgateway = Integer.parseInt(st.nextToken()); - String gatewayip = st.nextToken(); - String name = st.nextToken(); - - System.out.println("ip:" + stripQuotes(ip)); - //System.out.println("lat:" + lat); - //System.out.println("lon:" + lon); - //System.out.println("isgateway:" + isgateway); - //System.out.println("gatewayip:" + gatewayip); - //System.out.println("name:" + stripQuotes(name)); - - ip = stripQuotes(ip); //strip single quotes - name = stripQuotes(name); - gatewayip = stripQuotes(gatewayip); - - - // Use ip or coordinates as fqid if tooltip is missing - if (ip == null) { //i not need this but....! :-D - ip = null; - } - if (name == null) { - System.out.println("This node has no name!"); - if (ip == null) { - System.out.println("This node has no ip."); - System.out.println("I use (lat,lon) as name"); - name = lat + "," + lon; - } else { - System.out.println("I use ip as name"); - name = ip; - } - } - if (ip == null) { //we need at least one identifier - ip = name; - } + public void parseNode(String path) { + try { + BufferedReader in = new BufferedReader(new InputStreamReader(new URL(path).openStream())); + while (true) { + line = in.readLine(); + //System.out.println("Line: " + line); + if (line == null) { + break;//if there aren't string in a file + } //if substring is Node then add a node + if ((line.length() > 4) && (line.substring(0, 4).equals("Node"))) { - int index = getIndex(nodes, ip); - if (index != -1) { - if (isgateway == 1) { //if node is a Gateway - nodes.get(index).attributes.put("Gateway", "SELF"); //add attributes ("Gateway", "SELF") or ("Gateway", "OTHER:"+gatewayip) to attributes hash table of Node - } else { - nodes.get(index).attributes.put("Gateway", "OTHER: " + gatewayip); - } - nodes.get(index).ip = ip; - nodes.get(index).name = name; - //System.out.println("nnode.id:" + nodes.get(index).name); - //System.out.println("nnode: " + nodes.get(index)); - nodeByName.put(nodes.get(index).ip, nodes.get(index)); //add node to hashmap of nodebyname - System.out.println("node by name:" + nodeByName.values()); - } else if (index == -1) { - MapNode nnode; - if ((lat < -90d) || (lat > 90d) || (lon < -180d) || (lon > 180d)) { //obviously bogus. some people do that. - System.out.println("MapNode(" + ip + "," + name + ")"); - nnode = new MapNode(ip, name);//create a node with id=ip and name=fqid Default positions - } else { - System.out.println("MapNode(" + ip + "," + name + "." + lat + "," + lon + ")"); - - nnode = new MapNode(ip, name, lat, lon); //create a node with id=ip and name=fqid lat lon coordinates - } - nnode.ip = ip; - nnode.name = name; - if (isgateway == 1) { //if node is a Gateway - nnode.attributes.put("Gateway", "SELF"); //add attributes ("Gateway", "SELF") or ("Gateway", "OTHER:"+gatewayip) to attributes hash table of Node - } else { - nnode.attributes.put("Gateway", "OTHER: " + gatewayip); - } + //PARSE NODE + StringTokenizer st = new StringTokenizer(line.substring(5, line.length() - 2), ",", false); + String ip = st.nextToken(); + double lat = Double.parseDouble(st.nextToken()); + double lon = Double.parseDouble(st.nextToken()); + int isgateway = Integer.parseInt(st.nextToken()); + String gatewayip = st.nextToken(); + String name = st.nextToken(); + + System.out.println("IP Address: " + stripQuotes(ip)); + System.out.println("lat:" + lat); + System.out.println("lon:" + lon); + System.out.println("isgateway:" + isgateway); + System.out.println("gatewayip:" + gatewayip); + System.out.println("name:" + name); + + ip = stripQuotes(ip); //strip single quotes + name = stripQuotes(name); + gatewayip = stripQuotes(gatewayip); + + + // Use ip or coordinates as fqid if tooltip is missing + if (ip == null) { //i not need this but....! :-D + ip = null; + } + if (name == null) { + System.out.println("This node has no name!"); + if (ip == null) { + System.out.println("This node has also no ip."); + System.out.println("I use (lat,lon) as name"); + name = lat + "," + lon; + } else { + System.out.println("I use Ip Address as name"); + name = ip; + } + } + if (ip == null) { //we need at least one identifier + ip = name; + } - nodes.add(nnode);//add node to Vector "nodes" - // System.out.println("nnode.id(exist):" + nnode.name); - // System.out.println("nnode(exist): " + nnode); - nodeByName.put(nnode.name, nnode); //add node to hashmap of nodebyname - System.out.println("node by name(exist):" + nodeByName.values()); + int index = getIndex(nodes, ip); + if (index != -1) { + if (isgateway == 1) { //if node is a Gateway + nodes.get(index).attributes.put("Gateway", "SELF"); //add attributes ("Gateway", "SELF") or ("Gateway", "OTHER:"+gatewayip) to attributes hash table of Node + } else { + nodes.get(index).attributes.put("Gateway", "OTHER: " + gatewayip); + } + nodes.get(index).ip = ip; + nodes.get(index).name = name; + System.out.println("nnode.id:" + nodes.get(index).name); + System.out.println("nnode: " + nodes.get(index)); + nodeByIP.put(nodes.get(index).ip, nodes.get(index)); //add node to hashmap of nodebyname + System.out.println("node by name:" + nodeByIP.values()); + } else if (index == -1) { + MapNode nnode; + if ((lat < -90d) || (lat > 90d) || (lon < -180d) || (lon > 180d)) { //obviously bogus. some people do that. + System.out.println("MapNode(" + ip + "," + name + ")"); + nnode = new MapNode(ip, name);//create a node with id=ip and name=fqid Default positions + } else { + System.out.println("MapNode(" + ip + "," + name + "," + lat + "," + lon + ")"); + nnode = new MapNode(ip, name, lat, lon); //create a node with id=ip and name=fqid lat lon coordinates + } + nnode.ip = ip; + nnode.name = name; + if (isgateway == 1) { //if node is a Gateway + nnode.attributes.put("Gateway", "SELF"); //add attributes ("Gateway", "SELF") or ("Gateway", "OTHER:"+gatewayip) to attributes hash table of Node + } else { + nnode.attributes.put("Gateway", "OTHER: " + gatewayip); + } + + nodes.add(nnode);//add node to Vector "nodes" + System.out.println("nnode.id(exist):" + nnode.name); + System.out.println("nnode(exist): " + nnode); + nodeByName.put(nnode.name, nnode); //add node to hashmap of nodebyname + nodeByIP.put(nnode.ip,nnode);//add node to hashmap of nodebyip + System.out.println("Node by name (exist):" + nodeByName.values()); + System.out.println("Node by ip (exist):" + nodeByIP.values()); + } + } + } + } catch (Exception e) { } } - public void parseLink() { - //PARSE LINK - StringTokenizer stlink = new StringTokenizer(line.substring(5, line.length() - 2), ",", false); - String srclink = stlink.nextToken(); - String destlink = stlink.nextToken(); - System.out.println("SRCLINK: " + srclink); - System.out.println("DESTLINK: " + destlink); + public void parseLink(String path) { + try { + BufferedReader in = new BufferedReader(new InputStreamReader(new URL(path).openStream())); + while (true) { + line = in.readLine(); + //System.out.println("Line: " + line); + if (line == null) { + break;//if there aren't string in a file + } + if ((line.length() > 5) && (line.substring(0, 4).equals("Link"))) { + //PARSE LINK + StringTokenizer stlink = new StringTokenizer(line.substring(5, line.length() - 2), ",", false); + String srclink = stlink.nextToken(); + String destlink = stlink.nextToken(); + System.out.println("Src Link: " + srclink); + System.out.println("Dest Link: " + destlink); - double lqlink = Double.parseDouble(stlink.nextToken()); - double nlqlink = Double.parseDouble(stlink.nextToken()); - double etxlink = Double.parseDouble(stlink.nextToken()); + double lqlink = Double.parseDouble(stlink.nextToken()); + double nlqlink = Double.parseDouble(stlink.nextToken()); + double etxlink = Double.parseDouble(stlink.nextToken()); - System.out.println("lqLINK: " + lqlink); - System.out.println("nlqLINK: " + nlqlink); - System.out.println("etxLINK: " + etxlink); + System.out.println("Link Quality: " + lqlink); + System.out.println("Neighbor Link Quality: " + nlqlink); + System.out.println("Expected Transmission Count (ETX): " + etxlink); - srclink = stripQuotes(srclink); - destlink = stripQuotes(destlink); + srclink = stripQuotes(srclink); + destlink = stripQuotes(destlink); - MapNode nsrclink = nodeByName.get(srclink); - MapNode ndestlink = nodeByName.get(destlink); + MapNode nsrclink = nodeByIP.get(srclink); + MapNode ndestlink = nodeByIP.get(destlink); - if (nsrclink == null) { - System.err.println(srclink + " not found."); - } + if (nsrclink == null) { + System.err.println("Source Link: " + srclink + " not found."); + } - if (ndestlink == null) { - System.err.println(destlink + " not found."); - } + if (ndestlink == null) { + System.err.println("Destination Link: " + destlink + " not found."); + } - links.add(new Link(nsrclink, ndestlink, (float) lqlink, (float) nlqlink, (float) etxlink)); + links.add(new Link(nsrclink, ndestlink, (float) lqlink, (float) nlqlink, (float) etxlink)); + } + } + for (int i = 0; i < nodes.size(); i++) { + System.out.println("Nodes " + nodes.get(i).name + " has " + nodes.get(i).inter.size() + " interfaces"); + System.out.println(nodes.get(i).inter.toString()); + } + //System.out.println("nodes SIZE:" + nodes.size()); + //System.out.println("Links SIZE:" + links.size()); + System.out.println("finished."); + for (int i = 0; i < nodes.size(); i++) { + System.out.println("\n"); + System.out.println("Nodes " + nodes.get(i).name + " has: "); + System.out.println("ip:" + nodes.get(i).ip); + System.out.println("lat:" + nodes.get(i).lat); + System.out.println("lon:" + nodes.get(i).lon); + System.out.println("attributes:" + nodes.get(i).attributes); + System.out.println("uptime:" + nodes.get(i).uptime); + System.out.println("interfaces:" + nodes.get(i).inter.toString()); - for (int i = 0; i < nodes.size(); i++) { - System.out.println("Nodes " + nodes.get(i).name + " has " + nodes.get(i).inter.size() + " interfaces"); - System.out.println(nodes.get(i).inter.toString()); + } + } catch (Exception e) { + e.getMessage(); } - //System.out.println("nodes SIZE:" + nodes.size()); - //System.out.println("Links SIZE:" + links.size()); - System.out.println("finished."); - for (int i = 0; i < nodes.size(); i++) { - System.out.println("\n"); - System.out.println("Nodes " + nodes.get(i).name + " has: "); - System.out.println("ip:" + nodes.get(i).ip); - System.out.println("lat:" + nodes.get(i).lat); - System.out.println("lon:" + nodes.get(i).lon); - System.out.println("attributes:" + nodes.get(i).attributes); - System.out.println("uptime:" + nodes.get(i).uptime); - System.out.println("interfaces:" + nodes.get(i).inter.toString()); - } } - public void parsePLink() { + public void parsePLink(String path) { + try { + BufferedReader in = new BufferedReader(new InputStreamReader(new URL(path).openStream())); + while (true) { + line = in.readLine(); + //System.out.println("Line: " + line); + if (line == null) { + break;//if there aren't string in a file + } + //if substring is Link then add a link + if ((line.length() > 5) && (line.substring(0, 5).equals("PLink"))) { + //PARSE PLINK + StringTokenizer st = new StringTokenizer(line.substring(6, line.length() - 2), ",", false); + String src = st.nextToken(); + String dest = st.nextToken(); + System.out.println("SRC: " + stripQuotes(src)); + System.out.println("DEST: " + stripQuotes(dest)); - //PARSE PLINK - StringTokenizer st = new StringTokenizer(line.substring(6, line.length() - 2), ",", false); - String src = st.nextToken(); - String dest = st.nextToken(); - System.out.println("SRC: " + src); - System.out.println("DEST: " + dest); + double lq = Double.parseDouble(st.nextToken()); + double nlq = Double.parseDouble(st.nextToken()); + double etx = Double.parseDouble(st.nextToken()); - double lq = Double.parseDouble(st.nextToken()); - double nlq = Double.parseDouble(st.nextToken()); - double etx = Double.parseDouble(st.nextToken()); + System.out.println("lq: " + lq); + System.out.println("nlq: " + nlq); + System.out.println("etx: " + etx); - System.out.println("lq: " + lq); - System.out.println("nlq: " + nlq); - System.out.println("etx: " + etx); + src = stripQuotes(src); + dest = stripQuotes(dest); - src = stripQuotes(src); - dest = stripQuotes(dest); + MapNode nsrc = nodeByName.get(src); + MapNode ndest = nodeByName.get(dest); - MapNode nsrc = nodeByName.get(src); - MapNode ndest = nodeByName.get(dest); + links.add(new Link(nsrc, ndest, (float) lq, (float) nlq, false)); - if (nsrc == null) { - System.err.println(src + " not found."); - } - if (ndest == null) { - System.err.println(dest + " not found."); - } - links.add(new Link(nsrc, ndest, (float) lq, (float) nlq, false)); + if (nsrc == null) { + System.err.println("Source Node: " + src + " not found."); + } + if (ndest == null) { + System.err.println("Destination Node: " + dest + " not found."); + } + } + } + } catch (Exception e) { + e.getMessage(); + } } public void addInterfaces(String path) { System.out.println("Now take a control if nodes has more than one interface..."); - String sServerURL = null; + String sServerURL = path; try { - sServerURL = path; BufferedReader in = new BufferedReader(new InputStreamReader(new URL(sServerURL).openStream())); //PARSE MID while (true) { line = in.readLine(); //System.out.println("Line: " + line); - if (line == null || !(line.substring(0, 3).equals("Mid"))) { + if (line == null) { break;//if there aren't string in a file } if ((line.length() > 3) && (line.substring(0, 3).equals("Mid"))) { @@ -272,11 +313,11 @@ public void addInterfaces(String path) { MapNode nnode; nnode = new MapNode(nodeip, nodeip); //create a node with name=ip and Default Pos nodes.add(nnode); - System.out.println("Node Added now Nodes Size is: " + nodes.size()); + System.out.println("Node Added now Nodes structure Size is: " + nodes.size()); } else { - System.out.println("The node is present in Nodes"); - System.out.println("nodes name/interfaces:" + nodes.get(index).ip + "/" + nodes.get(index).inter.toString()); - if(!nodes.get(index).inter.contains(nodeip2)){ + System.out.println("The node is present in Nodes structure"); + System.out.println("Nodes name/interfaces:" + nodes.get(index).ip + "/" + nodes.get(index).inter.toString()); + if (!nodes.get(index).inter.contains(nodeip2)) { nodes.get(index).inter.add(nodeip2); } } @@ -373,10 +414,28 @@ public Vector getLinksFromDest(String dest) { return linksfd; } + @Override public Vector getNodeList() { return nodes; } + + + @Override + public void init() { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public HashMap read_conf(HashMap configuration) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Vector getLinks() { + return links; + } + //This method is DEPRECATED public MapNode getNodeById(String id) { for (int i = 0; i < nodes.size(); i++) { @@ -388,7 +447,7 @@ public MapNode getNodeById(String id) { } - public MapNode getNodeByIp(String ip) { + public MapNode getNodeByIp(String ip) { for (int i = 0; i < nodes.size(); i++) { if (nodes.elementAt(i).ip.equals(ip)) { return nodes.elementAt(i); @@ -401,35 +460,15 @@ public MapNode getNodeByIp(String ip) { public Vector getLinks(long time) { return links; } - - public static void main(String[] args) { - new LatLonJsDataSource("file:///var/run/latlon.js"); - } - + // public static void main(String[] args) { + // new LatLonJsDataSource("file:///var/run/latlon.js"); + // } private String line; public Vector nodes = new Vector(); public Vector links = new Vector(); public HashMap nodeByName = new HashMap(); + public HashMap nodeByIP= new HashMap(); public long initTime = System.currentTimeMillis() / 1000; - - @Override - public void init() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public HashMap read_conf(HashMap configuration) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getId() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getCurrentID() { - throw new UnsupportedOperationException("Not supported yet."); - } - + public int dsId = 0; } + diff --git a/src/freimapgsoc/Layer.java b/src/freimapgsoc/Layer.java index c638df0..b18f4c0 100644 --- a/src/freimapgsoc/Layer.java +++ b/src/freimapgsoc/Layer.java @@ -14,21 +14,23 @@ */ public class Layer { - public Layer(DataSource datasource){ - this.currentDs=datasource; - new MainLayer(currentDs).setVisible(true); + public Layer(HashMap, Vector> config,DataSource datasource) { + this.currentDS=datasource; + this.data = config; + this.id=generateNewID(); + createLayer(data,id); } - public Layer(HashMap, Vector> datasources) { - this.datasources = datasources; + public int getCurrentLayer() { + return this.id; } - public DataSource getCurrentDataSource() { - return this.currentDs; + public HashMap, Vector> getData(){ + return this.data; } - public HashMap getDataSources() { - return this.sources; + public HashMap, Vector>> getLayers() { + return this.layers; } /** @@ -41,31 +43,66 @@ public boolean setCurrentTime(long crtTime) { return false; } - - public void createLayer() { + public void createLayer(HashMap, Vector> data, int id) { try { - sources.put(this.id, currentDs.getCurrentID()); - Iterator j = sources.keySet().iterator(); - while (j.hasNext()) { - Double id = j.next(); - String source = sources.get(id); - } + //query al mysql per inserire i dati + initLayout(); + + } catch (Exception ex) { + ex.printStackTrace(); + return; + } + } + + public void UpdateLayer(HashMap, Vector> data, int id) { + //se sono uguali non aggiornare ma semplicemente crea aggiungi un id alle info giĆ  nel db + try { + layers.put(id, data); + initLayout(); + } catch (Exception ex) { ex.printStackTrace(); return; } } + public Vector getCurrentNodes(){ + return currentDS.getNodeList(); + } + + public MapNode getNodeByName(String name) { + try{ + for (int i = 0; i < currentDS.getNodeList().size(); i++) { + if (currentDS.getNodeList().elementAt(i).name.equals(name)) { + return currentDS.getNodeList().elementAt(i); + } + } + }catch(Exception e){ + System.out.println(e.getMessage()); + } + return null; + + } + + + public Vector getCurrentLinks(){ + return currentDS.getLinks(); + } + public void initLayout() { - new MainLayer(currentDs).setVisible(true); + new MainLayer(this).setVisible(true); + } + + public int generateNewID(){ + return id++; } - public double id; + public int id; public Vector nodes = new Vector(); public Vector links = new Vector(); - public DataSource currentDs =null; - public HashMap, Vector> datasources; - public HashMap sources; + public HashMap, Vector> data=null; + public DataSource currentDS=null; + public HashMap, Vector>> layers=null; } diff --git a/src/freimapgsoc/MainLayer.form b/src/freimapgsoc/MainLayer.form index 54d6b15..6b3b65a 100644 --- a/src/freimapgsoc/MainLayer.form +++ b/src/freimapgsoc/MainLayer.form @@ -128,6 +128,9 @@ + + + @@ -517,6 +520,9 @@ + + + @@ -537,31 +543,29 @@ - - - - - - - - + + + + + + + + - - + + - - - - - - + + - + + + @@ -583,46 +587,101 @@ - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + - - - - + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - - + + + + + + - + + + + @@ -633,19 +692,45 @@ - + + + + + + + + + + + + + + + + + + + - + + + + + - - + + + + - + - - + + + + - + @@ -656,7 +741,7 @@ - + @@ -670,12 +755,7 @@ - - - - - - + @@ -684,12 +764,7 @@ - - - - - - + @@ -698,12 +773,7 @@ - - - - - - + @@ -712,41 +782,36 @@ - - - - - - + - + - + - + - + - + - + @@ -754,12 +819,7 @@ - - - - - - + @@ -768,7 +828,7 @@ - + @@ -787,19 +847,17 @@ - + - - - - - - - + - + + + + + @@ -808,27 +866,151 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -848,17 +1030,17 @@ - - + + - - - + + + @@ -871,52 +1053,21 @@ + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -926,44 +1077,85 @@ + + + + + + + + + + + + + - + - + + + + + + + + + + + + + - + + + + + + + + + - + + + + + + + + + @@ -974,7 +1166,7 @@ - + diff --git a/src/freimapgsoc/MainLayer.java b/src/freimapgsoc/MainLayer.java index 750f65a..6aa292f 100644 --- a/src/freimapgsoc/MainLayer.java +++ b/src/freimapgsoc/MainLayer.java @@ -8,7 +8,6 @@ * * Created on 9-mar-2010, 13.56.29 */ - package freimapgsoc; import freimapgsoc.*; @@ -28,7 +27,9 @@ import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; import java.util.HashMap; import java.util.Hashtable; import java.util.Vector; @@ -60,6 +61,8 @@ import javax.swing.JList; import javax.swing.JMenuItem; import javax.swing.JSlider; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import javax.swing.event.MouseInputAdapter; import org.jdesktop.swingx.JXMapViewer; import org.jdesktop.swingx.mapviewer.DefaultTileFactory; @@ -79,9 +82,8 @@ public class MainLayer extends javax.swing.JFrame { /** Creates new form MainLayer */ - public MainLayer(DataSource currentDs) { - this.currentDS=currentDS; - + public MainLayer(Layer l) { + this.l = l; //public TileFactoryInfo(int minimumZoomLevel,int maximumZoomLevel,int totalMapZoom,int tileSize,boolean xr2l,boolean yt2b,String baseURL,String xparam,String yparam,String zparam)( TileFactoryInfo info = new TileFactoryInfo(0, maxzoomlevel, totalmapzoom, 256, false, false, "http://tile.openstreetmap.org", "x", "y", "z") { @@ -91,17 +93,70 @@ public String getTileUrl(int x, int y, int zoom) { } }; - final int maxzoomlevel = 14; + final int maxzoomlevel = 14; final int totalmapzoom = 14; //In a future: possibilty to change this with settings menu parameters; now is in Italy Rome tf = new DefaultTileFactory(info); - double default_lat = 41.86378 ; + double default_lat = 41.86378; double default_lon = 12.5534744; def = new GeoPosition(default_lat, default_lon); initComponents(); initMapComponents(); printDateTime(); + initData(); + drawAll(l.getCurrentLinks(), l.getCurrentNodes()); + System.out.println("NodeList:" + l.getCurrentNodes()); + System.out.println("LinksList:" + l.getCurrentLinks()); + } + + public void initData() { + try { + for (int i = 0; i < l.getCurrentNodes().size(); i++) { + System.out.println(l.getCurrentNodes().elementAt(i).toString()); + listOfNodes.add(i, l.getCurrentNodes().elementAt(i).toString()); + MouseListener mouseListener = new MouseAdapter() { + public void mouseClicked(MouseEvent mouseEvent) { + JList nodeList = (JList) mouseEvent.getSource(); + if (mouseEvent.getClickCount() == 2) { + int index = nodeList.locationToIndex(mouseEvent.getPoint()); + if (index >= 0) { + getInfoFromSelectedNodes(index); + } + } + } + }; + nodeList.addMouseListener(mouseListener); + //Select the node on the map and getInfo! + } + } catch (Exception e) { + System.out.println(e.getMessage()); + log.append(dateInfo.getText()+": Problem with loading components in MainLayer.java: "+ e.getMessage()); + e.printStackTrace(); + } + } + + public void getInfoFromSelectedNodes(int index) { + try { + String selNodeName = listOfNodes.getElementAt(index).toString(); + System.out.println("selNodeName:" + listOfNodes.getElementAt(index)); + MapNode selectedNode = l.getNodeByName(selNodeName); + System.out.println(l.getNodeByName(selNodeName)); + //drawSelection(double xposition, double yposition); + System.out.println("Lat: " + selectedNode.lat); + System.out.println("Lon: " + selectedNode.lon); + latitudeValue.setText(Double.toString(selectedNode.lat)); + longitudeValue.setText(Double.toString(selectedNode.lon)); + upTimeValue.setText(Double.toString(selectedNode.uptime)); + ipComboBox.removeAllItems(); + ipComboBox.insertItemAt(selectedNode.ip, 0); + for (int i = 0; i < selectedNode.inter.size(); i++) { + ipComboBox.insertItemAt(selectedNode.inter.elementAt(i), i + 1); + } + ipComboBox.setSelectedIndex(0); + } catch (Exception e) { + log.append("Exeption:" + e.getMessage() + " caused by: " + e.getCause() + "was occured in class: " + e.getClass()); + } } public void storeLatLon(Vector nodes) { @@ -116,17 +171,6 @@ public void storeLatLon(Vector nodes) { } } - public void mouseMovedOnNodes(MouseEvent evt, GeoPosition posNode) { - - Point2D gp_pt = mainMap.getTileFactory().geoToPixel(posNode, mainMap.getZoom()); - //convert to screen - Rectangle rect = mainMap.getViewportBounds(); - Point converted_gp_pt = new Point((int) gp_pt.getX() - rect.x, (int) gp_pt.getY() - rect.y); - //check if near the mouse - if (converted_gp_pt.distance(evt.getPoint()) < 10) { - System.out.println("OK SEI SUL NODO!"); - } - } public void drawNodes(Vector nodes) { for (int i = 0; i < nodes.size(); i++) { @@ -326,12 +370,11 @@ public void printDateTime() { } - public boolean nodeIsPresent(String nodeName) { boolean find = false; - for (int i = 0; i < currentDS.getNodeList().size(); i++) { - System.out.println("node name:" + currentDS.getNodeList().elementAt(i).toString()); - if (currentDS.getNodeList().elementAt(i).toString().equals(nodeName)) { + for (int i = 0; i < currentDataS.getNodeList().size(); i++) { + System.out.println("node name:" + currentDataS.getNodeList().elementAt(i).toString()); + if (currentDataS.getNodeList().elementAt(i).toString().equals(nodeName)) { System.out.println("node is present!"); find = true; } else { @@ -370,14 +413,28 @@ private void initComponents() { lonLabel = new javax.swing.JLabel(); latLabel = new javax.swing.JLabel(); xValue1 = new javax.swing.JLabel(); - yValue1 = new javax.swing.JLabel(); - yPos1 = new javax.swing.JLabel(); + yValue = new javax.swing.JLabel(); + xValue = new javax.swing.JLabel(); xPos1 = new javax.swing.JLabel(); latitudeValue = new javax.swing.JLabel(); locatedNodes = new javax.swing.JScrollPane(); - jList1 = new javax.swing.JList(); + nodeList = new JList(listOfNodes); fqidLabel = new javax.swing.JLabel(); ipLabel = new javax.swing.JLabel(); + ipComboBox = new javax.swing.JComboBox(); + locatedLabel1 = new javax.swing.JLabel(); + upTimeValue = new javax.swing.JLabel(); + fqidValue = new javax.swing.JLabel(); + locatedLabel2 = new javax.swing.JLabel(); + jSeparator4 = new javax.swing.JSeparator(); + rtLat = new javax.swing.JLabel(); + rtLogitude = new javax.swing.JLabel(); + rtxPos = new javax.swing.JLabel(); + rtxPosValue = new javax.swing.JLabel(); + rtyPos = new javax.swing.JLabel(); + rtyPosValue = new javax.swing.JLabel(); + rtLatValue = new javax.swing.JLabel(); + rtLonValue = new javax.swing.JLabel(); mapPanel = new javax.swing.JPanel(); mainMap = new org.jdesktop.swingx.JXMapViewer(); miniMap = new org.jdesktop.swingx.JXMapViewer(); @@ -485,75 +542,119 @@ private void initComponents() { contestMenuNode.add(SNMP); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setPreferredSize(new java.awt.Dimension(1252, 700)); jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jPanel1.setName("jPanel1"); // NOI18N - longitudeValue.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - longitudeValue.setText("jLabel1"); + longitudeValue.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + longitudeValue.setText(" "); longitudeValue.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); longitudeValue.setName("longitudeValue"); // NOI18N locatedLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - locatedLabel.setText("jLabel1"); - locatedLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + locatedLabel.setText("Located:"); locatedLabel.setName("locatedLabel"); // NOI18N lonLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - lonLabel.setText("jLabel1"); - lonLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + lonLabel.setText("Longitude:"); lonLabel.setName("lonLabel"); // NOI18N latLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - latLabel.setText("jLabel1"); - latLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + latLabel.setText("Latitude:"); latLabel.setName("latLabel"); // NOI18N xValue1.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - xValue1.setText("jLabel1"); - xValue1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + xValue1.setText("Y Position:"); xValue1.setName("xValue1"); // NOI18N - yValue1.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - yValue1.setText("jLabel1"); - yValue1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - yValue1.setName("yValue1"); // NOI18N + yValue.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + yValue.setText(" "); + yValue.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + yValue.setName("yValue"); // NOI18N - yPos1.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - yPos1.setText("jLabel1"); - yPos1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); - yPos1.setName("yPos1"); // NOI18N + xValue.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + xValue.setText(" "); + xValue.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + xValue.setName("xValue"); // NOI18N xPos1.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - xPos1.setText("jLabel1"); - xPos1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + xPos1.setText("X Position:"); xPos1.setName("xPos1"); // NOI18N - latitudeValue.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - latitudeValue.setText("jLabel1"); + latitudeValue.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + latitudeValue.setText(" "); latitudeValue.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); latitudeValue.setName("latitudeValue"); // NOI18N locatedNodes.setName("locatedNodes"); // NOI18N - jList1.setModel(new javax.swing.AbstractListModel() { - String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; - public int getSize() { return strings.length; } - public Object getElementAt(int i) { return strings[i]; } - }); - jList1.setName("jList1"); // NOI18N - locatedNodes.setViewportView(jList1); + nodeList.setName("nodeList"); // NOI18N + locatedNodes.setViewportView(nodeList); fqidLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - fqidLabel.setText("jLabel1"); - fqidLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + fqidLabel.setText("FQID:"); fqidLabel.setName("fqidLabel"); // NOI18N ipLabel.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - ipLabel.setText("jLabel1"); - ipLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + ipLabel.setText("Ip Address:"); ipLabel.setName("ipLabel"); // NOI18N + ipComboBox.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + ipComboBox.setName("ipComboBox"); // NOI18N + + locatedLabel1.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + locatedLabel1.setText("Uptime:"); + locatedLabel1.setName("locatedLabel1"); // NOI18N + + upTimeValue.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + upTimeValue.setText(" "); + upTimeValue.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + upTimeValue.setName("upTimeValue"); // NOI18N + + fqidValue.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + fqidValue.setText(" "); + fqidValue.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + fqidValue.setName("fqidValue"); // NOI18N + + locatedLabel2.setFont(new java.awt.Font("Lucida Grande", 0, 12)); + locatedLabel2.setText("EXT:"); + locatedLabel2.setName("locatedLabel2"); // NOI18N + + jSeparator4.setName("jSeparator4"); // NOI18N + + rtLat.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + rtLat.setText("Latitute:"); + rtLat.setName("rtLat"); // NOI18N + + rtLogitude.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + rtLogitude.setText("Logitude:"); + rtLogitude.setName("rtLogitude"); // NOI18N + + rtxPos.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + rtxPos.setText("X:"); + rtxPos.setName("rtxPos"); // NOI18N + + rtxPosValue.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + rtxPosValue.setText("V"); + rtxPosValue.setName("rtxPosValue"); // NOI18N + + rtyPos.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + rtyPos.setText("Y:"); + rtyPos.setName("rtyPos"); // NOI18N + + rtyPosValue.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + rtyPosValue.setText("V"); + rtyPosValue.setName("rtyPosValue"); // NOI18N + + rtLatValue.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + rtLatValue.setText("V"); + rtLatValue.setName("rtLatValue"); // NOI18N + + rtLonValue.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N + rtLonValue.setText("V"); + rtLonValue.setName("rtLonValue"); // NOI18N + org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( @@ -561,38 +662,77 @@ private void initComponents() { .add(jPanel1Layout.createSequentialGroup() .addContainerGap() .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(fqidLabel) - .add(ipLabel) .add(jPanel1Layout.createSequentialGroup() - .add(xValue1) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) - .add(yValue1)) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(rtxPos, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(rtxPosValue, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 73, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(jPanel1Layout.createSequentialGroup() + .add(rtLat) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(rtLatValue, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 53, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(8, 8, 8) + .add(rtyPos, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 34, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(rtyPosValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)) + .add(jPanel1Layout.createSequentialGroup() + .add(rtLogitude) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(rtLonValue, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 74, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))) + .add(locatedLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE) .add(jPanel1Layout.createSequentialGroup() - .add(xPos1) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) - .add(yPos1)) - .add(locatedLabel) - .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) - .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1Layout.createSequentialGroup() - .add(lonLabel) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) - .add(longitudeValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .add(org.jdesktop.layout.GroupLayout.LEADING, jPanel1Layout.createSequentialGroup() - .add(latLabel) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) - .add(latitudeValue, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 90, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) - .add(locatedNodes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 188, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .addContainerGap(16, Short.MAX_VALUE)) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createSequentialGroup() + .add(ipLabel) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(ipComboBox, 0, 189, Short.MAX_VALUE)) + .add(jPanel1Layout.createSequentialGroup() + .add(fqidLabel) + .add(47, 47, 47) + .add(fqidValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)) + .add(jPanel1Layout.createSequentialGroup() + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(xPos1) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) + .add(org.jdesktop.layout.GroupLayout.LEADING, locatedLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, xValue1))) + .add(18, 18, 18) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) + .add(org.jdesktop.layout.GroupLayout.LEADING, xValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(yValue, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .add(upTimeValue, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .add(jPanel1Layout.createSequentialGroup() + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) + .add(latLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(lonLabel)) + .add(18, 18, 18) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(longitudeValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE) + .add(latitudeValue, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)))) + .add(4, 4, 4)) + .add(locatedLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 215, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(org.jdesktop.layout.GroupLayout.TRAILING, locatedNodes, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE) + .add(jSeparator4, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE)) + .addContainerGap()) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup() + .add(jPanel1Layout.createSequentialGroup() .addContainerGap() - .add(locatedNodes, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 362, Short.MAX_VALUE) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) - .add(fqidLabel) + .add(locatedNodes, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 155, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(18, 18, 18) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(fqidLabel) + .add(fqidValue, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .add(4, 4, 4) - .add(ipLabel) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(ipLabel) + .add(ipComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(latLabel) @@ -601,81 +741,111 @@ private void initComponents() { .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(lonLabel) .add(longitudeValue, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .add(42, 42, 42) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false) + .add(jPanel1Layout.createSequentialGroup() + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(locatedLabel1) + .add(upTimeValue, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 17, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(xValue1) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(xPos1)) + .add(jPanel1Layout.createSequentialGroup() + .add(yValue) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(xValue))) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) .add(locatedLabel) - .add(30, 30, 30) - .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) - .add(xValue1) - .add(yValue1)) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(locatedLabel2) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jSeparator4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(18, 18, 18) .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) - .add(xPos1) - .add(yPos1)) - .add(53, 53, 53)) + .add(rtLat) + .add(rtLatValue) + .add(rtLogitude) + .add(rtLonValue)) + .add(31, 31, 31) + .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) + .add(rtxPos) + .add(rtxPosValue) + .add(rtyPosValue) + .add(rtyPos)) + .addContainerGap(67, Short.MAX_VALUE)) ); mapPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); mapPanel.setName("mapPanel"); // NOI18N mainMap.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + mainMap.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N mainMap.setName("mainMap"); // NOI18N mainMap.setTileFactory(tf); + mainMap.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + mainMapMouseClicked(evt); + } + }); + mainMap.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { + public void mouseMoved(java.awt.event.MouseEvent evt) { + mainMapMouseMoved(evt); + } + }); + mainMap.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); miniMap.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); + miniMap.setFont(new java.awt.Font("Lucida Grande", 0, 10)); // NOI18N miniMap.setName("miniMap"); // NOI18N + miniMap.setTileFactory(tf); + miniMap.setZoom(13); + miniMap.setZoomEnabled(false); org.jdesktop.layout.GroupLayout miniMapLayout = new org.jdesktop.layout.GroupLayout(miniMap); miniMap.setLayout(miniMapLayout); miniMapLayout.setHorizontalGroup( miniMapLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(0, 117, Short.MAX_VALUE) + .add(0, 158, Short.MAX_VALUE) ); miniMapLayout.setVerticalGroup( miniMapLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(0, 109, Short.MAX_VALUE) + .add(0, 138, Short.MAX_VALUE) ); + mainMap.add(miniMap, new org.netbeans.lib.awtextra.AbsoluteConstraints(690, 380, 160, 140)); + + zoomSlider.setMaximum(14); + zoomSlider.setOrientation(1); + zoomSlider.setValue(13); + zoomSlider.setInverted(true); zoomSlider.setName("zoomSlider"); // NOI18N + zoomSlider.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + zoomSliderStateChanged(evt); + } + }); + mainMap.add(zoomSlider, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 280, 40, -1)); zoomButtonIn.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - zoomButtonIn.setText("Zoom -"); + zoomButtonIn.setText("-"); zoomButtonIn.setName("zoomButtonIn"); // NOI18N + zoomButtonIn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + zoomButtonInActionPerformed(evt); + } + }); + mainMap.add(zoomButtonIn, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 480, -1, -1)); zoomButtonOut.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - zoomButtonOut.setText("Zoom +"); + zoomButtonOut.setText("+"); zoomButtonOut.setName("zoomButtonOut"); // NOI18N - - org.jdesktop.layout.GroupLayout mainMapLayout = new org.jdesktop.layout.GroupLayout(mainMap); - mainMap.setLayout(mainMapLayout); - mainMapLayout.setHorizontalGroup( - mainMapLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(org.jdesktop.layout.GroupLayout.TRAILING, mainMapLayout.createSequentialGroup() - .add(mainMapLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(mainMapLayout.createSequentialGroup() - .add(19, 19, 19) - .add(zoomSlider, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .add(mainMapLayout.createSequentialGroup() - .addContainerGap() - .add(zoomButtonIn) - .add(18, 18, 18) - .add(zoomButtonOut) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 460, Short.MAX_VALUE) - .add(miniMap, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) - .addContainerGap()) - ); - mainMapLayout.setVerticalGroup( - mainMapLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(org.jdesktop.layout.GroupLayout.TRAILING, mainMapLayout.createSequentialGroup() - .add(mainMapLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) - .add(zoomSlider, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) - .add(miniMap, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .addContainerGap()) - .add(org.jdesktop.layout.GroupLayout.TRAILING, mainMapLayout.createSequentialGroup() - .add(mainMapLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) - .add(zoomButtonIn) - .add(zoomButtonOut)) - .add(66, 66, 66)) - ); + zoomButtonOut.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + zoomButtonOutActionPerformed(evt); + } + }); + mainMap.add(zoomButtonOut, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 250, -1, -1)); org.jdesktop.layout.GroupLayout mapPanelLayout = new org.jdesktop.layout.GroupLayout(mapPanel); mapPanel.setLayout(mapPanelLayout); @@ -683,19 +853,19 @@ private void initComponents() { mapPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(mapPanelLayout.createSequentialGroup() .addContainerGap() - .add(mainMap, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addContainerGap()) + .add(mainMap, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 870, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); mapPanelLayout.setVerticalGroup( mapPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(mapPanelLayout.createSequentialGroup() - .addContainerGap() - .add(mainMap, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 651, Short.MAX_VALUE) - .addContainerGap()) + .add(20, 20, 20) + .add(mainMap, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 534, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); - dateInfo.setFont(new java.awt.Font("Lucida Grande", 0, 12)); - dateInfo.setText("jLabel1"); + dateInfo.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N + dateInfo.setText(" "); dateInfo.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); dateInfo.setName("dateInfo"); // NOI18N @@ -712,6 +882,11 @@ private void initComponents() { xmlOpenMenu.setFont(new java.awt.Font("Lucida Grande", 0, 12)); xmlOpenMenu.setText("XML File"); xmlOpenMenu.setName("xmlOpenMenu"); // NOI18N + xmlOpenMenu.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + xmlOpenMenuActionPerformed(evt); + } + }); openMenu.add(xmlOpenMenu); txtOpenMenu.setFont(new java.awt.Font("Lucida Grande", 0, 12)); @@ -938,36 +1113,102 @@ private void initComponents() { getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createSequentialGroup() - .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(dateInfo) - .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 226, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .add(18, 18, 18) - .add(mapPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addContainerGap()) + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(dateInfo, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE) + .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(mapPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(57, 57, 57)) ); layout.setVerticalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(layout.createSequentialGroup() + .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(mapPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() - .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) - .add(dateInfo))) - .addContainerGap()) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .add(mapPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED) + .add(dateInfo) + .add(113, 113, 113)) ); pack(); }// //GEN-END:initComponents - /** - * @param args the command line arguments - */ + private void zoomSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_zoomSliderStateChanged + // TODO add your handling code here: + if (!zoomChanging) { + mainMap.setZoom(zoomSlider.getValue()); + miniMap.setZoom(zoomSlider.getValue() + 3); + drawAll(l.getCurrentLinks(), l.getCurrentNodes()); + } + }//GEN-LAST:event_zoomSliderStateChanged - //MAP COMPONENTS + private void xmlOpenMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_xmlOpenMenuActionPerformed + if (evt.getSource() == xmlOpenMenu) { + JFileChooser fcxml = new JFileChooser(); + fcxml.addChoosableFileFilter(new xmlFileFilter()); + fcxml.setAcceptAllFileFilterUsed(false); + int returnVal = fcxml.showOpenDialog(fcxml); + if (returnVal == JFileChooser.APPROVE_OPTION) { + deleteAllfromMap(mainMap, locatedN); + File file = fcxml.getSelectedFile(); + //new Layer(new xmlDataSource().init(null)); + addRecentFile(file.getPath(), file.getName()); + } else if (returnVal == JFileChooser.CANCEL_OPTION) { + System.out.println("Open command cancelled by user." + "\n"); + } + + } + }//GEN-LAST:event_xmlOpenMenuActionPerformed + + private void zoomButtonInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoomButtonInActionPerformed + setZoom(mainMap.getZoom() + 1); + setZoom(miniMap.getZoom() + 5); + }//GEN-LAST:event_zoomButtonInActionPerformed + + private void zoomButtonOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_zoomButtonOutActionPerformed + setZoom(mainMap.getZoom() - 1); + setZoom(miniMap.getZoom() - 5);// TODO add your handling code here: + }//GEN-LAST:event_zoomButtonOutActionPerformed + + private void mainMapMouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainMapMouseMoved + GeoPosition gp = mainMap.convertPointToGeoPosition(new Point2D.Double(evt.getX(), evt.getY())); + DecimalFormat fmt = new DecimalFormat("#00.00000"); + rtLatValue.setText(fmt.format(gp.getLatitude())); + rtLonValue.setText(fmt.format(gp.getLongitude())); + rtxPosValue.setText(String.format("%.3f", mainMap.getTileFactory().geoToPixel(gp, mainMap.getZoom()).getX())); + rtyPosValue.setText(String.format("%.3f", mainMap.getTileFactory().geoToPixel(gp, mainMap.getZoom()).getY())); // TODO add your handling code here: + }//GEN-LAST:event_mainMapMouseMoved + + private void mainMapMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mainMapMouseClicked + GeoPosition posNode = mainMap.convertPointToGeoPosition(new Point2D.Double(evt.getX(), evt.getY())); + Point2D gp_pt = mainMap.getTileFactory().geoToPixel(posNode, mainMap.getZoom()); + //convert to screen + Rectangle rect = mainMap.getViewportBounds(); + Point converted_gp_pt = new Point((int) gp_pt.getX() - rect.x, (int) gp_pt.getY() - rect.y); + //check if near the mouse + if (converted_gp_pt.distance(evt.getPoint()) < 10 && isNearNode(posNode)) { + System.out.println("OK SEI SUL NODO!"); + } + }//GEN-LAST:event_mainMapMouseClicked + + public boolean isNearNode(GeoPosition posNode){ + for(int i=0; i() { + @Override public void paint(Graphics2D g, JXMapViewer map, int width, int height) { g.setPaint(Color.WHITE); g.drawString(" ", 50, map.getHeight() - 10); @@ -990,6 +1232,7 @@ public void paint(Graphics2D g, JXMapViewer map, int width, int height) { // adapter to move the minimap after the main map has moved MouseInputAdapter ma = new MouseInputAdapter() { + @Override public void mousePressed(MouseEvent evt) { String nodeName = ""; Point pt = evt.getPoint(); @@ -1007,6 +1250,7 @@ public void mousePressed(MouseEvent evt) { } + @Override public void mouseReleased(MouseEvent e) { miniMap.setCenterPosition(mapCenterPosition); } @@ -1017,6 +1261,7 @@ public void mouseReleased(MouseEvent e) { mainMap.addMouseListener(ma); mainMap.addPropertyChangeListener("center", new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { Point2D mapCenter = (Point2D) evt.getNewValue(); TileFactory tf = mainMap.getTileFactory(); @@ -1028,6 +1273,7 @@ public void propertyChange(PropertyChangeEvent evt) { mainMap.addPropertyChangeListener("centerPosition", new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { mapCenterPosition = (GeoPosition) evt.getNewValue(); miniMap.setCenterPosition(mapCenterPosition); @@ -1039,6 +1285,7 @@ public void propertyChange(PropertyChangeEvent evt) { mainMap.addPropertyChangeListener("zoom", new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { zoomSlider.setValue(mainMap.getZoom()); } @@ -1047,6 +1294,7 @@ public void propertyChange(PropertyChangeEvent evt) { miniMap.setOverlayPainter(new Painter() { + @Override public void paint(Graphics2D g, JXMapViewer map, int width, int height) { // get the viewport rect of the main map Rectangle mainMapBounds = mainMap.getViewportBounds(); @@ -1091,12 +1339,11 @@ public void paint(Graphics2D g, JXMapViewer map, int width, int height) { }//OK //END OF INITMAPCOMPONENTS() - //MAP METHODS ################################## public void setZoom(int zoom) { zoomChanging = true; mainMap.setZoom(zoom); - miniMap.setZoom(mainMap.getZoom() + 4); + miniMap.setZoom(mainMap.getZoom() + 5); if (sliderReversed) { zoomSlider.setValue(zoomSlider.getMaximum() - zoom); } else { @@ -1121,7 +1368,7 @@ public boolean isMiniMapVisible() { */ public void setMiniMapVisible(boolean miniMapVisible) { boolean old = this.isMiniMapVisible(); - this.miniMapVisible = miniMapVisible; + MainLayer.miniMapVisible = miniMapVisible; miniMap.setVisible(miniMapVisible); }//OK @@ -1139,7 +1386,7 @@ public boolean isZoomSliderVisible() { */ public void setZoomSliderVisible(boolean zoomSliderVisible) { boolean old = this.isZoomSliderVisible(); - this.zoomSliderVisible = zoomSliderVisible; + MainLayer.zoomSliderVisible = zoomSliderVisible; zoomSlider.setVisible(zoomSliderVisible); }//OK @@ -1159,7 +1406,7 @@ public boolean isZoomButtonsVisible() { */ public void setZoomButtonsVisible(boolean zoomButtonsVisible) { boolean old = this.isZoomButtonsVisible(); - this.zoomButtonsVisible = zoomButtonsVisible; + MainLayer.zoomButtonsVisible = zoomButtonsVisible; //zoomInButton.setVisible(zoomButtonsVisible); //zoomOutButton.setVisible(zoomButtonsVisible); }//OK @@ -1254,8 +1501,7 @@ public void takeScreenShot() throws AWTException, IOException { } //END OF MAP METHODS################################ - - private void serviceDActionPerformed(java.awt.event.ActionEvent evt) { + private void serviceDActionPerformed(java.awt.event.ActionEvent evt) { InetAddress intf = null; try { intf = InetAddress.getByName("10.0.1.29"); @@ -1269,13 +1515,6 @@ private void serviceDActionPerformed(java.awt.event.ActionEvent evt) { } // TODO add your handling code here: } - private void zoomSliderStateChanged(javax.swing.event.ChangeEvent evt) { - if (!zoomChanging) { - mainMap.setZoom(zoomSlider.getValue()); - drawAll(currentDS.getLinks(0), currentDS.getNodeList()); - } // TODO add your handling code here: - } - private void deleteAllfromMap(JXMapViewer map, DefaultListModel locatedN) { locatedN.removeAllElements(); Set remover = painter.getWaypoints(); @@ -1301,29 +1540,10 @@ private void newRecentFileActionPerformed(java.awt.event.ActionEvent evt, String // new Layer(new xmlDataSource().init(null)); } if (extension.equals(Utils.js)) { - new Layer(new LatLonJsDataSource().init(file.getPath())); + new LatLonJsDataSource(path); } } - private void xmlOpenMenuActionPerformed(java.awt.event.ActionEvent evt) { - if (evt.getSource() == xmlOpenMenu) { - JFileChooser fcxml = new JFileChooser(); - fcxml.addChoosableFileFilter(new xmlFileFilter()); - fcxml.setAcceptAllFileFilterUsed(false); - int returnVal = fcxml.showOpenDialog(fcxml); - if (returnVal == JFileChooser.APPROVE_OPTION) { - deleteAllfromMap(mainMap, locatedN); - File file = fcxml.getSelectedFile(); - //new Layer(new xmlDataSource().init(null)); - addRecentFile(file.getPath(), file.getName()); - } else if (returnVal == JFileChooser.CANCEL_OPTION) { - System.out.println("Open command cancelled by user." + "\n"); - } - - } - - } - /** DELETED BECUASE IS SIMILAR TO XML FILES*/ private void jsOpenMenuActionPerformed(java.awt.event.ActionEvent evt) { if (evt.getSource() == jsOpenMenu) { @@ -1337,8 +1557,8 @@ private void jsOpenMenuActionPerformed(java.awt.event.ActionEvent evt) { File file = fcjs.getSelectedFile(); System.out.println("FILE JS OPENED"); System.out.println("Opening: " + file.getName() + ".\n"); - new Layer(new LatLonJsDataSource().init(file.getPath())); - addRecentFile(file.getPath(), file.getName()); + new LatLonJsDataSource(file.getPath()); + addRecentFile(file.getPath(), file.getName()); } else if (returnVal == JFileChooser.CANCEL_OPTION) { System.out.println("Open command cancelled by user." + "\n"); } @@ -1367,69 +1587,34 @@ private void saveAsMenuActionPerformed(java.awt.event.ActionEvent evt) { } } - private void zoomButtonInMouseClicked(java.awt.event.MouseEvent evt) { - setZoom(mainMap.getZoom() - 1); -// TODO add your handling code here: - } - - private void zoomButtonOutMouseClicked(java.awt.event.MouseEvent evt) { - setZoom(mainMap.getZoom() + 1); - // TODO add your handling code here: - } - - private void locatedNodesValueChanged(javax.swing.event.ListSelectionEvent evt) { - try { - String selectedNode = locatedNodes.getName(); - for (int i = 0; i configuration) { throw new UnsupportedOperationException("Not supported yet."); } @@ -1612,25 +1796,17 @@ public void showMiniMap() { } } - // Variables declaration - do not modify - - public javax.swing.JButton defaultButton; public javax.swing.JScrollPane jScrollPane1; public javax.swing.JMenuItem listofnodes1;//contestMenu - public javax.swing.JLabel ncLabel; public javax.swing.JMenuItem takePicture;//contestMenu - // End of variables declaration - - private JDialog aboutBox; - private Runtime runtime; - public DefaultListModel locatedN = new DefaultListModel(); + public DefaultListModel listOfNodes = new DefaultListModel(); private int countPop = 0; private String nodeName = null; private File recentFile; @@ -1651,10 +1827,7 @@ public Vector getLinksFromDest(String id) { public MapNode getNodeByIp(String ip) { throw new UnsupportedOperationException("Not supported yet."); } - - private HashMap latlon; - - + private HashMap latlon; // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JMenu AppendMenu; private javax.swing.JMenu EditMenu; @@ -1677,18 +1850,20 @@ public MapNode getNodeByIp(String ip) { private javax.swing.JMenuItem deleteRecentMenu; private javax.swing.JMenuItem findNode; private javax.swing.JLabel fqidLabel; + private javax.swing.JLabel fqidValue; private javax.swing.JMenuItem goHere; private javax.swing.JMenuItem goToDefaultPos; private javax.swing.JMenuItem goToDefaultPosition; private javax.swing.JMenuItem guideItem; + private javax.swing.JComboBox ipComboBox; private javax.swing.JLabel ipLabel; private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItem1; - private javax.swing.JList jList1; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JPanel jPanel1; private javax.swing.JPopupMenu.Separator jSeparator1; private javax.swing.JPopupMenu.Separator jSeparator2; private javax.swing.JPopupMenu.Separator jSeparator3; + private javax.swing.JSeparator jSeparator4; private javax.swing.JMenuItem jsAppendMenu; private javax.swing.JMenuItem jsOpenMenu; private javax.swing.JMenuItem jsSaveMenu; @@ -1699,6 +1874,8 @@ public MapNode getNodeByIp(String ip) { private javax.swing.JCheckBoxMenuItem linksMenu; private javax.swing.JCheckBoxMenuItem listCheck; private javax.swing.JLabel locatedLabel; + private javax.swing.JLabel locatedLabel1; + private javax.swing.JLabel locatedLabel2; private javax.swing.JScrollPane locatedNodes; private javax.swing.JLabel lonLabel; private javax.swing.JLabel longitudeValue; @@ -1707,10 +1884,19 @@ public MapNode getNodeByIp(String ip) { private javax.swing.JPanel mapPanel; private org.jdesktop.swingx.JXMapViewer miniMap; private javax.swing.JCheckBoxMenuItem miniMapMenu; + private static javax.swing.JList nodeList; private javax.swing.JCheckBoxMenuItem nodesCheck; private javax.swing.JMenu openMenu; private javax.swing.JMenuItem preferencesItem; private javax.swing.JMenu recentFilesMenu; + private javax.swing.JLabel rtLat; + private javax.swing.JLabel rtLatValue; + private javax.swing.JLabel rtLogitude; + private javax.swing.JLabel rtLonValue; + private javax.swing.JLabel rtxPos; + private javax.swing.JLabel rtxPosValue; + private javax.swing.JLabel rtyPos; + private javax.swing.JLabel rtyPosValue; private javax.swing.JMenu saveAsMenu; private javax.swing.JMenu saveSelectedNodes; private javax.swing.JMenuItem selectAll; @@ -1721,14 +1907,15 @@ public MapNode getNodeByIp(String ip) { private javax.swing.JMenuItem txtOpenMenu; private javax.swing.JMenuItem txtSaveMenu; private javax.swing.JMenuItem txtSaveSelMenu; + private javax.swing.JLabel upTimeValue; private javax.swing.JLabel xPos1; + private javax.swing.JLabel xValue; private javax.swing.JLabel xValue1; private javax.swing.JMenuItem xmlAppendMenu; private javax.swing.JMenuItem xmlOpenMenu; private javax.swing.JMenuItem xmlSaveMenu; private javax.swing.JMenuItem xmlSaveSelMenu; - private javax.swing.JLabel yPos1; - private javax.swing.JLabel yValue1; + private javax.swing.JLabel yValue; private javax.swing.JButton zoomButtonIn; private javax.swing.JButton zoomButtonOut; private javax.swing.JCheckBoxMenuItem zoomButtons; @@ -1737,12 +1924,9 @@ public MapNode getNodeByIp(String ip) { private javax.swing.JCheckBoxMenuItem zoomSMenu; private javax.swing.JSlider zoomSlider; // End of variables declaration//GEN-END:variables - //MainMap and Minimap Variables - - private GeoPosition def;//OK - DefaultTileFactory tf=null; + DefaultTileFactory tf = null; private boolean zoomChanging = false;//OK private JLabel nodeLabel = new JLabel(); final List region = new ArrayList(); @@ -1758,115 +1942,11 @@ public MapNode getNodeByIp(String ip) { private Point2D mapCenter = new Point2D.Double(0, 0);//OK private GeoPosition mapCenterPosition = new GeoPosition(0, 0);//OK Vector coor = new Vector(); - - private final int maxzoomlevel = 14; + private final int maxzoomlevel = 14; private final int totalmapzoom = 14; private Layer l; private int layercount = 0; private Vector layers = new Vector(); - private DataSource currentDS = new DataSource() { - - @Override - public Vector getNodeList() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Hashtable getNodeAvailability(long time) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getFirstUpdateTime() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getLastUpdateTime() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getLastAvailableTime() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getFirstAvailableTime() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public long getClosestUpdateTime(long time) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public MapNode getNodeByName(String name) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public MapNode getNodeById(String id) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public MapNode getNodeByIp(String ip) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Vector getLinks(long time) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Vector getLinksFromSource(String id) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public Vector getLinksFromDest(String id) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void addDataSourceListener(DataSourceListener dsl) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void getLinkProfile(Link link, LinkInfo info) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void getLinkCountProfile(MapNode node, NodeInfo info) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public void init() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public HashMap read_conf(HashMap configuration) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getId() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getCurrentID() { - throw new UnsupportedOperationException("Not supported yet."); - } - }; - + private DataSource currentDataS; } - diff --git a/src/freimapgsoc/MysqlDataSource.java b/src/freimapgsoc/MysqlDataSource.java index 4aa7ff5..26b8b67 100755 --- a/src/freimapgsoc/MysqlDataSource.java +++ b/src/freimapgsoc/MysqlDataSource.java @@ -310,14 +310,11 @@ public HashMap read_conf(HashMap configuration) } @Override - public String getId() { + public Vector getLinks() { throw new UnsupportedOperationException("Not supported yet."); } - @Override - public String getCurrentID() { - throw new UnsupportedOperationException("Not supported yet."); - } + class LCPFetcher extends Thread { MapNode node; diff --git a/src/freimapgsoc/NodeLayer.java b/src/freimapgsoc/NodeLayer.java index fbc80bb..8c5750a 100755 --- a/src/freimapgsoc/NodeLayer.java +++ b/src/freimapgsoc/NodeLayer.java @@ -529,7 +529,8 @@ public boolean setCurrentTime(long crtTime) { long adjusted=source.getClosestUpdateTime(crtTime); //FIXME: if the interval between crtTime and the closest Display time is too high, display nothing. if (adjusted != this.crtTime) { - links = source.getLinks(this.crtTime); + links= source.getLinks(); + this.crtTime = adjusted; return true; } diff --git a/src/freimapgsoc/OlsrdDataSource.java b/src/freimapgsoc/OlsrdDataSource.java index cbbfb15..63dba72 100755 --- a/src/freimapgsoc/OlsrdDataSource.java +++ b/src/freimapgsoc/OlsrdDataSource.java @@ -252,14 +252,10 @@ public HashMap read_conf(HashMap configuration) } @Override - public String getId() { + public Vector getLinks() { throw new UnsupportedOperationException("Not supported yet."); } - @Override - public String getCurrentID() { - throw new UnsupportedOperationException("Not supported yet."); - } //Listener Of DotDraw Plugin diff --git a/src/freimapgsoc/Start.form b/src/freimapgsoc/Start.form index 5883feb..f796307 100644 --- a/src/freimapgsoc/Start.form +++ b/src/freimapgsoc/Start.form @@ -36,10 +36,10 @@ - - - - + + + + @@ -49,6 +49,11 @@ + + + + + @@ -68,7 +73,9 @@ - + + + @@ -135,5 +142,15 @@ + + + + + + + + + + diff --git a/src/freimapgsoc/Start.java b/src/freimapgsoc/Start.java index 946a00c..9c80a17 100644 --- a/src/freimapgsoc/Start.java +++ b/src/freimapgsoc/Start.java @@ -8,7 +8,6 @@ * * Created on 9-nov-2009, 19.44.22 */ - package freimapgsoc; import java.io.File; @@ -23,19 +22,18 @@ public class Start extends javax.swing.JFrame { /** Creates new form Start */ public Start() { initComponents(); - CheckActiveDataSource check=new CheckActiveDataSource(); - if(check.mySql){ - mySQLButton.setEnabled(true); + CheckActiveDataSource check = new CheckActiveDataSource(); + if (check.mySql) { + mySQLButton.setEnabled(true); } - if(check.nameservice){ + if (check.nameservice) { nameServiceButton.setEnabled(true); } - if(check.olsr){ + if (check.olsr) { olsrdButton.setEnabled(true); } - if(!check.mySql&&!check.nameservice&&!check.olsr){ + if (!check.mySql && !check.nameservice && !check.olsr) { firstLabel.setText("There aren't Live DataSources"); - secondLabel.setText("please choose a file."); } } @@ -55,6 +53,7 @@ private void initComponents() { jLabel1 = new javax.swing.JLabel(); firstLabel = new javax.swing.JLabel(); secondLabel = new javax.swing.JLabel(); + openExampleFile = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setName("Form"); // NOI18N @@ -106,6 +105,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { secondLabel.setText(resourceMap.getString("secondLabel.text")); // NOI18N secondLabel.setName("secondLabel"); // NOI18N + openExampleFile.setFont(resourceMap.getFont("openExampleFile.font")); // NOI18N + openExampleFile.setText(resourceMap.getString("openExampleFile.text")); // NOI18N + openExampleFile.setName("openExampleFile"); // NOI18N + openExampleFile.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + openExampleFileActionPerformed(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( @@ -121,14 +129,18 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(openFileButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE) - .addComponent(mySQLButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE) - .addComponent(olsrdButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE) - .addComponent(nameServiceButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 265, Short.MAX_VALUE)) + .addComponent(openFileButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE) + .addComponent(mySQLButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE) + .addComponent(olsrdButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE) + .addComponent(nameServiceButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE)) .addContainerGap()) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(secondLabel) .addGap(88, 88, 88)))) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(openExampleFile, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE) + .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) @@ -147,7 +159,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(mySQLButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(openFileButton) - .addContainerGap(44, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(openExampleFile) + .addContainerGap(25, Short.MAX_VALUE)) ); pack(); @@ -160,51 +174,59 @@ private void olsrdButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-F }//GEN-LAST:event_olsrdButtonActionPerformed private void nameServiceButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameServiceButtonActionPerformed - new Layer(new LatLonJsDataSource().init("/var/run/latlon.js")); + //new Layer(new LatLonJsDataSource().init("/var/run/latlon.js")); }//GEN-LAST:event_nameServiceButtonActionPerformed private void openFileButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openFileButtonActionPerformed - JFileChooser fc= new JFileChooser(); - fc.addChoosableFileFilter(new xmlFileFilter()); - fc.addChoosableFileFilter(new jsFileFilter()); - //fc.addChoosableFileFilter(new FmpFileFilter()); - fc.setAcceptAllFileFilterUsed(false); - int returnVal = fc.showOpenDialog(fc); - if (returnVal == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - String extension = Utils.getExtension(file); - if (extension.equals(Utils.xml)){ + JFileChooser fc = new JFileChooser(); + fc.addChoosableFileFilter(new xmlFileFilter()); + fc.addChoosableFileFilter(new jsFileFilter()); + //fc.addChoosableFileFilter(new FmpFileFilter()); + fc.setAcceptAllFileFilterUsed(false); + int returnVal = fc.showOpenDialog(fc); + if (returnVal == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + String extension = Utils.getExtension(file); + if (extension.equals(Utils.xml)) { // new Layer(new xmlDataSource().init(null)); - } - if (extension.equals(Utils.js)){ - new Layer(new LatLonJsDataSource().init("file://"+file.getPath())); - } - // FileMenu fm=new FileMenu(); - //fm.addRecentFile(file.getPath(), file.getName()); - } else if (returnVal == JFileChooser.CANCEL_OPTION) { - System.out.println("Open command cancelled by user." + "\n"); - } // TODO add your handling code here: + } + if (extension.equals(Utils.js)) { + new LatLonJsDataSource().init("file://" + file.getPath()); + this.dispose(); + + } + // FileMenu fm=new FileMenu(); + //fm.addRecentFile(file.getPath(), file.getName()); + } else if (returnVal == JFileChooser.CANCEL_OPTION) { + System.out.println("Open command cancelled by user." + "\n"); + } // TODO add your handling code here: }//GEN-LAST:event_openFileButtonActionPerformed + private void openExampleFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openExampleFileActionPerformed + new LatLonJsDataSource().init("file:///Users/Stefano/Desktop/FreimapSte/Freimap/hg/src/data/latlon.js"); + this.dispose(); + + }//GEN-LAST:event_openExampleFileActionPerformed + /** - * @param args the command line arguments - */ + * @param args the command line arguments + */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { new Start().setVisible(true); } }); } - // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel firstLabel; private javax.swing.JLabel jLabel1; private javax.swing.JButton mySQLButton; private javax.swing.JButton nameServiceButton; private javax.swing.JButton olsrdButton; + private javax.swing.JButton openExampleFile; private javax.swing.JButton openFileButton; private javax.swing.JLabel secondLabel; // End of variables declaration//GEN-END:variables - } diff --git a/src/freimapgsoc/YamlDataSource.java b/src/freimapgsoc/YamlDataSource.java index 34895c8..fd6817c 100755 --- a/src/freimapgsoc/YamlDataSource.java +++ b/src/freimapgsoc/YamlDataSource.java @@ -337,14 +337,11 @@ public HashMap read_conf(HashMap configuration) } @Override - public String getId() { + public Vector getLinks() { throw new UnsupportedOperationException("Not supported yet."); } - @Override - public String getCurrentID() { - throw new UnsupportedOperationException("Not supported yet."); - } + class TimeStampFetcher implements Runnable { //use an own connection for concurrency! private final static int OFFSET = 1000; diff --git a/src/freimapgsoc/log.java b/src/freimapgsoc/log.java index 6a65e8e..a586e95 100644 --- a/src/freimapgsoc/log.java +++ b/src/freimapgsoc/log.java @@ -9,7 +9,7 @@ public log() { public static void append(String message) { - String path = "/Users/stefanopilla/Desktop/FreimapGSoC/src/Data/log.txt"; + String path = "/Users/Stefano/Desktop/FreimapSte/Freimap/hg/src/Data/log.txt"; File file = new File(path); try { diff --git a/src/freimapgsoc/resources/Start.properties b/src/freimapgsoc/resources/Start.properties index c1058f4..bddce84 100644 --- a/src/freimapgsoc/resources/Start.properties +++ b/src/freimapgsoc/resources/Start.properties @@ -3,9 +3,12 @@ nameServiceButton.text=NameService mySQLButton.text=MySQL openFileButton.text=Open file... firstLabel.text=I've found more than one DataSource, -secondLabel.text=please choose one: olsrdButton.text=Olsr #NOI18N nameServiceButton.font=Lucida Grande-Plain-10 +openExampleFile.text=Open Example File... +#NOI18N +openExampleFile.font=Lucida Grande 10 Plain +secondLabel.text=please choose one: #NOI18N secondLabel.font=Lucida Grande-Plain-10 diff --git a/src/freimapgsoc/xmlDataSource.java b/src/freimapgsoc/xmlDataSource.java index 43a7d4d..319df71 100644 --- a/src/freimapgsoc/xmlDataSource.java +++ b/src/freimapgsoc/xmlDataSource.java @@ -251,12 +251,7 @@ public HashMap read_conf(HashMap configuration) } @Override - public String getId() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getCurrentID() { + public Vector getLinks() { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/src/freimapgsoc/LayerForm.form b/test/freimapgsoc/LayerForm.form similarity index 100% rename from src/freimapgsoc/LayerForm.form rename to test/freimapgsoc/LayerForm.form diff --git a/src/freimapgsoc/LayerForm.java b/test/freimapgsoc/LayerForm.java similarity index 99% rename from src/freimapgsoc/LayerForm.java rename to test/freimapgsoc/LayerForm.java index ed60a3f..e514999 100644 --- a/src/freimapgsoc/LayerForm.java +++ b/test/freimapgsoc/LayerForm.java @@ -1009,13 +1009,4 @@ public HashMap read_conf(HashMap configuration) throw new UnsupportedOperationException("Not supported yet."); } - @Override - public String getId() { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override - public String getCurrentID() { - throw new UnsupportedOperationException("Not supported yet."); - } } diff --git a/src/freimapgsoc/addNode.form b/test/freimapgsoc/addNode.form similarity index 100% rename from src/freimapgsoc/addNode.form rename to test/freimapgsoc/addNode.form diff --git a/src/freimapgsoc/addNode.java b/test/freimapgsoc/addNode.java similarity index 100% rename from src/freimapgsoc/addNode.java rename to test/freimapgsoc/addNode.java