/**
* Joint 0.4 - JavaScript diagramming library.
* Copyright (c) David Durman 2009 - 2011
* Licensed under the MIT license: (http://www.opensource.org/licenses/mit-license.php)
*/(function(g){var e=g.Joint;g=e.dia.Element;var h=e.point,f=e.dia.uml={};e.arrows.aggregation=function(){return{path:["M","7","0","L","0","5","L","-7","0","L","0","-5","z"],dx:9,dy:9,attrs:{stroke:"black","stroke-width":2,fill:"black"}}};f.aggregationArrow={endArrow:{type:"aggregation"},startArrow:{type:"none"},attrs:{"stroke-dasharray":"none"}};f.dependencyArrow={endArrow:{type:"basic",size:5},startArrow:{type:"none"},attrs:{"stroke-dasharray":"none"}};f.generalizationArrow={endArrow:{type:"basic", size:10,attrs:{fill:"white"}},startArrow:{type:"none"},attrs:{"stroke-dasharray":"none"}};f.arrow={startArrow:{type:"none"},endArrow:{type:"basic",size:5},attrs:{"stroke-dasharray":"none"}};f.State=g.extend({object:"State",module:"uml",init:function(a){a=e.DeepSupplement(this.properties,a,{radius:15,attrs:{fill:"white"},label:"",labelOffsetX:20,labelOffsetY:5,swimlaneOffsetY:18,actions:{entry:null,exit:null,inner:[]},actionsOffsetX:5,actionsOffsetY:5});this.setWrapper(this.paper.rect(a.rect.x,a.rect.y, a.rect.width,a.rect.height,a.radius).attr(a.attrs));this.addInner(this.getLabelElement());this.addInner(this.getSwimlaneElement());this.addInner(this.getActionsElement())},getLabelElement:function(){var a=this.properties,b=this.wrapper.getBBox(),c=this.paper.text(b.x,b.y,a.label).attr(a.labelAttrs||{}),d=c.getBBox();c.translate(b.x-d.x+a.labelOffsetX,b.y-d.y+a.labelOffsetY);return c},getSwimlaneElement:function(){var a=this.wrapper.getBBox(),b=this.properties;return this.paper.path(["M",a.x,a.y+b.labelOffsetY+ b.swimlaneOffsetY,"L",a.x+a.width,a.y+b.labelOffsetY+b.swimlaneOffsetY].join(" "))},getActionsElement:function(){var a=this.properties,b=a.actions.entry?"entry/ "+a.actions.entry+"\n":"";b+=a.actions.exit?"exit/ "+a.actions.exit+"\n":"";for(var c=a.actions.inner.length,d=0;d<c;d+=2)b+=a.actions.inner[d]+"/ "+a.actions.inner[d+1]+"\n";b=b.replace(/^\s\s*/,"").replace(/\s\s*$/,"");c=this.wrapper.getBBox();a=this.paper.text(c.x+a.actionsOffsetX,c.y+a.labelOffsetY+a.swimlaneOffsetY+a.actionsOffsetY,b); b=a.getBBox();a.attr("text-anchor","start");a.translate(0,b.height/2);return a},zoom:function(){this.wrapper.attr("r",this.properties.radius);this.shadow&&this.shadow.attr("r",this.properties.radius);this.inner[0].remove();this.inner[1].remove();this.inner[2].remove();this.inner[0]=this.getLabelElement();this.inner[1]=this.getSwimlaneElement();this.inner[2]=this.getActionsElement()}});f.StartState=g.extend({object:"StartState",module:"uml",init:function(a){a=e.DeepSupplement(this.properties,a,{position:h(0, 0),radius:10,attrs:{fill:"black"}});this.setWrapper(this.paper.circle(a.position.x,a.position.y,a.radius).attr(a.attrs))}});f.EndState=g.extend({object:"EndState",module:"uml",init:function(a){a=e.DeepSupplement(this.properties,a,{position:h(0,0),radius:10,innerRadius:a.radius&&a.radius/2||5,attrs:{fill:"white"},innerAttrs:{fill:"black"}});this.setWrapper(this.paper.circle(a.position.x,a.position.y,a.radius).attr(a.attrs));this.addInner(this.paper.circle(a.position.x,a.position.y,a.innerRadius).attr(a.innerAttrs))}, zoom:function(){this.inner[0].scale.apply(this.inner[0],arguments)}});f.Class=g.extend({object:"Class",module:"uml",init:function(a){a=e.DeepSupplement(this.properties,a,{attrs:{fill:"white"},label:"",labelOffsetX:20,labelOffsetY:5,swimlane1OffsetY:18,swimlane2OffsetY:18,attributes:[],attributesOffsetX:5,attributesOffsetY:5,methods:[],methodsOffsetX:5,methodsOffsetY:5});this.setWrapper(this.paper.rect(a.rect.x,a.rect.y,a.rect.width,a.rect.height).attr(a.attrs));this.addInner(this.getLabelElement()); this.addInner(this.getSwimlane1Element());this.addInner(this.getAttributesElement());this.addInner(this.getSwimlane2Element());this.addInner(this.getMethodsElement())},getLabelElement:function(){var a=this.properties,b=this.wrapper.getBBox(),c=this.paper.text(b.x,b.y,a.label).attr(a.labelAttrs||{}),d=c.getBBox();c.translate(b.x-d.x+a.labelOffsetX,b.y-d.y+a.labelOffsetY);return c},getSwimlane1Element:function(){var a=this.wrapper.getBBox(),b=this.properties;return this.paper.path(["M",a.x,a.y+b.labelOffsetY+ b.swimlane1OffsetY,"L",a.x+a.width,a.y+b.labelOffsetY+b.swimlane1OffsetY].join(" "))},getSwimlane2Element:function(){var a=this.properties,b=this.wrapper.getBBox(),c=this.inner[2].getBBox();return this.paper.path(["M",b.x,b.y+a.labelOffsetY+a.swimlane1OffsetY+c.height+a.swimlane2OffsetY,"L",b.x+b.width,b.y+a.labelOffsetY+a.swimlane1OffsetY+c.height+a.swimlane2OffsetY].join(" "))},getAttributesElement:function(){for(var a=" ",b=this.properties,c=0,d=b.attributes.length;c<d;c++)a+=b.attributes[c]+"\n"; a=a.replace(/^\s\s*/,"").replace(/\s\s*$/,"");c=this.wrapper.getBBox();a=this.paper.text(c.x+b.attributesOffsetX,c.y+b.labelOffsetY+b.swimlane1OffsetY+b.attributesOffsetY,a);b=a.getBBox();a.attr("text-anchor","start");a.translate(0,b.height/2);return a},getMethodsElement:function(){for(var a=" ",b=this.properties,c=0,d=b.methods.length;c<d;c++)a+=b.methods[c]+"\n";a=a.replace(/^\s\s*/,"").replace(/\s\s*$/,"");c=this.wrapper.getBBox();d=this.inner[2].getBBox();a=this.paper.text(c.x+b.methodsOffsetX, c.y+b.labelOffsetY+b.swimlane1OffsetY+b.attributesOffsetY+d.height+b.swimlane2OffsetY+b.methodsOffsetY,a);b=a.getBBox();a.attr("text-anchor","start");a.translate(0,b.height/2);return a},zoom:function(){this.inner[0].remove();this.inner[1].remove();this.inner[2].remove();this.inner[3].remove();this.inner[4].remove();this.inner[0]=this.getLabelElement();this.inner[1]=this.getSwimlane1Element();this.inner[2]=this.getAttributesElement();this.inner[3]=this.getSwimlane2Element();this.inner[4]=this.getMethodsElement()}})})(this);