/**
* 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(f){var g=f.Joint;f=g.dia.Element;var d=g.dia.erd={};d.arrow={startArrow:{type:"none"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"none"}};d.toMany={startArrow:{type:"none"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"none"},label:"n",labelAttrs:{position:-10,offset:-10}};d.manyTo={startArrow:{type:"none"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"none"},label:"n",labelAttrs:{position:10,offset:-10}};d.toOne={startArrow:{type:"none"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"none"}, label:"1",labelAttrs:{position:-10,offset:-10}};d.oneTo={startArrow:{type:"none"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"none"},label:"1",labelAttrs:{position:10,offset:-10}};d.oneToMany={startArrow:{type:"none"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"none"},label:["1","n"],labelAttrs:[{position:10,offset:-10},{position:-10,offset:-10}]};d.manyToOne={startArrow:{type:"none"},endArrow:{type:"none"},attrs:{"stroke-dasharray":"none"},label:["n","1"],labelAttrs:[{position:10,offset:-10}, {position:-10,offset:-10}]};d.Entity=f.extend({object:"Entity",module:"erd",init:function(a){a=g.DeepSupplement(this.properties,a,{attrs:{fill:"lightgreen",stroke:"#008e09","stroke-width":2},label:"",labelAttrs:{"font-weight":"bold"},shadow:true,weak:false,padding:5});this.setWrapper(this.paper.rect(a.rect.x,a.rect.y,a.rect.width,a.rect.height).attr(a.attrs));a.weak&&this.addInner(this.paper.rect(a.rect.x+a.padding,a.rect.y+a.padding,a.rect.width-2*a.padding,a.rect.height-2*a.padding).attr(a.attrs)); this.addInner(this.getLabelElement())},getLabelElement:function(){var a=this.properties,b=this.wrapper.getBBox(),c=this.paper.text(b.x+b.width/2,b.y+b.height/2,a.label).attr(a.labelAttrs||{}),e=c.getBBox();c.translate(b.x-e.x+a.labelOffsetX,b.y-e.y+a.labelOffsetY);return c}});d.Relationship=f.extend({object:"Relationship",module:"erd",init:function(a){a=g.DeepSupplement(this.properties,a,{attrs:{rotation:45,fill:"lightblue",stroke:"#000d5b","stroke-width":2},label:"",labelAttrs:{"font-weight":"bold"}}); this.setWrapper(this.paper.rect(a.rect.x,a.rect.y,a.rect.width,a.rect.height).attr(a.attrs));this.addInner(this.getLabelElement())},getLabelElement:function(){var a=this.properties,b=this.wrapper.getBBox(),c=this.paper.text(b.x+b.width/2,b.y+b.height/2,a.label).attr(a.labelAttrs||{}),e=c.getBBox();c.translate(b.x-e.x+a.labelOffsetX,b.y-e.y+a.labelOffsetY);return c}});d.Attribute=f.extend({object:"Attribute",module:"erd",init:function(a){a=g.DeepSupplement(this.properties,a,{attrs:{fill:"red",opacity:a.primaryKey? 0.8:0.5,stroke:"#5b0001","stroke-width":2,"stroke-dasharray":a.derived?".":"none"},label:"",labelAttrs:{"font-weight":"bold"},multivalued:false,derived:false,padding:5});this.setWrapper(this.paper.ellipse(a.ellipse.x,a.ellipse.y,a.ellipse.rx,a.ellipse.ry).attr(a.attrs));a.multivalued&&this.addInner(this.paper.ellipse(a.ellipse.x,a.ellipse.y,a.ellipse.rx-a.padding,a.ellipse.ry-a.padding).attr(a.attrs));this.addInner(this.getLabelElement())},getLabelElement:function(){var a=this.properties,b=this.wrapper.getBBox(), c=this.paper.text(b.x+b.width/2,b.y+b.height/2,a.label).attr(a.labelAttrs||{}),e=c.getBBox();c.translate(b.x-e.x+a.labelOffsetX,b.y-e.y+a.labelOffsetY);return c}})})(this);