Fixing visuals for the SDN-IP demo.

Change-Id: I1d3020ab3787c1b560438e32fe4254edf6a640bd
diff --git a/tools/test/topos/sdn-ip.json b/tools/test/topos/sdn-ip.json
index 80464b1..16f9b45 100644
--- a/tools/test/topos/sdn-ip.json
+++ b/tools/test/topos/sdn-ip.json
@@ -1,4 +1,17 @@
 {
+    "devices": [
+        { "alias":  "s1", "uri": "of:0000000000000001", "mac": "000000000001", "annotations": { "name": "DEN", "latitude": 39.739317, "longitude": -104.983791 }, "type": "SWITCH" },
+        { "alias":  "s2", "uri": "of:0000000000000002", "mac": "000000000002", "annotations": { "name": "ORD", "latitude": 41.880143, "longitude": -87.624257  }, "type": "SWITCH" },
+        { "alias":  "s3", "uri": "of:0000000000000003", "mac": "000000000003", "annotations": { "name": "ABQ", "latitude": 35.116541, "longitude": -106.604146 }, "type": "SWITCH" },
+        { "alias":  "s4", "uri": "of:0000000000000004", "mac": "000000000004", "annotations": { "name": "DFW", "latitude": 32.779501, "longitude": -96.801104  }, "type": "SWITCH" },
+        { "alias":  "s5", "uri": "of:0000000000000005", "mac": "000000000005", "annotations": { "name": "SEA", "latitude": 47.606126, "longitude": -122.332903 }, "type": "SWITCH" },
+        { "alias":  "s6", "uri": "of:0000000000000006", "mac": "000000000006", "annotations": { "name": "SFO", "latitude": 37.785286, "longitude": -122.406509 }, "type": "SWITCH" },
+        { "alias":  "s7", "uri": "of:0000000000000007", "mac": "000000000007", "annotations": { "name": "LAX", "latitude": 34.055604, "longitude": -118.248567 }, "type": "SWITCH" },
+        { "alias":  "s8", "uri": "of:0000000000000008", "mac": "000000000008", "annotations": { "name": "JFK", "latitude": 40.769487, "longitude": -73.972520  }, "type": "SWITCH" },
+        { "alias":  "s9", "uri": "of:0000000000000009", "mac": "000000000009", "annotations": { "name": "IAD", "latitude": 38.897676, "longitude": -77.036525  }, "type": "SWITCH" },
+        { "alias": "s10", "uri": "of:0000000000000010", "mac": "000000000010", "annotations": { "name": "ATL", "latitude": 33.756298, "longitude": -84.388507  }, "type": "SWITCH" }
+    ],
+
     "hosts" : [
         { "mac": "00:00:00:00:00:01", "vlan": -1, "location": "of:0000000000000001/10", "ip": "0.0.0.0", "annotations": { "type": "bgpSpeaker" } },
         { "mac": "00:00:00:00:00:02", "vlan": -1, "location": "of:0000000000000002/10", "ip": "0.0.0.0", "annotations": { "type": "bgpSpeaker" } },
diff --git a/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java b/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java
index 3a64f28..e99749e 100644
--- a/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java
+++ b/web/gui/src/main/java/org/onlab/onos/gui/TopologyViewMessages.java
@@ -56,6 +56,7 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.text.DecimalFormat;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -85,6 +86,15 @@
     private static final ProviderId PID = new ProviderId("core", "org.onlab.onos.core", true);
     private static final String COMPACT = "%s/%s-%s/%s";
 
+    private static final double KB = 1024;
+    private static final double MB = 1024 * KB;
+    private static final double GB = 1024 * MB;
+
+    private static final String GB_UNIT = "GB";
+    private static final String MB_UNIT = "MB";
+    private static final String KB_UNIT = "KB";
+    private static final String B_UNIT = "B";
+
     protected final ServiceDirectory directory;
     protected final ClusterService clusterService;
     protected final DeviceService deviceService;
@@ -424,14 +434,16 @@
             ArrayNode labels = mapper.createArrayNode();
             boolean hasTraffic = false;
             for (Link link : links) {
-                linksNode.add(compactLinkString(link));
-                Load load = statService.load(link);
-                String label = "";
-                if (load.rate() > 0) {
-                    hasTraffic = true;
-                    label = load.latest() + " bytes";
+                if (isInfrastructureEgress(link)) {
+                    linksNode.add(compactLinkString(link));
+                    Load load = statService.load(link);
+                    String label = "";
+                    if (load.rate() > 0) {
+                        hasTraffic = true;
+                        label = format(load);
+                    }
+                    labels.add(label);
                 }
-                labels.add(label);
             }
             pathNode.put("class", hasTraffic ? type + " animated" : type);
             pathNode.put("traffic", hasTraffic);
@@ -441,6 +453,32 @@
         }
     }
 
+    // Poor-mans formatting to get the labels with byte counts looking nice.
+    private String format(Load load) {
+        long bytes = load.latest();
+        String unit;
+        double value;
+        if (bytes > GB) {
+            value = bytes / GB;
+            unit = GB_UNIT;
+        } else if (bytes > MB) {
+            value = bytes / MB;
+            unit = MB_UNIT;
+        } else if (bytes > KB) {
+            value = bytes / KB;
+            unit = KB_UNIT;
+        } else {
+            value = bytes;
+            unit = B_UNIT;
+        }
+        DecimalFormat format = new DecimalFormat("#,###.##");
+        return format.format(value) +  " " + unit;
+    }
+
+    private boolean isInfrastructureEgress(Link link) {
+        return link.src().elementId() instanceof DeviceId;
+    }
+
     // Produces compact string representation of a link.
     private static String compactLinkString(Link link) {
         return String.format(COMPACT, link.src().elementId(), link.src().port(),
diff --git a/web/gui/src/main/webapp/topo2.css b/web/gui/src/main/webapp/topo2.css
index 94af382..3f87d47 100644
--- a/web/gui/src/main/webapp/topo2.css
+++ b/web/gui/src/main/webapp/topo2.css
@@ -143,7 +143,7 @@
 }
 #topo svg .link.animated {
     stroke: #f11;
-    stroke-width: 8px;
+    stroke-width: 6px;
     stroke-dasharray: 8 8
 }
 
@@ -162,15 +162,16 @@
 }
 
 #topo svg .linkLabel rect {
-    fill: #eef;
-    stroke: blue;
-    stroke-width: 0.3;
+    stroke: #999;
+    stroke-width: 1.2px;
+    fill: #eee;
+    stroke: none;
 }
 #topo svg .linkLabel text {
     text-anchor: middle;
-    fill: #a13d11;
-    stroke: none;
-    font-size: 8pt;
+    stroke: #777;
+    stroke-width: 0.1px;
+    font-size: 9pt;
 }
 
 /* Fly-in details pane */