/**
* 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 f=g.Joint;g=f.dia.Element;var c=f.dia.cdm={};f.arrows.crowfoot=function(a){a=a||2;return{path:["M",(4*a).toString(),4*a.toString(),"L",(-4*a).toString(),"0","L",(4*a).toString(),"0","M",(-4*a).toString(),"0","L",(4*a).toString(),(-a*4).toString()],dx:4*a,dy:4*a,attrs:{stroke:"#800040",fill:"none","stroke-width":1}}};f.arrows.crowfootdashed=function(a){a=a||2;return{path:["M",(4*a).toString(),4*a.toString(),"L",(-4*a).toString(),"0","L",(a/4).toString(),"0","M",(2*a).toString(),"0", "L",(4*a).toString(),"0","M",(-4*a).toString(),"0","L",(4*a).toString(),(-a*4).toString()],dx:4*a,dy:4*a,attrs:{stroke:"#800040",fill:"white","stroke-width":1}}};c.oneToMany={endArrow:{type:"crowfoot"},startArrow:{type:"none"},attrs:{"stroke-dasharray":"none",stroke:"#800040"}};c.manyToOne={startArrow:{type:"crowfoot"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"none",stroke:"#800040"}};c.manyToMany={startArrow:{type:"crowfoot"},endArrow:{type:"crowfoot"},attrs:{"stroke-dasharray":"none",stroke:"#800040"}}; c.plain={startArrow:{type:"none"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"none",stroke:"#800040"}};c.arrow={startArrow:{type:"none"},endArrow:{type:"basic",size:5,attrs:{fill:"#800040",stroke:"#800040"}},attrs:{"stroke-dasharray":"none",stroke:"#800040"}};c.oneToManyDashes={endArrow:{type:"crowfootdashed"},startArrow:{type:"none"},attrs:{"stroke-dasharray":"--",stroke:"#800040"}};c.manyToOneDashes={startArrow:{type:"crowfootdashed"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"--", stroke:"#800040"}};c.manyToManyDashes={startArrow:{type:"crowfoot"},endArrow:{type:"crowfoot"},attrs:{"stroke-dasharray":"-- ",stroke:"#800040"}};c.exampleArrow={startArrow:{type:"crowfoot"},endArrow:{type:"crowfootdashed"},attrs:{"stroke-dasharray":"--",stroke:"#800040"},subConnectionAttrs:[{from:1.1,to:0.5,"stroke-dasharray":"none",stroke:"#800040"}],label:["many","many"],labelAttrs:[{position:20,offset:-10},{position:-20,offset:-10}]};c.dashes={startArrow:{type:"none"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"--", stroke:"#800040"}};c.Entity=g.extend({object:"Entity",module:"cdm",init:function(a){a=f.DeepSupplement(this.properties,a,{radius:10,attrs:{fill:"white"},label:"",labelOffsetX:20,labelOffsetY:5,actions:{entry:null,exit:null,inner:[]},attributesOffsetX:5,attributesOffsetY: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.getAttributesElement())},getLabelElement:function(){var a=this.properties, b=this.wrapper.getBBox(),d=this.paper.text(b.x,b.y,a.label).attr(a.labelAttrs||{}),e=d.getBBox();d.translate(b.x-e.x+a.labelOffsetX,b.y-e.y+a.labelOffsetY);return d},getAttributesElement: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 d=a.actions.inner.length,e=0;e<d;e+=2)b+=a.actions.inner[e]+"/ "+a.actions.inner[e+1]+"\n";b=b.replace(/^\s\s*/,"").replace(/\s\s*$/,"");d=this.wrapper.getBBox();a=this.paper.text(d.x+ a.attributesOffsetX,d.y+a.labelOffsetY+a.attributesOffsetY,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[0]=this.getLabelElement();this.inner[1]=this.getAttributesElement()}})})(this);