仿IBM-BPM Editor实现的WorkFlowEditor

阅读更多
    在网上搜了一些例子,找了一大队资料,终于把workFlowEditor做得差不多了,这是一个类似IBM-BPM Editor的工作流编辑器,现还有一些功能没实现,现将部分代码贴在此,有需要的朋友可以交流,拍砖,哈哈。

上图:
仿IBM-BPM Editor实现的WorkFlowEditor_第1张图片

节点间的连线重绘:
package com
{
	import flash.geom.Point;
	
	public class RefreshLine
	{
		/** 和节点相关的线条的数组 **/
		public var lineList:Array = [];
		
		public var width:Number;
		public var height:Number;
		public var lineFlag:LineLag;
		public var line:Line;
		public var node:Nodes;
		private var isFromNode:Boolean=false;
		private var num1:int=0;		//开始节点,箭头右方向,连线数累加
		private var num2:int=0;		//开始节点,箭头左方向,连线数累加
		private var num3:int=0;		//开始节点,箭头上方向,连线数累加
		private var num4:int=0;		//开始节点,箭头下方向,连线数累加
		private var numA:int=0;		//结束节点,箭头右方向,连线数累加
		private var numB:int=0;		//结束节点,箭头左方向,连线数累加
		private var numC:int=0;		//结束节点,箭头上方向,连线数累加
		private var numD:int=0;		//结束节点,箭头下方向,连线数累加
		private var startX:int;
		private var startY:int;
		private var endX:int;
		private var endY:int;
		
		
		public function RefreshLine(node:Nodes)
		{
			this.node=node;
			lineList=node.lineList;
		}
		
		/**
		 * 重绘节点上的连线
		 * */
		public function getAspectArr():void{
			for(var j:int = 0; j < lineList.length; j++){
				lineFlag = lineList[j];
				line = lineFlag.line;
				
				switch(line.aspect){
					case 1:
						if(line.fromNode==node)
							num1++;
						else
							numA++;
						break;
					case 2:
						if(line.fromNode==node)
							num2++;
						else
							numB++;
						break;
					case 3:
						if(line.fromNode==node)
							num3++;
						else
							numC++;
						break;
					case 4:
						if(line.fromNode==node)
							num4++;
						else
							numD++;
						break;
				}
			}
		}
		
		public function refreshLine():void{
			var isHead:Boolean;
			var startNO:int=0;	//指向开始节点的连线的条数
			var endNO:int=0;	//指向结束节点的连线的条数
			
			width=node.width;
			height=node.height;
			getAspectArr();
			
			for(var i:int = 0; i < lineList.length; i++){
				startX = node.x;
				startY = node.y;
				endX = node.x;
				endY = node.y;
				lineFlag = lineList[i];
				line = lineFlag.line;
				isHead = lineFlag.isHead;
				
				if(line.fromNode==node){
					isFromNode=true;
					startNO++;
				}else{
					endNO++;
				}
				
				switch(node.type){
					case Nodes.NODE:
					case Nodes.EMAIL:
					case Nodes.CLOCK:
					case Nodes.ENDNODE:
						circleNodePosition(startNO,endNO);
						break;
					case Nodes.RECT:
						rectNodePosition(startNO,endNO);
						break;
					case Nodes.BRECT:
						rectNodePosition(startNO,endNO);
						break;
					case Nodes.DIAMOND:
						diamondNodePosition(startNO,endNO);
						break;
				}
				/**
				 * 如果是连线箭头所指的,则重设线条开始位置
				 * 如果不是,则重设连线结束
				 **/ 
				if(isHead)
					line.startPoint = new Point(startX,startY);
				else
					line.endPoint = new Point(endX,endY); 
				
				line.drawLine(line.aspect);
			}
			num1=0;
			num2=0;
			num3=0;
			num4=0;
			numA=0;
			numB=0;
			numC=0;
			numD=0;
		}
		
		private function circleNodePosition(startNO:int,endNO:int):void{
			switch(line.aspect){
				case 1:
					//箭头向右
					switch(line.lineStyle){
						case line.lineStyleArr[1]:
							if(line.fromNode.y 
 

键盘事件类:
package com
{
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	
	import mx.core.UITextField;
	
	import net.L4cd.iTrace;
	
	public class WFKeyboard
	{
		private var node:Nodes;
		private var line:Line;
		private var workFlow:CusWorkFlow;
		private var o:Object;
		/** CusWorkFlow对象的放大/缩小参数 **/
		private var scaleNO:Number=.2;
		/** 封装连线的对象 **/
		private var lineLag1:LineLag;
		
		public var trace:Function = iTrace.init;
		
		public function WFKeyboard()
		{
			
		}
		
		/** 选择键盘按键ASCII值 **/
		public function chooseKey(e:KeyboardEvent,mouseE:MouseEvent):void {
			o=getObjects(mouseE);
			node=o.node as Nodes;
			line=o.line as Line;
			workFlow=o.workFlow as CusWorkFlow;
			switch(e.keyCode){
				case 8:
				case 46:
					deleteNode(node,line,workFlow);
					break;
				case 65:
					if(!e.ctrlKey)return;
					
					break;
				case 107:
					if(!e.ctrlKey)return;
					workFlow.scaleX+=scaleNO;//放大CusWorkFlow对象
					workFlow.scaleY+=scaleNO;
					break;
				case 109:
					if(!e.ctrlKey)return;
					workFlow.scaleX-=scaleNO;//缩小CusWorkFlow对象
					workFlow.scaleY-=scaleNO;
					break;
			}
		}
		
		/** 删除节点或连线 **/
		private function deleteNode(node:Nodes,line:Line,workFlow:CusWorkFlow):void {
			if(!workFlow)return;
			
			if(node){
				var num:int=node.lineList.length;
				for(var i:int=0;i 
 

  • myWorkFlowEditor.zip (2.3 MB)
  • 下载次数: 622
  • 仿IBM-BPM Editor实现的WorkFlowEditor_第2张图片
  • 大小: 88 KB
  • 查看图片附件

你可能感兴趣的:(IBM,Workflow,Flash,J#)