/**
* 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 h=g.dia.devs={};h.arrow={endArrow:{type:"none"},startArrow:{type:"none"},attrs:{"stroke-dasharray":"none"}};h.Model=f.extend({object:"Model",module:"devs",init:function(a){a=g.DeepSupplement(this.properties,a,{labelOffsetX:20,labelOffsetY:5,portsOffsetX:5,portsOffsetY:20,iPortRadius:5,oPortRadius:5,iPortAttrs:{fill:"green",stroke:"black"},oPortAttrs:{fill:"red",stroke:"black"},iPortLabelOffsetX:-10,iPortLabelOffsetY:-10,oPortLabelOffsetX:10,oPortLabelOffsetY:-10, iPorts:[],oPorts:[]});var b;this.setWrapper(this.paper.rect(a.rect.x,a.rect.y,a.rect.width,a.rect.height).attr(a.attrs));this.addInner(this.getLabelElement());b=0;for(l=a.iPorts.length;b<l;b++)this.addInner(this.getPortElement("i",b+1,a.iPorts[b]));b=0;for(l=a.oPorts.length;b<l;b++)this.addInner(this.getPortElement("o",b+1,a.oPorts[b]));a.iPorts=a.oPorts=a.portsOffsetX=a.portsOffsetY=a.iPortRadius=a.oPortRadius=a.iPortAttrs=a.oPortAttrs=a.iPortLabelOffsetX=a.iPortLabelOffsetY=a.oPortLabelOffsetX= a.oPortLabelOffsetY=undefined},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},getPortElement:function(a,b,c){var d=this.wrapper.getBBox(),e=this.properties;return h.Port.create({label:c,type:a,position:{x:d.x+(a==="o"?d.width:0),y:d.y+e.portsOffsetY*b},radius:e[a+"PortRadius"],attrs:e[a+"PortAttrs"],offsetX:e[a+"PortLabelOffsetX"], offsetY:e[a+"PortLabelOffsetY"]})},port:function(a,b){for(var c,d=0,e=this.inner.length;d<e;d++){c=this.inner[d];if(c.properties&&b==c.properties.label&&a==c.properties.type)return c}},joint:function(a,b,c,d){if(b.port)return this.port("o",a).joint(b.port("i",c),d)},zoom:function(){}});h.Port=f.extend({object:"Port",module:"devs",init:function(a){a=g.DeepSupplement(this.properties,a,{label:"",offsetX:0,offsetY:0,type:"i"});this.setWrapper(this.paper.circle(a.position.x,a.position.y,a.radius).attr(a.attrs)); this.addInner(this.getLabelElement())},getLabelElement:function(){var a=this.wrapper.getBBox(),b=this.properties,c=this.paper.text(a.x,a.y,b.label),d=c.getBBox();c.translate(a.x-d.x+b.offsetX,a.y-d.y+b.offsetY);return c},zoom:function(){}})})(this);