Commit 176ded37 authored by Christian's avatar Christian
Browse files

Visualization for surf project

parent d529c723
......@@ -388,10 +388,16 @@ public class VisualizationTopologyView extends JFrame
protected class WorldPanel extends JLayeredPane {
protected HashMap<INodeID, VisNodeInformation> nodeInformation = new HashMap<INodeID, VisNodeInformation>();
protected HashMap<INodeID, VisNodeInformation> staticGwNodeInformation = new HashMap<INodeID, VisNodeInformation>();
protected HashMap<INodeID, VisNodeInformation> mobileGwNodeInformation = new HashMap<INodeID, VisNodeInformation>();
protected HashMap<INodeID, VisNodeInformation> citizenNodeInformation = new HashMap<INodeID, VisNodeInformation>();
protected final static int PADDING = 16;
protected final static int NODE_PAD = 2;
protected final static int STATIC_GW_NODE_PAD = 3;
protected final static int MOBILE_GW_NODE_PAD = 2;
protected final static int CITIZEN_NODE_PAD = 2;
private static final long serialVersionUID = -3023020559483652110L;
......@@ -439,10 +445,39 @@ public class VisualizationTopologyView extends JFrame
}
public void addTopologyComponent(TopologyComponent comp) {
if (!nodeInformation.containsKey(comp.getHost().getId())) {
VisNodeInformation tVis = new VisNodeInformation(comp);
comp.requestLocationUpdates(null, tVis);
nodeInformation.put(comp.getHost().getId(), tVis);
if(comp.getHost().toString().contains("StaticGateways")){
if (!staticGwNodeInformation.containsKey(comp.getHost().getId())) {
VisNodeInformation tVis = new VisNodeInformation(comp);
comp.requestLocationUpdates(null, tVis);
staticGwNodeInformation.put(comp.getHost().getId(), tVis);
}
}
else{
if(comp.getHost().toString().contains("MobileGateways")){
if (!mobileGwNodeInformation.containsKey(comp.getHost().getId())) {
VisNodeInformation tVis = new VisNodeInformation(comp);
comp.requestLocationUpdates(null, tVis);
mobileGwNodeInformation.put(comp.getHost().getId(), tVis);
}
}
else{
if(comp.getHost().toString().contains("Citizens")){
if (!citizenNodeInformation.containsKey(comp.getHost().getId())) {
VisNodeInformation tVis = new VisNodeInformation(comp);
comp.requestLocationUpdates(null, tVis);
citizenNodeInformation.put(comp.getHost().getId(), tVis);
}
}
else{
if (!nodeInformation.containsKey(comp.getHost().getId())) {
VisNodeInformation tVis = new VisNodeInformation(comp);
comp.requestLocationUpdates(null, tVis);
System.out.println("HERE: "+comp.getHost().toString());
nodeInformation.put(comp.getHost().getId(), tVis);
}
}
}
}
}
......@@ -478,6 +513,79 @@ public class VisualizationTopologyView extends JFrame
}
}
}
for (VisNodeInformation node : staticGwNodeInformation.values()) {
if (node.clicked) {
g2.setColor(Color.MAGENTA);
g2.fillRect((int) node.position.getX() - STATIC_GW_NODE_PAD,
(int) node.position.getY() - STATIC_GW_NODE_PAD,
STATIC_GW_NODE_PAD * 2 + 1, STATIC_GW_NODE_PAD * 2 + 1);
g2.setColor(Color.BLACK);
Font font = new Font("Helvetica", Font.BOLD, 10);
g2.setFont(font);
g2.drawString("SGw"+node.hostId, (int) node.position.getX()- STATIC_GW_NODE_PAD,(int) node.position.getY()- STATIC_GW_NODE_PAD);
} else {
if (showNodes) {
Color col = new Color(153, 0, 0);
g2.setColor(col);
g2.fillRect((int) node.position.getX() - STATIC_GW_NODE_PAD,
(int) node.position.getY() - STATIC_GW_NODE_PAD,
STATIC_GW_NODE_PAD * 2 + 1, STATIC_GW_NODE_PAD * 2 + 1);
g2.setColor(Color.BLACK);
Font font = new Font("Helvetica", Font.BOLD, 10);
g2.setFont(font);
g2.drawString("SGw"+node.hostId, (int) node.position.getX()- STATIC_GW_NODE_PAD,(int) node.position.getY()- STATIC_GW_NODE_PAD);
}
}
}
for (VisNodeInformation node : mobileGwNodeInformation.values()) {
if (node.clicked) {
g2.setColor(Color.MAGENTA);
g2.fillRect((int) node.position.getX() - MOBILE_GW_NODE_PAD,
(int) node.position.getY() - MOBILE_GW_NODE_PAD,
MOBILE_GW_NODE_PAD * 2 + 5, MOBILE_GW_NODE_PAD * 2);
g2.setColor(Color.BLACK);
Font font = new Font("Helvetica", Font.BOLD, 10);
g2.setFont(font);
g2.drawString("MGw"+node.hostId, (int) node.position.getX()- MOBILE_GW_NODE_PAD,(int) node.position.getY()- MOBILE_GW_NODE_PAD);
} else {
if (showNodes) {
// Draw nodes
Color col = new Color(0, 76, 153);
g2.setColor(col);
g2.fillRect((int) node.position.getX() - MOBILE_GW_NODE_PAD,
(int) node.position.getY() - MOBILE_GW_NODE_PAD,
MOBILE_GW_NODE_PAD * 2 + 5, MOBILE_GW_NODE_PAD * 2);
g2.setColor(Color.BLACK);
Font font = new Font("Helvetica", Font.BOLD, 10);
g2.setFont(font);
g2.drawString("MGw"+node.hostId, (int) node.position.getX()- MOBILE_GW_NODE_PAD,(int) node.position.getY()- MOBILE_GW_NODE_PAD);
}
}
}
for (VisNodeInformation node : citizenNodeInformation.values()) {
if (node.clicked) {
g2.setColor(Color.MAGENTA);
g2.fillOval((int) node.position.getX() - CITIZEN_NODE_PAD,
(int) node.position.getY() - CITIZEN_NODE_PAD,
CITIZEN_NODE_PAD * 2 + 1, CITIZEN_NODE_PAD * 2 + 1);
/*g2.setColor(Color.BLACK);
Font font = new Font("Helvetica", Font.BOLD, 12);
g2.setFont(font);
g2.drawString("Cit"+node.hostId, (int) node.position.getX()- CITIZEN_NODE_PAD,(int) node.position.getY()- CITIZEN_NODE_PAD);*/
} else {
if (showNodes) {
// Draw nodes
g2.setColor(Color.GREEN);
g2.fillOval((int) node.position.getX() - CITIZEN_NODE_PAD,
(int) node.position.getY() - CITIZEN_NODE_PAD,
CITIZEN_NODE_PAD * 2 + 1, CITIZEN_NODE_PAD * 2 + 1);
/*g2.setColor(Color.BLACK);
Font font = new Font("Helvetica", Font.BOLD, 12);
g2.setFont(font);
g2.drawString("Cit"+node.hostId, (int) node.position.getX()- CITIZEN_NODE_PAD,(int) node.position.getY()- CITIZEN_NODE_PAD);*/
}
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment