Index: lams_tool_mindmap/src/flash/AS/ActionLoader.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/ActionLoader.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/ActionLoader.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,28 @@ +package { + import flash.net.*; + import actions.*; + public class ActionLoader extends URLLoader { + protected var localId:int; + public var highestRelatedId:int; + public var action:UserAction; + public var undoAction:UserAction; + public var prevRelated:ActionLoader; + public var nextRelated:ActionLoader; + public var request:URLRequest; + public var current:Boolean; + public function ActionLoader(action:UserAction, server:String, id:int){ + this.localId = id; + this.action = action; + this.prevRelated = null; + this.nextRelated = null; + this.highestRelatedId = -1; + this.request = new URLRequest(server); + this.request.contentType = "application/x-www-form-urlencoded"; + this.request.method = URLRequestMethod.POST; + var xml:XML = action.toXml(); + xml.ID = id; + this.request.data = "actionXML="+xml.toXMLString(); + this.current = false; + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/BaseConcept.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/BaseConcept.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/BaseConcept.as 28 Apr 2009 06:18:18 -0000 1.1 @@ -0,0 +1,18 @@ +package { + import flash.text.*; + public class BaseConcept extends Concept{ + public function BaseConcept(word:String, color:int, free:Boolean, owned:Boolean, creator:String, id:int){ + super(word, color, free, owned, creator, id); + } + override protected function createTextFormat():TextFormat { + var textFormat:TextFormat = super.createTextFormat(); + textFormat.size = 24; + textFormat.bold = true; + return textFormat; + } + override protected function initCircleGraphics():void { + super.initCircleGraphics(); + this.circle.graphics.lineStyle(2, 0x232323, 1); + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/BasicColor.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/BasicColor.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/BasicColor.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,119 @@ +package { + import fl.motion.*; + public class BasicColor extends Color{ + public function get R():Number { + return this.redOffset/255; + } + public function set R(value:Number){ + if(value<0)value=0; + if(value>1)value=1; + this.redOffset = (int)(value*255); + } + public function get G():Number { + return this.greenOffset/255; + } + public function set G(value:Number){ + if(value<0)value=0; + if(value>1)value=1; + this.greenOffset = (int)(value*255); + } + public function get B():Number { + return this.blueOffset/255; + } + public function set B(value:Number){ + if(value<0)value=0; + if(value>1)value=1; + this.blueOffset = (int)(value*255); + } + public function get H():Number { + if(this.maxShade == this.minShade) return 0; + switch(this.maxShade){ + case this.R: + if(this.B>this.G) return ((this.G-this.B)/(this.maxShade-this.minShade)+6)/6; + else return (this.G-this.B)/(this.maxShade-this.minShade)/6; + case this.G: + return (2+(this.B-this.R)/(this.maxShade-this.minShade))/6; + case this.B: + return (4+(this.R-this.G)/(this.maxShade-this.minShade))/6; + } + return 0; + } + public function set H(value:Number){ + if(value<0)value=0; + if(value>1)value=1; + this.setParameters(value, this.S, this.L); + } + public function get S():Number{ + if(this.maxShade == this.minShade) return 0; + if(this.L<0.5){ + return (this.maxShade-this.minShade)/(this.maxShade+this.minShade); + }else{ + return (this.maxShade-this.minShade)/(2-this.maxShade-this.minShade); + } + } + public function set S(value:Number){ + if(value<0)value=0; + if(value>1)value=1; + this.setParameters(this.H, value, this.L); + } + public function get L():Number{ + return (this.maxShade+this.minShade)/2; + } + public function set L(value:Number){ + if(value<0)value=0; + if(value>1)value=1; + this.setParameters(this.H, this.S, value); + } + protected function get minShade():Number { + return Math.min(this.R,this.G,this.B); + } + protected function get maxShade():Number { + return Math.max(this.R,this.G,this.B); + } + public function BasicColor(R:Number=0, G:Number=0, B:Number=0){ + super(1,1,1,1,R,G,B,0); + } + protected function setParameters(H:Number, S:Number, L:Number):void { + if(S==0){ + this.R=this.G=this.B=L; + }else{ + var temp1:Number, temp2:Number, temp3:Number; + if(L<0.5) temp2 = L*(1+S); + else temp2 = L+S-L*S; + temp1 = 2*L - temp2; + temp3 = H+1/3; + if(temp3>1)temp3-=1; + if(6*temp3<1){ + this.R = temp1+(temp2-temp1)*6*temp3; + }else{ + if(2*temp3<1) this.R = temp2; + else{ + if(3*temp3<2) this.R = temp1+(temp2-temp1)*((2/3)-temp3)*6; + else this.R = temp1; + } + } + temp3 = H; + if(6*temp3<1){ + this.G = temp1+(temp2-temp1)*6*temp3; + }else{ + if(2*temp3<1) this.G = temp2; + else{ + if(3*temp3<2) this.G = temp1+(temp2-temp1)*((2/3)-temp3)*6; + else this.G = temp1; + } + } + temp3 = H-1/3; + if(temp3<0)temp3+=1; + if(6*temp3<1){ + this.B = temp1+(temp2-temp1)*6*temp3; + }else{ + if(2*temp3<1) this.B = temp2; + else{ + if(3*temp3<2) this.B = temp1+(temp2-temp1)*((2/3)-temp3)*6; + else this.B = temp1; + } + } + } + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/Branch.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/Branch.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/Branch.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,194 @@ +package { + import flash.display.*; + import flash.filters.*; + import flash.events.*; + import flash.geom.*; + public class Branch extends Sprite { + protected static var sonSpace:Number = 38; + public var base:Concept; + public var sons:Sprite; + protected var grid:Sprite; + public function get sonCount():int { + return this.sons.numChildren; + } + public function get mindMap():MindMap { + return this.tree; + } + protected var displayKids:Boolean; + public function get expanded():Boolean { + return this.displayKids; + } + public function set expanded(value:Boolean){ + this.displayKids = value; + this.expandButton.gotoAndStop(value?2:1); + } + protected var tree:MindMap; + protected var expandButton:ExpandSign; + protected var isHoveringBase:Boolean; + public function Branch(concept:Concept) { + this.grid = new Sprite(); + this.addChild(this.grid); + this.base = concept; + this.base.branch = this; + this.base.addEventListener(Event.CHANGE, this.onBaseChange); + this.addChild(this.base); + this.sons = new Sprite(); + this.addChild(this.sons); + this.applyCosmetics(); + this.expandButton = new ExpandSign(); + this.expandButton.width = this.expandButton.height = 8; + this.expandButton.addEventListener(MouseEvent.MOUSE_DOWN, this.onExpandPress); + this.expanded = true; + this.proper(); + this.isHoveringBase = false; + this.addChild(this.expandButton); + this.addEventListener(Event.ENTER_FRAME, this.onFrame); + } + public function drawGrid():void { + this.grid.graphics.clear(); + this.grid.graphics.lineStyle(2); + var i:int; + for (i=0; i=this.sonCount) { + return null; + } + return InternalBranch(this.sons.getChildAt(index)); + } + public function addSon(concept:InternalConcept):void { + var newSon:InternalBranch = this.nextBorn(concept); + concept.branch = newSon; + this.sons.addChild(newSon); + newSon.father = this; + newSon.mindMap = this.tree; + } + public function addBranch(branch:InternalBranch):void { + this.sons.addChild(branch); + branch.father = this; + branch.mindMap = this.tree; + } + public function removeSon(concept:InternalConcept):void { + if(concept.branch!=null && concept.branch.sonCount==0){ + this.removeBranch(InternalBranch(concept.branch)); + } + } + public function removeBranch(branch:InternalBranch):void { + try{ + this.sons.removeChild(branch); + }catch(error:ArgumentError){}; + this.mindMap.conceptRemoved(InternalConcept(branch.base)); + } + public function getConceptById(id:int):Concept { + if(this.base.ID == id){ + return this.base; + }else{ + var i:int; + for(i=0;i + result.concept = this.base.toXml(); + result.nodes = + var i:int; + for(i=0;i0){ + this.removeBranch(this.son(0)); + } + var node:XML; + var branch:InternalBranch; + for each(node in xml.nodes.branch){ + branch = new InternalBranch(new InternalConcept("", 0, free, false, "", -1), 0); + branch.mindMap = this.tree; + branch.fromXml(node, free); + this.addBranch(branch); + } + this.proper(); + } + public function obscure(obscure:Boolean):void { + this.base.alpha = obscure?0.4:1; + this.alpha = obscure?0.4:1; + } + protected function applyCosmetics():void { + var shadowFilter:DropShadowFilter = new DropShadowFilter(5, 62, 0, 1, 5, 5, 0.34, BitmapFilterQuality.HIGH); + this.base.filters = [shadowFilter]; + } + protected function onBaseChange(event:Event):void { + this.proper(); + } + protected function onExpandPress(event:MouseEvent):void { + if(!this.base.blocked){ + this.expanded = !this.expanded; + this.proper(); + } + } + protected function onFrame(event:Event):void { + if(this.base.mouseX>this.base.box.left-4 && this.base.mouseXthis.base.box.top-35 && this.mouseY0 && !this.base.blocked){ + this.expandButton.visible = true; + } + this.isHoveringBase = true; + }else{ + this.base.setHiding(); + if(this.isHoveringBase){ + this.mindMap.signalConceptHover(this.base, false); + } + if(this.expanded){ + this.expandButton.visible = false; + } + this.isHoveringBase = false; + } + } + public function proper():void { + } + protected function drawGridLine(childIndex:int):void { + } + protected function nextBorn(concept:InternalConcept):InternalBranch { + return null; + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/Concept.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/Concept.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/Concept.as 28 Apr 2009 06:18:18 -0000 1.1 @@ -0,0 +1,453 @@ +package { + import flash.display.*; + import flash.text.*; + import flash.geom.*; + import flash.filters.*; + import flash.events.*; + import fl.motion.*; + import flash.xml.*; + import basiccolorpicker.*; + import actions.*; + public class Concept extends Sprite { + static public var DEFAULT_TITLE:String; + protected var textField:TextField; + public function get word():String { + return this.textField.text; + } + public function set word(word:String) { + if(word=="")word = " "; + this.textField.text = word; + this.fixText(); + this.proper(); + } + protected var _color:int; + public function get color():int { + return this._color; + } + public function set color(color:int) { + this._color = color; + this.drawCircle(); + } + protected var circle:Sprite; + public function get box():Rectangle { + return this.circle.getRect(this); + } + protected var _branch:Branch; + public function get branch():Branch { + return this._branch; + } + public function set branch(branch:Branch) { + this._branch = branch; + } + protected function get buttonCount():int { + return 1 + (this.owned?1:0); + } + protected var _owned:Boolean + public function get owned():Boolean { + return this._owned; + } + public function set owned(owned:Boolean) { + if(this.newSonButton!=null)this.removeChild(this.newSonButton); + if(this.colorPicker!=null)this.removeChild(this.colorPicker); + this._owned = owned; + this.addButtons(); + this.formatText(); + } + protected var id:int; + public function get ID():int { + return this.id; + } + public function set ID(value:int) { + if(!this.free){ + this.id = value; + } + } + protected function get newSonButtonQueue():int { + return 0; + } + protected var newSonButton:NewNodeSign; + protected var newSonAnimator:Animator; + protected function get colorPickerQueue():int { + if(this.owned)return 1; + return -1; + } + protected var colorPicker:BasicColorPicker; + protected var colorPickerAnimator:Animator; + protected var free:Boolean; + protected var textUnsent:Boolean; + protected var oldText:String; + protected var firstTime:Boolean; + protected var block:Boolean; + public function get blocked():Boolean { + return this.block; + } + public function set blocked(value:Boolean) { + this.block = value; + if(value){ + if(this.owned) this.textField.type = TextFieldType.DYNAMIC; + }else{ + if(this.owned) this.textField.type = TextFieldType.INPUT; + } + this.setHiding(); + } + protected var shouldShow:Boolean, shouldHide:Boolean, isShowing:int, isHiding:int, isShown:Boolean; + protected const buttonFloat:Number=12; + protected const defaultColor:int=0xFFFFFF; + protected var _creator:String; + public function get creator():String { + return this._creator; + } + public function Concept(word:String, color:int, free:Boolean, owned:Boolean, creator:String, id:int) { + this.free = free; + this.textUnsent = false; + this.firstTime = false; + this._owned = owned; + this._creator = creator; + this._branch = null; + this.circle = new Sprite(); + this.addChild(circle); + this.textField = new TextField(); + this.textField.autoSize = TextFieldAutoSize.CENTER; + this.textField.maxChars = 100; + this.formatText(); + this.addChild(this.textField); + this.textField.addEventListener(FocusEvent.FOCUS_OUT, onTextBlur); + this.addButtons(); + this.word = word; + this.oldText = word; + this.color = color; + this.shouldShow = false; + this.shouldHide = false; + this.isShown = false; + this.isShowing = 0; + this.isHiding = 0; + this.blocked = false; + this.id = id; + } + public function turnArrow(left:Boolean){ + if(left){ + this.newSonButton.scaleX = Math.abs(this.newSonButton.scaleX); + }else{ + this.newSonButton.scaleX = -Math.abs(this.newSonButton.scaleX); + } + } + public function setShowing():void { + if(!this.blocked){ + this.shouldShow = true; + this.shouldHide = false; + if (this.isHiding==0 && this.isShowing==0 && !this.isShown) { + this.isShowing = this.buttonCount; + this.startShowAnimations(); + } + } + } + public function setHiding():void { + this.shouldHide = true; + this.shouldShow = false; + if (this.isHiding==0 && this.isShowing==0 && this.isShown) { + this.isHiding = this.buttonCount; + this.isShown = false; + this.startHideAnimations(); + } + } + public function toXml():XML { + var result:XML = + result.text = this.word; + result.color = this.color.toString(16); + result.creator = this.creator; + result.id = this.id; + return result; + } + public function fromXml(xml:XML):void { + this.color = (int)("0x"+xml.color); + this.word = xml.text; + this._creator = xml.creator; + this.id = int(xml.id); + this.owned = xml.edit=="0"?false:true; + if(this.branch!=null){ + this.branch.mindMap.allowConceptId(this.id); + } + } + protected function formatText():void { + this.textField.defaultTextFormat = this.createTextFormat(); + if (this.owned) { + this.textField.type = TextFieldType.INPUT; + this.textField.addEventListener(Event.CHANGE, this.onTextChange); + } else { + this.textField.type = TextFieldType.DYNAMIC; + } + } + protected function createTextFormat():TextFormat { + var textFormat:TextFormat = new TextFormat(); + textFormat.align = TextFormatAlign.CENTER; + textFormat.font = "Georgia"; + return textFormat; + } + protected function startShowAnimations():void { + this.newSonButton.visible=true; + this.newSonAnimator = this.createEllipseShowAnimator(this.newSonButton, this.newSonButtonQueue); + this.newSonAnimator.addEventListener(MotionEvent.MOTION_END, this.onShowEnd); + this.newSonAnimator.play(); + if(this.colorPickerQueue>=0){ + this.colorPicker.visible = true; + this.colorPickerAnimator = this.createEllipseShowAnimator(this.colorPicker, this.colorPickerQueue); + this.colorPickerAnimator.addEventListener(MotionEvent.MOTION_END, this.onShowEnd); + this.colorPickerAnimator.play(); + } + } + protected function startHideAnimations():void { + this.newSonAnimator = this.createEllipseHideAnimator(this.newSonButton, this.newSonButtonQueue); + this.newSonAnimator.addEventListener(MotionEvent.MOTION_END, this.onHideEnd); + this.newSonAnimator.play(); + if(this.colorPickerQueue>=0){ + this.colorPickerAnimator = this.createEllipseHideAnimator(this.colorPicker, this.colorPickerQueue); + this.colorPickerAnimator.addEventListener(MotionEvent.MOTION_END, this.onHideEnd); + this.colorPickerAnimator.play(); + } + } + protected function addButtons():void { + this.newSonButton = new NewNodeSign(); + this.newSonButton.width = 20; + this.newSonButton.height = 20; + this.addChild(this.newSonButton); + this.newSonButton.addEventListener(MouseEvent.CLICK, this.onClickNewSon); + this.newSonButton.addEventListener(MouseEvent.MOUSE_OVER, this.onHoverNewSon); + this.newSonButton.addEventListener(MouseEvent.MOUSE_OUT, this.onOutNewSon); + this.newSonButton.visible = false; + if(this.owned){ + this.colorPicker = new BasicColorPicker(15, [0xFFFFFF, 0x0909EE, 0x6699CC, 0xEE09EE, 0x999999, 0x6633BB ,0xEE0909, 0x090909, 0xEEEE09, 0xEE6609, 0x663309, 0x09EE09, 0x666609, 0x09EEEE, 0x095509]); + this.addChild(this.colorPicker); + this.colorPicker.addEventListener(BasicColorPickerEvent.PICK_COLOR, this.onPickColor); + this.colorPicker.visible = false; + } + } + protected function placeButtons():void { + var newSonButtonPosition:Point = this.getEllipseAnimationPoint(this.getButtonEndPosition(this.newSonButtonQueue, this.buttonFloat), this.buttonFloat); + this.newSonButton.x = newSonButtonPosition.x; + this.newSonButton.y = newSonButtonPosition.y; + if(this.colorPickerQueue>=0){ + var colorPickerPosition:Point = this.getEllipseAnimationPoint(this.getButtonEndPosition(this.colorPickerQueue, this.buttonFloat), this.buttonFloat); + this.colorPicker.x = colorPickerPosition.x; + this.colorPicker.y = colorPickerPosition.y; + } + } + protected function proper():void { + var glowing:GlowFilter = new GlowFilter(0xffffff, 1, 5, 5, 3, 3); + var wordFilters:Array = [glowing]; + this.textField.filters = wordFilters; + this.textField.x = -this.textField.width/2; + this.textField.y = -this.textField.height/2; + this.drawCircle(); + this.placeButtons(); + this.dispatchEvent(new Event(Event.CHANGE)); + } + protected function initCircleGraphics():void { + this.circle.graphics.clear(); + } + protected function drawCircle():void { + this.initCircleGraphics(); + var angle:Number = Math.PI/4; + var X:Number,Y:Number; + var a:Number,b:Number; + b = this.textField.height/2*1.8; + a = b*this.textField.width/2/Math.sqrt(b*b - Math.pow(this.textField.height/2,2)); + a = Math.max(a, 25); + var tg = Math.tan(angle); + X = -(a*a*tg)/Math.sqrt(a*a*tg*tg+b*b); + Y = -b*Math.sqrt(a*a-X*X)/a; + var matrix:Matrix; + matrix = new Matrix(); + matrix.createGradientBox(2*Math.abs(X), 2*Math.abs(Y), Math.PI/2 - Math.atan(tg*Math.abs(X)/Math.abs(Y)), X, Y); + var mainColor:BasicColor, lightColor:BasicColor, darkColor:BasicColor; + mainColor = new BasicColor(); + mainColor.color = this.color; + lightColor = new BasicColor(); + lightColor.color = this.color; + lightColor.L += 0.15; + darkColor = new BasicColor(); + darkColor.color = this.color; + darkColor.L -= (lightColor.L - mainColor.L); + this.circle.graphics.beginGradientFill(GradientType.LINEAR, [lightColor.color, this.color, darkColor.color], [1,1,1], [0, 127, 255], matrix); + this.circle.graphics.drawEllipse(-a, -b, 2*a, 2*b); + this.circle.graphics.endFill(); + } + public function getEllipseAnimationPoint(xRatio:Number, float:Number):Point { + var pX:Number, pY:Number; + var a:Number, b:Number; + a=this.box.width/2; + b=this.box.height/2; + var u:Number; + u=xRatio*a; + var bigSqrt:Number = Math.sqrt(b*b*u*u+a*a*(a*a-u*u)); + var smallSqrt:Number = Math.sqrt(a*a-u*u); + pX = float*b*u/bigSqrt+u; + pY = -b/a*smallSqrt-float*a*smallSqrt/bigSqrt; + return new Point(pX,pY); + } + protected function getButtonEndPosition(index:int, float:Number):Number { + if (index==0) { + return 0.95; + } else { + var previousRatio:Number = this.getButtonEndPosition(index-1, float); + var previousPosition:Point = this.getEllipseAnimationPoint(previousRatio, float); + var thisRatio:Number = previousRatio-0.01; + while (Point.distance(previousPosition, this.getEllipseAnimationPoint(thisRatio, float)) < 20) { + thisRatio-=0.01; + } + return thisRatio; + } + } + protected function getButtonStartPosition(index:int, float:int):Number { + return -0.95 + index * 0.1; + } + protected function createEllipseShowAnimator(object:Sprite, index:int):Animator { + var animator:Animator = new Animator(null, object); + animator.motion.keyframes = new Array(); + var startRatio:Number, endRatio:Number; + startRatio = this.getButtonStartPosition(index, this.buttonFloat); + endRatio = this.getButtonEndPosition(index, this.buttonFloat); + var i:int; + var F1:int =9, F2:int =12, F3:int =14; + animator.motion.duration = F3+1; + var position:Point; + var frame:Keyframe; + for (i=0; i<=F1; i++) { + animator.motion.keyframes[i] = new Keyframe(); + frame = animator.motion.keyframes[i]; + position = this.getEllipseAnimationPoint((endRatio*1.05-startRatio)/(F1*F1)*i*i+startRatio, this.buttonFloat); + frame.x = position.x-object.x; + frame.y = position.y-object.y; + frame.color = new Color(1,1,1,1/(F1*F1)*i*i); + frame.index = i; + } + for (i=F1+1; i<=F2; i++) { + animator.motion.keyframes[i] = new Keyframe(); + frame = animator.motion.keyframes[i]; + var A:Number, B:Number, C:Number; + A = (endRatio*1.05 - endRatio*0.95)/Math.pow(F1-F2, 2); + B = -2*A*F2; + C = endRatio*0.95+A*F2*F2; + position = this.getEllipseAnimationPoint(A*i*i+B*i+C, this.buttonFloat); + frame.x = position.x-object.x; + frame.y = position.y-object.y; + frame.index = i; + } + for (i=F2+1; i<=F3; i++) { + animator.motion.keyframes[i] = new Keyframe(); + frame = animator.motion.keyframes[i]; + position = this.getEllipseAnimationPoint((endRatio-endRatio*0.95)/ (Math.LOG2E * Math.log(F3-F2+1))*Math.LOG2E*Math.log(i-F2+1)+endRatio*0.95, this.buttonFloat); + frame.x = position.x-object.x; + frame.y = position.y-object.y; + frame.index = i; + } + return animator; + } + protected function createEllipseHideAnimator(object:Sprite, index:int):Animator { + var animator:Animator = new Animator(null, object); + animator.motion.keyframes = new Array(); + var i:int; + var F:int = 9; + animator.motion.duration = F+1; + var position:Point; + var frame:Keyframe; + for (i=0; i<=F; i++) { + animator.motion.keyframes[i] = new Keyframe(); + frame = animator.motion.keyframes[i]; + frame.color = new Color(1,1,1,1-1/(F*F)*i*i); + frame.index = i; + } + return animator; + } + protected function fixText(){ + if(this.textField.width > 300){ + this.textField.wordWrap = true; + this.textField.width = 300; + }else{ + if(this.textField.numLines==1){ + this.textField.wordWrap = false; + } + } + } + protected function onTextChange(event:Event):void { + this.fixText(); + this.proper(); + if(!this.free && this.owned && !this.firstTime){ + this.textUnsent = true; + } + } + protected function onClickNewSon(event:MouseEvent):void { + if(this.isShown){ + var newId:int; + if(this.free){ + newId = this.branch.mindMap.getNewConceptId() + }else{ + newId = -this.branch.mindMap.getNewConceptId(); + } + var newConcept:InternalConcept = new InternalConcept(DEFAULT_TITLE, this.defaultColor, this.free, true, this.branch.mindMap.player, newId); + this.branch.addSon(newConcept); + this.placeButtons(); + this.branch.expanded = true; + this.branch.proper(); + if(!this.free){ + newConcept.blocked=true; + newConcept.alpha = 0.6; + Concept(newConcept).textField.type = TextFieldType.INPUT; + Concept(newConcept).textField.setSelection(0, newConcept.word.length); + Concept(newConcept).firstTime = true; + } + this.stage.focus = Concept(newConcept).textField; + Concept(newConcept).textField.setSelection(0, newConcept.word.length); + } + } + protected function onHoverNewSon(event:MouseEvent):void { + this.newSonButton.transform.colorTransform = new ColorTransform(0, 0, 0, 1, 30, 200, 30, 0); + } + protected function onOutNewSon(event:MouseEvent):void { + this.newSonButton.transform.colorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 0, 0); + } + protected function onShowEnd(event:MotionEvent):void { + Animator(event.target).removeEventListener(MotionEvent.MOTION_END, this.onShowEnd); + this.isShowing--; + if (this.isShowing==0) { + this.isShown = true; + if (this.shouldHide) { + this.setHiding(); + } + } + } + protected function onHideEnd(event:MotionEvent):void { + Animator(event.target).removeEventListener(MotionEvent.MOTION_END, this.onHideEnd); + Animator(event.target).target.visible = false; + this.isHiding--; + if (this.isHiding == 0) { + if (this.shouldShow) { + this.setShowing(); + } + } + } + protected function onPickColor(event:BasicColorPickerEvent):void { + if(this.owned){ + if(!this.free){ + ServerMindMap(this.branch.mindMap).alertAction(new ColorAction(this.ID, this.colorPicker.picked), new ColorAction(this.ID, this.color)); + } + this.color = this.colorPicker.picked; + this.proper(); + } + } + protected function onTextBlur(event:FocusEvent):void { + if(!this.free && this.owned){ + if(this.textUnsent){ + ServerMindMap(this.branch.mindMap).alertAction(new TextAction(this.ID, this.word), new TextAction(this.ID, this.oldText)); + this.textUnsent = false; + this.oldText = this.word; + } + if(this.firstTime){ + ServerMindMap(this.branch.mindMap).alertAction(new CreateAction(InternalBranch(this.branch).father.base.ID, InternalConcept(this), this.ID), null); + this.firstTime = false; + this.alpha = 1; + this.blocked = true; + } + } + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/ConnectionIcon.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/ConnectionIcon.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/ConnectionIcon.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,43 @@ +package { + import flash.display.*; + import flash.filters.*; + public class ConnectionIcon extends MovieClip { + protected var leftTraffic:Boolean, rightTraffic:Boolean; + protected var full:Boolean; + public function set incoming(value:Boolean){ + if(value!=this.leftTraffic){ + this.leftTraffic = value; + this.display(); + } + } + public function set outgoing(value:Boolean){ + if(value!=this.rightTraffic){ + this.rightTraffic = value; + this.display(); + } + } + public function ConnectionIcon(){ + this.filters = [new GlowFilter(0xFFFFFF, 1, 8, 8, 16, BitmapFilterQuality.HIGH)]; + this.gotoAndStop("idle"); + this.full = this.rightTraffic = this.leftTraffic = true; + } + protected function display():void { + if(this.leftTraffic){ + if(this.rightTraffic){ + if(!this.full){ + this.full = true; + this.gotoAndPlay("fullConnection"); + } + }else{ + this.gotoAndStop("noOutgoing"); + } + }else{ + if(this.rightTraffic){ + this.gotoAndStop("noIncoming"); + }else{ + this.gotoAndStop("brokenConnection"); + } + } + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/DeleteMessage.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/DeleteMessage.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/DeleteMessage.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,94 @@ +package { + import flash.display.*; + import flash.events.*; + import flash.text.*; + import flash.filters.*; + import org.lamsfoundation.lams.common.dictionary.*; + public class DeleteMessage extends Sprite{ + protected var mindMap:MindMap; + public var concept:InternalConcept; + public function get isShown():Boolean { + return this.visible; + } + protected var question:Sprite; + public function DeleteMessage(mindMap:MindMap, dictionary:XMLDictionary){ + this.mindMap = mindMap; + this.question = new Sprite(); + this.addChild(this.question); + var format:TextFormat = new TextFormat("Comic Sans MS", 32, 0xFF6633); + var questionText:TextField = new TextField(); + questionText.defaultTextFormat = format; + questionText.autoSize = TextFieldAutoSize.CENTER; + questionText.selectable = false; + questionText.text = dictionary.getLabel("local.delete_question"); + question.addChild(questionText); + var yesButton:Sprite = new Sprite(); + var yesText:TextField = new TextField(); + yesText.defaultTextFormat = format; + yesText.autoSize = TextFieldAutoSize.CENTER; + yesText.selectable = false; + yesText.text = dictionary.getLabel("local.yes"); + yesButton.addChild(yesText); + yesButton.buttonMode = true; + yesText.x = -yesText.width/2; + yesText.y = -yesText.height/2; + this.question.addChild(yesButton); + yesButton.y = 60; + yesButton.addEventListener(MouseEvent.CLICK, this.onClickYes); + yesButton.addEventListener(MouseEvent.MOUSE_OVER, this.onHoverAnswer); + yesButton.addEventListener(MouseEvent.MOUSE_OUT, this.onOutAnswer); + var noButton:Sprite = new Sprite(); + var noText:TextField = new TextField(); + noText.defaultTextFormat = format; + noText.autoSize = TextFieldAutoSize.CENTER; + noText.selectable = false; + noText.text = dictionary.getLabel("local.no"); + noButton.addChild(noText); + noButton.buttonMode = true; + noText.x = -noText.width/2; + noText.y = -noText.height/2; + this.question.addChild(noButton); + noButton.y = 60; + noButton.addEventListener(MouseEvent.CLICK, this.onClickNo); + noButton.addEventListener(MouseEvent.MOUSE_OVER, this.onHoverAnswer); + noButton.addEventListener(MouseEvent.MOUSE_OUT, this.onOutAnswer); + var center:Number = Math.max(questionText.width, yesButton.width+30+noButton.width)/2; + questionText.x = center - questionText.width/2; + yesButton.x = center - noButton.width/2 - 15; + noButton.x = center + yesButton.width/2 + 15; + question.filters = [new GlowFilter(0xFFFFFF, 1, 32, 32, 32, BitmapFilterQuality.HIGH)]; + } + public function hide():void { + this.visible = false; + this.scaleX = 0.01; + this.scaleY = 0.01; + this.mindMap.unblock(); + } + public function show(concept:InternalConcept):void { + this.scaleX = 1; + this.scaleY = 1; + this.concept = concept; + this.circle.x = concept.x+concept.box.right+concept.branch.getPosition().x+20; + this.circle.y = concept.y+concept.box.top+concept.branch.getPosition().y-15; + this.circle.width = concept.box.width+40; + this.circle.height = concept.box.height+30; + this.question.x = -(InternalBranch)(concept.branch).balance*30-((InternalBranch)(concept.branch).balance+1)/2*(this.circle.width+this.question.width)+this.circle.x; + this.question.y = this.circle.y-10; + this.visible = true; + this.mindMap.block(); + } + protected function onClickNo(event:MouseEvent):void { + this.hide(); + } + protected function onClickYes(event:MouseEvent):void { + this.hide(); + this.mindMap.chooseDeletion(this.concept); + } + protected function onHoverAnswer(event:MouseEvent):void { + Sprite(event.currentTarget).scaleX = Sprite(event.currentTarget).scaleY = 1.1; + } + protected function onOutAnswer(event:MouseEvent):void { + Sprite(event.currentTarget).scaleX = Sprite(event.currentTarget).scaleY = 1; + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/Design.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/Design.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/Design.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,216 @@ +package { + import flash.display.*; + import flash.events.*; + import flash.external.*; + import flash.geom.*; + import flash.errors.*; + import flash.utils.*; + public class Design extends Sprite { + protected var mindMap:MindMap; + protected var frame:WhiteFrame; + protected var edgeOutline:Sprite; + protected var navigationBar:Sprite; + protected var navigate:Boolean; + protected var moving:Boolean; + protected var speedX:Number, speedY:Number; + protected var indicator:ArrowHead; + protected var toolTip:ToolTip; + protected var connectionIcon:ConnectionIcon; + protected var ground:Sprite; + public function Design(mindMap:MindMap, world:Stage) { + this.ground = new Sprite(); + this.ground.graphics.beginFill(0,0); + this.ground.graphics.drawRect(0,0,800,600); + this.ground.graphics.endFill(); + this.addChild(this.ground); + this.ground.addEventListener(MouseEvent.MOUSE_DOWN, this.onPressGround); + this.ground.addEventListener(MouseEvent.MOUSE_UP, this.onReleaseGround); + this.ground.addEventListener(MouseEvent.MOUSE_OUT, this.onLeaveGround); + this.mindMap = mindMap; + this.mindMap.x = 400; + this.mindMap.y = 300; + this.addChild(this.mindMap); + this.mindMap.addEventListener(ServerMindMapEvent.WIN_INCOMING_CONNECTION, this.onWinServerResponse); + this.mindMap.addEventListener(ServerMindMapEvent.FAILED_INCOMING_CONNECTION, this.onLostServerResponse); + this.mindMap.addEventListener(ServerMindMapEvent.WIN_OUTGOING_CONNECTION, this.onWinServerRequest); + this.mindMap.addEventListener(ServerMindMapEvent.FAILED_OUTGOING_CONNECTION, this.onLostServerRequest); + this.frame = new WhiteFrame(); + this.frame.width = 800; + this.frame.height = 600; + this.frame.addEventListener(MouseEvent.MOUSE_OVER, onNavigationHover); + this.frame.addEventListener(MouseEvent.MOUSE_OUT, onNavigationOut); + this.indicator = new ArrowHead(); + this.navigationBar = new Sprite(); + this.navigationBar.addChild(this.frame); + this.navigationBar.addChild(this.indicator); + this.edgeOutline = new Sprite(); + this.edgeOutline.graphics.lineStyle(2, 0x888888); + this.edgeOutline.graphics.drawRect(0, 0, 800, 600); + this.navigationBar.addChild(this.edgeOutline); + this.addChild(this.navigationBar); + this.connectionIcon = new ConnectionIcon(); + this.connectionIcon.y = 50; + this.connectionIcon.x = 400; + this.connectionIcon.scaleX = 0.7; + this.connectionIcon.scaleY = 0.7; + this.addChild(this.connectionIcon); + this.toolTip = new ToolTip(); + this.toolTip.y = 600 - 16; + this.navigationBar.addChild(this.toolTip); + this.navigate = false; + this.speedX = 0; + this.speedY = 0; + this.addEventListener(Event.ENTER_FRAME, onFrame); + world.addChild(this); + this.mindMap.addEventListener(InformationEvent.INFORMATION, onGetInfo); + this.mindMap.addEventListener(InformationEvent.NO_INFORMATION, onNoInfo); + try{ + ExternalInterface.addCallback("getMindmap", this.toString); + }catch(error:Error){ + } + } + protected function onGetInfo(event:InformationEvent):void { + this.toolTip.show(event.message); + this.toolTip.x = this.frame.width-this.toolTip.width; + } + protected function onNoInfo(event:InformationEvent):void { + this.toolTip.hide(); + } + protected function onNavigationHover(event:MouseEvent):void { + this.navigate = true; + } + protected function onNavigationOut(event:MouseEvent):void { + this.navigate = false; + } + protected function onFrame(event:Event):void { + var slowDownX:Boolean = true; + var slowDownY:Boolean = true; + if (navigate) { + var bounds:Rectangle = this.mindMap.getBounds(this.navigationBar); + var maxSpeed:Number = 8; + var minDistance:Number = 60; + if (this.navigationBar.mouseX <= minDistance) { + if(bounds.left<=100){ + slowDownX = false; + if (Math.abs(this.speedX)<0.1) { + this.speedX = 0.1; + } + this.speedX = 1.5 * Math.abs(this.speedX); + } + } + if (this.navigationBar.mouseX >= this.frame.width-minDistance) { + if(bounds.right>=this.frame.width-100){ + slowDownX = false; + if (Math.abs(this.speedX)<0.1) { + this.speedX = -0.1; + } + this.speedX = 1.5 * -Math.abs(this.speedX); + } + } + if (this.navigationBar.mouseY <= minDistance) { + if(bounds.top<=100){ + slowDownY = false; + if (Math.abs(this.speedY)<0.1) { + this.speedY = 0.1; + } + this.speedY = 1.5 * Math.abs(this.speedY); + } + } + if (this.navigationBar.mouseY >= this.frame.height-minDistance) { + if(bounds.bottom>=this.frame.height-100){ + slowDownY = false; + if (Math.abs(this.speedY)<0.1) { + this.speedY = -0.1; + } + this.speedY = 1.5 * -Math.abs(this.speedY); + } + } + } + if(slowDownX){ + this.speedX *= 0.8; + } + if(slowDownY){ + this.speedY *= 0.8; + } + if (Math.abs(this.speedX) < 0.001) { + this.speedX = 0; + } + if (Math.abs(this.speedY) < 0.001) { + this.speedY = 0; + } + if (Math.abs(this.speedX) > maxSpeed) { + this.speedX = this.speedX/Math.abs(this.speedX)*maxSpeed; + } + if (Math.abs(this.speedY) > maxSpeed) { + this.speedY = this.speedY/Math.abs(this.speedY)*maxSpeed; + } + if(this.speedX!=0 || this.speedY!=0){ + if(!slowDownY || !slowDownX){ + this.edgeOutline.visible = true; + }else{ + this.edgeOutline.visible = false; + } + this.mindMap.x += this.speedX; + this.mindMap.y += this.speedY; + if(this.mindMap.x<0 || this.mindMap.x>this.frame.width || this.mindMap.y<0 || this.mindMap.y>this.frame.height){ + this.indicator.visible = true; + var dx:Number, dy:Number; + var tg:Number = (this.frame.width/2-this.mindMap.x)/(this.frame.height/2-this.mindMap.y); + if(Math.abs(tg) <= this.frame.width/this.frame.height){ + dy = this.frame.height/2 * (this.mindMap.y>this.frame.height/2?1:-1); + dx = tg*dy; + }else{ + dx = this.frame.width/2 * (this.mindMap.x>this.frame.width/2?1:-1); + if(tg == Number.POSITIVE_INFINITY){ + dy = 0; + }else dy = dx/tg; + } + var px:Number, py:Number; + px = this.frame.width/2+dx; + py = this.frame.height/2+dy; + var distance:Number = Point.distance(new Point(this.mindMap.x, this.mindMap.y), new Point(px, py)); + this.indicator.alpha = distance/500; + var ax:Number, ay:Number; + if(this.frame.height/2 != py){ + ay = 20*(this.frame.height/2-py)/Math.sqrt(Math.pow(this.frame.height/2-py,2)+Math.pow(this.frame.width/2-px,2)) + py; + ax = (ay-py)*(this.frame.width/2-px)/(this.frame.height/2-py)+px; + }else{ + ay = py; + ax = px+20*(px0) { + result+=sonSpace; + } + } + return Math.max(this.base.box.height, result); + } + public function get upSpace():Number { + var result:Number = 0; + if(this.sonCount>0){ + var i:int; + for(i=0;i=this.sonCount){ + throw new ArgumentError("InternalBranch.indexAtPosition: position is out of bounds"); + } + if(position=0){ + this.pickupButton.visible = true; + this.pickupAnimator = this.createEllipseShowAnimator(this.pickupButton, this.pickupButtonQueue); + this.pickupAnimator.addEventListener(MotionEvent.MOTION_END, this.onShowEnd); + this.pickupAnimator.play(); + } + if(this.deleteButtonQueue>=0){ + this.deleteButton.visible = true; + this.deleteAnimator = this.createEllipseShowAnimator(this.deleteButton, this.deleteButtonQueue); + this.deleteAnimator.addEventListener(MotionEvent.MOTION_END, this.onShowEnd); + this.deleteAnimator.play(); + } + } + override protected function startHideAnimations():void { + super.startHideAnimations(); + if(this.pickupButtonQueue>=0){ + this.pickupAnimator = this.createEllipseHideAnimator(this.pickupButton, this.pickupButtonQueue); + this.pickupAnimator.addEventListener(MotionEvent.MOTION_END, this.onHideEnd); + this.pickupAnimator.play(); + } + if(this.deleteButtonQueue>=0){ + this.deleteAnimator = this.createEllipseHideAnimator(this.deleteButton, this.deleteButtonQueue); + this.deleteAnimator.addEventListener(MotionEvent.MOTION_END, this.onHideEnd); + this.deleteAnimator.play(); + } + } + override protected function addButtons():void { + this.deleteButton = new DeleteSign(); + this.deleteButton.addEventListener(MouseEvent.CLICK, this.onClickDelete); + this.deleteButton.addEventListener(MouseEvent.MOUSE_OVER, this.onHoverDelete); + this.deleteButton.addEventListener(MouseEvent.MOUSE_OUT, this.onOutDelete); + this.deleteButton.width = 20; + this.deleteButton.height = 20; + this.addChild(this.deleteButton); + this.deleteButton.visible = false; + if(this.owned && this.free){ + this.pickupButton = new HandSign(); + this.addChild(this.pickupButton); + this.pickupButton.addEventListener(MouseEvent.MOUSE_DOWN, this.onClickHand); + this.pickupButton.visible = false; + } + super.addButtons(); + } + override protected function placeButtons():void { + super.placeButtons(); + if(this.pickupButtonQueue>=0){ + var pickupButtonPosition:Point = this.getEllipseAnimationPoint(this.getButtonEndPosition(this.pickupButtonQueue, this.buttonFloat), this.buttonFloat); + this.pickupButton.x = pickupButtonPosition.x; + this.pickupButton.y = pickupButtonPosition.y; + } + if(this.deleteButtonQueue>=0){ + var deleteButtonPosition:Point = this.getEllipseAnimationPoint(this.getButtonEndPosition(this.deleteButtonQueue, this.buttonFloat), this.buttonFloat); + this.deleteButton.x = deleteButtonPosition.x; + this.deleteButton.y = deleteButtonPosition.y; + }else{ + this.deleteButton.alpha=0; + } + } + protected function onClickDelete(event:MouseEvent):void { + if(this.canDelete && this.isShown){ + this.branch.mindMap.requestDelete(this); + } + } + protected function onHoverDelete(event:MouseEvent):void { + var keepAlpha:Number = this.deleteButton.alpha; + this.deleteButton.transform.colorTransform = new ColorTransform(0, 0, 0, 1, 200, 30, 30, 0); + this.deleteButton.alpha = keepAlpha; + } + protected function onOutDelete(event:MouseEvent):void { + var keepAlpha:Number = this.deleteButton.alpha; + this.deleteButton.transform.colorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 0, 0); + this.deleteButton.alpha = keepAlpha; + } + protected function onClickHand(event:MouseEvent):void { + if(this.isShown){ + this.branch.mindMap.requestHandMove(this, new Point(this.pickupButton.x, this.pickupButton.y)); + } + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/MindMap.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/MindMap.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/MindMap.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,184 @@ +package { + import flash.display.*; + import flash.events.*; + import flash.geom.*; + import org.lamsfoundation.lams.common.dictionary.*; + public class MindMap extends Branch { + protected var deleteMessage:DeleteMessage; + protected var switchMessage:SwitchMessage; + protected var conceptHovered:Concept; + public var dictionary:XMLDictionary; + protected var _player:String; + public function get player():String { + return this._player; + } + protected var ids:int; + public function get leftUpSpace():Number { + var result:Number = 0; + if(this.sonCount>0){ + var i:int; + for(i=0;i1){ + var i:int; + for(i=1;i"+concept.creator+"")); + } else { + if(this.conceptHovered == concept){ + this.dispatchEvent(new InformationEvent(InformationEvent.NO_INFORMATION)); + } + } + } + public function chooseDeletion(concept:InternalConcept):void { + if(concept.branch.sonCount==0){ + this.deleteConcept(concept); + } + } + public function conceptRemoved(concept:InternalConcept):void { + if(this.deleteMessage.visible && this.deleteMessage.concept == concept){ + this.deleteMessage.hide(); + } + } + public function branchAdded(branch:InternalBranch):void { + if(this.deleteMessage.visible && this.deleteMessage.concept == branch.father.base){ + this.deleteMessage.hide(); + } + } + public function getNewConceptId():int { + return this.ids++; + } + public function allowConceptId(id:int):void { + this.ids = Math.max(id+1,this.ids); + } + protected function deleteConcept(concept:InternalConcept):void { + (InternalBranch)(concept.branch).father.removeSon(concept); + concept.branch.proper(); + } + protected function rebalance():void { + var i:int; + for (i=0; i0?sonSpace:0); + } else { + totalWidthRight += this.son(i).span+(totalWidthRight>0?sonSpace:0); + } + } + var dropperYLeft:Number = -leftUpSpace; + var dropperYRight:Number = -rightUpSpace; + for (i=0; iMath.floor((this.sonCount-1)/2)){ + throw new ArgumentError("MindMap.indexAtLeftPosition: position is out of bounds"); + } + if(positionMath.floor((this.sonCount-2)/2)){ + throw new ArgumentError("MindMap.indexAtRightPosition: position is out of bounds"); + } + if(position + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: lams_tool_mindmap/src/flash/AS/MultiPlayer.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/MultiPlayer.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/MultiPlayer.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,81 @@ +package { + import flash.display.*; + import flash.events.*; + import flash.net.*; + import flash.external.*; + import org.lamsfoundation.lams.common.dictionary.*; + public class MultiPlayer extends MovieClip{ + protected var xmlLabels:XML; + protected var originalXml:XML; + public function MultiPlayer() { + var request:URLRequest; + if (this.loaderInfo.parameters.dictionary == undefined) { + request = new URLRequest("dictionary.xml"); + }else{ + request = new URLRequest(this.loaderInfo.parameters.dictionary); + } + var labelsLoader:URLLoader = new URLLoader(request); + labelsLoader.addEventListener(Event.COMPLETE, this.onLabelsLoad); + if (this.loaderInfo.parameters.xml == "") { + ExternalInterface.addCallback("setMindmap", this.greenLight); + ExternalInterface.call("flashLoaded"); + } else { + if (this.loaderInfo.parameters.xml == undefined) { + request = new URLRequest("tree.xml"); + }else{ + request = new URLRequest(this.loaderInfo.parameters.xml); + } + var treeLoader:URLLoader = new URLLoader(request); + treeLoader.addEventListener(Event.COMPLETE, this.onTreeLoad); + } + } + public function greenLight(treeData:String):void { + this.originalXml = new XML(treeData); + if(this.xmlLabels!=null){ + this.startApplication(this.originalXml.branch[0], int(this.originalXml.lastActionId), this.xmlLabels); + } + } + protected function startApplication(originalXml:XML, lastActionId:int, xmlLabels:XML) { + var user:String; + var pollServer:String, notifyServer:String; + var id:int; + var dictionary:XMLDictionary; + if (this.loaderInfo.parameters.user==undefined) { + user = "Liviu"; + } else { + user = this.loaderInfo.parameters.user; + } + if (this.loaderInfo.parameters.pollServer==undefined) { + pollServer = "actions.xml"; + } else { + pollServer = this.loaderInfo.parameters.pollServer; + } + if (this.loaderInfo.parameters.notifyServer==undefined) { + notifyServer = "some server"; + } else { + notifyServer = this.loaderInfo.parameters.notifyServer; + } + if (this.loaderInfo.parameters.id==undefined) { + id = 126; + } else { + id = int(this.loaderInfo.parameters.id); + } + dictionary = new XMLDictionary(xmlLabels); + var mindMap:ServerMindMap = new ServerMindMap(originalXml, user, pollServer, notifyServer, lastActionId, dictionary); + var application:Design; + application = new Design(mindMap, stage); + } + protected function onTreeLoad(event:Event):void { + this.originalXml = new XML(URLLoader(event.target).data); + if(this.xmlLabels != null){ + this.startApplication(this.originalXml.branch[0], int(this.originalXml.lastActionId[0]), this.xmlLabels); + } + } + protected function onLabelsLoad(event:Event):void { + this.xmlLabels = new XML(URLLoader(event.target).data); + if(this.originalXml != null){ + this.startApplication(this.originalXml.branch[0], int(this.originalXml.lastActionId), this.xmlLabels); + } + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/NoPlayer.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/NoPlayer.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/NoPlayer.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,8 @@ +package { + public class NoPlayer extends SinglePlayer { + override protected function startApplication(originalXml:XML, xmlLabels:XML):void { + super.startApplication(originalXml, xmlLabels); + this.mindMap.block(); + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/ServerMindMap.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/ServerMindMap.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/ServerMindMap.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,177 @@ +package { + import flash.events.*; + import flash.net.*; + import flash.utils.*; + import flash.errors.*; + import actions.*; + import org.lamsfoundation.lams.common.dictionary.*; + public class ServerMindMap extends MindMap { + public var pollServer:String; + public var notifyServer:String; + protected var id:int; + protected var lastActionId:int; + protected var nextLocalId:int; + protected var pollTimer:Timer; + protected var loaders:Array; + public function ServerMindMap(originalXml:XML, player:String, pollServer:String, notifyServer:String, actionId:int, dictionary:XMLDictionary){ + super(new BaseConcept("", 0, false, false, "", -1), player, dictionary); + this.fromXml(originalXml, false); + this.loaders = new Array(); + this.pollServer = pollServer.indexOf('?')==-1?pollServer+"?":pollServer+"&"; + this.notifyServer = notifyServer; + this.id = id; + this.lastActionId = actionId; + this.nextLocalId = 0; + this.pollTimer = new Timer(1000, 1); + this.pollTimer.addEventListener(TimerEvent.TIMER, this.onTimer); + this.requestActions(); + } + public function alertAction(action:UserAction, reverse:UserAction):void { + this.sendAction(action, reverse); + } + protected function requestActions():void { + this.pollTimer.reset(); + var request:URLRequest = new URLRequest(this.pollServer); + request.method = URLRequestMethod.GET; + var urlVariables:URLVariables = new URLVariables("lastActionID="+this.lastActionId); + request.data = urlVariables; + var loader:URLLoader = new URLLoader(); + loader.addEventListener(Event.COMPLETE, onPollLoad); + loader.addEventListener(IOErrorEvent.IO_ERROR, onPollFail); + loader.load(request); + } + protected function sendAction(action:UserAction, reverse:UserAction):void { + var loader:ActionLoader = new ActionLoader(action, this.notifyServer, this.nextLocalId++); + this.loaders.push(loader); + loader.nextRelated = null; + loader.current = true; + loader.undoAction = reverse; + var i:int=this.loaders.length-2; + while(i>=0 && !UserAction.related(loader.action, this.loaders[i].action)){ + i--; + } + if(i<0){ + loader.prevRelated = null; + }else{ + loader.prevRelated = this.loaders[i]; + loader.prevRelated.current = false; + this.loaders[i].nextRelated = loader; + } + loader.addEventListener(Event.COMPLETE, this.onActionSent); + loader.addEventListener(IOErrorEvent.IO_ERROR, this.onSendError); + loader.load(loader.request); + } + protected function onPollLoad(event:Event):void { + this.dispatchEvent(new ServerMindMapEvent(ServerMindMapEvent.WIN_INCOMING_CONNECTION)); + var actionsXml:XML = new XML(URLLoader(event.target).data).actions[0]; + var action:UserAction; + var xmlNode:XML; + for each (xmlNode in actionsXml.action){ + var actionClass:Class = Class(getDefinitionByName(UserAction.types[xmlNode.type])); + action = UserAction.createEmptyAction(int(xmlNode.type)); + actionClass(action).fromXml(xmlNode); + try{ + actionClass(action).apply(this); + }catch(error:Error){ + break; + } + this.lastActionId = Math.max(int(xmlNode.ID), this.lastActionId); + } + this.pollTimer.reset(); + this.pollTimer.start(); + } + protected function onPollFail(event:IOErrorEvent):void { + this.dispatchEvent(new ServerMindMapEvent(ServerMindMapEvent.FAILED_INCOMING_CONNECTION)); + this.requestActions(); + } + protected function onActionSent(event:Event):void { + this.dispatchEvent(new ServerMindMapEvent(ServerMindMapEvent.WIN_OUTGOING_CONNECTION)); + var loader:ActionLoader = ActionLoader(event.target); + var xml:XML = new XML(loader.data); + var reject:Boolean; + var neighbour:ActionLoader; + if(xml.ok == "0" || int(xml.id) < loader.highestRelatedId) reject = true; + else { + reject = false; + neighbour = loader.prevRelated; + while(neighbour!=null){ + neighbour.highestRelatedId = int(xml.id); + neighbour = neighbour.prevRelated; + } + neighbour = loader.nextRelated; + while(neighbour!=null){ + neighbour.highestRelatedId = int(xml.id); + neighbour = neighbour.nextRelated; + } + } + var concept:InternalConcept; + if(reject){ + if(loader.nextRelated == null){ + if(loader.current){ + switch(loader.action.type){ + case 0: + concept = InternalConcept(this.getConceptById(loader.action.nodeId)); + concept.blocked = false; + concept.alpha = 1; + break; + case 1: + concept = InternalConcept(this.getConceptById(loader.action.nodeId)); + InternalBranch(concept.branch).removeBranch(InternalBranch(CreateAction(loader.action).reference.branch)); + this.proper(); + break; + default: + loader.undoAction.apply(this); + } + if(loader.prevRelated!=null){ + loader.prevRelated.current = true; + } + } + }else{ + loader.nextRelated.undoAction = loader.undoAction; + } + }else{ + if(!loader.current){ + while(neighbour.nextRelated!=null){ + neighbour = neighbour.nextRelated; + } + if(!neighbour.current){ + loader.action.apply(this); + } + }else{ + switch(loader.action.type){ + case 0: + concept = InternalConcept(this.getConceptById(loader.action.nodeId)); + this.deleteConcept(concept); + break; + case 1: + concept = InternalConcept(this.getConceptById(CreateAction(loader.action).tempId)); + concept.blocked = false; + concept.ID = int(xml.data); + this.allowConceptId(concept.ID); + break; + } + } + } + if(loader.prevRelated!=null){ + loader.prevRelated.nextRelated = loader.nextRelated; + } + if(loader.nextRelated!=null){ + loader.nextRelated.prevRelated = loader.prevRelated; + } + this.loaders.splice(this.loaders.indexOf(loader), 1); + } + protected function onSendError(event:IOErrorEvent):void { + this.dispatchEvent(new ServerMindMapEvent(ServerMindMapEvent.FAILED_OUTGOING_CONNECTION)); + var loader:ActionLoader = ActionLoader(event.target); + loader.load(loader.request); + } + protected function onTimer(event:TimerEvent):void { + this.requestActions(); + } + override public function chooseDeletion(concept:InternalConcept):void { + concept.blocked = true; + concept.alpha = 0.4; + this.sendAction(new DeleteAction(concept.ID), null); + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/ServerMindMapEvent.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/ServerMindMapEvent.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/ServerMindMapEvent.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,12 @@ +package { + import flash.events.*; + public class ServerMindMapEvent extends Event { + static public var FAILED_INCOMING_CONNECTION:String = "failedIncomingConnection"; + static public var WIN_INCOMING_CONNECTION:String = "winIncomingConnection"; + static public var FAILED_OUTGOING_CONNECTION:String = "failedOutgoingConnection"; + static public var WIN_OUTGOING_CONNECTION:String = "winOutgoingConnection"; + public function ServerMindMapEvent(type:String){ + super(type); + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/SinglePlayer.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/SinglePlayer.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/SinglePlayer.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,71 @@ +package { + import flash.display.*; + import flash.events.*; + import flash.net.*; + import flash.text.*; + import flash.external.*; + import flash.errors.*; + import org.lamsfoundation.lams.common.dictionary.*; + public class SinglePlayer extends MovieClip { + protected var xmlLabels:XML; + protected var originalXml:XML; + protected var mindMap:MindMap; + public function SinglePlayer() { + var originalXml:XML; + var request:URLRequest; + if (this.loaderInfo.parameters.dictionary == undefined) { + request = new URLRequest("dictionary.xml"); + }else{ + request = new URLRequest(this.loaderInfo.parameters.dictionary); + } + var labelsLoader:URLLoader = new URLLoader(request); + labelsLoader.addEventListener(Event.COMPLETE, this.onLabelsLoad); + if (this.loaderInfo.parameters.xml == "") { + try{ + ExternalInterface.addCallback("setMindmap", this.greenLight); + ExternalInterface.call("flashLoaded"); + }catch(error:Error){ + } + } else { + if (this.loaderInfo.parameters.xml == undefined) { + request = new URLRequest("stree.xml"); + } else { + request = new URLRequest(this.loaderInfo.parameters.xml); + } + var treeLoader:URLLoader = new URLLoader(request); + treeLoader.addEventListener(Event.COMPLETE, this.onTreeLoad); + } + } + public function greenLight(treeData:String):void { + this.originalXml = new XML(treeData); + if(this.xmlLabels!=null){ + this.startApplication(this.originalXml, this.xmlLabels); + } + } + protected function startApplication(originalXml:XML, xmlLabels:XML):void { + var user:String; + if (this.loaderInfo.parameters.user==undefined) { + user = "Liviu"; + } else { + user = this.loaderInfo.parameters.user; + } + var dictionary:XMLDictionary = new XMLDictionary(xmlLabels); + this.mindMap = new MindMap(new BaseConcept("", 0, true, false, "", -1), user, dictionary); + this.mindMap.fromXml(originalXml, true); + var application:Design; + application = new Design(this.mindMap, stage); + } + protected function onTreeLoad(event:Event):void { + this.originalXml = new XML(URLLoader(event.target).data); + if(this.xmlLabels != null){ + this.startApplication(this.originalXml, this.xmlLabels); + } + } + protected function onLabelsLoad(event:Event):void { + this.xmlLabels = new XML(URLLoader(event.target).data); + if(this.originalXml != null){ + this.startApplication(this.originalXml, this.xmlLabels); + } + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/SwitchMessage.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/SwitchMessage.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/SwitchMessage.as 28 Apr 2009 06:18:19 -0000 1.1 @@ -0,0 +1,116 @@ +package { + import flash.display.*; + import flash.events.*; + import flash.geom.*; + import flash.filters.*; + import flash.ui.*; + import flash.utils.*; + public class SwitchMessage extends Sprite{ + protected var target:Concept; + protected var dragging:InternalConcept; + protected var mindMap:MindMap; + protected var closedHand:ClosedHand; + protected var ghost:Sprite; + protected var ghostConcept:InternalConcept; + protected var timer:Timer; + protected var longEnough:Boolean; + public function SwitchMessage(mindMap:MindMap){ + this.mindMap = mindMap; + this.ghostConcept = new InternalConcept("", 0, false, false, "", -1); + this.ghostConcept.filters = [new GlowFilter(0x2277CC, 1, 16, 16, 1, BitmapFilterQuality.HIGH)]; + this.ghost = new Sprite(); + this.ghost.addChild(this.ghostConcept); + this.addChild(this.ghost); + this.closedHand = new ClosedHand(); + this.closedHand.addEventListener(MouseEvent.MOUSE_UP, this.onReleaseHand); + this.addChild(this.closedHand); + this.addEventListener(Event.ENTER_FRAME, this.onFrame); + this.longEnough = true; + this.timer = new Timer(300, 1); + this.timer.addEventListener(TimerEvent.TIMER, this.onTimer); + } + public function hide():void { + this.dragging = null; + this.visible = false; + this.timer.reset(); + this.scaleX = 0.01; + this.scaleY = 0.01; + } + public function show(concept:InternalConcept, handX:int):void { + this.scaleX = 1; + this.scaleY = 1; + this.visible = true; + this.mindMap.block(); + var branch:InternalBranch = (InternalBranch)(concept.branch); + var branchPosition:Point = branch.getPosition(); + Mouse.hide(); + concept.branch.obscure(true); + this.ghostConcept.word = concept.word; + this.ghostConcept.color = concept.color; + this.ghostConcept.x = -handX; + this.ghostConcept.y = concept.box.height/concept.box.width*Math.sqrt(Math.pow(concept.box.width/2,2)-Math.pow(handX,2)); + this.dragging = concept; + this.longEnough = false; + this.timer.start(); + } + public function switchConcept(concept:Concept):void { + if(concept!=this.target){ + this.target = concept; + this.circle.x = concept.x+concept.box.right+concept.branch.getPosition().x+20; + this.circle.y = concept.y+concept.box.top+concept.branch.getPosition().y-15; + this.circle.width = concept.box.width+40; + this.circle.height = concept.box.height+30; + } + } + protected function getClosestValidConcept(sourceBranch:Branch, invalidBranch:InternalBranch):Concept { + var branchPosition:Point; + branchPosition = sourceBranch.getPosition(); + var shortestDistance:Number = Point.distance(new Point(this.mouseX, this.mouseY), new Point(branchPosition.x+sourceBranch.base.x, branchPosition.y+sourceBranch.base.y)); + var closestConcept:Concept = sourceBranch.base; + var i:int; + var distance:Number; + var concept:Concept; + for(i=0;i + xml.type = this.type; + xml.nodeID = this.nodeId; + return xml; + } + } +} \ No newline at end of file Index: lams_tool_mindmap/src/flash/AS/basiccolorpicker/BasicColorPicker.as =================================================================== RCS file: /usr/local/cvsroot/lams_tool_mindmap/src/flash/AS/basiccolorpicker/BasicColorPicker.as,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_mindmap/src/flash/AS/basiccolorpicker/BasicColorPicker.as 28 Apr 2009 06:18:18 -0000 1.1 @@ -0,0 +1,198 @@ +package basiccolorpicker { + import flash.display.*; + import flash.filters.*; + import fl.motion.*; + import flash.events.*; + public class BasicColorPicker extends Sprite{ + static protected var blurring:BlurFilter = new BlurFilter(2, 2, BitmapFilterQuality.HIGH); + protected var plate:MovieClip; + protected var enlarger:Animator, shrinker:Animator; + protected var enlarged:Boolean, enlarging:Boolean, shrinking:Boolean, shouldEnlarge:Boolean, shouldShrink:Boolean; + protected var rolled:ColorSlice; + protected var color:int; + public function get picked():int { + return this.color; + } + public function BasicColorPicker(parts:int, colors:Array){ + this.addChild(this.plate = new MovieClip()); + this.plate.graphics.beginFill(0, 0); + this.plate.graphics.drawCircle(0,0,70); + this.plate.graphics.endFill(); + this.plate.graphics.beginFill(0xbbbbbb); + this.plate.graphics.drawCircle(0,0,50); + this.plate.scaleX = 0.12; + this.plate.scaleY = 0.12; + this.enlarging = false; + this.shouldEnlarge = false; + this.shrinking = false; + this.shouldShrink = false; + this.enlarged = false; + var enlarger_xml:XML = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + this.enlarger = new Animator(enlarger_xml, this.plate); + this.enlarger.addEventListener(MotionEvent.MOTION_END, this.onEnlarge); + var shrinker_xml:XML = + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + this.shrinker = new Animator(shrinker_xml, this.plate); + this.shrinker.addEventListener(MotionEvent.MOTION_END, this.onShrink); + var i:int; + for(i=0;i