Skip to content

Commit

Permalink
Fixed the issue for the start button with noStore()
Browse files Browse the repository at this point in the history
Fixed the issues for the start/resume/create Button
Now there is a control on the Database name when you create a new Db (you cannot create an Database with no name)
There is no way to read data from httpinfo plugin for other information so I have to Implement the LatLonDataSource for the realtime stream (needs of the latlon.js file of the nameservice plugin)
Added the Runnable Thread for the refreshing of MainLayer
Now MainLayer appear but always with the same information
Starting coding to take Lat/Lon of the nodes from LatLonDataSource

TO DO:
Setting in which store the position of the latlon.js file
Find a method to update the id number of the Layer (Autoincrement in the MySQL?)
Store the information in the Database
Add the possibility to read from two database
Add the possibility to encrypt data during authentication and transactions
Fix issues of the map and the drawing of the links and the nodes on the map
control the status of service discovery and store it in the database
  • Loading branch information
stefano authored and stefano committed Aug 6, 2010
1 parent c15a720 commit 2973a44
Show file tree
Hide file tree
Showing 7 changed files with 275 additions and 262 deletions.
2 changes: 1 addition & 1 deletion src/data/log.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
PopUp Message: There aren't DataSource file to draw! Open a file from File -> Open menu
PopUp Message: There aren't DataSource file to draw Open a file from File -> Open menu
14 changes: 0 additions & 14 deletions src/freimapgsoc/DotPluginListener.java

This file was deleted.

81 changes: 55 additions & 26 deletions src/freimapgsoc/LatLonJsDataSource.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package freimapgsoc;

import java.awt.Point;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -28,6 +29,49 @@ public LatLonJsDataSource(String path) {
this.init(path);
}

public LatLonJsDataSource(String ip, String path){
this.initFromIp(ip,path);
}


public void initFromIp(String ip, String path){
HashMap<Vector<MapNode>, Vector<Link>> config = new HashMap<Vector<MapNode>, Vector<Link>>();
String sServerURL = null;
try {
sServerURL = 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()));
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();
}
config.put(nodes, links);
}


public void init(String path) {
HashMap<Vector<MapNode>, Vector<Link>> config = new HashMap<Vector<MapNode>, Vector<Link>>();
String sServerURL = null;
Expand Down Expand Up @@ -87,12 +131,7 @@ public void parseNode(String path) {
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);
Expand Down Expand Up @@ -215,17 +254,7 @@ public void parseLink(String path) {
//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());

}

} catch (Exception e) {
e.getMessage();
}
Expand Down Expand Up @@ -283,7 +312,7 @@ public void parsePLink(String path) {
}

public void addInterfaces(String path) {
System.out.println("Now take a control if nodes has more than one interface...");
System.out.println("Now check if nodes has more than one interface...");
String sServerURL = path;
try {
BufferedReader in = new BufferedReader(new InputStreamReader(new URL(sServerURL).openStream()));
Expand All @@ -308,15 +337,15 @@ public void addInterfaces(String path) {
//System.out.println("NodesSize: " + nodes.size());

int index = getIndex(nodes, nodeip);
System.out.println(index);
if (index == -1) {
System.out.println("Node is not present in Nodes structure! I create it...");
MapNode nnode;
nnode = new MapNode(nodeip, nodeip); //create a node with name=ip and Default Pos
MapNode nnode=new MapNode(nodeip, nodeip); //create a node with name=ip and Default Pos
nodes.add(nnode);
System.out.println("Node Added now Nodes structure Size is: " + nodes.size());
} else {
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());
// 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);
}
Expand All @@ -332,7 +361,7 @@ public void addInterfaces(String path) {
}

int getIndex(Vector<MapNode> nodes, String nodeip) {
for (int i = 0; i < nodes.size(); i++) {
for (int i = 1; i < nodes.size(); i++) {
if (nodeip.equals(nodes.get(i).ip)) {
return i;
}
Expand Down Expand Up @@ -473,9 +502,9 @@ public MapNode getNodeByIp(String ip) {
public Vector<Link> 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<MapNode> nodes = new Vector<MapNode>();
public Vector<Link> links = new Vector<Link>();
Expand Down
2 changes: 0 additions & 2 deletions src/freimapgsoc/MainLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,11 @@ public String getTileUrl(int x, int y, int zoom) {
}

public void initData(DataSource ds) {

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) {
Expand Down
22 changes: 12 additions & 10 deletions src/freimapgsoc/MySQLCredential.form
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
<Component id="newDb" min="-2" max="-2" attributes="0"/>
<EmptySpace min="5" pref="5" max="5" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="newDbText" min="-2" pref="160" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
Expand Down Expand Up @@ -134,16 +134,18 @@
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="newDbText" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="startButton" alignment="3" min="-2" max="-2" attributes="1"/>
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="1"/>
</Group>
</Group>
<Group type="102" attributes="0">
<EmptySpace min="2" pref="2" max="2" attributes="0"/>
<Component id="newDb" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="newDbText" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="startButton" alignment="3" min="-2" max="-2" attributes="1"/>
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="1"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
Expand Down Expand Up @@ -184,7 +186,7 @@
<Property name="icon" type="javax.swing.Icon" noResource="true" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/freimapgsoc/resources/statuok.png"/>
</Property>
<Property name="text" type="java.lang.String" value="Start"/>
<Property name="text" type="java.lang.String" value="Create"/>
<Property name="enabled" type="boolean" value="false"/>
<Property name="name" type="java.lang.String" value="startButton" noResource="true"/>
</Properties>
Expand Down Expand Up @@ -252,7 +254,7 @@
</Component>
<Component class="javax.swing.JButton" name="continueButton">
<Properties>
<Property name="font" type="java.awt.Font" noResource="true" editor="org.netbeans.beaninfo.editors.FontEditor">
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Lucida Grande" size="10" style="0"/>
</Property>
<Property name="icon" type="javax.swing.Icon" noResource="true" editor="org.netbeans.modules.form.editors2.IconEditor">
Expand Down
Loading

0 comments on commit 2973a44

Please sign in to comment.