Commit 8a806635 authored by Matt Strum's avatar Matt Strum
Browse files

Added support to combine overlapping nodegroup markers and updated interface. ...

Added support to combine overlapping nodegroup markers and updated interface.  For some reason all the files are 'modified' so most of these files probably haven't changed .... ugh
parent e26a123f
......@@ -9,6 +9,9 @@
<mx:Script>
<![CDATA[
import com.google.maps.MapZoomEvent;
import com.google.maps.MapMoveEvent;
import mx.events.ResizeEvent;
import mx.events.ListEvent;
import mx.events.CollectionEvent;
import mx.collections.ArrayCollection;
......@@ -39,7 +42,6 @@
public var console:ConsoleWindow;
public var rspecView:XmlWindow;
public var about:AboutWindow = new AboutWindow();
public var userWindow:ChangeUserWindow = new ChangeUserWindow();
[Bindable]
public var pgHandler:ProtoGeniHandler;
......@@ -84,10 +86,6 @@
PopUpManager.centerPopUp(about);
}
public function changeUser():void {
userWindow.open();
}
//------------------------------------------
// Component Manager
private function changeCM():void {
......@@ -102,6 +100,7 @@
private function viewRspec():void {
PopUpManager.addPopUp(rspecView, this, false);
PopUpManager.centerPopUp(rspecView);
rspecView.title = "Advertisement RSPEC from " + pgHandler.rpc.ComponentManagerURL;
rspecView.loadXml(pgHandler.rpc.Rspec);
}
......@@ -183,10 +182,17 @@
map.enableScrollWheelZoom();
map.enableContinuousZoom();
map.addEventListener(MapZoomEvent.ZOOM_CHANGED, afterMove);
changeCM();
}
private function afterMove(evt:MapZoomEvent):void
{
pgHandler.map.drawMap();
}
public function setProgress(message:String, color:String):void {
progressLabel.text = message;
if(color.length > 0) {
......@@ -211,7 +217,7 @@
</mx:Script>
<mx:ApplicationControlBar dock="true">
<mx:Label text="ProtoGENI Component Display" fontWeight="bold" fontSize="12"/>
<mx:Label text="ProtoGENI Map" fontWeight="bold" fontSize="12"/>
<mx:VRule height="14"/>
<pgmap:ImageButton id="refreshButton"
source="@Embed('../images/arrow_refresh.png')"
......@@ -231,15 +237,11 @@
toolTip="View the most recent RSpec"/>
<mx:VRule height="14"/>
<mx:ComboBox id="slicesCombobox" dataProvider="{slicesMenu}" labelFunction="getSliceLabel" change="sliceSelected(event)"></mx:ComboBox>
<mx:CheckBox label="Only my resources" id="onlyMyResourcesCheckbox" click="userResourcesOnly = onlyMyResourcesCheckbox.selected; pgHandler.map.drawMap()"/>
<mx:CheckBox label="Mine" id="onlyMyResourcesCheckbox" click="userResourcesOnly = onlyMyResourcesCheckbox.selected; pgHandler.map.drawMap()"/>
<mx:Spacer width="100%"/>
<mx:Label text="Initialized" id="progressLabel" fontStyle="normal" fontWeight="bold"/>
<mx:SWFLoader id="waitingIcon" source="@Embed('../images/waiting.swf')" visible="false"/>
<mx:Spacer width="100%"/>
<pgmap:ImageButton id="userButton"
source="@Embed('../images/user.png')"
click="changeUser()"
toolTip="View the most recent RSpec"/>
<mx:Label text="{pgHandler.CurrentUser.uid}"/>
<pgmap:ImageButton id="infoButton"
source="@Embed('../images/information.png')"
......
<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"
borderAlpha=".9" borderColor="#D2E1F0"
layout="vertical" width="300" title="Change User" showCloseButton="true"
close="close()">
<mx:Script>
<![CDATA[
import mx.managers.PopUpManager;
private var main:pgmap;
public function success():void {
main.pgHandler.CurrentUser.uid = userInput.text;
close();
}
public function close():void {
PopUpManager.removePopUp(this);
}
public function open():void {
main = Common.Main();
PopUpManager.addPopUp(this, main, true);
PopUpManager.centerPopUp(this);
userInput.text = main.pgHandler.CurrentUser.uid;
}
]]>
</mx:Script>
<mx:TextInput width="100%" id="userInput"/>
<mx:HBox width="100%">
<mx:Spacer width="100%"/>
<mx:Button label="Cancel" icon="@Embed('../images/cross.png')" click="close();"/>
<mx:Button label="OK" icon="@Embed('../images/tick.png')" click="success();"/>
</mx:HBox>
</mx:TitleWindow>
......@@ -56,10 +56,10 @@
</mx:HBox>
<mx:HBox width="100%" horizontalAlign="right">
<mx:Label id="progressLabel" fontStyle="normal" fontWeight="bold"/>
<mx:SWFLoader id="waitingIcon" source="@Embed('../../images/waiting.swf')" visible="false"/>
<mx:Spacer width="100%"/>
<mx:Button id="cancelButton" label="Cancel" icon="@Embed('../images/cross.png')" click="close();"/>
<mx:Button id="okButton" label="Go" icon="@Embed('../images/tick.png')" click="success();" enabled="false"/>
<mx:SWFLoader id="waitingIcon" source="@Embed('../../images/waiting.swf')" visible="false"/>
<mx:Spacer width="100%"/>
<mx:Button id="cancelButton" label="Cancel" icon="@Embed('../images/cross.png')" click="close();"/>
<mx:Button id="okButton" label="Go" icon="@Embed('../images/tick.png')" click="success();" enabled="false"/>
</mx:HBox>
</mx:TitleWindow>
......@@ -24,6 +24,7 @@
public function viewRspec():void {
var rspecView:XmlWindow = new XmlWindow();
rspecView.title = "Advertisement RSPEC for " + link.name;
PopUpManager.addPopUp(rspecView, main, false);
PopUpManager.centerPopUp(rspecView);
rspecView.loadXml(link.rspec);
......
......@@ -24,84 +24,68 @@
imgAvailable.source = Common.assignAvailabilityIcon(n);
imgExclusive.source = Common.assignIcon(n.exclusive);
sliverButton.visible = n.sliverRspec != null;
sliverButton.visible = node.sliverRspec != null && node.slice == main.selectedSlice && main.userResourcesOnly;
sliverButton.includeInLayout = sliverButton.visible;
linksEndpointVbox.removeAllChildren();
linksStartpointVbox.removeAllChildren();
physicalLinksVbox.removeAllChildren();
var endpointArray:ArrayCollection = new ArrayCollection();
var startpointArray:ArrayCollection = new ArrayCollection();
loadEndpoints();
loadStartpoints();
loadPhysicalLinks();
loadSlices();
}
public function loadSlices():void {
slicesVbox.removeAllChildren();
if(node.slice != null) {
var slice:Label = new Label();
slice.text = node.slice.hrn;
slicesVbox.addChild(slice);
sliceLinksVbox.removeAllChildren();
if(node.slice != null && node.slice == main.selectedSlice && main.userResourcesOnly) {
linkTabs.addChild(sliceLinksVbox);
var nodeSliceLinks:ArrayCollection = new ArrayCollection();
for each(var l:PointLink in node.slice.Links) {
if(l.node1 == node || l.node2 == node)
nodeSliceLinks.addItem(l);
}
sliceLinksVbox.label = "Slice (" + nodeSliceLinks.length + " Nodes)"
var connectedLabel:Label = new Label();
if(nodeSliceLinks.length > 0)
connectedLabel.text = "Connected on " + node.slice.hrn + " to";
else
connectedLabel.text = "No linked nodes on " + node.slice.hrn;
sliceLinksVbox.addChild(connectedLabel);
for each(var pl:PointLink in node.slice.Links) {
for each(var pl:PointLink in nodeSliceLinks) {
var endNode:Node;
if(pl.node1 == node)
endNode = pl.node2;
else if(pl.node2 == node)
endNode = pl.node1;
else
continue;
var pointLinkHbox:HBox = new HBox();
var space:Spacer = new Spacer();
space.width = 16;
pointLinkHbox.addChild(space);
pointLinkHbox.addChild(Common.getNodeButton(endNode));
slicesVbox.addChild(pointLinkHbox);
}
} else {
var noSlice:Label = new Label();
noSlice.text = "N/A";
slicesVbox.addChild(noSlice);
}
}
public function loadStartpoints():void {
linksStartpointVbox.removeAllChildren();
var nodes:ArrayCollection = new ArrayCollection();
for each(var ni:NodeInterface in node.interfaces.collection) {
var niLabel:Label = new Label();
niLabel.text = ni.id;
linksStartpointVbox.addChild(niLabel);
for each(var l:Link in ni.links) {
var endNode:Node;
if(l.interface1 == ni)
endNode = l.interface2.owner;
else
endNode = l.interface1.owner;
endNode = pl.node1;
if(!nodes.contains(endNode)) {
nodes.addItem(endNode);
var linkHbox:HBox = new HBox();
var space:Spacer = new Spacer();
space.width = 16;
linkHbox.addChild(space);
linkHbox.addChild(Common.getNodeButton(endNode));
linksStartpointVbox.addChild(linkHbox);
}
sliceLinksVbox.addChild(Common.getNodeButton(endNode));
//var pointLinkHbox:HBox = new HBox();
//var space:Spacer = new Spacer();
//space.width = 16;
//pointLinkHbox.addChild(space);
//sliceLinksVbox.addChild(pointLinkHbox);
}
}
} else if(linkTabs.getChildren().length > 1)
linkTabs.removeChild(sliceLinksVbox);
}
public function loadEndpoints():void {
linksEndpointVbox.removeAllChildren();
public function loadPhysicalLinks():void {
physicalLinksVbox.removeAllChildren();
var nodes:ArrayCollection = node.GetNodes();
physicalLinksVbox.label = "Physical (" + nodes.length + " Nodes)"
var connectedLabel:Label = new Label();
if(nodes.length > 0)
connectedLabel.text = "Connected to";
else
connectedLabel.text = "No physically linked nodes";
physicalLinksVbox.addChild(connectedLabel);
for each(var n:Node in nodes) {
linksEndpointVbox.addChild(Common.getNodeButton(n));
physicalLinksVbox.addChild(Common.getNodeButton(n));
var nodeLinks:ArrayCollection = n.GetNodeLinks(node);
for each(var l:Link in nodeLinks) {
......@@ -118,90 +102,14 @@
var endInterfaceButton:Button = Common.getLinkButton(endInterface, l);
endInterfaceButton.label = endInterface.id;
linkHbox.addChild(endInterfaceButton);
linksEndpointVbox.addChild(linkHbox);
physicalLinksVbox.addChild(linkHbox);
}
}
/*
for each(var i:NodeInterface in n.interfaces.collection) {
for each(var l:Link in i.links) {
var n:Node;
var iEnd:NodeInterface;
var iStart:NodeInterface;
if(l.interface1 == i) {
n = l.interface2.owner;
iEnd = l.interface2;
iStart = l.interface1;
} else {
n = l.interface1.owner;
iEnd = l.interface1;
iStart = l.interface2;
}
// Build up endpoint
var nodeFound:Boolean = false;
for each(var na:Object in endpointArray) {
if(na.node == n) {
nodeFound = true;
na.links.addItem({i: iEnd, l: l});
break;
}
}
if(!nodeFound) {
var newLinks:ArrayCollection = new ArrayCollection();
newLinks.addItem({i: iEnd, l: l});
endpointArray.addItem({node: n, links: newLinks});
}
// Build up startpoint
var interfaceFound:Boolean = false;
for each(var ia:Object in startpointArray) {
if(ia.link.i == iStart) {
interfaceFound = true;
if(!ia.nodes.contains(n))
ia.nodes.addItem(n);
break;
}
}
if(!interfaceFound) {
var newNodes:ArrayCollection = new ArrayCollection();
newNodes.addItem(n);
startpointArray.addItem({link: {i: iStart, l: l}, nodes: newNodes});
}
// Build endpoint interface
for each(var nodeInfo:Object in endpointArray) {
linksEndpointVbox.addChild(Common.getNodeButton(nodeInfo.node));
for each(var nodeLink:Object in nodeInfo.links) {
var linkHbox:HBox = new HBox();
var space:Spacer = new Spacer();
space.width = 16;
linkHbox.addChild(space);
linkHbox.addChild(Common.getLinkButton(nodeLink.i, nodeLink.l));
linksEndpointVbox.addChild(linkHbox);
}
}
// Build startpoint interface
for each(var linkInfo:Object in startpointArray) {
linksStartpointVbox.addChild(Common.getLinkButton(linkInfo.link.i, linkInfo.link.l));
for each(var node:Node in linkInfo.nodes) {
var linkHbox2:HBox = new HBox();
var space2:Spacer = new Spacer();
space2.width = 16;
linkHbox2.addChild(space2);
linkHbox2.addChild(Common.getNodeButton(node));
linksStartpointVbox.addChild(linkHbox2);
}
}
}
}*/
}
public function viewComponentRspec():void {
var rspecView:XmlWindow = new XmlWindow();
rspecView.title = "Advertisement RSPEC for " + node.name;
PopUpManager.addPopUp(rspecView, main, false);
PopUpManager.centerPopUp(rspecView);
rspecView.loadXml(node.rspec);
......@@ -212,6 +120,7 @@
Alert.show("No Sliver RSPEC!");
else {
var rspecView:XmlWindow = new XmlWindow();
rspecView.title = "Request RSPEC for " + node.name;
PopUpManager.addPopUp(rspecView, main, false);
PopUpManager.centerPopUp(rspecView);
rspecView.loadXml(node.sliverRspec);
......@@ -230,11 +139,11 @@
<pgmap:ImageButton id="componentButton"
source="@Embed('../images/page_white_code.png')"
click="viewComponentRspec()"
toolTip="Component RSPEC" />
toolTip="View Advertisement RSPEC" />
<pgmap:ImageButton id="sliverButton"
source="@Embed('../images/page_code.png')"
click="viewSliverRspec()"
toolTip="Sliver RSPEC" visible="false" />
toolTip="View Request RSPEC" visible="false" />
</mx:GridItem>
</mx:GridRow>
<mx:GridRow width="100%">
......@@ -293,12 +202,10 @@
</mx:VBox>
</mx:GridItem>
<mx:GridItem width="100%">
<mx:TabNavigator width="100%" height="100%" paddingTop="2" paddingRight="2" paddingLeft="2" paddingBottom="2">
<mx:VBox label="Endpoint" width="100%" height="100%" id="linksEndpointVbox">
</mx:VBox>
<mx:VBox label="Startpoint" width="100%" height="100%" id="linksStartpointVbox">
<mx:TabNavigator id="linkTabs" width="100%" height="100%" paddingTop="2" paddingRight="2" paddingLeft="2" paddingBottom="2">
<mx:VBox label="Physical" width="100%" height="100%" id="physicalLinksVbox">
</mx:VBox>
<mx:VBox label="Slice" width="100%" height="100%" id="slicesVbox">
<mx:VBox label="Slice" width="100%" height="100%" id="sliceLinksVbox">
</mx:VBox>
</mx:TabNavigator>
</mx:GridItem>
......
......@@ -8,6 +8,8 @@
<mx:Script>
<![CDATA[
import mx.collections.SortField;
import mx.collections.Sort;
import mx.controls.Spacer;
import mx.containers.HBox;
import mx.controls.Button;
......@@ -26,6 +28,14 @@
public function loadCollection(group:ArrayCollection):void {
nodes = group;
var nameSort:Sort = new Sort();
var dataSortField:SortField = new SortField();
dataSortField.name = "name";
nameSort.fields = [dataSortField];
nodes.sort = nameSort;
nodes.refresh();
if(nodes.length > 1) {
listNodes.selectedIndex = 0;
title += " Group";
......
......@@ -28,6 +28,8 @@
[Bindable]
public var node2:Node;
public var type:String;
public var slice : Slice = null;
public var sliverRspec:XML;
......
......@@ -18,8 +18,10 @@
import flash.utils.Dictionary;
import mx.collections.ArrayCollection;
import mx.collections.Sort;
import mx.controls.Alert;
import mx.managers.PopUpManager;
import mx.utils.ObjectUtil;
public class ProtoGeniHandler
{
......@@ -37,8 +39,6 @@
public var Nodes:NodeGroupCollection = new NodeGroupCollection();
public var Links:LinkGroupCollection = new LinkGroupCollection();
public var Slices:ArrayCollection = new ArrayCollection();
public function ProtoGeniHandler(m:pgmap)
{
rpc = new ProtoGeniRpcHandler();
......@@ -52,7 +52,6 @@
{
Nodes = new NodeGroupCollection();
Links = new LinkGroupCollection();
Slices = new ArrayCollection();
}
public function getCredential(afterCompletion : Function):void {
......@@ -163,7 +162,7 @@
return;
}
//main.console.appendText("parsing...");
main.console.appendText(fullIdx.toString());
//main.console.appendText(fullIdx.toString());
var location:XML = locations[fullIdx];
var lat:Number = Number(location.@latitude);
......
......@@ -5,6 +5,8 @@ package pgmap
import com.google.maps.MapMouseEvent;
import com.google.maps.overlays.Marker;
import com.google.maps.overlays.MarkerOptions;
import com.google.maps.overlays.Polygon;
import com.google.maps.overlays.PolygonOptions;
import com.google.maps.overlays.Polyline;
import com.google.maps.overlays.PolylineOptions;
import com.google.maps.services.ClientGeocoder;
......@@ -13,10 +15,12 @@ package pgmap
import com.google.maps.styles.FillStyle;
import com.google.maps.styles.StrokeStyle;
import flash.display.DisplayObject;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;
import mx.collections.ArrayCollection;
import mx.managers.PopUpManager;
public class ProtoGeniMapHandler
......@@ -27,6 +31,9 @@ package pgmap
{
}
private var markers:ArrayCollection;
private var nodeGroupClusters:ArrayCollection;
private function addMarker(g:NodeGroup):void
{
// Create the group to be drawn
......@@ -85,10 +92,10 @@ package pgmap
geocoder.addEventListener(GeocodingEvent.GEOCODING_FAILURE,
function(event:GeocodingEvent):void {
//Alert.show("Geocoding failed");
main.console.appendText("Geocoding failed!\n");
});
//geocoder.reverseGeocode(new LatLng(g.latitude, g.longitude));
geocoder.reverseGeocode(new LatLng(g.latitude, g.longitude));
m.addEventListener(MapMouseEvent.CLICK, function(e:Event):void {
m.openInfoWindow(
......@@ -102,6 +109,7 @@ package pgmap
});
main.map.addOverlay(m);
markers.addItem({marker:m, nodeGroup:g});
} else {
// Draw an empty marker
var nonodes:Marker = new Marker(
......@@ -118,11 +126,63 @@ package pgmap
}
private function addNodeGroupCluster(nodeGroups:ArrayCollection):void {
var totalNodes:Number = 0;
var upperLat:Number = nodeGroups[0].nodeGroup.latitude;
var lowerLat:Number = nodeGroups[0].nodeGroup.latitude;
var rightLong:Number = nodeGroups[0].nodeGroup.longitude;
var leftLong:Number = nodeGroups[0].nodeGroup.longitude;
for each(var o:Object in nodeGroups) {
if(o.nodeGroup.latitude > upperLat)
upperLat = o.nodeGroup.latitude;
else if(o.nodeGroup.latitude < lowerLat)
lowerLat = o.nodeGroup.latitude;
if(o.nodeGroup.longitude > rightLong)
rightLong = o.nodeGroup.longitude;
else if(o.nodeGroup.longitude < leftLong)
leftLong = o.nodeGroup.longitude;
totalNodes += o.nodeGroup.collection.length;
o.marker.visible = false;
}
var polygon:Polygon = new Polygon([
new LatLng(upperLat, leftLong),
new LatLng(upperLat, rightLong),
new LatLng(lowerLat, rightLong),
new LatLng(lowerLat, leftLong),
new LatLng(upperLat, leftLong)
],
new PolygonOptions({
strokeStyle: new StrokeStyle({
color: 0x0000ff,
thickness: 2,
alpha: 0.5}),
fillStyle: new FillStyle({
color: 0x0000ff,
alpha: 0.5})
}));
main.map.addOverlay(polygon);
var m:Marker = new Marker(
new LatLng((upperLat + lowerLat)/2, (rightLong + leftLong)/2),
new MarkerOptions({
strokeStyle: new StrokeStyle({color: 0x092791}),
fillStyle: new FillStyle({color: 0xa0c8f1, alpha: 1}),
radius: 14,
hasShadow: true,
//tooltip: g.country,
label: totalNodes.toString()
}));
main.map.addOverlay(m);
}
public function addLink(lg:LinkGroup):void {
// Create the group to be drawn
var drawGroup:LinkGroup = lg;
if(drawGroup.collection.length > 0) {
if(drawGroup.collection.length > 0 && !main.userResourcesOnly) {
// Add line
var polyline:Polyline = new Polyline([
new LatLng(drawGroup.latitude1, drawGroup.longitude1),
......@@ -162,15 +222,19 @@ package pgmap
public function addPointLink(pl:PointLink):void {
// Create the group to be drawn
if(pl.slice != main.selectedSlice)
if(pl.slice != main.selectedSlice ||