flex拓扑图制作

1、把节点封装成as的类
2、把连线也封装成as的类
3、一个测试文件

NeMap.as 节点类
  1. package{  
  2.     import mx.containers.Canvas;  
  3.     import mx.controls.Image;  
  4.     import mx.controls.Label;  
  5.     import flash.ui.ContextMenu;  
  6.     import flash.ui.ContextMenuItem;  
  7.     import mx.events.MenuEvent;  
  8.     import flash.events.MouseEvent;  
  9.     import mx.containers.Canvas;  
  10.     import flash.display.Sprite;  
  11.     import mx.controls.Alert;  
  12.     import flash.events.FocusEvent;  
  13.     import flash.events.ActivityEvent;  
  14.     import flash.utils.Dictionary;  
  15.     import flash.events.Event;  
  16.     import mx.events.DragEvent;  
  17.     import mx.events.StateChangeEvent;  
  18.     import mx.events.FlexEvent;  
  19.     import mx.events.MoveEvent;  
  20.     import flash.events.StatusEvent;  
  21.     public class NeMap extends mx.containers.Canvas {  
  22.         private var nePic :String = "ASSETS/LSTP.PNG";//网元图  
  23.         private var neState:String = "ASSETS/clearStatus.gif";//网元状态图  
  24.         private var neName:String = "北京HSTPA";  
  25.         private var lineList:Array =new Array();  
  26.         private var lineCount:int = 0;  
  27.         private var x_Coordinates:int = 100;  
  28.         private var y_Coordinates:int = 100;  
  29.           
  30.         private var nePicImage:Image = new Image();  
  31.         private var neStateImage:Image = new Image();  
  32.         private var neNameLable:Label = new Label();  
  33.           
  34.         private var oldIndex:int = 0;  
  35.           
  36.         public function NeMap(x:int,y:int,ne:String){  
  37.             this.width  = 60;  
  38.             this.height = 60;  
  39.             this.x = x;  
  40.             this.y = y;  
  41.             this.neName = ne;  
  42.             init();  
  43.         }  
  44.           
  45.           
  46.         private function init():void{  
  47.                   
  48.             this.addEventListener(flash.events.MouseEvent.MOUSE_DOWN,dragBegin);  
  49.             this.addEventListener(flash.events.MouseEvent.MOUSE_UP,dragEnd);  
  50.             this.addEventListener(flash.events.MouseEvent.MOUSE_MOVE,dragEnd2);  
  51.             this.addEventListener(mx.events.MoveEvent.MOVE,dragEnd1);  
  52.             //this.addEventListener(mx.events.MoveEvent.MOVE,dragEnd1);  
  53.             //neStateImage.addEventListener();  
  54.               
  55.             //this.addEventListener(flash.events.MouseEvent.ROLL_OUT,dragEnd);  
  56.             this.addEventListener(flash.events.MouseEvent.MOUSE_OVER,selectedNe);  
  57.             this.addEventListener(flash.events.MouseEvent.MOUSE_OUT,noSelectedNe);  
  58.           
  59.             initNePic();  
  60.             initNeState();        
  61.             initLabel();  
  62.               
  63.             this.addChild(nePicImage);  
  64.             this.addChild(neStateImage);  
  65.             this.addChild(neNameLable);  
  66.             this.verticalScrollPolicy = "off";  
  67.             this.horizontalScrollPolicy = "off";  
  68.               
  69.             this.contextMenu = initPopMenu();             
  70.         }  
  71.           
  72.         private function dragBegin(event:MouseEvent):void{  
  73.             //Alert.show(String(this.parent.numChildren));  
  74.             oldIndex = this.parent.getChildIndex(this);  
  75.             this.parent.setChildIndex(this,this.parent.numChildren-1);  
  76.             this.startDrag(false);        
  77.         }  
  78.           
  79.         private function dragEnd(event:MouseEvent):void{  
  80.             this.parent.setChildIndex(this,oldIndex);  
  81.             this.stopDrag();              
  82.             /*var x:int = getCenterX(); 
  83.             var y:int = getCenterY(); 
  84.             for(var i:int=0;i<lineList.length;i++){               
  85.                 var nelineFlag:NeLineFlag = lineList[i]; 
  86.                 var line:ExpanLine = nelineFlag.getLine(); 
  87.                 var isHeaderLine:Boolean =  nelineFlag.getFlag(); 
  88.                 line.removeLine(); 
  89.                 if(isHeaderLine){ 
  90.                     line.setBeginX(x); 
  91.                     line.setBeginY(y); 
  92.                     line.resetBeginLine(x,y); 
  93.                 }else{ 
  94.                     line.setEndX(x); 
  95.                     line.setEndY(y); 
  96.                     line.resetEndLine(x,y); 
  97.                 }    
  98.             }*/       
  99.         }  
  100.           
  101.         private function dragEnd1(event:MoveEvent):void{  
  102.            refreshLine();  
  103.         }  
  104.           
  105.         private function dragEnd2(event:MouseEvent):void{  
  106.            refreshLine();  
  107.         }  
  108.           
  109.         private function refreshLine():void{  
  110.              var x:int = getCenterX();  
  111.             var y:int = getCenterY();  
  112.             for(var i:int=0;i<lineList.length;i++){                
  113.                 var nelineFlag:NeLineFlag = lineList[i];  
  114.                 var line:ExpanLine = nelineFlag.getLine();  
  115.                 var isHeaderLine:Boolean =  nelineFlag.getFlag();  
  116.                 line.removeLine();  
  117.                 if(isHeaderLine){  
  118.                     line.setBeginX(x);  
  119.                     line.setBeginY(y);  
  120.                     line.resetBeginLine(x,y);  
  121.                 }else{  
  122.                     line.setEndX(x);  
  123.                     line.setEndY(y);  
  124.                     line.resetEndLine(x,y);  
  125.                 }     
  126.             }         
  127.         }  
  128.           
  129.         //增加边框  
  130.         private function selectedNe(event:MouseEvent):void{  
  131.             //this.setStyle("borderColor","#FF0000");  
  132.             //this.setStyle("borderStyle","outset");  
  133.         }  
  134.           
  135.         private function noSelectedNe(event:MouseEvent):void{  
  136.             this.setStyle("borderColor","");  
  137.             this.setStyle("borderStyle","");  
  138.         }  
  139.           
  140.         private function initNePic():void{  
  141.             nePicImage.source = nePic;  
  142.             nePicImage.x = 10;  
  143.             nePicImage.y = 0;  
  144.             nePicImage.width = 30;  
  145.             nePicImage.height = 46;  
  146.         }  
  147.           
  148.         private function initNeState():void{  
  149.             neStateImage.source = neState;  
  150.             neStateImage.x = 0;  
  151.             neStateImage.y = 0;  
  152.             neStateImage.width = 10;  
  153.             neStateImage.height = 10;  
  154.         }  
  155.           
  156.         private function initLabel():void{  
  157.             neNameLable.text = neName;  
  158.             neNameLable.x = 0;  
  159.             neNameLable.y = 45;  
  160.             neNameLable.width = 60;  
  161.             neNameLable.height = 20;  
  162.         }  
  163.           
  164.         private function initPopMenu():ContextMenu{  
  165.             var contextMenu : ContextMenu = new ContextMenu();  
  166.             contextMenu.hideBuiltInItems();  
  167.             var contextMenuItem1 : ContextMenuItem = new ContextMenuItem("网元信息");  
  168.             var contextMenuItem2 : ContextMenuItem = new ContextMenuItem("告警信息");  
  169.             var contextMenuItem3 : ContextMenuItem = new ContextMenuItem("历史告警");  
  170.             contextMenu.customItems.push(contextMenuItem1);  
  171.             contextMenu.customItems.push(contextMenuItem2);  
  172.             contextMenu.customItems.push(contextMenuItem3);  
  173.               
  174.             return contextMenu;  
  175.         }  
  176.           
  177.         public function getCenterX():int{  
  178.             return this.x+10;  
  179.         }  
  180.           
  181.         public function getCenterY():int{  
  182.             return this.y+10;  
  183.         }  
  184.           
  185.         public function setLine(line1:ExpanLine,flag:Boolean):void{  
  186.             var neLineFlag:NeLineFlag = new NeLineFlag(line1,flag);  
  187.             lineList[lineCount] = neLineFlag;  
  188.             lineCount++;  
  189.             //this.line = line1;  
  190.             //this.isHeaderLine = flag;  
  191.         }  
  192.           
  193.         public function setNeState(state:String):void{  
  194.             neStateImage.source = state;  
  195.         }  
  196.           
  197.     }  
  198. }  
package{ 	import mx.containers.Canvas; 	import mx.controls.Image; 	import mx.controls.Label; 	import flash.ui.ContextMenu; 	import flash.ui.ContextMenuItem; 	import mx.events.MenuEvent; 	import flash.events.MouseEvent; 	import mx.containers.Canvas; 	import flash.display.Sprite; 	import mx.controls.Alert; 	import flash.events.FocusEvent; 	import flash.events.ActivityEvent; 	import flash.utils.Dictionary; 	import flash.events.Event; 	import mx.events.DragEvent; 	import mx.events.StateChangeEvent; 	import mx.events.FlexEvent; 	import mx.events.MoveEvent; 	import flash.events.StatusEvent; 	public class NeMap extends mx.containers.Canvas { 		private var nePic :String = "ASSETS/LSTP.PNG";//网元图 		private var neState:String = "ASSETS/clearStatus.gif";//网元状态图 		private var neName:String = "北京HSTPA"; 		private var lineList:Array =new Array(); 		private var lineCount:int = 0; 		private var x_Coordinates:int = 100; 		private var y_Coordinates:int = 100; 		 		private var nePicImage:Image = new Image(); 		private var neStateImage:Image = new Image(); 		private var neNameLable:Label = new Label(); 		 		private var oldIndex:int = 0; 		 		public function NeMap(x:int,y:int,ne:String){ 			this.width  = 60; 			this.height = 60; 			this.x = x; 			this.y = y; 			this.neName = ne; 			init(); 		} 		 		 		private function init():void{ 				 			this.addEventListener(flash.events.MouseEvent.MOUSE_DOWN,dragBegin); 			this.addEventListener(flash.events.MouseEvent.MOUSE_UP,dragEnd); 			this.addEventListener(flash.events.MouseEvent.MOUSE_MOVE,dragEnd2); 			this.addEventListener(mx.events.MoveEvent.MOVE,dragEnd1); 			//this.addEventListener(mx.events.MoveEvent.MOVE,dragEnd1); 			//neStateImage.addEventListener(); 			 			//this.addEventListener(flash.events.MouseEvent.ROLL_OUT,dragEnd); 			this.addEventListener(flash.events.MouseEvent.MOUSE_OVER,selectedNe); 			this.addEventListener(flash.events.MouseEvent.MOUSE_OUT,noSelectedNe); 		 			initNePic(); 			initNeState();		 			initLabel(); 			 			this.addChild(nePicImage); 			this.addChild(neStateImage); 			this.addChild(neNameLable); 			this.verticalScrollPolicy = "off"; 			this.horizontalScrollPolicy = "off"; 			 			this.contextMenu = initPopMenu();			 		} 		 		private function dragBegin(event:MouseEvent):void{ 			//Alert.show(String(this.parent.numChildren)); 			oldIndex = this.parent.getChildIndex(this); 			this.parent.setChildIndex(this,this.parent.numChildren-1); 			this.startDrag(false);		 		} 		 		private function dragEnd(event:MouseEvent):void{ 			this.parent.setChildIndex(this,oldIndex); 			this.stopDrag();		     			/*var x:int = getCenterX(); 			var y:int = getCenterY(); 			for(var i:int=0;i<lineList.length;i++){				 				var nelineFlag:NeLineFlag = lineList[i]; 			    var line:ExpanLine = nelineFlag.getLine(); 			    var isHeaderLine:Boolean = 	nelineFlag.getFlag(); 			    line.removeLine(); 			    if(isHeaderLine){ 					line.setBeginX(x); 					line.setBeginY(y); 					line.resetBeginLine(x,y); 				}else{ 					line.setEndX(x); 					line.setEndY(y); 					line.resetEndLine(x,y); 				}	 			}*/		 		} 		 		private function dragEnd1(event:MoveEvent):void{ 		   refreshLine(); 		} 		 		private function dragEnd2(event:MouseEvent):void{ 		   refreshLine(); 		} 		 		private function refreshLine():void{ 			 var x:int = getCenterX(); 			var y:int = getCenterY(); 			for(var i:int=0;i<lineList.length;i++){				 				var nelineFlag:NeLineFlag = lineList[i]; 			    var line:ExpanLine = nelineFlag.getLine(); 			    var isHeaderLine:Boolean = 	nelineFlag.getFlag(); 			    line.removeLine(); 			    if(isHeaderLine){ 					line.setBeginX(x); 					line.setBeginY(y); 					line.resetBeginLine(x,y); 				}else{ 					line.setEndX(x); 					line.setEndY(y); 					line.resetEndLine(x,y); 				}	 			}		 		} 		 		//增加边框 		private function selectedNe(event:MouseEvent):void{ 			//this.setStyle("borderColor","#FF0000"); 			//this.setStyle("borderStyle","outset"); 		} 		 		private function noSelectedNe(event:MouseEvent):void{ 			this.setStyle("borderColor",""); 			this.setStyle("borderStyle",""); 		} 		 		private function initNePic():void{ 			nePicImage.source = nePic; 			nePicImage.x = 10; 			nePicImage.y = 0; 			nePicImage.width = 30; 			nePicImage.height = 46; 		} 		 		private function initNeState():void{ 			neStateImage.source = neState; 			neStateImage.x = 0; 			neStateImage.y = 0; 			neStateImage.width = 10; 			neStateImage.height = 10; 		} 		 		private function initLabel():void{ 			neNameLable.text = neName; 			neNameLable.x = 0; 			neNameLable.y = 45; 			neNameLable.width = 60; 			neNameLable.height = 20; 		} 		 		private function initPopMenu():ContextMenu{ 			var contextMenu : ContextMenu = new ContextMenu(); 			contextMenu.hideBuiltInItems(); 			var contextMenuItem1 : ContextMenuItem = new ContextMenuItem("网元信息"); 			var contextMenuItem2 : ContextMenuItem = new ContextMenuItem("告警信息"); 			var contextMenuItem3 : ContextMenuItem = new ContextMenuItem("历史告警"); 			contextMenu.customItems.push(contextMenuItem1); 			contextMenu.customItems.push(contextMenuItem2); 			contextMenu.customItems.push(contextMenuItem3); 			 			return contextMenu; 		} 		 		public function getCenterX():int{ 			return this.x+10; 		} 		 		public function getCenterY():int{ 			return this.y+10; 		} 		 		public function setLine(line1:ExpanLine,flag:Boolean):void{ 			var neLineFlag:NeLineFlag = new NeLineFlag(line1,flag); 			lineList[lineCount] = neLineFlag; 			lineCount++; 			//this.line = line1; 			//this.isHeaderLine = flag; 		} 		 		public function setNeState(state:String):void{ 			neStateImage.source = state; 		} 		 	} } 


ExpanLine.as 连线类
  1. package   
  2. {      
  3.     import flash.display.Shape;  
  4.     import mx.core.UIComponent;  
  5.     import flash.display.Sprite;  
  6.     import flash.ui.ContextMenu;  
  7.     import flash.ui.ContextMenuItem;  
  8.     import mx.containers.Canvas;  
  9.     import mx.containers.Panel;  
  10.     import flash.events.MouseEvent;  
  11.     import mx.controls.Alert;  
  12.     import mx.controls.Label;  
  13.     import mx.managers.PopUpManager;  
  14.     import flash.display.DisplayObject;  
  15.     import mx.managers.ToolTipManager;  
  16.     import mx.controls.ToolTip;  
  17.     import flash.events.Event;  
  18.     import flash.events.TextEvent;  
  19.     import flash.events.TimerEvent;  
  20.     import flash.events.SyncEvent;  
  21.     import mx.events.ToolTipEvent;  
  22.     import mx.core.IToolTip;  
  23.     import mx.controls.Button;  
  24.     import flash.net.URLRequest;  
  25.     import flash.net.navigateToURL;  
  26.       
  27.     public class ExpanLine extends mx.controls.Button  
  28.     {  
  29.         private var line_x1:int;//连线一段  
  30.         private var line_y1:int;  
  31.         private var line_x2:int;//连线另一段  
  32.         private var line_y2:int;  
  33.         //private var lines :Sprite =  new Sprite();  
  34.           
  35.         private var lines:Label = new Label();  
  36.           
  37.         private var myPanel:ShowFlow = null;  
  38.           
  39.         private var parentWindow:Cond;  
  40.           
  41.         public var myTip:IToolTip;  
  42.           
  43.           
  44.           
  45.         public function ExpanLine(x1:int,y1:int,x2:int,y2:int,parent:Cond){  
  46.             line_x1 = x1;  
  47.             line_y1 = y1;  
  48.             line_x2 = x2;  
  49.             line_y2 = y2;         
  50.             parentWindow = parent;  
  51.               
  52.               
  53.               
  54.             lines.graphics.lineStyle(2,0x0099ff,1);  
  55.             lines.graphics.moveTo(line_x1,line_y1);  
  56.             lines.graphics.lineTo(line_x2,line_y2);   
  57.               
  58.             lines.toolTip = "111111111";  
  59.               
  60.             //lines.addEventListener(flash.events.MouseEvent.ROLL_OVER,createToopTip);  
  61.             //lines.addEventListener(flash.events.MouseEvent.ROLL_OUT,hideToopTip);           
  62.             //lines.addEventListener(mx.events.ToolTipEvent.TOOL_TIP_CREATE,createCustomToolTip);  
  63.             lines.addEventListener(flash.events.MouseEvent.CLICK,doubleLineInterface);  
  64.               
  65.               
  66.               
  67.             var contextMenu : ContextMenu = new ContextMenu();  
  68.             contextMenu.hideBuiltInItems(); // 隐藏一些内建的鼠标右键菜单项  
  69.             var contextMenuItem1 : ContextMenuItem = new ContextMenuItem("链路信息");  
  70.             var contextMenuItem2 : ContextMenuItem = new ContextMenuItem("告警信息");  
  71.             var contextMenuItem3 : ContextMenuItem = new ContextMenuItem("历史告警");  
  72.             contextMenu.customItems.push(contextMenuItem1);  
  73.             contextMenu.customItems.push(contextMenuItem2);  
  74.             contextMenu.customItems.push(contextMenuItem3);  
  75.             lines.contextMenu = contextMenu;              
  76.               
  77.         }  
  78.           
  79.         public function doubleLineInterface(event:MouseEvent):void{  
  80.             Alert.show("aaaaa");  
  81.             //var url:URLRequest=new URLRequest("./ipInterface.do?ipInterfaceId="+interfaceId);  
  82.             //navigateToURL(url,"_blank");  
  83.         }  
  84.           
  85.         public function createToopTip(event:MouseEvent):void{  
  86.               
  87.             var ptt:PanelToolTip = new PanelToolTip();  
  88.               
  89.               
  90.             //ToolTipManager.toolTipClass = myTip;  
  91.             //myTip.addEventListener(mx.events.ToolTipEvent.TOOL_TIP_CREATE,createCustomToolTip);  
  92.             myTip = ToolTipManager.createToolTip("aaa",10,10) as IToolTip;  
  93.               
  94.             //ToolTipManager.currentToolTip = ptt;  
  95.             //ToolTipManager.enabled = true;  
  96.               
  97.               
  98.             //myTip = ToolTip(ptt);  
  99.             myTip.x = event.localX;  
  100.             myTip.y = event.localY;       
  101.               
  102.             //myTip.setStyle("backgroundColor",0xFFCC00);  
  103.             //myTip.width = 150;  
  104.             //myTip.height = 200;  
  105.         }  
  106.           
  107.         public function hideToopTip(event:MouseEvent):void{  
  108.             ToolTipManager.destroyToolTip(myTip);  
  109.         }  
  110.           
  111.         public function createCustomToolTip(event:ToolTipEvent):void{  
  112.             var ptt:PanelToolTip = new PanelToolTip();  
  113.             ptt.nodeId = "10";  
  114.             event.toolTip = ptt;  
  115.         }  
  116.           
  117.         public function resetBeginLine(x1:int,y1:int):void{  
  118.             lines.graphics.clear();  
  119.             lines.graphics.lineStyle(2,0x0099ff,1);  
  120.             lines.graphics.moveTo(x1,y1);  
  121.             lines.graphics.lineTo(line_x2,line_y2);  
  122.         }  
  123.           
  124.         public function resetEndLine(x1:int,y1:int):void{  
  125.             lines.graphics.clear();  
  126.             lines.graphics.lineStyle(2,0x0099ff,1);  
  127.             lines.graphics.moveTo(line_x1,line_y1);  
  128.             lines.graphics.lineTo(x1,y1);  
  129.         }  
  130.           
  131.         public function refreshLine():void{  
  132.             lines.graphics.clear();  
  133.             lines.graphics.lineStyle(2,0xFF0000,1);  
  134.             lines.graphics.moveTo(line_x1,line_y1);  
  135.             lines.graphics.lineTo(line_x2,line_y2);   
  136.         }  
  137.           
  138.         public function removeLine():void{  
  139.             lines.graphics.clear();  
  140.         }  
  141.           
  142.         public function getLine():Sprite{  
  143.             return lines;  
  144.         }     
  145.           
  146.         public function getBeginX():int{  
  147.             return line_x1;  
  148.         }  
  149.           
  150.         public function getBeginY():int{  
  151.             return line_y1;  
  152.         }  
  153.           
  154.         public function getEndX():int{  
  155.             return line_x2;  
  156.         }  
  157.           
  158.         public function getEndY():int{  
  159.             return line_y2;  
  160.         }  
  161.           
  162.         public function setBeginX(x1:int):void{  
  163.             line_x1 = x1;  
  164.         }  
  165.           
  166.         public function setBeginY(y1:int):void{  
  167.             line_y1 = y1;  
  168.         }  
  169.           
  170.         public function setEndX(x2:int):void{  
  171.             line_x2 = x2;  
  172.         }  
  173.           
  174.         public function setEndY(y2:int):void{  
  175.             line_y2 = y2;  
  176.         }         
  177.     }  
  178. }  
package  {         import flash.display.Shape; 	import mx.core.UIComponent; 	import flash.display.Sprite; 	import flash.ui.ContextMenu; 	import flash.ui.ContextMenuItem; 	import mx.containers.Canvas; 	import mx.containers.Panel; 	import flash.events.MouseEvent; 	import mx.controls.Alert; 	import mx.controls.Label; 	import mx.managers.PopUpManager; 	import flash.display.DisplayObject; 	import mx.managers.ToolTipManager; 	import mx.controls.ToolTip; 	import flash.events.Event; 	import flash.events.TextEvent; 	import flash.events.TimerEvent; 	import flash.events.SyncEvent; 	import mx.events.ToolTipEvent; 	import mx.core.IToolTip; 	import mx.controls.Button; 	import flash.net.URLRequest; 	import flash.net.navigateToURL; 	 	public class ExpanLine extends mx.controls.Button 	{ 		private var line_x1:int;//连线一段 		private var line_y1:int; 		private var line_x2:int;//连线另一段 		private var line_y2:int; 		//private var lines :Sprite =  new Sprite(); 		 		private var lines:Label = new Label(); 		 		private var myPanel:ShowFlow = null; 		 		private var parentWindow:Cond; 		 		public var myTip:IToolTip; 		 		 		 		public function ExpanLine(x1:int,y1:int,x2:int,y2:int,parent:Cond){ 			line_x1 = x1; 			line_y1 = y1; 			line_x2 = x2; 			line_y2 = y2;		 			parentWindow = parent; 			 			 			 			lines.graphics.lineStyle(2,0x0099ff,1); 			lines.graphics.moveTo(line_x1,line_y1); 			lines.graphics.lineTo(line_x2,line_y2);	 			 			lines.toolTip = "111111111"; 			 			//lines.addEventListener(flash.events.MouseEvent.ROLL_OVER,createToopTip); 			//lines.addEventListener(flash.events.MouseEvent.ROLL_OUT,hideToopTip);			             //lines.addEventListener(mx.events.ToolTipEvent.TOOL_TIP_CREATE,createCustomToolTip);             lines.addEventListener(flash.events.MouseEvent.CLICK,doubleLineInterface); 			 			 			 			var contextMenu : ContextMenu = new ContextMenu(); 			contextMenu.hideBuiltInItems(); // 隐藏一些内建的鼠标右键菜单项 			var contextMenuItem1 : ContextMenuItem = new ContextMenuItem("链路信息"); 			var contextMenuItem2 : ContextMenuItem = new ContextMenuItem("告警信息"); 			var contextMenuItem3 : ContextMenuItem = new ContextMenuItem("历史告警"); 			contextMenu.customItems.push(contextMenuItem1); 			contextMenu.customItems.push(contextMenuItem2); 			contextMenu.customItems.push(contextMenuItem3); 			lines.contextMenu = contextMenu;			 			 		} 		 		public function doubleLineInterface(event:MouseEvent):void{ 			Alert.show("aaaaa"); 			//var url:URLRequest=new URLRequest("./ipInterface.do?ipInterfaceId="+interfaceId);   	    	//navigateToURL(url,"_blank"); 		} 		 		public function createToopTip(event:MouseEvent):void{ 			 			var ptt:PanelToolTip = new PanelToolTip(); 			 			 			//ToolTipManager.toolTipClass = myTip; 			//myTip.addEventListener(mx.events.ToolTipEvent.TOOL_TIP_CREATE,createCustomToolTip); 			myTip = ToolTipManager.createToolTip("aaa",10,10) as IToolTip; 			 			//ToolTipManager.currentToolTip = ptt; 			//ToolTipManager.enabled = true; 			 			 			//myTip = ToolTip(ptt); 			myTip.x = event.localX; 			myTip.y = event.localY;		 			 			//myTip.setStyle("backgroundColor",0xFFCC00); 			//myTip.width = 150; 			//myTip.height = 200; 		} 		 		public function hideToopTip(event:MouseEvent):void{ 			ToolTipManager.destroyToolTip(myTip); 		} 		 		public function createCustomToolTip(event:ToolTipEvent):void{ 			var ptt:PanelToolTip = new PanelToolTip(); 			ptt.nodeId = "10"; 			event.toolTip = ptt; 		} 		 		public function resetBeginLine(x1:int,y1:int):void{ 			lines.graphics.clear(); 			lines.graphics.lineStyle(2,0x0099ff,1); 			lines.graphics.moveTo(x1,y1); 			lines.graphics.lineTo(line_x2,line_y2); 		} 		 		public function resetEndLine(x1:int,y1:int):void{ 			lines.graphics.clear(); 			lines.graphics.lineStyle(2,0x0099ff,1); 			lines.graphics.moveTo(line_x1,line_y1); 			lines.graphics.lineTo(x1,y1); 		} 		 		public function refreshLine():void{ 			lines.graphics.clear(); 			lines.graphics.lineStyle(2,0xFF0000,1); 			lines.graphics.moveTo(line_x1,line_y1); 			lines.graphics.lineTo(line_x2,line_y2);	 		} 		 		public function removeLine():void{ 			lines.graphics.clear(); 		} 		 		public function getLine():Sprite{ 			return lines; 		}	 		 		public function getBeginX():int{ 			return line_x1; 		} 		 		public function getBeginY():int{ 			return line_y1; 		} 		 		public function getEndX():int{ 			return line_x2; 		} 		 		public function getEndY():int{ 			return line_y2; 		} 		 		public function setBeginX(x1:int):void{ 			line_x1 = x1; 		} 		 		public function setBeginY(y1:int):void{ 			line_y1 = y1; 		} 		 		public function setEndX(x2:int):void{ 			line_x2 = x2; 		} 		 		public function setEndY(y2:int):void{ 			line_y2 = y2; 		}		 	} } 


一个测试类Conf.mxlm
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="*" width="660" height="422">  
  3.     <mx:Style>  
  4.         AlertTitle{   
  5.             font-size: 12pt;   
  6.             font-weight: bold;  
  7.         }  
  8.         ToopTip{  
  9.             backgroundColor:red;  
  10.             backgroundImage:url("ASSETS/MAP.GIF");  
  11.         }     
  12.     </mx:Style>  
  13.     <mx:Script>  
  14.         <![CDATA[  
  15.             import mx.events.ToolTipEvent;  
  16.         /*import flash.display.Shape; 
  17.         import mx.core.UIComponent; 
  18.         import flash.display.DisplayObjectContainer;*/  
  19.           
  20.         public var map1:NeMap;  
  21.         public var map2:NeMap;  
  22.         public var map3:NeMap;  
  23.           
  24.         public var line:ExpanLine;  
  25.         public var line2:ExpanLine;  
  26.         public var line3:ExpanLine;  
  27.         import mx.managers.PopUpManager;  
  28.         import mx.controls.Alert;  
  29.           
  30.         public var myPanel1:ShowFlow;  
  31.           
  32.         public function init():void{  
  33.               
  34.             map1 = new NeMap(200,100,"map1");  
  35.             map2 = new NeMap(100,200,"map2");  
  36.             map3 = new NeMap(200,200,"map3");  
  37.               
  38.             myCanvas.setStyle("backgroundImage",'ASSETS/MAP.GIF');  
  39.               
  40.             line  = new ExpanLine(map1.getCenterX(),map1.getCenterY(),map2.getCenterX(),map2.getCenterY(),this);  
  41.             line2 = new ExpanLine(map2.getCenterX(),map2.getCenterY(),map3.getCenterX(),map3.getCenterY(),this);  
  42.             line3 = new ExpanLine(map1.getCenterX(),map1.getCenterY(),map3.getCenterX(),map3.getCenterY(),this);  
  43.               
  44.               
  45.             mylabel.addChild(line.getLine());  
  46.             mylabel.addChild(line2.getLine());  
  47.             mylabel.addChild(line3.getLine());  
  48.               
  49.               
  50.             map1.toolTip = "map1map1map1map1map1map1map1map1map1map1map1map1map1map1map1map1";  
  51.             map2.toolTip = "map2map2map2map2map2map2map2map2map2map2map2map2map2map2map2map2";  
  52.             map3.toolTip = "map3map3map3map3map3map3map3map3map3map3map3map3map3map3map3map3";  
  53.               
  54.              
  55.             map1.setLine(line,true);  
  56.             map2.setLine(line,false);  
  57.               
  58.             map2.setLine(line2,true);  
  59.             map3.setLine(line2,false);  
  60.               
  61.             map1.setLine(line3,true);  
  62.             map3.setLine(line3,false);              
  63.               
  64.             myCanvas.addChild(map3);  
  65.             myCanvas.addChild(map1);  
  66.             myCanvas.addChild(map2);  
  67.               
  68.               
  69.         }     
  70.           
  71.         public function createCustomToolTip(event:ToolTipEvent):void{  
  72.             var ptt:PanelToolTip = new PanelToolTip();  
  73.             event.toolTip = ptt;  
  74.         }  
  75.           
  76.         public function linkAlarm():void{  
  77.             line.refreshLine();  
  78.         }  
  79.           
  80.         public function neDown():void{  
  81.             map1.setNeState("assets/criticlaStatus.gif");  
  82.         }  
  83.           
  84.         public function show(aa:Cond):void{  
  85.             Alert.show("show");  
  86.             myPanel1 = ShowFlow(PopUpManager.createPopUp(aa, ShowFlow, true));                
  87.         }  
  88.           
  89.           
  90.         ]]>  
  91.     </mx:Script>  
  92.     <mx:Canvas id="myCanvas" x="0" y="0" width="659" height="412" borderColor="#FF0000" borderStyle="solid" verticalScrollPolicy="off">  
  93.         <mx:Panel x="0" y="0" width="650" height="410" layout="absolute" id="myPanel" alpha="0.5">  
  94.             <mx:Button x="450" y="99" label="生成Topo" click="init();" id="mybutton"  borderColor="#008080" toolTip="aaaaaaaa"/>  
  95.             <mx:Label x="0" y="0" id="mylabel" />  
  96.             <mx:Button x="450" y="152" label="链路变色" width="75" click="show(this);"/>  
  97.             <mx:Button x="450" y="202" label="节点Down" width="75"/>  
  98.         </mx:Panel>  
  99.     </mx:Canvas>    
  100. </mx:Application> 
 
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值