if(!ORYX){var ORYX={}}ORYX.Utils={getParamFromUrl:function(name){name=name.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var regexS="[\\?&]"+name+"=([^]*)";var regex=new RegExp(regexS);var results=regex.exec(window.location.href);if(results==null){return null}else{return results[1]}},adjustLightness:function(){return arguments[0]},adjustGradient:function(gradient,reference){if(ORYX.CONFIG.DISABLE_GRADIENT&&gradient){var col=reference.getAttributeNS(null,"stop-color")||"#ffffff";$A(gradient.getElementsByTagName("stop")).each(function(stop){if(stop==reference){return}stop.setAttributeNS(null,"stop-color",col)})}}};XMLNS={ATOM:"http://www.w3.org/2005/Atom",XHTML:"http://www.w3.org/1999/xhtml",ERDF:"http://purl.org/NET/erdf/profile",RDFS:"http://www.w3.org/2000/01/rdf-schema#",RDF:"http://www.w3.org/1999/02/22-rdf-syntax-ns#",RAZIEL:"http://b3mn.org/Raziel",SCHEMA:""};var Kickstart={started:false,callbacks:[],alreadyLoaded:[],PATH:"",load:function(){Kickstart.kick()},kick:function(){if(!Kickstart.started){Kickstart.started=true;Kickstart.callbacks.each(function(callback){window.setTimeout(callback,1)})}},register:function(callback){with(Kickstart){if(started){window.setTimeout(callback,1)}else{Kickstart.callbacks.push(callback)}}},require:function(url){if(Kickstart.alreadyLoaded.member(url)){return false}return Kickstart.include(url)},include:function(url){var head=document.getElementsByTagNameNS(XMLNS.XHTML,"head")[0];var s=document.createElementNS(XMLNS.XHTML,"script");s.setAttributeNS(XMLNS.XHTML,"type","text/javascript");s.src=Kickstart.PATH+url;head.appendChild(s);Kickstart.alreadyLoaded.push(url);return true}};Event.observe(window,"load",Kickstart.load);var ERDF={LITERAL:1,RESOURCE:2,DELIMITERS:[".","-"],HASH:"#",HYPHEN:"-",schemas:[],callback:undefined,log:undefined,init:function(callback){ERDF.callback=callback;ERDF.registerSchema("schema",XMLNS.SCHEMA);ERDF.registerSchema("rdfs",XMLNS.RDFS)},run:function(){return ERDF._checkProfile()&&ERDF.parse()},parse:function(){ERDF.__startTime=new Date();var bodies=document.getElementsByTagNameNS(XMLNS.XHTML,"body");var subject={type:ERDF.RESOURCE,value:""};var result=ERDF._parseDocumentMetadata()&&ERDF._parseFromTag(bodies[0],subject);ERDF.__stopTime=new Date();var duration=(ERDF.__stopTime-ERDF.__startTime)/1000;return result},_parseDocumentMetadata:function(){var heads=document.getElementsByTagNameNS(XMLNS.XHTML,"head");var links=heads[0].getElementsByTagNameNS(XMLNS.XHTML,"link");var metas=heads[0].getElementsByTagNameNS(XMLNS.XHTML,"meta");$A(links).each(function(link){var properties=link.getAttribute("rel");var reversedProperties=link.getAttribute("rev");var value=link.getAttribute("href");ERDF._parseTriplesFrom(ERDF.RESOURCE,"",properties,ERDF.RESOURCE,value);ERDF._parseTriplesFrom(ERDF.RESOURCE,value,reversedProperties,ERDF.RESOURCE,"")});$A(metas).each(function(meta){var property=meta.getAttribute("name");var value=meta.getAttribute("content");ERDF._parseTriplesFrom(ERDF.RESOURCE,"",property,ERDF.LITERAL,value)});return true},_parseFromTag:function(node,subject,depth){if(!node||!node.namespaceURI||node.namespaceURI!=XMLNS.XHTML){return}if(!depth){depth=0}var id=node.getAttribute("id");if(node.nodeName.endsWith(":a")||node.nodeName=="a"){var properties=node.getAttribute("rel");var reversedProperties=node.getAttribute("rev");var value=node.getAttribute("href");var title=node.getAttribute("title");var content=node.textContent;ERDF._parseTriplesFrom(subject.type,subject.value,properties,ERDF.RESOURCE,value,function(triple){var label=title?title:content;ERDF._parseTriplesFrom(triple.object.type,triple.object.value,"rdfs.label",ERDF.LITERAL,label)});ERDF._parseTriplesFrom(subject.type,subject.value,reversedProperties,ERDF.RESOURCE,"");ERDF._parseTypeTriplesFrom(subject.type,subject.value,properties)}else{if(node.nodeName.endsWith(":img")||node.nodeName=="img"){var properties=node.getAttribute("class");var value=node.getAttribute("src");var alt=node.getAttribute("alt");ERDF._parseTriplesFrom(subject.type,subject.value,properties,ERDF.RESOURCE,value,function(triple){var label=alt;ERDF._parseTriplesFrom(triple.object.type,triple.object.value,"rdfs.label",ERDF.LITERAL,label)})}}var properties=node.getAttribute("class");var title=node.getAttribute("title");var content=node.textContent;var label=title?title:content;ERDF._parseTriplesFrom(subject.type,subject.value,properties,ERDF.LITERAL,label);if(id){subject={type:ERDF.RESOURCE,value:ERDF.HASH+id}}ERDF._parseTypeTriplesFrom(subject.type,subject.value,properties);var children=node.childNodes;if(children){$A(children).each(function(_node){if(_node.nodeType==_node.ELEMENT_NODE){ERDF._parseFromTag(_node,subject,depth+1)}})}},_parseTriplesFrom:function(subjectType,subject,properties,objectType,object,callback){if(!properties){return}properties.toLowerCase().split(" ").each(function(property){var schema=ERDF.schemas.find(function(schema){return false||ERDF.DELIMITERS.find(function(delimiter){return property.startsWith(schema.prefix+delimiter)
})});if(schema&&object){property=property.substring(schema.prefix.length+1,property.length);var triple=ERDF.registerTriple(new ERDF.Resource(subject),{prefix:schema.prefix,name:property},(objectType==ERDF.RESOURCE)?new ERDF.Resource(object):new ERDF.Literal(object));if(callback){callback(triple)}}})},_parseTypeTriplesFrom:function(subjectType,subject,properties,callback){if(!properties){return}properties.toLowerCase().split(" ").each(function(property){var schema=ERDF.schemas.find(function(schema){return false||ERDF.DELIMITERS.find(function(delimiter){return property.startsWith(ERDF.HYPHEN+schema.prefix+delimiter)})});if(schema&&subject){property=property.substring(schema.prefix.length+2,property.length);var triple=ERDF.registerTriple((subjectType==ERDF.RESOURCE)?new ERDF.Resource(subject):new ERDF.Literal(subject),{prefix:"rdf",name:"type"},new ERDF.Resource(schema.namespace+property));if(callback){callback(triple)}}})},_checkProfile:function(){var heads=document.getElementsByTagNameNS(XMLNS.XHTML,"head");var profiles=heads[0].getAttribute("profile");var found=false;if(profiles&&profiles.split(" ").member(XMLNS.ERDF)){return true}else{return false}},__stripHashes:function(s){return(s&&(typeof s.substring=="function")&&s.substring(0,1)=="#")?s.substring(1,s.length):s},registerSchema:function(prefix,namespace){ERDF.schemas.push({prefix:prefix,namespace:namespace})},registerTriple:function(subject,predicate,object){if(predicate.prefix.toLowerCase()=="schema"){this.registerSchema(predicate.name,object.value)}var triple=new ERDF.Triple(subject,predicate,object);ERDF.callback(triple);return triple},__enhanceObject:function(){this.isResource=function(){return this.type==ERDF.RESOURCE};this.isLocal=function(){return this.isResource()&&this.value.startsWith("#")};this.isCurrentDocument=function(){return this.isResource()&&(this.value=="")};this.getId=function(){return this.isLocal()?ERDF.__stripHashes(this.value):false};this.isLiteral=function(){return this.type==ERDF.LIITERAL}},serialize:function(literal){if(!literal){return""}else{if(literal.constructor==String){return literal}else{if(literal.constructor==Boolean){return literal?"true":"false"}else{return literal.toString()}}}}};ERDF.Triple=function(subject,predicate,object){this.subject=subject;this.predicate=predicate;this.object=object;this.toString=function(){return"[ERDF.Triple] "+this.subject.toString()+" "+this.predicate.prefix+":"+this.predicate.name+" "+this.object.toString()}};ERDF.Resource=function(uri){this.type=ERDF.RESOURCE;this.value=uri;ERDF.__enhanceObject.apply(this);this.toString=function(){return"<"+this.value+">"}};ERDF.Literal=function(literal){this.type=ERDF.LITERAL;this.value=ERDF.serialize(literal);ERDF.__enhanceObject.apply(this);this.toString=function(){return'"'+this.value+'"'}};var USE_ASYNCHRONOUS_REQUESTS=true;var DISCARD_UNUSED_TRIPLES=true;var PREFER_SPANS_OVER_DIVS=true;var PREFER_TITLE_OVER_TEXTNODE=false;var RESOURCE_ID_PREFIX="resource";var SHOW_DEBUG_ALERTS_WHEN_SAVING=false;var SHOW_EXTENDED_DEBUG_INFORMATION=false;var USE_ARESS_WORKAROUNDS=true;var RESOURCE_CREATED=1;var RESOURCE_REMOVED=2;var RESOURCE_SAVED=4;var RESOURCE_RELOADED=8;var RESOURCE_SYNCHRONIZED=16;var TRIPLE_REMOVE=1;var TRIPLE_ADD=2;var TRIPLE_RELOAD=4;var TRIPLE_SAVE=8;var PROCESSDATA_REF="processdata";var DataManager={init:function(){ERDF.init(DataManager._registerTriple);DataManager.__synclocal()},_triples:[],_registerTriple:function(triple){DataManager._triples.push(triple)},__synclocal:function(){DataManager._triples=[];ERDF.run()},__synchronizeShape:function(shape){var r=ResourceManager.getResource(shape.resourceId);var serialize=shape.serialize();serialize.each(function(ser){var resource=(ser.type=="resource");var _triple=new ERDF.Triple(new ERDF.Resource(shape.resourceId),{prefix:ser.prefix,name:ser.name},resource?new ERDF.Resource(ser.value):new ERDF.Literal(ser.value));DataManager.setObject(_triple)});return r},__storeShape:function(shape){var resource=DataManager.__synchronizeShape(shape);resource.save()},__forceExistance:function(shape){if(!$(shape.resourceId)){if(!$$("."+PROCESSDATA_REF)[0]){DataManager.graft(XMLNS.XHTML,document.getElementsByTagNameNS(XMLNS.XHTML,"body").item(0),["div",{"class":PROCESSDATA_REF,"style":"display:none;"}])}DataManager.graft(XMLNS.XHTML,$$("."+PROCESSDATA_REF)[0],["div",{"id":shape.resourceId,"class":(shape instanceof ORYX.Core.Canvas)?"-oryx-canvas":undefined}])}else{var resource=$(shape.resourceId);var children=$A(resource.childNodes);children.each(function(child){resource.removeChild(child)})}},__persistShape:function(shape){var shapeData=shape.serialize();var triplesArray=[];var shapeResource=new ERDF.Resource(shape.resourceId);DataManager.removeTriples(DataManager.query(shapeResource,undefined,undefined));shapeData.each(function(data){var value=(data.type=="resource")?new ERDF.Resource(data.value):new ERDF.Literal(data.value);DataManager.addTriple(new ERDF.Triple(shapeResource,{prefix:data.prefix,name:data.name},value))
})},__persistDOM:function(facade){var canvas=facade.getCanvas();var shapes=canvas.getChildShapes(true);var result="";shapes.each(function(shape){DataManager.__forceExistance(shape)});DataManager.__renderCanvas(facade);result+=DataManager.serialize($(ERDF.__stripHashes(facade.getCanvas().resourceId)),true);shapes.each(function(shape){DataManager.__persistShape(shape);result+=DataManager.serialize($(ERDF.__stripHashes(shape.resourceId)),true)});return result},__renderCanvas:function(facade){var canvas=facade.getCanvas();var stencilSets=facade.getStencilSets();var shapes=canvas.getChildShapes(true);DataManager.__forceExistance(canvas);DataManager.__persistShape(canvas);var shapeResource=new ERDF.Resource(canvas.resourceId);DataManager.removeTriples(DataManager.query(shapeResource,undefined,undefined));DataManager.addTriple(new ERDF.Triple(shapeResource,{prefix:"oryx",name:"mode"},new ERDF.Literal("writable")));DataManager.addTriple(new ERDF.Triple(shapeResource,{prefix:"oryx",name:"mode"},new ERDF.Literal("fullscreen")));stencilSets.values().each(function(stencilset){DataManager.addTriple(new ERDF.Triple(shapeResource,{prefix:"oryx",name:"stencilset"},new ERDF.Resource(stencilset.source().replace(/&/g,"%26"))));DataManager.addTriple(new ERDF.Triple(shapeResource,{prefix:"oryx",name:"ssnamespace"},new ERDF.Resource(stencilset.namespace())));stencilset.extensions().keys().each(function(extension){DataManager.addTriple(new ERDF.Triple(shapeResource,{prefix:"oryx",name:"ssextension"},new ERDF.Literal(extension)))})});shapes.each(function(shape){DataManager.addTriple(new ERDF.Triple(shapeResource,{prefix:"oryx",name:"render"},new ERDF.Resource("#"+shape.resourceId)))})},__counter:0,__provideId:function(){while($(RESOURCE_ID_PREFIX+DataManager.__counter)){DataManager.__counter++}return RESOURCE_ID_PREFIX+DataManager.__counter},serializeDOM:function(facade){return DataManager.__persistDOM(facade)},syncGlobal:function(facade){return DataManager.__syncglobal(facade)},__syncglobal:function(facade){var canvas=facade.getCanvas();var shapes=canvas.getChildShapes(true);shapes.select(function(shape){return !($(shape.resourceId))}).each(function(shape){if(USE_ARESS_WORKAROUNDS){var razielType=shape.properties["raziel-type"];var div='
'+''+razielType+"
";var r=ResourceManager.__createResource(div);shape.resourceId=r.id()}else{var r=ResourceManager.__createResource();shape.resourceId=r.id()}});shapes.each(function(shape){DataManager.__storeShape(shape)})},serialize:function(node,preserveNamespace){if(node.nodeType==node.ELEMENT_NODE){var children=$A(node.childNodes);var attributes=$A(node.attributes);var clazz=new String(node.getAttribute("class"));var ignore=clazz.split(" ").member("transient");if(ignore){return""}var result="<"+node.nodeName;if(!preserveNamespace){result+=' xmlns="'+(node.namespaceURI?node.namespaceURI:XMLNS.XHTML)+'" xmlns:oryx="http://oryx-editor.org"'}attributes.each(function(attribute){result+=" "+attribute.nodeName+'="'+attribute.nodeValue+'"'});if(children.length==0){result+="/>"}else{result+=">";children.each(function(_node){result+=DataManager.serialize(_node,true)});result+=""+node.nodeName+">"}return result}else{if(node.nodeType==node.TEXT_NODE){return node.nodeValue}}},addTriple:function(triple){if(!triple.subject.type==ERDF.LITERAL){throw"Cannot add the triple "+triple.toString()+" because the subject is not a resource."}var elementId=ERDF.__stripHashes(triple.subject.value);var element=$(elementId);if(!element){throw"Cannot add the triple "+triple.toString()+' because the subject "'+elementId+'" is not in the document.'}if(triple.object.type==ERDF.LITERAL){DataManager.graft(XMLNS.XHTML,element,["span",{"class":(triple.predicate.prefix+"-"+triple.predicate.name)},triple.object.value.escapeHTML()])}else{DataManager.graft(XMLNS.XHTML,element,["a",{"rel":(triple.predicate.prefix+"-"+triple.predicate.name),"href":triple.object.value}])}return true},removeTriples:function(triples){var removed=triples.select(function(triple){return DataManager.__removeTriple(triple)});return removed},removeTriple:function(triple){var result=DataManager.__removeTriple(triple);return result},__removeTriple:function(triple){if(!triple.subject.type==ERDF.LITERAL){throw"Cannot remove the triple "+triple.toString()+" because the subject is not a resource."}var elementId=ERDF.__stripHashes(triple.subject.value);var element=$(elementId);if(!element){throw"Cannot remove the triple "+triple.toString()+" because the subject is not in the document."}if(triple.object.type==ERDF.LITERAL){var result=DataManager.__removeTripleRecursively(triple,element);return result}},__removeTripleRecursively:function(triple,continueFrom){if(continueFrom.nodeType!=continueFrom.ELEMENT_NODE){return false}var classes=new String(continueFrom.getAttribute("class"));var children=$A(continueFrom.childNodes);if(classes.include(triple.predicate.prefix+"-"+triple.predicate.name)){var content=continueFrom.textContent;
if((triple.object.type==ERDF.LITERAL)&&(triple.object.value==content)){continueFrom.parentNode.removeChild(continueFrom)}return true}else{children.each(function(_node){DataManager.__removeTripleRecursively(triple,_node)});return false}},graft:function(namespace,parent,t,doc){doc=(doc||(parent&&parent.ownerDocument)||document);var e;if(t===undefined){echo("Can't graft an undefined value")}else{if(t.constructor==String){e=doc.createTextNode(t)}else{for(var i=0;i1)?" There is more than one raziel:entry URL.":" There is no raziel:entry URL."));return false},__createResource:function(alternativeDiv){var collectionUrls=DataManager.query(new ERDF.Resource(""),{prefix:"raziel",name:"collection"},undefined);if((collectionUrls.length==1)&&(collectionUrls[0].object.isResource())){var collectionUrl=collectionUrls[0].object.value;var resource=undefined;var serialization=alternativeDiv?alternativeDiv:'';ResourceManager.__request("POST",collectionUrl,serialization,function(){var response=(this.responseXML);var div=response.childNodes[0];var id=div.getAttribute("id");if(!$$("."+PROCESSDATA_REF)[0]){DataManager.graft(XMLNS.XHTML,document.getElementsByTagNameNS(XMLNS.XHTML,"body").item(0),["div",{"class":PROCESSDATA_REF,"style":"display:none;"}])
}$$("."+PROCESSDATA_REF)[0].appendChild(div.cloneNode(true));DataManager.__synclocal();resource=new ResourceManager.getResource(id);ResourceManager.__resourceActionSucceeded(this,RESOURCE_CREATED,undefined)},function(){ResourceManager.__resourceActionFailed(this,RESOURCE_CREATED,undefined)},false);return resource}throw"Could not create resource! raziel:collection URL is missing!";return false},__Resource:function(id,url){this.__id=id;this.__url=url;this.id=function(){return this.__id};this.url=function(){return this.__url};this.reload=function(){var _url=this.__url;var _id=this.__id;ResourceManager.__request("GET",_url,null,function(){ResourceManager.__resourceActionSucceeded(this,RESOURCE_RELOADED,_id)},function(){ResourceManager.__resourceActionFailed(this,RESURCE_RELOADED,_id)},USE_ASYNCHRONOUS_REQUESTS)};this.save=function(synchronize){var _url=this.__url;var _id=this.__id;data=DataManager.serialize($(_id));ResourceManager.__request("PUT",_url,data,function(){ResourceManager.__resourceActionSucceeded(this,synchronize?RESOURCE_SAVED|RESOURCE_SYNCHRONIZED:RESOURCE_SAVED,_id)},function(){ResourceManager.__resourceActionFailed(this,synchronize?RESOURCE_SAVED|RESOURCE_SYNCHRONIZED:RESOURCE.SAVED,_id)},USE_ASYNCHRONOUS_REQUESTS)};this.remove=function(){var _url=this.__url;var _id=this.__id;ResourceManager.__request("DELETE",_url,null,function(){ResourceManager.__resourceActionSucceeded(this,RESOURCE_REMOVED,_id)},function(){ResourceManager.__resourceActionFailed(this,RESOURCE_REMOVED,_id)},USE_ASYNCHRONOUS_REQUESTS)}},request:function(url,requestOptions){var options={method:"get",asynchronous:true,parameters:{}};Object.extend(options,requestOptions||{});var params=Hash.toQueryString(options.parameters);if(params){url+=(url.include("?")?"&":"?")+params}return ResourceManager.__request(options.method,url,options.data,(options.onSuccess instanceof Function?function(){options.onSuccess(this)}:undefined),(options.onFailure instanceof Function?function(){options.onFailure(this)}:undefined),options.asynchronous&&USE_ASYNCHRONOUS_REQUESTS,options.headers)},__request:function(method,url,data,success,error,async,headers){var httpRequest=Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")});if(!httpRequest){if(!this.__corrupt){throw"This browser does not provide any AJAX functionality. You will not be able to use the software provided with the page you are viewing. Please consider installing appropriate extensions."}this.__corrupt=true;return false}if(success instanceof Function){httpRequest.onload=success}if(error instanceof Function){httpRequest.onerror=error}var h=$H(headers);h.keys().each(function(key){httpRequest.setRequestHeader(key,h[key])});try{if(SHOW_DEBUG_ALERTS_WHEN_SAVING){alert(method+" "+url+"\n"+SHOW_EXTENDED_DEBUG_INFORMATION?data:"")}httpRequest.open(method,url,!async?false:true);httpRequest.send(data)}catch(e){return false}return true},__resourceActionSucceeded:function(transport,action,id){var status=transport.status;var response=transport.responseText;if(SHOW_DEBUG_ALERTS_WHEN_SAVING){alert(status+" "+url+"\n"+SHOW_EXTENDED_DEBUG_INFORMATION?data:"")}if(status>=300){throw"The server responded with an error: "+status+"\n"+(SHOW_EXTENDED_DEBUG_INFORMATION?+data:"If you need additional information here, including the data sent by the server, consider setting SHOW_EXTENDED_DEBUG_INFORMATION to true.")}switch(action){case RESOURCE_REMOVED:var response=(transport.responseXML);var div=response.childNodes[0];var id=div.getAttribute("id");var localDiv=document.getElementById(id);localDiv.parentNode.removeChild(localDiv);break;case RESOURCE_CREATED:break;case RESOURCE_SAVED|RESOURCE_SYNCHRONIZED:DataManager.__synclocal();case RESOURCE_SAVED:break;case RESOURCE_RELOADED:var response=(transport.responseXML);var div=response.childNodes[0];var id=div.getAttribute("id");var localDiv=document.getElementById(id);localDiv.parentNode.removeChild(localDiv);if(!$$(PROCESSDATA_REF)[0]){DataManager.graft(XMLNS.XHTML,document.getElementsByTagNameNS(XMLNS.XHTML,"body").item(0),["div",{"class":PROCESSDATA_REF,"style":"display:none;"}])}$$(PROCESSDATA_REF)[0].appendChild(div.cloneNode(true));DataManager.__synclocal();break;default:DataManager.__synclocal()}ResourceManager.__dispatchEvent(new ResourceManager.__Event(action,id))},__resourceActionFailed:function(transport,action,id){throw"Fatal: Resource action failed. There is something horribly "+"wrong with either the server, the transport protocol or your "+"online status. Sure you're online?"}};var Clazz=function(){};Clazz.prototype.construct=function(){};Clazz.extend=function(def){var classDef=function(){if(arguments[0]!==Clazz){this.construct.apply(this,arguments)}};var proto=new this(Clazz);var superClass=this.prototype;for(var n in def){var item=def[n];if(item instanceof Function){item.$=superClass}proto[n]=item}classDef.prototype=proto;classDef.extend=this.extend;
return classDef};if(!ORYX){var ORYX={}}if(!ORYX.CONFIG){ORYX.CONFIG={}}ORYX.CONFIG.ROOT_PATH="editor/";ORYX.CONFIG.EXPLORER_PATH="explorer";ORYX.CONFIG.LIBS_PATH="libs";ORYX.CONFIG.SERVER_HANDLER_ROOT="service";ORYX.CONFIG.SERVER_EDITOR_HANDLER=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/editor";ORYX.CONFIG.SERVER_MODEL_HANDLER=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/model";ORYX.CONFIG.STENCILSET_HANDLER=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/editor_stencilset?embedsvg=true&url=true&namespace=";ORYX.CONFIG.STENCIL_SETS_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/editor_stencilset";ORYX.CONFIG.PLUGINS_CONFIG="editor-app/plugins.xml";ORYX.CONFIG.SYNTAXCHECKER_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/syntaxchecker";ORYX.CONFIG.DEPLOY_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/model/deploy";ORYX.CONFIG.MODEL_LIST_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/models";ORYX.CONFIG.FORM_FLOW_LIST_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/formflows";ORYX.CONFIG.FORM_FLOW_IMAGE_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/formflow";ORYX.CONFIG.FORM_LIST_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/forms";ORYX.CONFIG.FORM_IMAGE_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/form";ORYX.CONFIG.SUB_PROCESS_LIST_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/subprocesses";ORYX.CONFIG.SUB_PROCESS_IMAGE_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/subprocess";ORYX.CONFIG.TEST_SERVICE_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/service/";ORYX.CONFIG.SERVICE_LIST_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/services";ORYX.CONFIG.CONDITION_ELEMENT_LIST_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/conditionelements";ORYX.CONFIG.VARIABLEDEF_ELEMENT_LIST_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/variabledefinitionelements";ORYX.CONFIG.VALIDATOR_LIST_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/validators";ORYX.CONFIG.SS_EXTENSIONS_FOLDER=ORYX.CONFIG.ROOT_PATH+"stencilsets/extensions/";ORYX.CONFIG.SS_EXTENSIONS_CONFIG=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/editor_ssextensions";ORYX.CONFIG.ORYX_NEW_URL="/new";ORYX.CONFIG.BPMN_LAYOUTER=ORYX.CONFIG.ROOT_PATH+"bpmnlayouter";ORYX.CONFIG.EXPRESSION_METADATA_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/expression-metadata";ORYX.CONFIG.DATASOURCE_METADATA_URL=ORYX.CONFIG.SERVER_HANDLER_ROOT+"/datasource-metadata";if(!ORYX){var ORYX={}}if(!ORYX.CONFIG){ORYX.CONFIG={}}ORYX.CONFIG.BACKEND_SWITCH=true;ORYX.CONFIG.PANEL_LEFT_WIDTH=250;ORYX.CONFIG.PANEL_RIGHT_COLLAPSED=true;ORYX.CONFIG.PANEL_RIGHT_WIDTH=300;ORYX.CONFIG.APPNAME="KISBPM";ORYX.CONFIG.WEB_URL=".";ORYX.CONFIG.BLANK_IMAGE=ORYX.CONFIG.LIBS_PATH+"/ext-2.0.2/resources/images/default/s.gif";ORYX.CONFIG.OFFSET_HEADER=61;ORYX.CONFIG.SHOW_GRIDLINE=true;ORYX.CONFIG.MODE_READONLY="readonly";ORYX.CONFIG.MODE_FULLSCREEN="fullscreen";ORYX.CONFIG.WINDOW_HEIGHT=800;ORYX.CONFIG.PREVENT_LOADINGMASK_AT_READY=false;ORYX.CONFIG.PLUGINS_ENABLED=true;ORYX.CONFIG.PLUGINS_FOLDER="Plugins/";ORYX.CONFIG.BPMN20_SCHEMA_VALIDATION_ON=true;ORYX.CONFIG.NAMESPACE_ORYX="http://www.b3mn.org/oryx";ORYX.CONFIG.NAMESPACE_SVG="http://www.w3.org/2000/svg";ORYX.CONFIG.CANVAS_WIDTH=1200;ORYX.CONFIG.CANVAS_HEIGHT=1050;ORYX.CONFIG.CANVAS_RESIZE_INTERVAL=100;ORYX.CONFIG.CANVAS_MIN_WIDTH=800;ORYX.CONFIG.CANVAS_MIN_HEIGHT=300;ORYX.CONFIG.SELECTED_AREA_PADDING=4;ORYX.CONFIG.CANVAS_BACKGROUND_COLOR="none";ORYX.CONFIG.GRID_DISTANCE=30;ORYX.CONFIG.GRID_ENABLED=true;ORYX.CONFIG.ZOOM_OFFSET=0.1;ORYX.CONFIG.DEFAULT_SHAPE_MARGIN=60;ORYX.CONFIG.SCALERS_SIZE=7;ORYX.CONFIG.MINIMUM_SIZE=20;ORYX.CONFIG.MAXIMUM_SIZE=10000;ORYX.CONFIG.OFFSET_MAGNET=15;ORYX.CONFIG.OFFSET_EDGE_LABEL_TOP=8;ORYX.CONFIG.OFFSET_EDGE_LABEL_BOTTOM=8;ORYX.CONFIG.OFFSET_EDGE_BOUNDS=5;ORYX.CONFIG.COPY_MOVE_OFFSET=30;ORYX.CONFIG.BORDER_OFFSET=14;ORYX.CONFIG.MAX_NUM_SHAPES_NO_GROUP=20;ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET_CORNER=30;ORYX.CONFIG.SHAPEMENU_CREATE_OFFSET=45;ORYX.CONFIG.SHAPEMENU_RIGHT="Oryx_Right";ORYX.CONFIG.SHAPEMENU_BOTTOM="Oryx_Bottom";ORYX.CONFIG.SHAPEMENU_LEFT="Oryx_Left";ORYX.CONFIG.SHAPEMENU_TOP="Oryx_Top";ORYX.CONFIG.MORPHITEM_DISABLED="Oryx_MorphItem_disabled";ORYX.CONFIG.TYPE_STRING="string";ORYX.CONFIG.TYPE_BOOLEAN="boolean";ORYX.CONFIG.TYPE_INTEGER="integer";ORYX.CONFIG.TYPE_FLOAT="float";ORYX.CONFIG.TYPE_COLOR="color";ORYX.CONFIG.TYPE_DATE="date";ORYX.CONFIG.TYPE_CHOICE="choice";ORYX.CONFIG.TYPE_URL="url";ORYX.CONFIG.TYPE_DIAGRAM_LINK="diagramlink";ORYX.CONFIG.TYPE_COMPLEX="complex";ORYX.CONFIG.TYPE_MULTIPLECOMPLEX="multiplecomplex";ORYX.CONFIG.TYPE_TEXT="text";ORYX.CONFIG.TYPE_KISBPM_MULTIINSTANCE="kisbpm-multiinstance";ORYX.CONFIG.TYPE_MODEL_LINK="modellink";ORYX.CONFIG.TYPE_FORM_FLOW_LINK="formflowlink";ORYX.CONFIG.TYPE_FORM_LINK="formlink";ORYX.CONFIG.TYPE_SUB_PROCESS_LINK="subprocesslink";ORYX.CONFIG.TYPE_SERVICE_LINK="servicelink";ORYX.CONFIG.TYPE_CONDITIONS="conditions";ORYX.CONFIG.TYPE_VARIABLES="variables";ORYX.CONFIG.TYPE_LISTENER="listener";ORYX.CONFIG.TYPE_EPC_FREQ="epcfrequency";ORYX.CONFIG.TYPE_GLOSSARY_LINK="glossarylink";ORYX.CONFIG.TYPE_EXPRESSION="expression";ORYX.CONFIG.TYPE_DATASOURCE="datasource";ORYX.CONFIG.TYPE_DATASOURCE_MINIMAL="datasource-minimal";ORYX.CONFIG.TYPE_VALIDATORS="validators";ORYX.CONFIG.LABEL_LINE_DISTANCE=2;
ORYX.CONFIG.LABEL_DEFAULT_LINE_HEIGHT=12;ORYX.CONFIG.ENABLE_MORPHMENU_BY_HOVER=false;ORYX.CONFIG.EDITOR_ALIGN_BOTTOM=1;ORYX.CONFIG.EDITOR_ALIGN_MIDDLE=2;ORYX.CONFIG.EDITOR_ALIGN_TOP=4;ORYX.CONFIG.EDITOR_ALIGN_LEFT=8;ORYX.CONFIG.EDITOR_ALIGN_CENTER=16;ORYX.CONFIG.EDITOR_ALIGN_RIGHT=32;ORYX.CONFIG.EDITOR_ALIGN_SIZE=48;ORYX.CONFIG.EVENT_MOUSEDOWN="mousedown";ORYX.CONFIG.EVENT_MOUSEUP="mouseup";ORYX.CONFIG.EVENT_MOUSEOVER="mouseover";ORYX.CONFIG.EVENT_MOUSEOUT="mouseout";ORYX.CONFIG.EVENT_MOUSEMOVE="mousemove";ORYX.CONFIG.EVENT_MOUSEWHEEL="mousewheel";ORYX.CONFIG.EVENT_DBLCLICK="dblclick";ORYX.CONFIG.EVENT_KEYDOWN="keydown";ORYX.CONFIG.EVENT_KEYUP="keyup";ORYX.CONFIG.EVENT_LOADED="editorloaded";ORYX.CONFIG.EVENT_SAVED="editorSaved";ORYX.CONFIG.EVENT_EXECUTE_COMMANDS="executeCommands";ORYX.CONFIG.EVENT_STENCIL_SET_LOADED="stencilSetLoaded";ORYX.CONFIG.EVENT_SELECTION_CHANGED="selectionchanged";ORYX.CONFIG.EVENT_SHAPEADDED="shapeadded";ORYX.CONFIG.EVENT_SHAPEREMOVED="shaperemoved";ORYX.CONFIG.EVENT_PROPERTY_CHANGED="propertyChanged";ORYX.CONFIG.EVENT_DRAGDROP_START="dragdrop.start";ORYX.CONFIG.EVENT_SHAPE_MENU_CLOSE="shape.menu.close";ORYX.CONFIG.EVENT_DRAGDROP_END="dragdrop.end";ORYX.CONFIG.EVENT_RESIZE_START="resize.start";ORYX.CONFIG.EVENT_RESIZE_END="resize.end";ORYX.CONFIG.EVENT_DRAGDOCKER_DOCKED="dragDocker.docked";ORYX.CONFIG.EVENT_HIGHLIGHT_SHOW="highlight.showHighlight";ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE="highlight.hideHighlight";ORYX.CONFIG.EVENT_LOADING_ENABLE="loading.enable";ORYX.CONFIG.EVENT_LOADING_DISABLE="loading.disable";ORYX.CONFIG.EVENT_LOADING_STATUS="loading.status";ORYX.CONFIG.EVENT_OVERLAY_SHOW="overlay.show";ORYX.CONFIG.EVENT_OVERLAY_HIDE="overlay.hide";ORYX.CONFIG.EVENT_ARRANGEMENT_TOP="arrangement.setToTop";ORYX.CONFIG.EVENT_ARRANGEMENT_BACK="arrangement.setToBack";ORYX.CONFIG.EVENT_ARRANGEMENT_FORWARD="arrangement.setForward";ORYX.CONFIG.EVENT_ARRANGEMENT_BACKWARD="arrangement.setBackward";ORYX.CONFIG.EVENT_PROPWINDOW_PROP_CHANGED="propertyWindow.propertyChanged";ORYX.CONFIG.EVENT_LAYOUT_ROWS="layout.rows";ORYX.CONFIG.EVENT_LAYOUT_BPEL="layout.BPEL";ORYX.CONFIG.EVENT_LAYOUT_BPEL_VERTICAL="layout.BPEL.vertical";ORYX.CONFIG.EVENT_LAYOUT_BPEL_HORIZONTAL="layout.BPEL.horizontal";ORYX.CONFIG.EVENT_LAYOUT_BPEL_SINGLECHILD="layout.BPEL.singlechild";ORYX.CONFIG.EVENT_LAYOUT_BPEL_AUTORESIZE="layout.BPEL.autoresize";ORYX.CONFIG.EVENT_AUTOLAYOUT_LAYOUT="autolayout.layout";ORYX.CONFIG.EVENT_UNDO_EXECUTE="undo.execute";ORYX.CONFIG.EVENT_UNDO_ROLLBACK="undo.rollback";ORYX.CONFIG.EVENT_BUTTON_UPDATE="toolbar.button.update";ORYX.CONFIG.EVENT_LAYOUT="layout.dolayout";ORYX.CONFIG.EVENT_GLOSSARY_LINK_EDIT="glossary.link.edit";ORYX.CONFIG.EVENT_GLOSSARY_SHOW="glossary.show.info";ORYX.CONFIG.EVENT_GLOSSARY_NEW="glossary.show.new";ORYX.CONFIG.EVENT_DOCKERDRAG="dragTheDocker";ORYX.CONFIG.EVENT_CANVAS_SCROLL="canvas.scroll";ORYX.CONFIG.EVENT_SHOW_PROPERTYWINDOW="propertywindow.show";ORYX.CONFIG.EVENT_ABOUT_TO_SAVE="file.aboutToSave";ORYX.CONFIG.EVENT_SHOW_DUPLICATE_SHAPE="extends.showDuplicateShape";ORYX.CONFIG.EVENT_VALIDATE_SHAPE="extends.validateShape";ORYX.CONFIG.SELECTION_HIGHLIGHT_SIZE=5;ORYX.CONFIG.SELECTION_HIGHLIGHT_COLOR="#4444FF";ORYX.CONFIG.SELECTION_HIGHLIGHT_COLOR2="#9999FF";ORYX.CONFIG.SELECTION_HIGHLIGHT_STYLE_CORNER="corner";ORYX.CONFIG.SELECTION_HIGHLIGHT_STYLE_RECTANGLE="rectangle";ORYX.CONFIG.SELECTION_VALID_COLOR="#00FF00";ORYX.CONFIG.SELECTION_INVALID_COLOR="#FF0000";ORYX.CONFIG.DOCKER_DOCKED_COLOR="#00FF00";ORYX.CONFIG.DOCKER_UNDOCKED_COLOR="#FF0000";ORYX.CONFIG.DOCKER_SNAP_OFFSET=10;ORYX.CONFIG.EDIT_OFFSET_PASTE=10;ORYX.CONFIG.KEY_CODE_X=88;ORYX.CONFIG.KEY_CODE_C=67;ORYX.CONFIG.KEY_CODE_V=86;ORYX.CONFIG.KEY_CODE_DELETE=46;ORYX.CONFIG.KEY_CODE_META=224;ORYX.CONFIG.KEY_CODE_BACKSPACE=8;ORYX.CONFIG.KEY_CODE_LEFT=37;ORYX.CONFIG.KEY_CODE_RIGHT=39;ORYX.CONFIG.KEY_CODE_UP=38;ORYX.CONFIG.KEY_CODE_DOWN=40;ORYX.CONFIG.KEY_Code_enter=12;ORYX.CONFIG.KEY_Code_left=37;ORYX.CONFIG.KEY_Code_right=39;ORYX.CONFIG.KEY_Code_top=38;ORYX.CONFIG.KEY_Code_bottom=40;ORYX.CONFIG.META_KEY_META_CTRL="metactrl";ORYX.CONFIG.META_KEY_ALT="alt";ORYX.CONFIG.META_KEY_SHIFT="shift";ORYX.CONFIG.KEY_ACTION_DOWN="down";ORYX.CONFIG.KEY_ACTION_UP="up";ORYX.CONFIG.FORM_ROW_WIDTH=350;ORYX.CONFIG.FORM_GROUP_MARGIN=5;ORYX.CONFIG.FORM_GROUP_EMPTY_HEIGHT=100;ORYX.CONFIG.FORM_ELEMENT_ID_PREFIX="http://b3mn.org/stencilset/xforms";ORYX.CONFIG.FORM_ELEMENT_TYPE_ROOT="http://b3mn.org/stencilset/xforms#XForm";ORYX.CONFIG.FORM_ELEMENT_TYPE_GROUP="http://b3mn.org/stencilset/xforms#Group";ORYX.CONFIG.FORM_ELEMENT_TYPE_REPEATING_GROUP="http://b3mn.org/stencilset/xforms#RepeatingGroup";ORYX.CONFIG.FORM_ELEMENT_TYPE_LABEL_FIELD="http://b3mn.org/stencilset/xforms#LabelField";function printf(){var result=arguments[0];for(var i=1;i=ORYX_LOGLEVEL_TRACE){ORYX.Log.__log("TRACE",arguments)}},debug:function(){if(ORYX_LOGLEVEL>=ORYX_LOGLEVEL_DEBUG){ORYX.Log.__log("DEBUG",arguments)}},info:function(){if(ORYX_LOGLEVEL>=ORYX_LOGLEVEL_INFO){ORYX.Log.__log("INFO",arguments)}},warn:function(){if(ORYX_LOGLEVEL>=ORYX_LOGLEVEL_WARN){ORYX.Log.__log("WARN",arguments)}},error:function(){if(ORYX_LOGLEVEL>=ORYX_LOGLEVEL_ERROR){ORYX.Log.__log("ERROR",arguments)}},fatal:function(){if(ORYX_LOGLEVEL>=ORYX_LOGLEVEL_FATAL){ORYX.Log.__log("FATAL",arguments)}},__log:function(prefix,messageParts){messageParts[0]=(new Date()).getTime()+" "+prefix+" "+messageParts[0];var message=printf.apply(null,messageParts);ORYX.Log.__appenders.each(function(appender){appender.append(message)})},addAppender:function(appender){ORYX.Log.__appenders.push(appender)}},load:function(){ORYX.Log.debug("Oryx begins loading procedure.");if((typeof Prototype=="undefined")||(typeof Element=="undefined")||(typeof Element.Methods=="undefined")||parseFloat(Prototype.Version.split(".")[0]+"."+Prototype.Version.split(".")[1])<1.5){throw ("Application requires the Prototype JavaScript framework >= 1.5.3")}ORYX.Log.debug("Prototype > 1.5 found.");ORYX._load()},_load:function(){ORYX.loadPlugins()},loadPlugins:function(){if(ORYX.CONFIG.PLUGINS_ENABLED){ORYX._loadPlugins()}else{ORYX.Log.warn("Ignoring plugins, loading Core only.")}init()},_loadPlugins:function(){var source=ORYX.CONFIG.PLUGINS_CONFIG;ORYX.Log.debug("Loading plugin configuration from '%0'.",source);new Ajax.Request(source,{asynchronous:false,method:"get",onSuccess:function(result){ORYX.Log.info("Plugin configuration file loaded.");var resultXml=result.responseXML;var globalProperties=[];var preferences=$A(resultXml.getElementsByTagName("properties"));preferences.each(function(p){var props=$A(p.childNodes);props.each(function(prop){var property=new Hash();var attributes=$A(prop.attributes);attributes.each(function(attr){property[attr.nodeName]=attr.nodeValue});if(attributes.length>0){globalProperties.push(property)}})});var plugin=resultXml.getElementsByTagName("plugin");$A(plugin).each(function(node){var pluginData=new Hash();$A(node.attributes).each(function(attr){pluginData[attr.nodeName]=attr.nodeValue});if(!pluginData["name"]){ORYX.Log.error("A plugin is not providing a name. Ingnoring this plugin.");return}if(!pluginData["source"]){ORYX.Log.error("Plugin with name '%0' doesn't provide a source attribute.",pluginData["name"]);return}var propertyNodes=node.getElementsByTagName("property");var properties=[];$A(propertyNodes).each(function(prop){var property=new Hash();var attributes=$A(prop.attributes);attributes.each(function(attr){property[attr.nodeName]=attr.nodeValue});if(attributes.length>0){properties.push(property)}});properties=properties.concat(globalProperties);pluginData["properties"]=properties;var requireNodes=node.getElementsByTagName("requires");var requires;$A(requireNodes).each(function(req){var namespace=$A(req.attributes).find(function(attr){return attr.name=="namespace"});if(namespace&&namespace.nodeValue){if(!requires){requires={namespaces:[]}}requires.namespaces.push(namespace.nodeValue)}});if(requires){pluginData["requires"]=requires}var notUsesInNodes=node.getElementsByTagName("notUsesIn");var notUsesIn;$A(notUsesInNodes).each(function(not){var namespace=$A(not.attributes).find(function(attr){return attr.name=="namespace"});if(namespace&&namespace.nodeValue){if(!notUsesIn){notUsesIn={namespaces:[]}}notUsesIn.namespaces.push(namespace.nodeValue)}});if(notUsesIn){pluginData["notUsesIn"]=notUsesIn}var url=ORYX.PATH+ORYX.CONFIG.PLUGINS_FOLDER+pluginData["source"];ORYX.Log.debug("Requireing '%0'",url);ORYX.Log.info("Plugin '%0' successfully loaded.",pluginData["name"]);ORYX.availablePlugins.push(pluginData)})},onFailure:this._loadPluginsOnFails})},_loadPluginsOnFails:function(result){ORYX.Log.error("Plugin configuration file not available.")}});if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}if(!ORYX.Core.SVG){ORYX.Core.SVG={}}ORYX.Core.SVG.EditPathHandler=Clazz.extend({construct:function(){arguments.callee.$.construct.apply(this,arguments);this.x=0;this.y=0;this.oldX=0;this.oldY=0;this.deltaWidth=1;this.deltaHeight=1;this.d=""},init:function(x,y,oldX,oldY,deltaWidth,deltaHeight){this.x=x;this.y=y;this.oldX=oldX;this.oldY=oldY;this.deltaWidth=deltaWidth;this.deltaHeight=deltaHeight;this.d=""},editPointsAbs:function(points){if(points instanceof Array){var newPoints=[];var x,y;for(var i=0;i1){var minX=parseFloat(pointsArray[0]);var minY=parseFloat(pointsArray[1]);var maxX=parseFloat(pointsArray[0]);var maxY=parseFloat(pointsArray[1]);for(var i=0;i1){var widthDelta=(this.oldWidth===0)?0:this.width/this.oldWidth;var heightDelta=(this.oldHeight===0)?0:this.height/this.oldHeight;var updatedPoints="";for(var i=0;i=this.x&&pointX<=this.x+this.width&&pointY>=this.y&&pointY<=this.y+this.height);break;case"Circle":return ORYX.Core.Math.isPointInEllipse(pointX,pointY,this.x+this.width/2,this.y+this.height/2,this.radiusX,this.radiusX);break;case"Ellipse":return ORYX.Core.Math.isPointInEllipse(pointX,pointY,this.x+this.radiusX,this.y+this.radiusY,this.radiusX,this.radiusY);break;case"Line":return ORYX.Core.Math.isPointInLine(pointX,pointY,this.x,this.y,this.x+this.width,this.y+this.height);break;case"Polyline":var points=this.element.getAttributeNS(null,"points");if(points){points=points.replace(/,/g," ").split(" ").without("");points=points.collect(function(n){return parseFloat(n)});return ORYX.Core.Math.isPointInPolygone(pointX,pointY,points)}else{return false}break;case"Path":if(!this.handler){var parser=new PathParser();this.handler=new ORYX.Core.SVG.PointsPathHandler();parser.setHandler(this.handler);parser.parsePath(this.element)}return ORYX.Core.Math.isPointInPolygone(pointX,pointY,this.handler.points);break;default:return false}},isVisible:function(elem){if(this.visible!==undefined){return this.visible}if(!elem){elem=this.element}var hasOwnerSVG=false;try{hasOwnerSVG=!!elem.ownerSVGElement}catch(e){}if(hasOwnerSVG){if(ORYX.Editor.checkClassType(elem,SVGGElement)){if(elem.className&&elem.className.baseVal=="me"){this.visible=true;return this.visible}}var fill=elem.getAttributeNS(null,"fill");var stroke=elem.getAttributeNS(null,"stroke");if(fill&&fill=="none"&&stroke&&stroke=="none"){this.visible=false}else{var attr=elem.getAttributeNS(null,"display");if(!attr){this.visible=this.isVisible(elem.parentNode)}else{if(attr=="none"){this.visible=false}else{this.visible=true}}}}else{this.visible=true}return this.visible},toString:function(){return(this.element)?"SVGShape "+this.element.id:"SVGShape "+this.element}});if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}if(!ORYX.Core.SVG){ORYX.Core.SVG={}}ORYX.Core.SVG.Label=Clazz.extend({_characterSets:["%W","@","m","wDGMOQ?????#+=<>~^","ABCHKNRSUVXZ??????????&","bdghnopqux???????????ETY1234567890?????_????${}*????`???????????","aeksvyz?????FLP????????????????","c-",'rtJ"/()[]:;!|\\',"fjI., ","'","il"],_characterSetValues:[15,14,13,11,10,9,8,7,6,5,4,3],construct:function(options){arguments.callee.$.construct.apply(this,arguments);if(!options.textElement){throw"Label: No parameter textElement."}else{if(!ORYX.Editor.checkClassType(options.textElement,SVGTextElement)){throw"Label: Parameter textElement is not an SVGTextElement."}}this.invisibleRenderPoint=-5000;this.node=options.textElement;this.node.setAttributeNS(null,"stroke-width","0pt");this.node.setAttributeNS(null,"letter-spacing","-0.01px");this.shapeId=options.shapeId;this.id;this.fitToElemId;this.edgePosition;this.x;this.y;this.oldX;this.oldY;this.isVisible=true;this._text;this._verticalAlign;this._horizontalAlign;this._rotate;this._rotationPoint;this.anchorLeft;this.anchorRight;this.anchorTop;this.anchorBottom;this._isChanged=true;var _id=this.node.getAttributeNS(null,"id");if(_id){this.id=_id}this.fitToElemId=this.node.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"fittoelem");if(this.fitToElemId){this.fitToElemId=this.shapeId+this.fitToElemId}var alignValues=this.node.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"align");if(alignValues){alignValues=alignValues.replace(/,/g," ");alignValues=alignValues.split(" ");alignValues=alignValues.without("");alignValues.each((function(alignValue){switch(alignValue){case"top":case"middle":case"bottom":if(!this._verticalAlign){this._originVerticalAlign=this._verticalAlign=alignValue}break;case"left":case"center":case"right":if(!this._horizontalAlign){this._originHorizontalAlign=this._horizontalAlign=alignValue}break}}).bind(this))}this.edgePosition=this.node.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"edgePosition");if(this.edgePosition){this.originEdgePosition=this.edgePosition=this.edgePosition.toLowerCase()}this.offsetTop=this.node.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"offsetTop")||ORYX.CONFIG.OFFSET_EDGE_LABEL_TOP;if(this.offsetTop){this.offsetTop=parseInt(this.offsetTop)}this.offsetBottom=this.node.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"offsetBottom")||ORYX.CONFIG.OFFSET_EDGE_LABEL_BOTTOM;if(this.offsetBottom){this.offsetBottom=parseInt(this.offsetBottom)}var rotateValue=this.node.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"rotate");if(rotateValue){try{this._rotate=parseFloat(rotateValue)}catch(e){this._rotate=0}}else{this._rotate=0}var anchorAttr=this.node.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"anchors");if(anchorAttr){anchorAttr=anchorAttr.replace("/,/g"," ");var anchors=anchorAttr.split(" ").without("");for(var i=0;irefBoxLength){var startIndex=0;var lastSeperatorIndex=0;var numOfChars=this.getTrimmedTextLength(tspan.textContent);for(var i=0;irefBoxLength-2){var newtspan=this.node.ownerDocument.createElementNS(ORYX.CONFIG.NAMESPACE_SVG,"tspan");if(lastSeperatorIndex<=startIndex){lastSeperatorIndex=(i==0)?i:i-1;newtspan.textContent=tspan.textContent.slice(startIndex,lastSeperatorIndex).trim()}else{newtspan.textContent=tspan.textContent.slice(startIndex,++lastSeperatorIndex).trim()}newtspan.setAttributeNS(null,"x",this.invisibleRenderPoint);newtspan.setAttributeNS(null,"y",this.invisibleRenderPoint);newtspans.push(newtspan);startIndex=lastSeperatorIndex}else{var curChar=tspan.textContent.charAt(i);if(curChar==" "||curChar=="-"||curChar=="."||curChar==","||curChar==";"||curChar==":"){lastSeperatorIndex=i}}}tspan.textContent=tspan.textContent.slice(startIndex).trim()}newtspans.push(tspan)}while(this.node.hasChildNodes()){this.node.removeChild(this.node.childNodes[0])}while(newtspans.length>0){this.node.appendChild(newtspans.shift())}}}catch(e){ORYX.Log.fatal("Error "+e)}window.setTimeout(this._positionText.bind(this),0)},_positionText:function(){try{var tspans=this.node.childNodes;var fontSize=this.getFontSize(this.node);var invalidTSpans=[];var x=this.x,y=this.y;if(this.position){x=this.position.x;y=this.position.y}x=Math.floor(x);y=Math.floor(y);var i=0,indic=[];var is=(this.indices||$R(0,tspans.length-1).toArray());var length=is.length;is.each((function(index){if("undefined"==typeof index){return}var tspan=tspans[i++];if(tspan.textContent.trim()===""){invalidTSpans.push(tspan)}else{var dy=0;switch(this._verticalAlign){case"bottom":dy=-(length-index-1)*(fontSize);break;case"middle":dy=-(length/2-index-1)*(fontSize);dy-=ORYX.CONFIG.LABEL_LINE_DISTANCE/2;break;case"top":dy=index*(fontSize);dy+=fontSize;break}tspan.setAttributeNS(null,"dy",Math.floor(dy));tspan.setAttributeNS(null,"x",x);tspan.setAttributeNS(null,"y",y);indic.push(index)}}).bind(this));indic.length=tspans.length;this.indices=this.indices||indic;invalidTSpans.each(function(tspan){this.node.removeChild(tspan)}.bind(this));switch(this._horizontalAlign){case"left":this.node.setAttributeNS(null,"text-anchor","start");break;case"center":this.node.setAttributeNS(null,"text-anchor","middle");break;case"right":this.node.setAttributeNS(null,"text-anchor","end");break}}catch(e){this._isChanged=true}if(this.isVisible){this.node.removeAttributeNS(null,"visibility")}delete this._isUpdating;(this.changeCallbacks||[]).each(function(fn){fn.apply(fn)})},_getRenderedTextLength:function(tspan,startIndex,endIndex,fontSize){if(startIndex===undefined){return tspan.getComputedTextLength()}else{return tspan.getSubStringLength(startIndex,endIndex)}},_estimateTextWidth:function(text,fontSize){var sum=0;for(var i=0;i=0){return this._characterSetValues[i]}}return 9},getReferencedElementWidth:function(){var refNode=this.node.ownerDocument.getElementById(this.fitToElemId);if(refNode){var refbb=refNode.getBBox();if(refbb){return(this._rotate!=0&&this._rotate%180!=0&&this._rotate%90==0?refbb.height:refbb.width)}}return undefined},text:function(){switch(arguments.length){case 0:return this._text;break;case 1:var oldText=this._text;if(arguments[0]){this._text=arguments[0].toString();if(this._text!=null&&this._text!=undefined){this._text=this._text.replace(/ {2,}/g," ")}}else{this._text=""}if(oldText!==this._text){this._isChanged=true;this._textHasChanged=true}break;default:break}},getOriginVerticalAlign:function(){return this._originVerticalAlign},verticalAlign:function(){switch(arguments.length){case 0:return this._verticalAlign;case 1:if(["top","middle","bottom"].member(arguments[0])){var oldValue=this._verticalAlign;
this._verticalAlign=arguments[0];if(this._verticalAlign!==oldValue){this._isChanged=true}}break;default:break}},getOriginHorizontalAlign:function(){return this._originHorizontalAlign},horizontalAlign:function(){switch(arguments.length){case 0:return this._horizontalAlign;case 1:if(["left","center","right"].member(arguments[0])){var oldValue=this._horizontalAlign;this._horizontalAlign=arguments[0];if(this._horizontalAlign!==oldValue){this._isChanged=true}}break;default:break}},rotate:function(){switch(arguments.length){case 0:return this._rotate;case 1:if(this._rotate!=arguments[0]){this._rotate=arguments[0];this._rotationPoint=undefined;this._isChanged=true}case 2:if(this._rotate!=arguments[0]||!this._rotationPoint||this._rotationPoint.x!=arguments[1].x||this._rotationPoint.y!=arguments[1].y){this._rotate=arguments[0];this._rotationPoint=arguments[1];this._isChanged=true}}},hide:function(){if(this.isVisible){this.isVisible=false;this._isChanged=true}},show:function(){if(!this.isVisible){this.isVisible=true;this._isChanged=true;this._textHasChanged=true}},getInheritedFontSize:function(node){if(!node||!node.getAttributeNS){return}var attr=node.getAttributeNS(null,"font-size");if(attr){return parseFloat(attr)}else{if(!ORYX.Editor.checkClassType(node,SVGSVGElement)){return this.getInheritedFontSize(node.parentNode)}}},getFontSize:function(node){var tspans=this.node.getElementsByTagNameNS(ORYX.CONFIG.NAMESPACE_SVG,"tspan");var fontSize=this.getInheritedFontSize(this.node);if(!fontSize){if(tspans[0]&&/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)&&new Number(RegExp.$1)>=3){fontSize=tspans[0].getExtentOfChar(0).height}else{fontSize=ORYX.CONFIG.LABEL_DEFAULT_LINE_HEIGHT}if(fontSize<=0){fontSize=ORYX.CONFIG.LABEL_DEFAULT_LINE_HEIGHT}}if(fontSize){this.node.setAttribute("oryx:fontSize",fontSize)}return fontSize},getTrimmedTextLength:function(text){text=text.strip().gsub(" "," ");var oldLength;do{oldLength=text.length;text=text.gsub(" "," ")}while(oldLength>text.length);return text.length},getOffsetBottom:function(){return this.offsetBottom},getOffsetTop:function(){return this.offsetTop},deserialize:function(obj,shape){if(obj&&"undefined"!=typeof obj.x&&"undefined"!=typeof obj.y){this.setPosition({x:obj.x,y:obj.y});if("undefined"!=typeof obj.distance){var from=shape.dockers[obj.from];var to=shape.dockers[obj.to];if(from&&to){this.setReferencePoint({dirty:true,distance:obj.distance,intersection:{x:obj.x,y:obj.y},orientation:obj.orientation,segment:{from:from,fromIndex:obj.from,fromPosition:from.bounds.center(),to:to,toIndex:obj.to,toPosition:to.bounds.center()}})}}if(obj.left){this.anchorLeft=true}if(obj.right){this.anchorRight=true}if(obj.top){this.anchorTop=true}if(obj.bottom){this.anchorBottom=true}if(obj.valign){this.verticalAlign(obj.valign)}if(obj.align){this.horizontalAlign(obj.align)}}else{if(obj&&"undefined"!=typeof obj.edge){this.setEdgePosition(obj.edge)}}},serialize:function(){if(this.getEdgePosition()){if(this.getOriginEdgePosition()!==this.getEdgePosition()){return{edge:this.getEdgePosition()}}else{return null}}if(this.position){var pos={x:this.position.x,y:this.position.y};if(this.isAnchorLeft()&&this.isAnchorLeft()!==this.isOriginAnchorLeft()){pos.left=true}if(this.isAnchorRight()&&this.isAnchorRight()!==this.isOriginAnchorRight()){pos.right=true}if(this.isAnchorTop()&&this.isAnchorTop()!==this.isOriginAnchorTop()){pos.top=true}if(this.isAnchorBottom()&&this.isAnchorBottom()!==this.isOriginAnchorBottom()){pos.bottom=true}if(this.getOriginVerticalAlign()!==this.verticalAlign()){pos.valign=this.verticalAlign()}if(this.getOriginHorizontalAlign()!==this.horizontalAlign()){pos.align=this.horizontalAlign()}return pos}if(this.getReferencePoint()){var ref=this.getReferencePoint();return{distance:ref.distance,x:ref.intersection.x,y:ref.intersection.y,from:ref.segment.fromIndex,to:ref.segment.toIndex,orientation:ref.orientation,valign:this.verticalAlign(),align:this.horizontalAlign()}}return null},toString:function(){return"Label "+this.id}});if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}if(!ORYX.Core.Math){ORYX.Core.Math={}}ORYX.Core.Math.midPoint=function(point1,point2){return{x:(point1.x+point2.x)/2,y:(point1.y+point2.y)/2}};ORYX.Core.Math.isPointInLine=function(pointX,pointY,lPoint1X,lPoint1Y,lPoint2X,lPoint2Y,offset){offset=offset?Math.abs(offset):1;if(Math.abs(lPoint1X-lPoint2X)<=offset&&Math.abs(pointX-lPoint1X)<=offset&&pointY-Math.max(lPoint1Y,lPoint2Y)<=offset&&Math.min(lPoint1Y,lPoint2Y)-pointY<=offset){return true}if(Math.abs(lPoint1Y-lPoint2Y)<=offset&&Math.abs(pointY-lPoint1Y)<=offset&&pointX-Math.max(lPoint1X,lPoint2X)<=offset&&Math.min(lPoint1X,lPoint2X)-pointX<=offset){return true}if(pointX>Math.max(lPoint1X,lPoint2X)||pointXMath.max(lPoint1Y,lPoint2Y)||pointY=pointY)!=(y2>=pointY)){crossings+=y2-y1>=0?d>=0:d<=0}if(!d&&Math.min(x1,x2)<=pointX&&pointX<=Math.max(x1,x2)&&Math.min(y1,y2)<=pointY&&pointY<=Math.max(y1,y2)){return true}}return(crossings%2)?true:false};ORYX.Core.Math.distancePointLinie=function(lineP1,lineP2,point,toSegmentOnly){var intersectionPoint=ORYX.Core.Math.getPointOfIntersectionPointLine(lineP1,lineP2,point,toSegmentOnly);if(!intersectionPoint){return null}return ORYX.Core.Math.getDistancePointToPoint(point,intersectionPoint)};ORYX.Core.Math.getDistancePointToPoint=function(point1,point2){return Math.sqrt(Math.pow(point1.x-point2.x,2)+Math.pow(point1.y-point2.y,2))};ORYX.Core.Math.getDistanceBetweenTwoPoints=function(between1,between2,point){return ORYX.Core.Math.getDistancePointToPoint(point,between1)/ORYX.Core.Math.getDistancePointToPoint(between1,between2)};ORYX.Core.Math.pointIsLeftOfLine=function(lineP1,lineP2,point){var vec1=ORYX.Core.Math.getVector(lineP1,lineP2);var vec2=ORYX.Core.Math.getVector(lineP1,point);return((vec1.x*vec2.y)-(vec2.x*vec1.y))>0};ORYX.Core.Math.getPointBetweenTwoPoints=function(point1,point2,relative){relative=Math.max(Math.min(relative||0,1),0);if(relative===0){return point1}else{if(relative===1){return point2}}return{x:point1.x+((point2.x-point1.x)*relative),y:point1.y+((point2.y-point1.y)*relative)}};ORYX.Core.Math.getVector=function(point1,point2){return{x:point2.x-point1.x,y:point2.y-point1.y}};ORYX.Core.Math.getIdentityVector=function(vector){if(arguments.length==2){vector=ORYX.Core.Math.getVector(arguments[0],arguments[1])}var length=Math.sqrt((vector.x*vector.x)+(vector.y*vector.y));return{x:vector.x/(length||1),y:vector.y/(length||1)}};ORYX.Core.Math.getOrthogonalIdentityVector=function(point1,point2){var vec=arguments.length==1?point1:ORYX.Core.Math.getIdentityVector(point1,point2);return{x:vec.y,y:-vec.x}};ORYX.Core.Math.getPointOfIntersectionPointLine=function(lineP1,lineP2,point,onSegmentOnly){var denominator=Math.pow(lineP2.x-lineP1.x,2)+Math.pow(lineP2.y-lineP1.y,2);if(denominator==0){return undefined}var u=((point.x-lineP1.x)*(lineP2.x-lineP1.x)+(point.y-lineP1.y)*(lineP2.y-lineP1.y))/denominator;if(onSegmentOnly){if(!(0<=u&&u<=1)){return undefined}}pointOfIntersection=new Object();pointOfIntersection.x=lineP1.x+u*(lineP2.x-lineP1.x);pointOfIntersection.y=lineP1.y+u*(lineP2.y-lineP1.y);return pointOfIntersection};ORYX.Core.Math.getTranslatedPoint=function(point,matrix){var x=matrix.a*point.x+matrix.c*point.y+matrix.e*1;var y=matrix.b*point.x+matrix.d*point.y+matrix.f*1;return{x:x,y:y}};ORYX.Core.Math.getInverseMatrix=function(matrix){var det=ORYX.Core.Math.getDeterminant(matrix),m=matrix;return{a:det*((m.d*1)-(m.f*0)),b:det*((m.f*0)-(m.b*1)),c:det*((m.e*0)-(m.c*1)),d:det*((m.a*1)-(m.e*0)),e:det*((m.c*m.f)-(m.e*m.d)),f:det*((m.e*m.b)-(m.a*m.f))}};ORYX.Core.Math.getDeterminant=function(m){return(m.a*m.d*1)+(m.c*m.f*0)+(m.e*m.b*0)-(m.e*m.d*0)-(m.c*m.b*1)-(m.a*m.f*0)};ORYX.Core.Math.getTranslatedBoundingBox=function(node){var matrix=node.getCTM();var bb=node.getBBox();var ul=ORYX.Core.Math.getTranslatedPoint({x:bb.x,y:bb.y},matrix);var ll=ORYX.Core.Math.getTranslatedPoint({x:bb.x,y:bb.y+bb.height},matrix);var ur=ORYX.Core.Math.getTranslatedPoint({x:bb.x+bb.width,y:bb.y},matrix);var lr=ORYX.Core.Math.getTranslatedPoint({x:bb.x+bb.width,y:bb.y+bb.height},matrix);var minPoint={x:Math.min(ul.x,ll.x,ur.x,lr.x),y:Math.min(ul.y,ll.y,ur.y,lr.y)};var maxPoint={x:Math.max(ul.x,ll.x,ur.x,lr.x),y:Math.max(ul.y,ll.y,ur.y,lr.y)};return{x:minPoint.x,y:minPoint.y,width:maxPoint.x-minPoint.x,height:maxPoint.y-minPoint.y}};ORYX.Core.Math.getAngle=function(p1,p2){if(p1.x==p2.x&&p1.y==p2.y){return 0}var angle=Math.asin(Math.sqrt(Math.pow(p1.y-p2.y,2))/(Math.sqrt(Math.pow(p2.x-p1.x,2)+Math.pow(p1.y-p2.y,2))))*180/Math.PI;if(p2.x>=p1.x&&p2.y<=p1.y){return angle}else{if(p2.xp1.y){return 180+angle}else{return 360-angle}}}};new function(){var RIGHT=2,TOP=8,BOTTOM=4,LEFT=1;function computeOutCode(x,y,xmin,ymin,xmax,ymax){var code=0;if(y>ymax){code|=TOP}else{if(yxmax){code|=RIGHT}else{if(x0){done=true}else{var x=0,y=0;outcodeOut=outcode0!=0?outcode0:outcode1;if((outcodeOut&TOP)>0){x=x1+(x2-x1)*(ymax-y1)/(y2-y1);y=ymax}else{if((outcodeOut&BOTTOM)>0){x=x1+(x2-x1)*(ymin-y1)/(y2-y1);y=ymin}else{if((outcodeOut&RIGHT)>0){y=y1+(y2-y1)*(xmax-x1)/(x2-x1);x=xmax}else{if((outcodeOut&LEFT)>0){y=y1+(y2-y1)*(xmin-x1)/(x2-x1);x=xmin}}}}if(outcodeOut==outcode0){x1=x;y1=y;outcode0=computeOutCode(x1,y1,xmin,ymin,xmax,ymax)}else{x2=x;y2=y;outcode1=computeOutCode(x2,y2,xmin,ymin,xmax,ymax)}}}hhh++}while(done!=true&&hhh<5000);if(accept){return{a:{x:x1,y:y1},b:{x:x2,y:y2}}}return null}}();if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}if(!ORYX.Core.StencilSet){ORYX.Core.StencilSet={}}ORYX.Core.StencilSet.Stencil={construct:function(jsonStencil,namespace,source,stencilSet,propertyPackages,defaultPosition){arguments.callee.$.construct.apply(this,arguments);if(!jsonStencil){throw"Stencilset seems corrupt."}if(!namespace){throw"Stencil does not provide namespace."}if(!source){throw"Stencil does not provide SVG source."}if(!stencilSet){throw"Fatal internal error loading stencilset."}this._source=source;this._jsonStencil=jsonStencil;this._stencilSet=stencilSet;this._namespace=namespace;this._propertyPackages=propertyPackages;if(defaultPosition&&!this._jsonStencil.position){this._jsonStencil.position=defaultPosition}this._view;this._properties=new Hash();if(!this._jsonStencil.type||!(this._jsonStencil.type==="edge"||this._jsonStencil.type==="node")){throw"ORYX.Core.StencilSet.Stencil(construct): Type is not defined."}if(!this._jsonStencil.id||this._jsonStencil.id===""){throw"ORYX.Core.StencilSet.Stencil(construct): Id is not defined."}if(!this._jsonStencil.title||this._jsonStencil.title===""){throw"ORYX.Core.StencilSet.Stencil(construct): Title is not defined."}if(!this._jsonStencil.description){this._jsonStencil.description=""}if(!this._jsonStencil.groups){this._jsonStencil.groups=[]}if(!this._jsonStencil.roles){this._jsonStencil.roles=[]}this._jsonStencil.roles.push(this._jsonStencil.id);this._jsonStencil.roles.each((function(role,index){this._jsonStencil.roles[index]=namespace+role}).bind(this));this._jsonStencil.roles=this._jsonStencil.roles.uniq();this._jsonStencil.id=namespace+this._jsonStencil.id;this.postProcessProperties();if(!this._jsonStencil.serialize){this._jsonStencil.serialize={}}if(!this._jsonStencil.deserialize){this._jsonStencil.deserialize={}}if(!this._jsonStencil.layout){this._jsonStencil.layout=[]}var url=source+"view/"+jsonStencil.view;if(this._jsonStencil.view.trim().match(/)){var parser=new DOMParser();var xml=parser.parseFromString(this._jsonStencil.view,"text/xml");if(ORYX.Editor.checkClassType(xml.documentElement,SVGSVGElement)){this._view=xml.documentElement}else{throw"ORYX.Core.StencilSet.Stencil(_loadSVGOnSuccess): The response is not a SVG document."}}else{new Ajax.Request(url,{asynchronous:false,method:"get",onSuccess:this._loadSVGOnSuccess.bind(this),onFailure:this._loadSVGOnFailure.bind(this)})}},postProcessProperties:function(){if(this._jsonStencil.propertyPackages&&this._jsonStencil.propertyPackages instanceof Array){this._jsonStencil.propertyPackages.each((function(ppId){var pp=this._propertyPackages[ppId];if(pp){pp.each((function(prop){var oProp=new ORYX.Core.StencilSet.Property(prop,this._namespace,this);this._properties[oProp.prefix()+"-"+oProp.id()]=oProp}).bind(this))}}).bind(this))}if(this._jsonStencil.properties&&this._jsonStencil.properties instanceof Array){this._jsonStencil.properties.each((function(prop){var oProp=new ORYX.Core.StencilSet.Property(prop,this._namespace,this);this._properties[oProp.prefix()+"-"+oProp.id()]=oProp}).bind(this))}},equals:function(stencil){return(this.id()===stencil.id())},stencilSet:function(){return this._stencilSet},type:function(){return this._jsonStencil.type},namespace:function(){return this._namespace},id:function(){return this._jsonStencil.id},idWithoutNs:function(){return this.id().replace(this.namespace(),"")},title:function(){return ORYX.Core.StencilSet.getTranslation(this._jsonStencil,"title")},description:function(){return ORYX.Core.StencilSet.getTranslation(this._jsonStencil,"description")},groups:function(){return ORYX.Core.StencilSet.getTranslation(this._jsonStencil,"groups")},position:function(){return(isNaN(this._jsonStencil.position)?0:this._jsonStencil.position)},view:function(){return this._view.cloneNode(true)||this._view},icon:function(){return this._jsonStencil.icon},fixedAspectRatio:function(){return this._jsonStencil.fixedAspectRatio===true},hasMultipleRepositoryEntries:function(){return(this.getRepositoryEntries().length>0)},getRepositoryEntries:function(){return(this._jsonStencil.repositoryEntries)?$A(this._jsonStencil.repositoryEntries):$A([])},properties:function(){return this._properties.values()},property:function(id){return this._properties[id]
},roles:function(){return this._jsonStencil.roles},defaultAlign:function(){if(!this._jsonStencil.defaultAlign){return"east"}return this._jsonStencil.defaultAlign},serialize:function(shape,data){return this._jsonStencil.serialize},deserialize:function(shape,data){return this._jsonStencil.deserialize},layout:function(shape){return this._jsonStencil.layout},addProperty:function(property,namespace){if(property&&namespace){var oProp=new ORYX.Core.StencilSet.Property(property,namespace,this);this._properties[oProp.prefix()+"-"+oProp.id()]=oProp}},removeProperty:function(propertyId){if(propertyId){var oProp=this._properties.values().find(function(prop){return(propertyId==prop.id())});if(oProp){delete this._properties[oProp.prefix()+"-"+oProp.id()]}}},_loadSVGOnSuccess:function(result){var xml=null;xml=result.responseXML;if(ORYX.Editor.checkClassType(xml.documentElement,SVGSVGElement)){this._view=xml.documentElement}else{throw"ORYX.Core.StencilSet.Stencil(_loadSVGOnSuccess): The response is not a SVG document."}},_loadSVGOnFailure:function(result){throw"ORYX.Core.StencilSet.Stencil(_loadSVGOnFailure): Loading SVG document failed."},toString:function(){return"Stencil "+this.title()+" ("+this.id()+")"}};ORYX.Core.StencilSet.Stencil=Clazz.extend(ORYX.Core.StencilSet.Stencil);function _evenMoreEvilHack(str,contentType){if(window.ActiveXObject){var d=new ActiveXObject("MSXML.DomDocument");d.loadXML(str);return d}else{if(window.XMLHttpRequest){var req=new XMLHttpRequest;req.open("GET","data:"+(contentType||"application/xml")+";charset=utf-8,"+encodeURIComponent(str),false);if(req.overrideMimeType){req.overrideMimeType(contentType)}req.send(null);return req.responseXML}}}function _evilSafariHack(serializedXML){var xml=serializedXML;var url="data:text/xml;charset=utf-8,"+encodeURIComponent(xml);var dom=null;var req=new XMLHttpRequest();req.open("GET",url);req.onload=function(){dom=req.responseXML};req.send(null);return dom}if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}if(!ORYX.Core.StencilSet){ORYX.Core.StencilSet={}}ORYX.Core.StencilSet.Property=Clazz.extend({construct:function(jsonProp,namespace,stencil){arguments.callee.$.construct.apply(this,arguments);this._jsonProp=jsonProp||ORYX.Log.error("Parameter jsonProp is not defined.");this._namespace=namespace||ORYX.Log.error("Parameter namespace is not defined.");this._stencil=stencil||ORYX.Log.error("Parameter stencil is not defined.");this._items={};this._complexItems={};this._hidden=false;jsonProp.id=jsonProp.id||ORYX.Log.error("ORYX.Core.StencilSet.Property(construct): Id is not defined.");jsonProp.id=jsonProp.id.toLowerCase();if(!jsonProp.type){ORYX.Log.info("Type is not defined for stencil '%0', id '%1'. Falling back to 'String'.",stencil,jsonProp.id);jsonProp.type="string"}else{jsonProp.type=jsonProp.type.toLowerCase()}jsonProp.prefix=jsonProp.prefix||"oryx";jsonProp.title=jsonProp.title||"";jsonProp.value=jsonProp.value||"";jsonProp.description=jsonProp.description||"";jsonProp.readonly=jsonProp.readonly||false;jsonProp.optional=jsonProp.optional!==false;if(this._jsonProp.refToView){if(!(this._jsonProp.refToView instanceof Array)){this._jsonProp.refToView=[this._jsonProp.refToView]}}else{this._jsonProp.refToView=[]}var globalMin=this.getMinForType(jsonProp.type);if(jsonProp.min===undefined||jsonProp.min===null){jsonProp.min=globalMin}else{if(jsonProp.minglobalMax){jsonProp.min=globalMax}}if(!jsonProp.fillOpacity){jsonProp.fillOpacity=false}if("number"!=typeof jsonProp.lightness){jsonProp.lightness=1}else{jsonProp.lightness=Math.max(0,Math.min(1,jsonProp.lightness))}if(!jsonProp.strokeOpacity){jsonProp.strokeOpacity=false}if(jsonProp.length===undefined||jsonProp.length===null){jsonProp.length=Number.MAX_VALUE}if(!jsonProp.wrapLines){jsonProp.wrapLines=false}if(!jsonProp.dateFormat){jsonProp.dateFormat=ORYX.I18N.PropertyWindow.dateFormat||"m/d/y"}if(!jsonProp.fill){jsonProp.fill=false}if(!jsonProp.stroke){jsonProp.stroke=false}if(!jsonProp.inverseBoolean){jsonProp.inverseBoolean=false}if(!jsonProp.directlyEditable&&jsonProp.directlyEditable!=false){jsonProp.directlyEditable=true}if(jsonProp.visible!==false){jsonProp.visible=true}if(jsonProp.isList!==true){jsonProp.isList=false;if(!jsonProp.list||!(jsonProp.list instanceof Array)){jsonProp.list=[]}}if(!jsonProp.category){if(jsonProp.popular){jsonProp.category="popular"}else{jsonProp.category="others"}}if(!jsonProp.alwaysAppearInMultiselect){jsonProp.alwaysAppearInMultiselect=false}if(jsonProp.type===ORYX.CONFIG.TYPE_CHOICE){if(jsonProp.items&&jsonProp.items instanceof Array){jsonProp.items.each((function(jsonItem){this._items[jsonItem.value.toLowerCase()]=new ORYX.Core.StencilSet.PropertyItem(jsonItem,namespace,this)}).bind(this))}else{throw"ORYX.Core.StencilSet.Property(construct): No property items defined."}}else{if(jsonProp.type===ORYX.CONFIG.TYPE_COMPLEX||jsonProp.type==ORYX.CONFIG.TYPE_MULTIPLECOMPLEX){if(jsonProp.complexItems&&jsonProp.complexItems instanceof Array){jsonProp.complexItems.each((function(jsonComplexItem){this._complexItems[jsonComplexItem.id.toLowerCase()]=new ORYX.Core.StencilSet.ComplexPropertyItem(jsonComplexItem,namespace,this)
}).bind(this))}}}},getMinForType:function(type){if(type.toLowerCase()==ORYX.CONFIG.TYPE_INTEGER){return -Math.pow(2,31)}else{return -Number.MAX_VALUE+1}},getMaxForType:function(type){if(type.toLowerCase()==ORYX.CONFIG.TYPE_INTEGER){return Math.pow(2,31)-1}else{return Number.MAX_VALUE}},equals:function(property){return(this._namespace===property.namespace()&&this.id()===property.id())?true:false},namespace:function(){return this._namespace},stencil:function(){return this._stencil},id:function(){return this._jsonProp.id},prefix:function(){return this._jsonProp.prefix},type:function(){return this._jsonProp.type},inverseBoolean:function(){return this._jsonProp.inverseBoolean},category:function(){return this._jsonProp.category},setCategory:function(value){this._jsonProp.category=value},directlyEditable:function(){return this._jsonProp.directlyEditable},visible:function(){return this._jsonProp.visible},title:function(){return ORYX.Core.StencilSet.getTranslation(this._jsonProp,"title")},value:function(){return this._jsonProp.value},readonly:function(){return this._jsonProp.readonly},optional:function(){return this._jsonProp.optional},description:function(){return ORYX.Core.StencilSet.getTranslation(this._jsonProp,"description")},refToView:function(){return this._jsonProp.refToView},min:function(){return this._jsonProp.min},max:function(){return this._jsonProp.max},fillOpacity:function(){return this._jsonProp.fillOpacity},strokeOpacity:function(){return this._jsonProp.strokeOpacity},length:function(){return this._jsonProp.length?this._jsonProp.length:Number.MAX_VALUE},wrapLines:function(){return this._jsonProp.wrapLines},dateFormat:function(){return this._jsonProp.dateFormat},fill:function(){return this._jsonProp.fill},lightness:function(){return this._jsonProp.lightness},stroke:function(){return this._jsonProp.stroke},items:function(){return $H(this._items).values()},item:function(value){if(value){return this._items[value.toLowerCase()]}else{return null}},toString:function(){return"Property "+this.title()+" ("+this.id()+")"},complexItems:function(){return $H(this._complexItems).values()},complexItem:function(id){if(id){return this._complexItems[id.toLowerCase()]}else{return null}},complexAttributeToView:function(){return this._jsonProp.complexAttributeToView||""},isList:function(){return !!this._jsonProp.isList},getListItems:function(){return this._jsonProp.list},linkableType:function(){return this._jsonProp.linkableType||""},alwaysAppearInMultiselect:function(){return this._jsonProp.alwaysAppearInMultiselect},popular:function(){return this._jsonProp.popular||false},setPopular:function(){this._jsonProp.popular=true},hide:function(){this._hidden=true},isHidden:function(){return this._hidden}});if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}if(!ORYX.Core.StencilSet){ORYX.Core.StencilSet={}}ORYX.Core.StencilSet.PropertyItem=Clazz.extend({construct:function(jsonItem,namespace,property){arguments.callee.$.construct.apply(this,arguments);if(!jsonItem){throw"ORYX.Core.StencilSet.PropertyItem(construct): Parameter jsonItem is not defined."}if(!namespace){throw"ORYX.Core.StencilSet.PropertyItem(construct): Parameter namespace is not defined."}if(!property){throw"ORYX.Core.StencilSet.PropertyItem(construct): Parameter property is not defined."}this._jsonItem=jsonItem;this._namespace=namespace;this._property=property;if(!jsonItem.value){throw"ORYX.Core.StencilSet.PropertyItem(construct): Value is not defined."}if(this._jsonItem.refToView){if(!(this._jsonItem.refToView instanceof Array)){this._jsonItem.refToView=[this._jsonItem.refToView]}}else{this._jsonItem.refToView=[]}},equals:function(item){return(this.property().equals(item.property())&&this.value()===item.value())},namespace:function(){return this._namespace},property:function(){return this._property},value:function(){return this._jsonItem.value},title:function(){return ORYX.Core.StencilSet.getTranslation(this._jsonItem,"title")},refToView:function(){return this._jsonItem.refToView},icon:function(){return(this._jsonItem.icon)?this.property().stencil()._source+"icons/"+this._jsonItem.icon:""},toString:function(){return"PropertyItem "+this.property()+" ("+this.value()+")"}});if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}if(!ORYX.Core.StencilSet){ORYX.Core.StencilSet={}}ORYX.Core.StencilSet.ComplexPropertyItem=Clazz.extend({construct:function(jsonItem,namespace,property){arguments.callee.$.construct.apply(this,arguments);if(!jsonItem){throw"ORYX.Core.StencilSet.ComplexPropertyItem(construct): Parameter jsonItem is not defined."}if(!namespace){throw"ORYX.Core.StencilSet.ComplexPropertyItem(construct): Parameter namespace is not defined."}if(!property){throw"ORYX.Core.StencilSet.ComplexPropertyItem(construct): Parameter property is not defined."}this._jsonItem=jsonItem;this._namespace=namespace;this._property=property;this._items=new Hash();this._complexItems=new Hash();if(!jsonItem.name){throw"ORYX.Core.StencilSet.ComplexPropertyItem(construct): Name is not defined."
}if(!jsonItem.type){throw"ORYX.Core.StencilSet.ComplexPropertyItem(construct): Type is not defined."}else{jsonItem.type=jsonItem.type.toLowerCase()}if(jsonItem.type===ORYX.CONFIG.TYPE_CHOICE){if(jsonItem.items&&jsonItem.items instanceof Array){jsonItem.items.each((function(item){this._items[item.value]=new ORYX.Core.StencilSet.PropertyItem(item,namespace,this)}).bind(this))}else{throw"ORYX.Core.StencilSet.Property(construct): No property items defined."}}else{if(jsonItem.type===ORYX.CONFIG.TYPE_COMPLEX){if(jsonItem.complexItems&&jsonItem.complexItems instanceof Array){jsonItem.complexItems.each((function(complexItem){this._complexItems[complexItem.id]=new ORYX.Core.StencilSet.ComplexPropertyItem(complexItem,namespace,this)}).bind(this))}else{throw"ORYX.Core.StencilSet.Property(construct): No property items defined."}}}},equals:function(item){return(this.property().equals(item.property())&&this.name()===item.name())},namespace:function(){return this._namespace},property:function(){return this._property},name:function(){return ORYX.Core.StencilSet.getTranslation(this._jsonItem,"name")},id:function(){return this._jsonItem.id},type:function(){return this._jsonItem.type},optional:function(){return this._jsonItem.optional},width:function(){return this._jsonItem.width},value:function(){return this._jsonItem.value},items:function(){return this._items.values()},complexItems:function(){return this._complexItems.values()},disable:function(){return this._jsonItem.disable}});if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}if(!ORYX.Core.StencilSet){ORYX.Core.StencilSet={}}ORYX.Core.StencilSet.Rules={construct:function(){arguments.callee.$.construct.apply(this,arguments);this._stencilSets=[];this._stencils=[];this._containerStencils=[];this._cachedConnectSET=new Hash();this._cachedConnectSE=new Hash();this._cachedConnectTE=new Hash();this._cachedCardSE=new Hash();this._cachedCardTE=new Hash();this._cachedContainPC=new Hash();this._cachedMorphRS=new Hash();this._connectionRules=new Hash();this._cardinalityRules=new Hash();this._containmentRules=new Hash();this._morphingRules=new Hash();this._layoutRules=new Hash()},initializeRules:function(stencilSet){var existingSS=this._stencilSets.find(function(ss){return(ss.namespace()==stencilSet.namespace())});if(existingSS){var stencilsets=this._stencilSets.clone();stencilsets=stencilsets.without(existingSS);stencilsets.push(stencilSet);this._stencilSets=[];this._stencils=[];this._containerStencils=[];this._cachedConnectSET=new Hash();this._cachedConnectSE=new Hash();this._cachedConnectTE=new Hash();this._cachedCardSE=new Hash();this._cachedCardTE=new Hash();this._cachedContainPC=new Hash();this._cachedMorphRS=new Hash();this._connectionRules=new Hash();this._cardinalityRules=new Hash();this._containmentRules=new Hash();this._morphingRules=new Hash();this._layoutRules=new Hash();stencilsets.each(function(ss){this.initializeRules(ss)}.bind(this));return}else{this._stencilSets.push(stencilSet);var jsonRules=new Hash(stencilSet.jsonRules());var namespace=stencilSet.namespace();var stencils=stencilSet.stencils();stencilSet.extensions().values().each(function(extension){if(extension.rules){if(extension.rules.connectionRules){jsonRules.connectionRules=jsonRules.connectionRules.concat(extension.rules.connectionRules)}if(extension.rules.cardinalityRules){jsonRules.cardinalityRules=jsonRules.cardinalityRules.concat(extension.rules.cardinalityRules)}if(extension.rules.containmentRules){jsonRules.containmentRules=jsonRules.containmentRules.concat(extension.rules.containmentRules)}if(extension.rules.morphingRules){jsonRules.morphingRules=jsonRules.morphingRules.concat(extension.rules.morphingRules)}}if(extension.stencils){stencils=stencils.concat(extension.stencils)}});this._stencils=this._stencils.concat(stencilSet.stencils());var cr=this._connectionRules;if(jsonRules.connectionRules){jsonRules.connectionRules.each((function(rules){if(this._isRoleOfOtherNamespace(rules.role)){if(!cr[rules.role]){cr[rules.role]=new Hash()}}else{if(!cr[namespace+rules.role]){cr[namespace+rules.role]=new Hash()}}rules.connects.each((function(connect){var toRoles=[];if(connect.to){if(!(connect.to instanceof Array)){connect.to=[connect.to]}connect.to.each((function(to){if(this._isRoleOfOtherNamespace(to)){toRoles.push(to)}else{toRoles.push(namespace+to)}}).bind(this))}var role,from;if(this._isRoleOfOtherNamespace(rules.role)){role=rules.role}else{role=namespace+rules.role}if(this._isRoleOfOtherNamespace(connect.from)){from=connect.from}else{from=namespace+connect.from}if(!cr[role][from]){cr[role][from]=toRoles}else{cr[role][from]=cr[role][from].concat(toRoles)}}).bind(this))}).bind(this))}var cardr=this._cardinalityRules;if(jsonRules.cardinalityRules){jsonRules.cardinalityRules.each((function(rules){var cardrKey;if(this._isRoleOfOtherNamespace(rules.role)){cardrKey=rules.role}else{cardrKey=namespace+rules.role}if(!cardr[cardrKey]){cardr[cardrKey]={};for(i in rules){cardr[cardrKey][i]=rules[i]}}var oe=new Hash();if(rules.outgoingEdges){rules.outgoingEdges.each((function(rule){if(this._isRoleOfOtherNamespace(rule.role)){oe[rule.role]=rule
}else{oe[namespace+rule.role]=rule}}).bind(this))}cardr[cardrKey].outgoingEdges=oe;var ie=new Hash();if(rules.incomingEdges){rules.incomingEdges.each((function(rule){if(this._isRoleOfOtherNamespace(rule.role)){ie[rule.role]=rule}else{ie[namespace+rule.role]=rule}}).bind(this))}cardr[cardrKey].incomingEdges=ie}).bind(this))}var conr=this._containmentRules;if(jsonRules.containmentRules){jsonRules.containmentRules.each((function(rules){var conrKey;if(this._isRoleOfOtherNamespace(rules.role)){conrKey=rules.role}else{this._containerStencils.push(namespace+rules.role);conrKey=namespace+rules.role}if(!conr[conrKey]){conr[conrKey]=[]}(rules.contains||[]).each((function(containRole){if(this._isRoleOfOtherNamespace(containRole)){conr[conrKey].push(containRole)}else{conr[conrKey].push(namespace+containRole)}}).bind(this))}).bind(this))}var morphr=this._morphingRules;if(jsonRules.morphingRules){jsonRules.morphingRules.each((function(rules){var morphrKey;if(this._isRoleOfOtherNamespace(rules.role)){morphrKey=rules.role}else{morphrKey=namespace+rules.role}if(!morphr[morphrKey]){morphr[morphrKey]=[]}if(!rules.preserveBounds){rules.preserveBounds=false}rules.baseMorphs.each((function(baseMorphStencilId){var morphStencil=this._getStencilById(namespace+baseMorphStencilId);if(morphStencil){morphr[morphrKey].push(morphStencil)}}).bind(this))}).bind(this))}var layoutRules=this._layoutRules;if(jsonRules.layoutRules){var getDirections=function(o){return{"edgeRole":o.edgeRole||undefined,"t":o["t"]||1,"r":o["r"]||1,"b":o["b"]||1,"l":o["l"]||1}};jsonRules.layoutRules.each(function(rules){var layoutKey;if(this._isRoleOfOtherNamespace(rules.role)){layoutKey=rules.role}else{layoutKey=namespace+rules.role}if(!layoutRules[layoutKey]){layoutRules[layoutKey]={}}if(rules["in"]){layoutRules[layoutKey]["in"]=getDirections(rules["in"])}if(rules["ins"]){layoutRules[layoutKey]["ins"]=(rules["ins"]||[]).map(function(e){return getDirections(e)})}if(rules["out"]){layoutRules[layoutKey]["out"]=getDirections(rules["out"])}if(rules["outs"]){layoutRules[layoutKey]["outs"]=(rules["outs"]||[]).map(function(e){return getDirections(e)})}}.bind(this))}}},_getStencilById:function(id){return this._stencils.find(function(stencil){return stencil.id()==id})},_cacheConnect:function(args){result=this._canConnect(args);if(args.sourceStencil&&args.targetStencil){var source=this._cachedConnectSET[args.sourceStencil.id()];if(!source){source=new Hash();this._cachedConnectSET[args.sourceStencil.id()]=source}var edge=source[args.edgeStencil.id()];if(!edge){edge=new Hash();source[args.edgeStencil.id()]=edge}edge[args.targetStencil.id()]=result}else{if(args.sourceStencil){var source=this._cachedConnectSE[args.sourceStencil.id()];if(!source){source=new Hash();this._cachedConnectSE[args.sourceStencil.id()]=source}source[args.edgeStencil.id()]=result}else{var target=this._cachedConnectTE[args.targetStencil.id()];if(!target){target=new Hash();this._cachedConnectTE[args.targetStencil.id()]=target}target[args.edgeStencil.id()]=result}}return result},_cacheCard:function(args){if(args.sourceStencil){var source=this._cachedCardSE[args.sourceStencil.id()];if(!source){source=new Hash();this._cachedCardSE[args.sourceStencil.id()]=source}var max=this._getMaximumNumberOfOutgoingEdge(args);if(max==undefined){max=-1}source[args.edgeStencil.id()]=max}if(args.targetStencil){var target=this._cachedCardTE[args.targetStencil.id()];if(!target){target=new Hash();this._cachedCardTE[args.targetStencil.id()]=target}var max=this._getMaximumNumberOfIncomingEdge(args);if(max==undefined){max=-1}target[args.edgeStencil.id()]=max}},_cacheContain:function(args){var result=[this._canContain(args),this._getMaximumOccurrence(args.containingStencil,args.containedStencil)];if(result[1]==undefined){result[1]=-1}var children=this._cachedContainPC[args.containingStencil.id()];if(!children){children=new Hash();this._cachedContainPC[args.containingStencil.id()]=children}children[args.containedStencil.id()]=result;return result},_cacheMorph:function(role){var morphs=this._cachedMorphRS[role];if(!morphs){morphs=[];if(this._morphingRules.keys().include(role)){morphs=this._stencils.select(function(stencil){return stencil.roles().include(role)})}this._cachedMorphRS[role]=morphs}return morphs},outgoingEdgeStencils:function(args){if(!args.sourceShape&&!args.sourceStencil){return[]}if(args.sourceShape){args.sourceStencil=args.sourceShape.getStencil()}var _edges=[];this._stencils.each((function(stencil){if(stencil.type()==="edge"){var newArgs=Object.clone(args);newArgs.edgeStencil=stencil;if(this.canConnect(newArgs)){_edges.push(stencil)}}}).bind(this));return _edges},incomingEdgeStencils:function(args){if(!args.targetShape&&!args.targetStencil){return[]}if(args.targetShape){args.targetStencil=args.targetShape.getStencil()}var _edges=[];this._stencils.each((function(stencil){if(stencil.type()==="edge"){var newArgs=Object.clone(args);newArgs.edgeStencil=stencil;if(this.canConnect(newArgs)){_edges.push(stencil)}}}).bind(this));
return _edges},sourceStencils:function(args){if(!args||!args.edgeShape&&!args.edgeStencil){return[]}if(args.targetShape){args.targetStencil=args.targetShape.getStencil()}if(args.edgeShape){args.edgeStencil=args.edgeShape.getStencil()}var _sources=[];this._stencils.each((function(stencil){var newArgs=Object.clone(args);newArgs.sourceStencil=stencil;if(this.canConnect(newArgs)){_sources.push(stencil)}}).bind(this));return _sources},targetStencils:function(args){if(!args||!args.edgeShape&&!args.edgeStencil){return[]}if(args.sourceShape){args.sourceStencil=args.sourceShape.getStencil()}if(args.edgeShape){args.edgeStencil=args.edgeShape.getStencil()}var _targets=[];this._stencils.each((function(stencil){var newArgs=Object.clone(args);newArgs.targetStencil=stencil;if(this.canConnect(newArgs)){_targets.push(stencil)}}).bind(this));return _targets},canConnect:function(args){if(!args||(!args.sourceShape&&!args.sourceStencil&&!args.targetShape&&!args.targetStencil)||!args.edgeShape&&!args.edgeStencil){return false}if(args.sourceShape){args.sourceStencil=args.sourceShape.getStencil()}if(args.targetShape){args.targetStencil=args.targetShape.getStencil()}if(args.edgeShape){args.edgeStencil=args.edgeShape.getStencil()}var result;if(args.sourceStencil&&args.targetStencil){var source=this._cachedConnectSET[args.sourceStencil.id()];if(!source){result=this._cacheConnect(args)}else{var edge=source[args.edgeStencil.id()];if(!edge){result=this._cacheConnect(args)}else{var target=edge[args.targetStencil.id()];if(target==undefined){result=this._cacheConnect(args)}else{result=target}}}}else{if(args.sourceStencil){var source=this._cachedConnectSE[args.sourceStencil.id()];if(!source){result=this._cacheConnect(args)}else{var edge=source[args.edgeStencil.id()];if(edge==undefined){result=this._cacheConnect(args)}else{result=edge}}}else{var target=this._cachedConnectTE[args.targetStencil.id()];if(!target){result=this._cacheConnect(args)}else{var edge=target[args.edgeStencil.id()];if(edge==undefined){result=this._cacheConnect(args)}else{result=edge}}}}if(result){if(args.sourceShape){var source=this._cachedCardSE[args.sourceStencil.id()];if(!source){this._cacheCard(args);source=this._cachedCardSE[args.sourceStencil.id()]}var max=source[args.edgeStencil.id()];if(max==undefined){this._cacheCard(args)}max=source[args.edgeStencil.id()];if(max!=-1){result=args.sourceShape.getOutgoingShapes().all(function(cs){if((cs.getStencil().id()===args.edgeStencil.id())&&((args.edgeShape)?cs!==args.edgeShape:true)){max--;return(max>0)?true:false}else{return true}})}}if(args.targetShape){var target=this._cachedCardTE[args.targetStencil.id()];if(!target){this._cacheCard(args);target=this._cachedCardTE[args.targetStencil.id()]}var max=target[args.edgeStencil.id()];if(max==undefined){this._cacheCard(args)}max=target[args.edgeStencil.id()];if(max!=-1){result=args.targetShape.getIncomingShapes().all(function(cs){if((cs.getStencil().id()===args.edgeStencil.id())&&((args.edgeShape)?cs!==args.edgeShape:true)){max--;return(max>0)?true:false}else{return true}})}}}return result},_canConnect:function(args){if(!args||(!args.sourceShape&&!args.sourceStencil&&!args.targetShape&&!args.targetStencil)||!args.edgeShape&&!args.edgeStencil){return false}if(args.sourceShape){args.sourceStencil=args.sourceShape.getStencil()}if(args.targetShape){args.targetStencil=args.targetShape.getStencil()}if(args.edgeShape){args.edgeStencil=args.edgeShape.getStencil()}var resultCR;var edgeRules=this._getConnectionRulesOfEdgeStencil(args.edgeStencil);if(edgeRules.keys().length===0){resultCR=false}else{if(args.sourceStencil){resultCR=args.sourceStencil.roles().any(function(sourceRole){var targetRoles=edgeRules[sourceRole];if(!targetRoles){return false}if(args.targetStencil){return(targetRoles.any(function(targetRole){return args.targetStencil.roles().member(targetRole)}))}else{return true}})}else{resultCR=edgeRules.values().any(function(targetRoles){return args.targetStencil.roles().any(function(targetRole){return targetRoles.member(targetRole)})})}}return resultCR},isContainer:function(shape){return this._containerStencils.member(shape.getStencil().id())},canContain:function(args){if(!args||!args.containingStencil&&!args.containingShape||!args.containedStencil&&!args.containedShape){return false}if(args.containedShape){args.containedStencil=args.containedShape.getStencil()}if(args.containingShape){args.containingStencil=args.containingShape.getStencil()}if(args.containedStencil.type()=="edge"){return false}var childValues;var parent=this._cachedContainPC[args.containingStencil.id()];if(!parent){childValues=this._cacheContain(args)}else{childValues=parent[args.containedStencil.id()];if(!childValues){childValues=this._cacheContain(args)}}if(!childValues[0]){return false}else{if(childValues[1]==-1){return true}else{if(args.containingShape){var max=childValues[1];return args.containingShape.getChildShapes(false).all(function(as){if(as.getStencil().id()===args.containedStencil.id()){max--;return(max>0)?true:false
}else{return true}})}else{return true}}}},_canContain:function(args){if(!args||!args.containingStencil&&!args.containingShape||!args.containedStencil&&!args.containedShape){return false}if(args.containedShape){args.containedStencil=args.containedShape.getStencil()}if(args.containingShape){args.containingStencil=args.containingShape.getStencil()}var result;result=args.containingStencil.roles().any((function(role){var roles=this._containmentRules[role];if(roles){return roles.any(function(role){return args.containedStencil.roles().member(role)})}else{return false}}).bind(this));return result},morphStencils:function(args){if(!args.stencil&&!args.shape){return[]}if(args.shape){args.stencil=args.shape.getStencil()}var _morphStencils=[];args.stencil.roles().each(function(role){this._cacheMorph(role).each(function(stencil){_morphStencils.push(stencil)})}.bind(this));var baseMorphs=this.baseMorphs();_morphStencils=_morphStencils.uniq().sort(function(a,b){return baseMorphs.include(a)&&!baseMorphs.include(b)?-1:(baseMorphs.include(b)&&!baseMorphs.include(a)?1:0)});return _morphStencils},baseMorphs:function(){var _baseMorphs=[];this._morphingRules.each(function(pair){pair.value.each(function(baseMorph){_baseMorphs.push(baseMorph)})});return _baseMorphs},containsMorphingRules:function(){return this._stencilSets.any(function(ss){return !!ss.jsonRules().morphingRules})},connectMorph:function(args){if(!args||(!args.sourceShape&&!args.sourceStencil&&!args.targetShape&&!args.targetStencil)){return false}if(args.sourceShape){args.sourceStencil=args.sourceShape.getStencil()}if(args.targetShape){args.targetStencil=args.targetShape.getStencil()}var incoming=this.incomingEdgeStencils(args);var outgoing=this.outgoingEdgeStencils(args);var edgeStencils=incoming.select(function(e){return outgoing.member(e)});var baseEdgeStencils=this.baseMorphs().select(function(e){return edgeStencils.member(e)});if(baseEdgeStencils.size()>0){return baseEdgeStencils[0]}else{if(edgeStencils.size()>0){return edgeStencils[0]}}return null},showInShapeMenu:function(stencil){return this._stencilSets.any(function(ss){return ss.jsonRules().morphingRules.any(function(r){return stencil.roles().include(ss.namespace()+r.role)&&r.showInShapeMenu!==false})})},preserveBounds:function(stencil){return this._stencilSets.any(function(ss){return ss.jsonRules().morphingRules.any(function(r){return stencil.roles().include(ss.namespace()+r.role)&&r.preserveBounds})})},getLayoutingRules:function(shape,edgeShape){if(!shape||!(shape instanceof ORYX.Core.Shape)){return}var layout={"in":{},"out":{}};var parseValues=function(o,v){if(o&&o[v]){["t","r","b","l"].each(function(d){layout[v][d]=Math.max(o[v][d],layout[v][d]||0)})}if(o&&o[v+"s"] instanceof Array){["t","r","b","l"].each(function(d){var defaultRule=o[v+"s"].find(function(e){return !e.edgeRole});var edgeRule;if(edgeShape instanceof ORYX.Core.Edge){edgeRule=o[v+"s"].find(function(e){return this._hasRole(edgeShape,e.edgeRole)}.bind(this))}layout[v][d]=Math.max(edgeRule?edgeRule[d]:defaultRule[d],layout[v][d]||0)}.bind(this))}}.bind(this);shape.getStencil().roles().each(function(role){if(this._layoutRules[role]){parseValues(this._layoutRules[role],"in");parseValues(this._layoutRules[role],"out")}}.bind(this));["in","out"].each(function(v){["t","r","b","l"].each(function(d){layout[v][d]=layout[v][d]!==undefined?layout[v][d]:1})});return layout},_hasRole:function(shape,role){if(!(shape instanceof ORYX.Core.Shape)||!role){return}var isRole=shape.getStencil().roles().any(function(r){return r==role});return isRole||shape.getStencil().id()==(shape.getStencil().namespace()+role)},_stencilsWithRole:function(role){return this._stencils.findAll(function(stencil){return(stencil.roles().member(role))?true:false})},_edgesWithRole:function(role){return this._stencils.findAll(function(stencil){return(stencil.roles().member(role)&&stencil.type()==="edge")?true:false})},_nodesWithRole:function(role){return this._stencils.findAll(function(stencil){return(stencil.roles().member(role)&&stencil.type()==="node")?true:false})},_getMaximumOccurrence:function(parent,child){var max;child.roles().each((function(role){var cardRule=this._cardinalityRules[role];if(cardRule&&cardRule.maximumOccurrence){if(max){max=Math.min(max,cardRule.maximumOccurrence)}else{max=cardRule.maximumOccurrence}}}).bind(this));return max},_getMaximumNumberOfOutgoingEdge:function(args){if(!args||!args.sourceStencil||!args.edgeStencil){return false}var max;args.sourceStencil.roles().each((function(role){var cardRule=this._cardinalityRules[role];if(cardRule&&cardRule.outgoingEdges){args.edgeStencil.roles().each(function(edgeRole){var oe=cardRule.outgoingEdges[edgeRole];if(oe&&oe.maximum){if(max){max=Math.min(max,oe.maximum)}else{max=oe.maximum}}})}}).bind(this));return max},_getMaximumNumberOfIncomingEdge:function(args){if(!args||!args.targetStencil||!args.edgeStencil){return false}var max;args.targetStencil.roles().each((function(role){var cardRule=this._cardinalityRules[role];if(cardRule&&cardRule.incomingEdges){args.edgeStencil.roles().each(function(edgeRole){var ie=cardRule.incomingEdges[edgeRole];
if(ie&&ie.maximum){if(max){max=Math.min(max,ie.maximum)}else{max=ie.maximum}}})}}).bind(this));return max},_getConnectionRulesOfEdgeStencil:function(edgeStencil){var edgeRules=new Hash();edgeStencil.roles().each((function(role){if(this._connectionRules[role]){this._connectionRules[role].each(function(cr){if(edgeRules[cr.key]){edgeRules[cr.key]=edgeRules[cr.key].concat(cr.value)}else{edgeRules[cr.key]=cr.value}})}}).bind(this));return edgeRules},_isRoleOfOtherNamespace:function(role){return(role.indexOf("#")>0)},toString:function(){return"Rules"}};ORYX.Core.StencilSet.Rules=Clazz.extend(ORYX.Core.StencilSet.Rules);if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}if(!ORYX.Core.StencilSet){ORYX.Core.StencilSet={}}ORYX.Core.StencilSet.StencilSet=Clazz.extend({construct:function(source,modelMetaData,editorId){arguments.callee.$.construct.apply(this,arguments);if(!source){throw"ORYX.Core.StencilSet.StencilSet(construct): Parameter 'source' is not defined."}if(source.endsWith("/")){source=source.substr(0,source.length-1)}this._extensions=new Hash();this._source=source;this._baseUrl=source.substring(0,source.lastIndexOf("/")+1);this._jsonObject={};this._stencils=new Hash();this._availableStencils=new Hash();if(ORYX.CONFIG.BACKEND_SWITCH){this._baseUrl="editor/stencilsets/bpmn2.0/";this._source="stencilsets/bpmn2.0/bpmn2.0.json";new Ajax.Request("editor-app/editor/stencilset.json?version="+Date.now(),{asynchronous:false,method:"get",onSuccess:this._init.bind(this),onFailure:this._cancelInit.bind(this)})}else{new Ajax.Request(source,{asynchronous:false,method:"get",onSuccess:this._init.bind(this),onFailure:this._cancelInit.bind(this)})}if(this.errornous){throw"Loading stencil set "+source+" failed."}},findRootStencilName:function(){var rootStencil=this._stencils.values().find(function(stencil){return stencil._jsonStencil.mayBeRoot});if(!rootStencil){ORYX.Log.warn("Did not find any stencil that may be root. Taking a guess.");rootStencil=this._stencils.values()[0]}return rootStencil.id()},equals:function(stencilSet){return(this.namespace()===stencilSet.namespace())},stencils:function(rootStencil,rules,sortByGroup){if(rootStencil&&rules){var stencils=this._availableStencils.values();var containers=[rootStencil];var checkedContainers=[];var result=[];while(containers.size()>0){var container=containers.pop();checkedContainers.push(container);var children=stencils.findAll(function(stencil){var args={containingStencil:container,containedStencil:stencil};return rules.canContain(args)});for(var i=0;i=ul.x-offset&&pointX<=lr.x+offset&&pointY>=ul.y-offset&&pointY<=lr.y+offset){return true}else{return false}},clone:function(){return new ORYX.Core.Bounds(this)},toString:function(){return"( "+this.a.x+" | "+this.a.y+" )/( "+this.b.x+" | "+this.b.y+" )"},serializeForERDF:function(){return this.a.x+","+this.a.y+","+this.b.x+","+this.b.y}};ORYX.Core.Bounds=Clazz.extend(ORYX.Core.Bounds);if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}ORYX.Core.UIObject={construct:function(options){this.isChanged=true;this.isResized=true;this.isVisible=true;this.isSelectable=false;this.isResizable=false;this.isMovable=false;this.id=ORYX.Editor.provideId();this.parent=undefined;this.node=undefined;this.children=[];this.bounds=new ORYX.Core.Bounds();this._changedCallback=this._changed.bind(this);this.bounds.registerCallback(this._changedCallback);if(options&&options.eventHandlerCallback){this.eventHandlerCallback=options.eventHandlerCallback}},_changed:function(bounds,isResized){this.isChanged=true;if(this.bounds==bounds){this.isResized=isResized||this.isResized}},update:function(){if(this.isChanged){this.refresh();this.isChanged=false;this.children.each(function(value){value.update()})}},refresh:function(){},getChildren:function(){return this.children.clone()},getParents:function(){var parents=[];var parent=this.parent;while(parent){parents.push(parent);parent=parent.parent}return parents},isParent:function(parent){var cparent=this;while(cparent){if(cparent===parent){return true}cparent=cparent.parent}return false},getId:function(){return this.id},getChildById:function(id,deep){return this.children.find(function(uiObj){if(uiObj.getId()===id){return uiObj}else{if(deep){var obj=uiObj.getChildById(id,deep);if(obj){return obj}}}})},add:function(uiObject){if(!(this.children.member(uiObject))){if(uiObject.parent){uiObject.remove(uiObject)}this.children.push(uiObject);uiObject.parent=this;uiObject.node=this.node.appendChild(uiObject.node);uiObject.bounds.registerCallback(this._changedCallback)}else{ORYX.Log.info("add: ORYX.Core.UIObject is already a child of this object.")}},remove:function(uiObject){if(this.children.member(uiObject)){this.children=this._uiObjects.without(uiObject);uiObject.parent=undefined;uiObject.node=this.node.removeChild(uiObject.node);uiObject.bounds.unregisterCallback(this._changedCallback)}else{ORYX.Log.info("remove: ORYX.Core.UIObject is not a child of this object.")}},absoluteBounds:function(){if(this.parent){var absUL=this.absoluteXY();return new ORYX.Core.Bounds(absUL.x,absUL.y,absUL.x+this.bounds.width(),absUL.y+this.bounds.height())}else{return this.bounds.clone()}},absoluteXY:function(){if(this.parent){var pXY=this.parent.absoluteXY();var result={};result.x=pXY.x+this.bounds.upperLeft().x;result.y=pXY.y+this.bounds.upperLeft().y;return result}else{var result={};result.x=this.bounds.upperLeft().x;result.y=this.bounds.upperLeft().y;return result}},absoluteCenterXY:function(){if(this.parent){var pXY=this.parent.absoluteXY();var result={};result.x=pXY.x+this.bounds.center().x;result.y=pXY.y+this.bounds.center().y;return result}else{var result={};result.x=this.bounds.center().x;result.y=this.bounds.center().y;return result}},hide:function(){this.node.setAttributeNS(null,"display","none");this.isVisible=false;this.children.each(function(uiObj){uiObj.hide()})},show:function(){this.node.setAttributeNS(null,"display","inherit");this.isVisible=true;this.children.each(function(uiObj){uiObj.show()})},addEventHandlers:function(node){node.addEventListener(ORYX.CONFIG.EVENT_MOUSEDOWN,this._delegateEvent.bind(this),false);node.addEventListener(ORYX.CONFIG.EVENT_MOUSEMOVE,this._delegateEvent.bind(this),false);node.addEventListener(ORYX.CONFIG.EVENT_MOUSEUP,this._delegateEvent.bind(this),false);node.addEventListener(ORYX.CONFIG.EVENT_MOUSEOVER,this._delegateEvent.bind(this),false);node.addEventListener(ORYX.CONFIG.EVENT_MOUSEOUT,this._delegateEvent.bind(this),false);node.addEventListener("click",this._delegateEvent.bind(this),false);node.addEventListener(ORYX.CONFIG.EVENT_DBLCLICK,this._delegateEvent.bind(this),false)},_delegateEvent:function(event){if(this.eventHandlerCallback){this.eventHandlerCallback(event,this)}},toString:function(){return"UIObject "+this.id}};ORYX.Core.UIObject=Clazz.extend(ORYX.Core.UIObject);if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}ORYX.Core.AbstractShape=ORYX.Core.UIObject.extend({construct:function(options,stencil,facade){arguments.callee.$.construct.apply(this,arguments);this.resourceId=ORYX.Editor.provideId();this._stencil=stencil;if(this._stencil._jsonStencil.superId){stencilId=this._stencil.id();
superStencilId=stencilId.substring(0,stencilId.indexOf("#")+1)+stencil._jsonStencil.superId;stencilSet=this._stencil.stencilSet();this._stencil=stencilSet.stencil(superStencilId)}this.properties=new Hash();this.propertiesChanged=new Hash();this.hiddenProperties=new Hash();this._stencil.properties().each((function(property){var key=property.prefix()+"-"+property.id();this.properties[key]=property.value();this.propertiesChanged[key]=true}).bind(this));if(stencil._jsonStencil.superId){stencil.properties().each((function(property){var key=property.prefix()+"-"+property.id();var value=property.value();var oldValue=this.properties[key];this.properties[key]=value;this.propertiesChanged[key]=true;this._delegateEvent({type:ORYX.CONFIG.EVENT_PROPERTY_CHANGED,name:key,value:value,oldValue:oldValue})}).bind(this))}},layout:function(){},getStencil:function(){return this._stencil},getChildShapeByResourceId:function(resourceId){resourceId=ERDF.__stripHashes(resourceId);return this.getChildShapes(true).find(function(shape){return shape.resourceId==resourceId})},getChildShapes:function(deep,iterator){var result=[];this.children.each(function(uiObject){if(uiObject instanceof ORYX.Core.Shape&&uiObject.isVisible){if(iterator){iterator(uiObject)}result.push(uiObject);if(deep){result=result.concat(uiObject.getChildShapes(deep,iterator))}}});return result},hasChildShape:function(shape){return this.getChildShapes().any(function(child){return(child===shape)||child.hasChildShape(shape)})},getChildNodes:function(deep,iterator){var result=[];this.children.each(function(uiObject){if(uiObject instanceof ORYX.Core.Node&&uiObject.isVisible){if(iterator){iterator(uiObject)}result.push(uiObject)}if(uiObject instanceof ORYX.Core.Shape){if(deep){result=result.concat(uiObject.getChildNodes(deep,iterator))}}});return result},getChildEdges:function(deep,iterator){var result=[];this.children.each(function(uiObject){if(uiObject instanceof ORYX.Core.Edge&&uiObject.isVisible){if(iterator){iterator(uiObject)}result.push(uiObject)}if(uiObject instanceof ORYX.Core.Shape){if(deep){result=result.concat(uiObject.getChildEdges(deep,iterator))}}});return result},getAbstractShapesAtPosition:function(){var x,y;switch(arguments.length){case 1:x=arguments[0].x;y=arguments[0].y;break;case 2:x=arguments[0];y=arguments[1];break;default:throw"getAbstractShapesAtPosition needs 1 or 2 arguments!"}if(this.isPointIncluded(x,y)){var result=[];result.push(this);var childNodes=this.getChildNodes();var childEdges=this.getChildEdges();[childNodes,childEdges].each(function(ne){var nodesAtPosition=new Hash();ne.each(function(node){if(!node.isVisible){return}var candidates=node.getAbstractShapesAtPosition(x,y);if(candidates.length>0){var nodesInZOrder=$A(node.node.parentNode.childNodes);var zOrderIndex=nodesInZOrder.indexOf(node.node);nodesAtPosition[zOrderIndex]=candidates}});nodesAtPosition.keys().sort().each(function(key){result=result.concat(nodesAtPosition[key])})});return result}else{return[]}},setProperty:function(key,value,force){var oldValue=this.properties[key];if(oldValue!==value||force===true){this.properties[key]=value;this.propertiesChanged[key]=true;this._changed();if(!this._isInSetProperty){this._isInSetProperty=true;this._delegateEvent({type:ORYX.CONFIG.EVENT_PROPERTY_CHANGED,elements:[this],name:key,value:value,oldValue:oldValue});delete this._isInSetProperty}}},isPropertyChanged:function(){return this.propertiesChanged.any(function(property){return property.value})},setHiddenProperty:function(key,value){if(value===undefined){delete this.hiddenProperties[key];return}var oldValue=this.hiddenProperties[key];if(oldValue!==value){this.hiddenProperties[key]=value}},isPointIncluded:function(pointX,pointY,absoluteBounds){var absBounds=absoluteBounds?absoluteBounds:this.absoluteBounds();return absBounds.isIncluded(pointX,pointY)},serialize:function(){var serializedObject=[];serializedObject.push({name:"type",prefix:"oryx",value:this.getStencil().id(),type:"literal"});this.hiddenProperties.each(function(prop){serializedObject.push({name:prop.key.replace("oryx-",""),prefix:"oryx",value:prop.value,type:"literal"})}.bind(this));this.getStencil().properties().each((function(property){var prefix=property.prefix();var name=property.id();serializedObject.push({name:name,prefix:prefix,value:this.properties[prefix+"-"+name],type:"literal"})}).bind(this));return serializedObject},deserialize:function(serialize){var initializedDocker=0;serialize=serialize.sort(function(a,b){a=Number(this.properties.keys().member(a.prefix+"-"+a.name));b=Number(this.properties.keys().member(b.prefix+"-"+b.name));return a>b?1:(a'));
this.focusEl.swallowEvent("click",true)}this.focusEl.focus.defer(1,this.focusEl);this.focusEl.blur.defer(3,this.focusEl)}catch(e){}},setHightlightState:function(state){if(this.colHighlightEnabled&&this.colHighlightState!=state){if(state==0){this.columnHightlight1.setAttribute("visibility","hidden");this.columnHightlight2.setAttribute("visibility","hidden")}else{if(state==1){this.columnHightlight1.setAttribute("visibility","visible");this.columnHightlight2.setAttribute("visibility","hidden")}else{if(state==2){this.columnHightlight1.setAttribute("visibility","hidden");this.columnHightlight2.setAttribute("visibility","visible")}else{if(state==3){this.columnHightlight1.setAttribute("visibility","visible");this.columnHightlight2.setAttribute("visibility","visible")}}}}this.colHighlightState=state}},setHightlightStateBasedOnX:function(x){if(x>ORYX.CONFIG.FORM_ROW_WIDTH+30){this.setHightlightState(2)}else{this.setHightlightState(1)}},update:function(){this.nodes.each(function(node){this._traverseForUpdate(node)}.bind(this));var layoutEvents=this.getStencil().layout();if(layoutEvents){layoutEvents.each(function(event){event.shape=this;event.forceExecution=true;event.target=this.rootNode;this._delegateEvent(event)}.bind(this))}this.nodes.invoke("_update");this.edges.invoke("_update",true)},_traverseForUpdate:function(shape){var childRet=shape.isChanged;shape.getChildNodes(false,function(child){if(this._traverseForUpdate(child)){childRet=true}}.bind(this));if(childRet){shape.layout();return true}else{return false}},layout:function(){},getChildNodes:function(deep,iterator){if(!deep&&!iterator){return this.nodes.clone()}else{var result=[];this.nodes.each(function(uiObject){if(iterator){iterator(uiObject)}result.push(uiObject);if(deep&&uiObject instanceof ORYX.Core.Shape){result=result.concat(uiObject.getChildNodes(deep,iterator))}});return result}},add:function(uiObject,index,silent){if(uiObject instanceof ORYX.Core.UIObject){if(!(this.children.member(uiObject))){if(uiObject.parent){uiObject.parent.remove(uiObject,true)}if(index!=undefined){this.children.splice(index,0,uiObject)}else{this.children.push(uiObject)}uiObject.parent=this;if(uiObject instanceof ORYX.Core.Shape){if(uiObject instanceof ORYX.Core.Edge){uiObject.addMarkers(this.rootNode.getElementsByTagNameNS(NAMESPACE_SVG,"defs")[0]);uiObject.node=this.node.childNodes[0].childNodes[2].appendChild(uiObject.node);this.edges.push(uiObject)}else{uiObject.node=this.node.childNodes[0].childNodes[1].appendChild(uiObject.node);this.nodes.push(uiObject)}}else{uiObject.node=this.node.appendChild(uiObject.node)}uiObject.bounds.registerCallback(this._changedCallback);if(this.eventHandlerCallback&&silent!==true){this.eventHandlerCallback({type:ORYX.CONFIG.EVENT_SHAPEADDED,shape:uiObject})}}else{ORYX.Log.warn("add: ORYX.Core.UIObject is already a child of this object.")}}else{ORYX.Log.fatal("add: Parameter is not of type ORYX.Core.UIObject.")}},remove:function(uiObject,silent){if(this.children.member(uiObject)){var parent=uiObject.parent;this.children=this.children.without(uiObject);uiObject.parent=undefined;if(uiObject instanceof ORYX.Core.Shape){if(uiObject instanceof ORYX.Core.Edge){uiObject.removeMarkers();uiObject.node=this.node.childNodes[0].childNodes[2].removeChild(uiObject.node);this.edges=this.edges.without(uiObject)}else{uiObject.node=this.node.childNodes[0].childNodes[1].removeChild(uiObject.node);this.nodes=this.nodes.without(uiObject)}}else{uiObject.node=this.node.removeChild(uiObject.node)}if(this.eventHandlerCallback&&silent!==true){this.eventHandlerCallback({type:ORYX.CONFIG.EVENT_SHAPEREMOVED,shape:uiObject,parent:parent})}uiObject.bounds.unregisterCallback(this._changedCallback)}else{ORYX.Log.warn("remove: ORYX.Core.UIObject is not a child of this object.")}},addShapeObjects:function(shapeObjects,eventHandler){if(!shapeObjects){return}this.initializingShapes=true;var addShape=function(shape,parent){var stencil=ORYX.Core.StencilSet.stencil(this.getStencil().namespace()+shape.stencil.id);var ShapeClass=(stencil.type()=="node")?ORYX.Core.Node:ORYX.Core.Edge;var newShape=new ShapeClass({"eventHandlerCallback":eventHandler},stencil,this.facade);newShape.resourceId=shape.resourceId;newShape.node.id="svg-"+shape.resourceId;shape.parent="#"+((shape.parent&&shape.parent.resourceId)||parent.resourceId);this.add(newShape);return{json:shape,object:newShape}}.bind(this);var addChildShapesRecursively=function(shape){var addedShapes=[];if(shape.childShapes&&shape.childShapes.constructor==String){shape.childShapes=JSON.parse(shape.childShapes)}shape.childShapes.each(function(childShape){addedShapes.push(addShape(childShape,shape));addedShapes=addedShapes.concat(addChildShapesRecursively(childShape))});return addedShapes}.bind(this);var shapes=addChildShapesRecursively({childShapes:shapeObjects,resourceId:this.resourceId});shapes.each(function(shape){var properties=[];for(field in shape.json.properties){properties.push({prefix:"oryx",name:field,value:shape.json.properties[field]})
}shape.json.outgoing.each(function(out){properties.push({prefix:"raziel",name:"outgoing",value:"#"+out.resourceId})});if(shape.object instanceof ORYX.Core.Edge){var target=shape.json.target||shape.json.outgoing[0];if(target){properties.push({prefix:"raziel",name:"target",value:"#"+target.resourceId})}}if(shape.json.bounds){properties.push({prefix:"oryx",name:"bounds",value:shape.json.bounds.upperLeft.x+","+shape.json.bounds.upperLeft.y+","+shape.json.bounds.lowerRight.x+","+shape.json.bounds.lowerRight.y})}if(shape.json.dockers){properties.push({prefix:"oryx",name:"dockers",value:shape.json.dockers.inject("",function(dockersStr,docker){return dockersStr+docker.x+" "+docker.y+" "})+" #"})}properties.push({prefix:"raziel",name:"parent",value:shape.json.parent});shape.__properties=properties}.bind(this));shapes.each(function(shape){if(shape.object instanceof ORYX.Core.Node){shape.object.deserialize(shape.__properties,shape.json)}});shapes.each(function(shape){if(shape.object instanceof ORYX.Core.Edge){shape.object.deserialize(shape.__properties,shape.json);shape.object._oldBounds=shape.object.bounds.clone();shape.object._update()}});delete this.initializingShapes;return shapes.pluck("object")},updateSize:function(){var maxWidth=0;var maxHeight=0;var offset=100;this.getChildShapes(true,function(shape){var b=shape.bounds;maxWidth=Math.max(maxWidth,b.lowerRight().x+offset);maxHeight=Math.max(maxHeight,b.lowerRight().y+offset)});if(this.bounds.width()=0})){if(!match.notUsesIn||!match.notUsesIn.namespaces||!match.notUsesIn.namespaces.any(function(req){return loadedStencilSetsNamespaces.indexOf(req)>=0})){try{var className=eval(match.name);var newPlugin=new className(facade,match);newPlugin.type=match.name;if(newPlugin.registryChanged){newPlugin.registryChanged(me.pluginsData)}if(newPlugin.onSelectionChanged){me.registerOnEvent(ORYX.CONFIG.EVENT_SELECTION_CHANGED,newPlugin.onSelectionChanged.bind(newPlugin))}this.loadedPlugins.push(newPlugin);this.loadedPlugins.each(function(loaded){if(loaded.registryChanged){loaded.registryChanged(this.pluginsData)}}.bind(me));callback(true)}catch(e){ORYX.Log.warn("Plugin %0 is not available",match.name);if(!!loadTry){callback(false,"INITFAILED");return}this.loadScript("plugins/scripts/"+match.source,this.activatePluginByName.bind(this,match.name,callback,true))}}else{callback(false,"NOTUSEINSTENCILSET");ORYX.Log.info("Plugin need a stencilset which is not loaded'",match.name)}}else{callback(false,"REQUIRESTENCILSET");
ORYX.Log.info("Plugin need a stencilset which is not loaded'",match.name)}}else{callback(false,match?"NOTFOUND":"YETACTIVATED")}},loadPlugins:function(){var me=this;var newPlugins=[];var loadedStencilSetsNamespaces=this.getStencilSets().keys();var facade=this._getPluginFacade();if(ORYX.MashupAPI&&ORYX.MashupAPI.loadablePlugins&&ORYX.MashupAPI.loadablePlugins instanceof Array){ORYX.availablePlugins=$A(ORYX.availablePlugins).findAll(function(value){return ORYX.MashupAPI.loadablePlugins.include(value.name)});ORYX.MashupAPI.loadablePlugins.each(function(className){if(!(ORYX.availablePlugins.find(function(val){return val.name==className}))){ORYX.availablePlugins.push({name:className})}})}ORYX.availablePlugins.each(function(value){ORYX.Log.debug("Initializing plugin '%0'",value.name);if((!value.requires||!value.requires.namespaces||value.requires.namespaces.any(function(req){return loadedStencilSetsNamespaces.indexOf(req)>=0}))&&(!value.notUsesIn||!value.notUsesIn.namespaces||!value.notUsesIn.namespaces.any(function(req){return loadedStencilSetsNamespaces.indexOf(req)>=0}))&&(value.engaged||(value.engaged===undefined))){try{var className=eval(value.name);if(className){var plugin=new className(facade,value);plugin.type=value.name;newPlugins.push(plugin);plugin.engaged=true}}catch(e){ORYX.Log.warn("Plugin %0 is not available %1",value.name,e)}}else{ORYX.Log.info("Plugin need a stencilset which is not loaded'",value.name)}});newPlugins.each(function(value){if(value.registryChanged){value.registryChanged(me.pluginsData)}if(value.onSelectionChanged){me.registerOnEvent(ORYX.CONFIG.EVENT_SELECTION_CHANGED,value.onSelectionChanged.bind(value))}});this.loadedPlugins=newPlugins;this.registerPluginsOnKeyEvents();this.setSelection()},_createCanvas:function(stencilType,canvasConfig){if(stencilType){if(stencilType.search(/^http/)===-1){stencilType=this.getStencilSets().values()[0].namespace()+stencilType}}else{stencilType=this.getStencilSets().values()[0].findRootStencilName()}var canvasStencil=ORYX.Core.StencilSet.stencil(stencilType);if(!canvasStencil){ORYX.Log.fatal("Initialisation failed, because the stencil with the type %0 is not part of one of the loaded stencil sets.",stencilType)}var div=ORYX.Editor.graft("http://www.w3.org/1999/xhtml",null,["div"]);div.addClassName("ORYX_Editor");this._canvas=new ORYX.Core.Canvas({width:ORYX.CONFIG.CANVAS_WIDTH,height:ORYX.CONFIG.CANVAS_HEIGHT,"eventHandlerCallback":this.handleEvents.bind(this),id:this.id,parentNode:div},canvasStencil,this._getPluginFacade());if(canvasConfig){var properties=[];for(field in canvasConfig){properties.push({prefix:"oryx",name:field,value:canvasConfig[field]})}this._canvas.deserialize(properties)}},_getPluginFacade:function(){if(!(this._pluginFacade)){this._pluginFacade={activatePluginByName:this.activatePluginByName.bind(this),getAvailablePlugins:this.getAvailablePlugins.bind(this),getLoadedPluginByName:this.getLoadedPluginByName.bind(this),offer:this.offer.bind(this),getStencilSets:this.getStencilSets.bind(this),getStencilSetExtensionDefinition:function(){return Object.clone(this.ss_extensions_def||{})}.bind(this),getRules:this.getRules.bind(this),loadStencilSet:this.loadStencilSet.bind(this),createShape:this.createShape.bind(this),deleteShape:this.deleteShape.bind(this),getSelection:this.getSelection.bind(this),setSelection:this.setSelection.bind(this),updateSelection:this.updateSelection.bind(this),getCanvas:this.getCanvas.bind(this),importJSON:this.importJSON.bind(this),getJSON:this.getJSON.bind(this),getSerializedJSON:this.getSerializedJSON.bind(this),executeCommands:this.executeCommands.bind(this),isExecutingCommands:this.isExecutingCommands.bind(this),registerOnEvent:this.registerOnEvent.bind(this),unregisterOnEvent:this.unregisterOnEvent.bind(this),raiseEvent:this.handleEvents.bind(this),enableEvent:this.enableEvent.bind(this),disableEvent:this.disableEvent.bind(this),eventCoordinates:this.eventCoordinates.bind(this),eventCoordinatesXY:this.eventCoordinatesXY.bind(this),getModelMetaData:this.getModelMetaData.bind(this)}}return this._pluginFacade},isExecutingCommands:function(){return !!this.commandExecuting},executeCommands:function(commands){if(!this.commandStack){this.commandStack=[]}if(!this.commandStackExecuted){this.commandStackExecuted=[]}this.commandStack=[].concat(this.commandStack).concat(commands);if(this.commandExecuting){return}this.commandExecuting=true;while(this.commandStack.length>0){var command=this.commandStack.shift();command.execute();this.commandStackExecuted.push(command)}this.handleEvents({type:ORYX.CONFIG.EVENT_EXECUTE_COMMANDS,commands:this.commandStackExecuted});delete this.commandStack;delete this.commandStackExecuted;delete this.commandExecuting;this.updateSelection()},getJSON:function(){delete Array.prototype.toJSON;var canvasJSON=this.getCanvas().toJSON();canvasJSON.ssextensions=this.getStencilSets().values()[0].extensions().keys().findAll(function(sse){return !sse.endsWith("/meta#")});return canvasJSON},getSerializedJSON:function(){return JSON.stringify(this.getJSON())
},importJSON:function(jsonObject,noSelectionAfterImport){try{jsonObject=this.renewResourceIds(jsonObject)}catch(error){throw error}if(jsonObject.stencilset.namespace&&jsonObject.stencilset.namespace!==this.getCanvas().getStencil().stencilSet().namespace()){alert(String.format(ORYX.I18N.JSONImport.wrongSS,jsonObject.stencilset.namespace,this.getCanvas().getStencil().stencilSet().namespace()));return null}else{var commandClass=ORYX.Core.Command.extend({construct:function(jsonObject,loadSerializedCB,noSelectionAfterImport,facade){this.jsonObject=jsonObject;this.noSelection=noSelectionAfterImport;this.facade=facade;this.shapes;this.connections=[];this.parents=new Hash();this.selection=this.facade.getSelection();this.loadSerialized=loadSerializedCB},execute:function(){if(!this.shapes){this.shapes=this.loadSerialized(this.jsonObject);this.shapes.each(function(shape){if(shape.getDockers){var dockers=shape.getDockers();if(dockers){if(dockers.length>0){this.connections.push([dockers.first(),dockers.first().getDockedShape(),dockers.first().referencePoint])}if(dockers.length>1){this.connections.push([dockers.last(),dockers.last().getDockedShape(),dockers.last().referencePoint])}}}this.parents[shape.id]=shape.parent}.bind(this))}else{this.shapes.each(function(shape){this.parents[shape.id].add(shape)}.bind(this));this.connections.each(function(con){con[0].setDockedShape(con[1]);con[0].setReferencePoint(con[2]);con[0].update()})}this.facade.getCanvas().update();if(!this.noSelection){this.facade.setSelection(this.shapes)}else{this.facade.updateSelection()}this.facade.getCanvas().updateSize()},rollback:function(){var selection=this.facade.getSelection();this.shapes.each(function(shape){selection=selection.without(shape);this.facade.deleteShape(shape)}.bind(this));this.facade.getCanvas().update();this.facade.setSelection(selection)}});var command=new commandClass(jsonObject,this.loadSerialized.bind(this),noSelectionAfterImport,this._getPluginFacade());this.executeCommands([command]);return command.shapes.clone()}},renewResourceIds:function(jsonObject){if(Object.prototype.toString.call(jsonObject)==="String"){try{var serJsonObject=jsonObject;jsonObject=JSON.parse(jsonObject)}catch(error){throw new SyntaxError(error.message)}}else{var serJsonObject=JSON.stringify(jsonObject)}var collectResourceIds=function(shapes){if(!shapes){return[]}return shapes.map(function(shape){return collectResourceIds(shape.childShapes).concat(shape.resourceId)}).flatten()};var resourceIds=collectResourceIds(jsonObject.childShapes);resourceIds.each(function(oldResourceId){var newResourceId=ORYX.Editor.provideId();serJsonObject=serJsonObject.replace(new RegExp(oldResourceId,"g"),newResourceId)});var serObj=JSON.parse(serJsonObject);if(serObj.childShapes&&typeof serObj.childShapes=="string"){serObj.childShapes=JSON.parse(serObj.childShapes)}if(serObj.ssextensions&&typeof serObj.ssextensions=="string"){serObj.ssextensions=JSON.parse(serObj.ssextensions)}return serObj},loadSerialized:function(model,requestMeta){var canvas=this.getCanvas();this.loadSSExtensions(model.ssextensions);if(requestMeta===true){var metaDataExtension=this.getExtensionForMetaData();if(metaDataExtension){this.loadSSExtension(metaDataExtension)}}var shapes=this.getCanvas().addShapeObjects(model.childShapes,this.handleEvents.bind(this));if(model.properties){for(key in model.properties){var value=model.properties[key];var prop=this.getCanvas().getStencil().property("oryx-"+key);if(!(typeof value==="string")&&(!prop||!prop.isList())){value=JSON.stringify(value)}this.getCanvas().setProperty("oryx-"+key,value)}}this.getCanvas().updateSize();this.selection=[null];this.setSelection([]);return shapes},getExtensionForMetaData:function(){if(!this.ss_extensions_def||!(this.ss_extensions_def.extensions instanceof Array)){return null}var stencilsets=this.getStencilSets();var extension=this.ss_extensions_def.extensions.find(function(ex){return !!stencilsets[ex["extends"]]&&ex.namespace.endsWith("/meta#")});return extension?extension.namespace||null:null},loadSSExtensions:function(ss_extension_namespaces){if(!ss_extension_namespaces||ss_extension_namespaces.length==0){return}ss_extension_namespaces.each(function(ss_extension_namespace){this.loadSSExtension(ss_extension_namespace)}.bind(this))},loadSSExtension:function(ss_extension_namespace){if(this.ss_extensions_def){var extension=this.ss_extensions_def.extensions.find(function(ex){return(ex.namespace==ss_extension_namespace)});if(!extension){return}var stencilset=this.getStencilSets()[extension["extends"]];if(!stencilset){return}if((extension["definition"]||"").startsWith("/")){stencilset.addExtension(extension["definition"])}else{stencilset.addExtension(ORYX.CONFIG.SS_EXTENSIONS_FOLDER+extension["definition"])}this.getRules().initializeRules(stencilset);this._getPluginFacade().raiseEvent({type:ORYX.CONFIG.EVENT_STENCIL_SET_LOADED})}},disableEvent:function(eventType){if(eventType==ORYX.CONFIG.EVENT_KEYDOWN){this._keydownEnabled=false}if(eventType==ORYX.CONFIG.EVENT_KEYUP){this._keyupEnabled=false
}if(this.DOMEventListeners.keys().member(eventType)){var value=this.DOMEventListeners.remove(eventType);this.DOMEventListeners["disable_"+eventType]=value}},enableEvent:function(eventType){if(eventType==ORYX.CONFIG.EVENT_KEYDOWN){this._keydownEnabled=true}if(eventType==ORYX.CONFIG.EVENT_KEYUP){this._keyupEnabled=true}if(this.DOMEventListeners.keys().member("disable_"+eventType)){var value=this.DOMEventListeners.remove("disable_"+eventType);this.DOMEventListeners[eventType]=value}},registerOnEvent:function(eventType,callback){if(!(this.DOMEventListeners.keys().member(eventType))){this.DOMEventListeners[eventType]=[]}this.DOMEventListeners[eventType].push(callback)},unregisterOnEvent:function(eventType,callback){if(this.DOMEventListeners.keys().member(eventType)){this.DOMEventListeners[eventType]=this.DOMEventListeners[eventType].without(callback)}else{}},getSelection:function(){return this.selection||[]},getStencilSets:function(){return ORYX.Core.StencilSet.stencilSets(this.id)},getRules:function(){return ORYX.Core.StencilSet.rules(this.id)},loadStencilSet:function(source){try{ORYX.Core.StencilSet.loadStencilSet(source,this.modelMetaData,this.id);this.handleEvents({type:ORYX.CONFIG.EVENT_STENCIL_SET_LOADED})}catch(e){ORYX.Log.warn("Requesting stencil set file failed. ("+e+")")}},offer:function(pluginData){if(!this.pluginsData.member(pluginData)){this.pluginsData.push(pluginData)}},registerPluginsOnKeyEvents:function(){this.pluginsData.each(function(pluginData){if(pluginData.keyCodes){pluginData.keyCodes.each(function(keyComb){var eventName="key.event";eventName+="."+keyComb.keyAction;if(keyComb.metaKeys){if(keyComb.metaKeys.indexOf(ORYX.CONFIG.META_KEY_META_CTRL)>-1){eventName+="."+ORYX.CONFIG.META_KEY_META_CTRL}if(keyComb.metaKeys.indexOf(ORYX.CONFIG.META_KEY_ALT)>-1){eventName+="."+ORYX.CONFIG.META_KEY_ALT}if(keyComb.metaKeys.indexOf(ORYX.CONFIG.META_KEY_SHIFT)>-1){eventName+="."+ORYX.CONFIG.META_KEY_SHIFT}}if(keyComb.keyCode){eventName+="."+keyComb.keyCode}ORYX.Log.debug("Register Plugin on Key Event: %0",eventName);if(pluginData.toggle===true&&pluginData.buttonInstance){this.registerOnEvent(eventName,function(){pluginData.buttonInstance.toggle(!pluginData.buttonInstance.pressed);pluginData.functionality.call(pluginData,pluginData.buttonInstance,pluginData.buttonInstance.pressed)})}else{this.registerOnEvent(eventName,pluginData.functionality)}}.bind(this))}}.bind(this))},isEqual:function(a,b){return a===b||(a.length===b.length&&a.all(function(r){return b.include(r)}))},isDirty:function(a){return a.any(function(shape){return shape.isPropertyChanged()})},setSelection:function(elements,subSelectionElement,force){if(!elements){elements=[]}if(!(elements instanceof Array)){elements=[elements]}elements=elements.findAll(function(n){return n&&n instanceof ORYX.Core.Shape});if(elements[0] instanceof ORYX.Core.Canvas){elements=[]}if(!force&&this.isEqual(this.selection,elements)&&!this.isDirty(elements)){return}this.selection=elements;this._subSelection=subSelectionElement;this.handleEvents({type:ORYX.CONFIG.EVENT_SELECTION_CHANGED,elements:elements,subSelection:subSelectionElement,force:!!force})},updateSelection:function(){this.setSelection(this.selection,this._subSelection,true)},getCanvas:function(){return this._canvas},createShape:function(option){if(option&&option.serialize&&option.serialize instanceof Array){var type=option.serialize.find(function(obj){return(obj.prefix+"-"+obj.name)=="oryx-type"});var stencil=ORYX.Core.StencilSet.stencil(type.value);if(stencil.type()=="node"){var newShapeObject=new ORYX.Core.Node({"eventHandlerCallback":this.handleEvents.bind(this)},stencil,this._getPluginFacade())}else{var newShapeObject=new ORYX.Core.Edge({"eventHandlerCallback":this.handleEvents.bind(this)},stencil,this._getPluginFacade())}this.getCanvas().add(newShapeObject);newShapeObject.deserialize(option.serialize);return newShapeObject}if(!option||!option.type||!option.namespace){throw"To create a new shape you have to give an argument with type and namespace"}var canvas=this.getCanvas();var newShapeObject;var shapetype=option.type;var sset=ORYX.Core.StencilSet.stencilSet(option.namespace);if(sset.stencil(shapetype).type()=="node"){newShapeObject=new ORYX.Core.Node({"eventHandlerCallback":this.handleEvents.bind(this)},sset.stencil(shapetype),this._getPluginFacade())}else{newShapeObject=new ORYX.Core.Edge({"eventHandlerCallback":this.handleEvents.bind(this)},sset.stencil(shapetype),this._getPluginFacade())}if(option.template){newShapeObject._jsonStencil.properties=option.template._jsonStencil.properties;newShapeObject.postProcessProperties()}if(option.parent&&newShapeObject instanceof ORYX.Core.Node){option.parent.add(newShapeObject)}else{canvas.add(newShapeObject)}var point=option.position?option.position:{x:100,y:200};var con;if(option.connectingType&&option.connectedShape&&!(newShapeObject instanceof ORYX.Core.Edge)){con=new ORYX.Core.Edge({"eventHandlerCallback":this.handleEvents.bind(this)},sset.stencil(option.connectingType));
con.dockers.first().setDockedShape(option.connectedShape);var magnet=option.connectedShape.getDefaultMagnet();var cPoint=magnet?magnet.bounds.center():option.connectedShape.bounds.midPoint();con.dockers.first().setReferencePoint(cPoint);con.dockers.last().setDockedShape(newShapeObject);con.dockers.last().setReferencePoint(newShapeObject.getDefaultMagnet().bounds.center());canvas.add(con)}if(newShapeObject instanceof ORYX.Core.Edge&&option.connectedShape){newShapeObject.dockers.first().setDockedShape(option.connectedShape);if(option.connectedShape instanceof ORYX.Core.Node){newShapeObject.dockers.first().setReferencePoint(option.connectedShape.getDefaultMagnet().bounds.center());newShapeObject.dockers.last().bounds.centerMoveTo(point)}else{newShapeObject.dockers.first().setReferencePoint(option.connectedShape.bounds.midPoint())}var start=newShapeObject.dockers.first();var end=newShapeObject.dockers.last();if(start.getDockedShape()&&end.getDockedShape()){var startPoint=start.getAbsoluteReferencePoint();var endPoint=end.getAbsoluteReferencePoint();var docker=newShapeObject.createDocker();docker.bounds.centerMoveTo({x:startPoint.x+(endPont.x-startPoint.x)/2,y:startPoint.y+(endPont.y-startPoint.y)/2})}}else{var b=newShapeObject.bounds;if(newShapeObject instanceof ORYX.Core.Node&&newShapeObject.dockers.length==1){b=newShapeObject.dockers.first().bounds}b.centerMoveTo(point);var upL=b.upperLeft();b.moveBy(-Math.min(upL.x,0),-Math.min(upL.y,0));var lwR=b.lowerRight();b.moveBy(-Math.max(lwR.x-canvas.bounds.width(),0),-Math.max(lwR.y-canvas.bounds.height(),0))}if(newShapeObject instanceof ORYX.Core.Edge){newShapeObject._update(false)}if(!(newShapeObject instanceof ORYX.Core.Edge)&&!(option.dontUpdateSelection)){this.setSelection([newShapeObject])}if(con&&con.alignDockers){}if(newShapeObject.alignDockers){newShapeObject.alignDockers()}return newShapeObject},deleteShape:function(shape){if(!shape||!shape.parent){return}shape.parent.remove(shape);shape.getOutgoingShapes().each(function(os){var docker=os.getDockers().first();if(docker&&docker.getDockedShape()==shape){docker.setDockedShape(undefined)}});shape.getIncomingShapes().each(function(is){var docker=is.getDockers().last();if(docker&&docker.getDockedShape()==shape){docker.setDockedShape(undefined)}});shape.getDockers().each(function(docker){docker.setDockedShape(undefined)})},getModelMetaData:function(){return this.modelMetaData},_executeEventImmediately:function(eventObj){if(this.DOMEventListeners.keys().member(eventObj.event.type)){this.DOMEventListeners[eventObj.event.type].each((function(value){value(eventObj.event,eventObj.arg)}).bind(this))}},_executeEvents:function(){this._queueRunning=true;while(this._eventsQueue.length>0){var val=this._eventsQueue.shift();this._executeEventImmediately(val)}this._queueRunning=false},handleEvents:function(event,uiObj){ORYX.Log.trace("Dispatching event type %0 on %1",event.type,uiObj);switch(event.type){case ORYX.CONFIG.EVENT_MOUSEDOWN:this._handleMouseDown(event,uiObj);break;case ORYX.CONFIG.EVENT_MOUSEMOVE:this._handleMouseMove(event,uiObj);break;case ORYX.CONFIG.EVENT_MOUSEUP:this._handleMouseUp(event,uiObj);break;case ORYX.CONFIG.EVENT_MOUSEOVER:this._handleMouseHover(event,uiObj);break;case ORYX.CONFIG.EVENT_MOUSEOUT:this._handleMouseOut(event,uiObj);break}if(event.forceExecution){this._executeEventImmediately({event:event,arg:uiObj})}else{this._eventsQueue.push({event:event,arg:uiObj})}if(!this._queueRunning){this._executeEvents()}return false},isValidEvent:function(e){try{var isInput=["INPUT","TEXTAREA"].include(e.target.tagName.toUpperCase());var gridHasFocus=e.target.className.include("x-grid3-focus")&&!e.target.className.include("x-grid3-focus-canvas");return !isInput&&!gridHasFocus}catch(e){return false}},catchKeyUpEvents:function(event){if(!this._keyupEnabled){return}if(!event){event=window.event}if(!this.isValidEvent(event)){return}var keyUpEvent=this.createKeyCombEvent(event,ORYX.CONFIG.KEY_ACTION_UP);ORYX.Log.debug("Key Event to handle: %0",keyUpEvent);this.handleEvents({type:keyUpEvent,event:event})},catchKeyDownEvents:function(event){if(!this._keydownEnabled){return}if(!event){event=window.event}if(!this.isValidEvent(event)){return}var keyDownEvent=this.createKeyCombEvent(event,ORYX.CONFIG.KEY_ACTION_DOWN);ORYX.Log.debug("Key Event to handle: %0",keyDownEvent);this.handleEvents({type:keyDownEvent,event:event})},createKeyCombEvent:function(keyEvent,keyAction){var pressedKey=keyEvent.which||keyEvent.keyCode;var eventName="key.event";if(keyAction){eventName+="."+keyAction}if(keyEvent.ctrlKey||keyEvent.metaKey){eventName+="."+ORYX.CONFIG.META_KEY_META_CTRL}if(keyEvent.altKey){eventName+="."+ORYX.CONFIG.META_KEY_ALT}if(keyEvent.shiftKey){eventName+="."+ORYX.CONFIG.META_KEY_SHIFT}return eventName+"."+pressedKey},_handleMouseDown:function(event,uiObj){var canvas=this.getCanvas();canvas.focus();var element=event.currentTarget;var elementController=uiObj;var currentIsSelectable=(elementController!==null)&&(elementController!==undefined)&&(elementController.isSelectable);
var currentIsMovable=(elementController!==null)&&(elementController!==undefined)&&(elementController.isMovable);var modifierKeyPressed=event.shiftKey||event.ctrlKey;var noObjectsSelected=this.selection.length===0;var currentIsSelected=this.selection.member(elementController);if(currentIsSelectable&&noObjectsSelected){this.setSelection([elementController]);ORYX.Log.trace("Rule #1 applied for mouse down on %0",element.id)}else{if(currentIsSelectable&&!noObjectsSelected&&!modifierKeyPressed&&!currentIsSelected){this.setSelection([elementController]);ORYX.Log.trace("Rule #3 applied for mouse down on %0",element.id)}else{if(currentIsSelectable&&modifierKeyPressed&&!currentIsSelected){var newSelection=this.selection.clone();newSelection.push(elementController);this.setSelection(newSelection);ORYX.Log.trace("Rule #4 applied for mouse down on %0",element.id)}else{if(currentIsSelectable&¤tIsSelected&&modifierKeyPressed){var newSelection=this.selection.clone();this.setSelection(newSelection.without(elementController));ORYX.Log.trace("Rule #6 applied for mouse down on %0",elementController.id)}else{if(!currentIsSelectable&&!currentIsMovable){this.setSelection([]);ORYX.Log.trace("Rule #2 applied for mouse down on %0",element.id);return}else{if(!currentIsSelectable&¤tIsMovable&&!(elementController instanceof ORYX.Core.Controls.Docker)){ORYX.Log.trace("Rule #7 applied for mouse down on %0",element.id)}else{if(currentIsSelectable&¤tIsSelected&&!modifierKeyPressed){this._subSelection=this._subSelection!=elementController?elementController:undefined;this.setSelection(this.selection,this._subSelection);ORYX.Log.trace("Rule #8 applied for mouse down on %0",element.id)}}}}}}}return},_handleMouseMove:function(event,uiObj){return},_handleMouseUp:function(event,uiObj){var canvas=this.getCanvas();var elementController=uiObj;var evPos=this.eventCoordinates(event)},_handleMouseHover:function(event,uiObj){return},_handleMouseOut:function(event,uiObj){return},eventCoordinates:function(event){var canvas=this.getCanvas();var svgPoint=canvas.node.ownerSVGElement.createSVGPoint();svgPoint.x=event.clientX;svgPoint.y=event.clientY;var additionalIEZoom=1;if(!isNaN(screen.logicalXDPI)&&!isNaN(screen.systemXDPI)){var ua=navigator.userAgent;if(ua.indexOf("MSIE")>=0){var zoom=Math.round((screen.deviceXDPI/screen.logicalXDPI)*100);if(zoom!==100){additionalIEZoom=zoom/100}}}if(additionalIEZoom!==1){svgPoint.x=svgPoint.x*additionalIEZoom;svgPoint.y=svgPoint.y*additionalIEZoom}var matrix=canvas.node.getScreenCTM();return svgPoint.matrixTransform(matrix.inverse())},eventCoordinatesXY:function(x,y){var canvas=this.getCanvas();var svgPoint=canvas.node.ownerSVGElement.createSVGPoint();svgPoint.x=x;svgPoint.y=y;var additionalIEZoom=1;if(!isNaN(screen.logicalXDPI)&&!isNaN(screen.systemXDPI)){var ua=navigator.userAgent;if(ua.indexOf("MSIE")>=0){var zoom=Math.round((screen.deviceXDPI/screen.logicalXDPI)*100);if(zoom!==100){additionalIEZoom=zoom/100}}}if(additionalIEZoom!==1){svgPoint.x=svgPoint.x*additionalIEZoom;svgPoint.y=svgPoint.y*additionalIEZoom}var matrix=canvas.node.getScreenCTM();return svgPoint.matrixTransform(matrix.inverse())}};ORYX.Editor=Clazz.extend(ORYX.Editor);ORYX.Editor.createByUrl=function(modelUrl){new Ajax.Request(modelUrl,{method:"GET",onSuccess:function(transport){var editorConfig=JSON.parse(transport.responseText);new ORYX.Editor(editorConfig)}.bind(this)})};ORYX.Editor.graft=function(namespace,parent,t,doc){doc=(doc||(parent&&parent.ownerDocument)||document);var e;if(t===undefined){throw"Can't graft an undefined value"}else{if(t.constructor==String){e=doc.createTextNode(t)}else{for(var i=0;i0){onclickAttr.textContent="window.location = '../service/editor?id="+prop+"_form'"}else{newFormFacade=this.facade;onclickAttr.textContent="displayNewFormDialog('"+this.resourceId+"');"}}}else{if(ref=="linkIndicator"){if(prop&&prop.length>0){svgElem.setAttributeNS(null,"display","inherit")}else{svgElem.setAttributeNS(null,"display","none")}}}break;case ORYX.CONFIG.TYPE_URL:case ORYX.CONFIG.TYPE_DIAGRAM_LINK:var hrefAttr=svgElem.getAttributeNodeNS("http://www.w3.org/1999/xlink","xlink:href");if(hrefAttr){hrefAttr.textContent=prop}else{svgElem.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",prop)}break}}}).bind(this))}}}}).bind(this));this._labels.values().each(function(label){label.update()})}},layout:function(){var layoutEvents=this.getStencil().layout();if(layoutEvents){layoutEvents.each(function(event){event.shape=this;event.forceExecution=true;this._delegateEvent(event)}.bind(this))}},getLabels:function(){return this._labels.values()},getLabel:function(ref){if(!ref){return null}return(this._labels.find(function(o){return o.key.endsWith(ref)})||{}).value||null},hideLabels:function(){this.getLabels().invoke("hide")},showLabels:function(){var labels=this.getLabels();labels.invoke("show");labels.each(function(label){label.update()})},setOpacity:function(value,animate){value=Math.max(Math.min((typeof value=="number"?value:1),1),0);if(value!==1){value=String(value);this.node.setAttributeNS(null,"fill-opacity",value);this.node.setAttributeNS(null,"stroke-opacity",value)}else{this.node.removeAttributeNS(null,"fill-opacity");this.node.removeAttributeNS(null,"stroke-opacity")}},getDockers:function(){return this.dockers},getMagnets:function(){return this.magnets},getDefaultMagnet:function(){if(this._defaultMagnet){return this._defaultMagnet}else{if(this.magnets.length>0){return this.magnets[0]}else{return undefined}}},getParentShape:function(){return this.parent},getIncomingShapes:function(iterator){if(iterator){this.incoming.each(iterator)}return this.incoming},getIncomingNodes:function(iterator){return this.incoming.select(function(incoming){var isNode=(incoming instanceof ORYX.Core.Node);if(isNode&&iterator){iterator(incoming)}return isNode})},getOutgoingShapes:function(iterator){if(iterator){this.outgoing.each(iterator)}return this.outgoing},getOutgoingNodes:function(iterator){return this.outgoing.select(function(out){var isNode=(out instanceof ORYX.Core.Node);if(isNode&&iterator){iterator(out)}return isNode})},getAllDockedShapes:function(iterator){var result=this.incoming.concat(this.outgoing);if(iterator){result.each(iterator)}return result},getCanvas:function(){if(this.parent instanceof ORYX.Core.Canvas){return this.parent}else{if(this.parent instanceof ORYX.Core.Shape){return this.parent.getCanvas()}else{return undefined}}},getChildNodes:function(deep,iterator){if(!deep&&!iterator){return this.nodes.clone()}else{var result=[];this.nodes.each(function(uiObject){if(!uiObject.isVisible){return}if(iterator){iterator(uiObject)}result.push(uiObject);if(deep&&uiObject instanceof ORYX.Core.Shape){result=result.concat(uiObject.getChildNodes(deep,iterator))}});return result}},add:function(uiObject,index,silent){if(uiObject instanceof ORYX.Core.UIObject&&!(uiObject instanceof ORYX.Core.Edge)){if(!(this.children.member(uiObject))){if(uiObject.parent){uiObject.parent.remove(uiObject,true)}if(index!=undefined){this.children.splice(index,0,uiObject)}else{this.children.push(uiObject)}uiObject.parent=this;var parent;if(uiObject instanceof ORYX.Core.Node){parent=this.node.childNodes[0].childNodes[1];this.nodes.push(uiObject)}else{if(uiObject instanceof ORYX.Core.Controls.Control){var ctrls=this.node.childNodes[1];if(uiObject instanceof ORYX.Core.Controls.Docker){parent=ctrls.childNodes[0];if(this.dockers.length>=2){this.dockers.splice(index!==undefined?Math.min(index,this.dockers.length-1):this.dockers.length-1,0,uiObject)}else{this.dockers.push(uiObject)}}else{if(uiObject instanceof ORYX.Core.Controls.Magnet){parent=ctrls.childNodes[1];this.magnets.push(uiObject)}else{parent=ctrls}}}else{parent=this.node}}if(index!=undefined&&index0){json.labels=labels}return json},_init:function(svgDocument){this._adjustIds(svgDocument,0)},_adjustIds:function(element,idIndex){if(element instanceof Element){var eid=element.getAttributeNS(null,"id");if(eid&&eid!==""){element.setAttributeNS(null,"id",this.id+eid)}else{element.setAttributeNS(null,"id",this.id+"_"+this.id+"_"+idIndex);idIndex++}var fill=element.getAttributeNS(null,"fill");if(fill&&fill.include("url(#")){fill=fill.replace(/url\(#/g,"url(#"+this.id);element.setAttributeNS(null,"fill",fill)}if(element.hasChildNodes()){for(var i=0;i1?(dockerIndex===0?this.parent.dockers[dockerIndex+1]:this.parent.dockers[dockerIndex-1]):undefined;var absoluteReferenzPoint1=dock1.getDockedShape()?dock1.getAbsoluteReferencePoint():dock1.bounds.center();var absoluteReferenzPoint2=dock2&&dock2.getDockedShape()?dock2.getAbsoluteReferencePoint():dock2?dock2.bounds.center():undefined;if(!absoluteReferenzPoint2){var center=this._dockedShape.absoluteCenterXY();var minDimension=this._dockedShape.bounds.width()*this._dockedShape.bounds.height();absoluteReferenzPoint2={x:absoluteReferenzPoint1.x+(center.x-absoluteReferenzPoint1.x)*-minDimension,y:absoluteReferenzPoint1.y+(center.y-absoluteReferenzPoint1.y)*-minDimension}}var newPoint=undefined;newPoint=this._dockedShape.getIntersectionPoint(absoluteReferenzPoint1,absoluteReferenzPoint2);if(!newPoint){newPoint=this.getAbsoluteReferencePoint()}if(this.parent&&this.parent.parent){var grandParentPos=this.parent.parent.absoluteXY();newPoint.x-=grandParentPos.x;newPoint.y-=grandParentPos.y}this.bounds.centerMoveTo(newPoint);this._oldRefPoint1=absoluteReferenzPoint1;this._oldRefPoint2=absoluteReferenzPoint2}arguments.callee.$.update.apply(this,arguments)},refresh:function(){arguments.callee.$.refresh.apply(this,arguments);var p=this.bounds.upperLeft();this._dockerNode.setAttributeNS(null,"transform","translate("+p.x+", "+p.y+")");p=Object.clone(this.referencePoint);if(p&&this._dockedShape){var upL;if(this.parent instanceof ORYX.Core.Edge){upL=this._dockedShape.absoluteXY()}else{upL=this._dockedShape.bounds.upperLeft()}p.x+=upL.x;p.y+=upL.y}else{p=this.bounds.center()}this._referencePointNode.setAttributeNS(null,"transform","translate("+p.x+", "+p.y+")")},setReferencePoint:function(point){if(this.referencePoint!==point&&(!this.referencePoint||!point||this.referencePoint.x!==point.x||this.referencePoint.y!==point.y)){this.referencePoint=point;this._changed()}},getAbsoluteReferencePoint:function(){if(!this.referencePoint||!this._dockedShape){return undefined}else{var absUL=this._dockedShape.absoluteXY();return{x:this.referencePoint.x+absUL.x,y:this.referencePoint.y+absUL.y}}},setDockedShape:function(shape){if(this._dockedShape){this._dockedShape.bounds.unregisterCallback(this._updateCallback);
if(this===this.parent.dockers.first()){this.parent.incoming=this.parent.incoming.without(this._dockedShape);this._dockedShape.outgoing=this._dockedShape.outgoing.without(this.parent)}else{if(this===this.parent.dockers.last()){this.parent.outgoing=this.parent.outgoing.without(this._dockedShape);this._dockedShape.incoming=this._dockedShape.incoming.without(this.parent)}}}this._dockedShape=shape;this._dockedShapeBounds=undefined;var referencePoint=undefined;if(this._dockedShape){if(this===this.parent.dockers.first()){this.parent.incoming.push(shape);shape.outgoing.push(this.parent)}else{if(this===this.parent.dockers.last()){this.parent.outgoing.push(shape);shape.incoming.push(this.parent)}}var bounds=this.bounds;var absUL=shape.absoluteXY();referencePoint={x:bounds.center().x-absUL.x,y:bounds.center().y-absUL.y};this._dockedShapeBounds=this._dockedShape.bounds.clone();this._dockedShape.bounds.registerCallback(this._updateCallback);this.setDockerColor(ORYX.CONFIG.DOCKER_DOCKED_COLOR)}else{this.setDockerColor(ORYX.CONFIG.DOCKER_UNDOCKED_COLOR)}this.setReferencePoint(referencePoint);this._changed()},getDockedShape:function(){return this._dockedShape},isDocked:function(){return !!this._dockedShape},setDockerColor:function(color){this._dockerNode.lastChild.setAttributeNS(null,"fill",color)},preventHiding:function(prevent){this._preventHiding=Math.max(0,(this._preventHiding||0)+(prevent?1:-1))},hide:function(){if(this._preventHiding){return false}this.node.setAttributeNS(null,"visibility","hidden");this._referencePointNode.setAttributeNS(null,"visibility","hidden");this.children.each(function(uiObj){uiObj.hide()})},show:function(){this.node.setAttributeNS(null,"visibility","visible");if(this.getDockedShape() instanceof ORYX.Core.Edge){this._referencePointNode.setAttributeNS(null,"visibility","hidden")}else{this._referencePointNode.setAttributeNS(null,"visibility","visible")}this.children.each(function(uiObj){uiObj.show()})},toString:function(){return"Docker "+this.id}});if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}if(!ORYX.Core.Controls){ORYX.Core.Controls={}}ORYX.Core.Controls.Magnet=ORYX.Core.Controls.Control.extend({construct:function(){arguments.callee.$.construct.apply(this,arguments);this.anchorLeft;this.anchorRight;this.anchorTop;this.anchorBottom;this.bounds.set(0,0,16,16);this.node=ORYX.Editor.graft("http://www.w3.org/2000/svg",null,["g",{"pointer-events":"all"},["circle",{cx:"8",cy:"8",r:"4",stroke:"none",fill:"red","fill-opacity":"0.3"}],]);this.hide()},update:function(){arguments.callee.$.update.apply(this,arguments)},_update:function(){arguments.callee.$.update.apply(this,arguments)},refresh:function(){arguments.callee.$.refresh.apply(this,arguments);var p=this.bounds.upperLeft();this.node.setAttributeNS(null,"transform","translate("+p.x+", "+p.y+")")},show:function(){arguments.callee.$.show.apply(this,arguments)},toString:function(){return"Magnet "+this.id}});if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}ORYX.Core.Node={construct:function(options,stencil,facade){arguments.callee.$.construct.apply(this,arguments);this.isSelectable=true;this.isMovable=true;this._dockerUpdated=false;this.facade=facade;this._oldBounds=new ORYX.Core.Bounds();this._svgShapes=[];this.minimumSize=undefined;this.maximumSize=undefined;this.isHorizontallyResizable=false;this.isVerticallyResizable=false;this.dataId=undefined;this._init(this._stencil.view());this.forcedHeight=-1},_update:function(){this.dockers.invoke("update");if(this.isChanged){var bounds=this.bounds;var oldBounds=this._oldBounds;if(this.isResized){var widthDelta=bounds.width()/oldBounds.width();var heightDelta=bounds.height()/oldBounds.height();this._svgShapes.each(function(svgShape){if(svgShape.isHorizontallyResizable){svgShape.width=svgShape.oldWidth*widthDelta}if(svgShape.isVerticallyResizable){svgShape.height=svgShape.oldHeight*heightDelta}var anchorOffset;var leftIncluded=svgShape.anchorLeft;var rightIncluded=svgShape.anchorRight;if(rightIncluded){anchorOffset=oldBounds.width()-(svgShape.oldX+svgShape.oldWidth);if(leftIncluded){svgShape.width=bounds.width()-svgShape.x-anchorOffset}else{svgShape.x=bounds.width()-(anchorOffset+svgShape.width)}}else{if(!leftIncluded){svgShape.x=widthDelta*svgShape.oldX;if(!svgShape.isHorizontallyResizable){svgShape.x=svgShape.x+svgShape.width*widthDelta/2-svgShape.width/2}}}var topIncluded=svgShape.anchorTop;var bottomIncluded=svgShape.anchorBottom;if(bottomIncluded){anchorOffset=oldBounds.height()-(svgShape.oldY+svgShape.oldHeight);if(topIncluded){svgShape.height=bounds.height()-svgShape.y-anchorOffset}else{if(!svgShape._isYLocked){svgShape.y=bounds.height()-(anchorOffset+svgShape.height)}}}else{if(!topIncluded){svgShape.y=heightDelta*svgShape.oldY;if(!svgShape.isVerticallyResizable){svgShape.y=svgShape.y+svgShape.height*heightDelta/2-svgShape.height/2}}}});var p={x:0,y:0};if(!this.isHorizontallyResizable&&bounds.width()!==oldBounds.width()){p.x=oldBounds.width()-bounds.width()}if(!this.isVerticallyResizable&&bounds.height()!==oldBounds.height()){p.y=oldBounds.height()-bounds.height()
}if(p.x!==0||p.y!==0){bounds.extend(p)}p={x:0,y:0};var widthDifference,heightDifference;if(this.minimumSize){ORYX.Log.debug("Shape (%0)'s min size: (%1x%2)",this,this.minimumSize.width,this.minimumSize.height);widthDifference=this.minimumSize.width-bounds.width();if(widthDifference>0){p.x+=widthDifference}heightDifference=this.minimumSize.height-bounds.height();if(heightDifference>0){p.y+=heightDifference}}if(this.maximumSize){ORYX.Log.debug("Shape (%0)'s max size: (%1x%2)",this,this.maximumSize.width,this.maximumSize.height);widthDifference=bounds.width()-this.maximumSize.width;if(widthDifference>0){p.x-=widthDifference}heightDifference=bounds.height()-this.maximumSize.height;if(heightDifference>0){p.y-=heightDifference}}if(p.x!==0||p.y!==0){bounds.extend(p)}var widthDelta=bounds.width()/oldBounds.width();var heightDelta=bounds.height()/oldBounds.height();var leftIncluded,rightIncluded,topIncluded,bottomIncluded,center,newX,newY;this.magnets.each(function(magnet){leftIncluded=magnet.anchorLeft;rightIncluded=magnet.anchorRight;topIncluded=magnet.anchorTop;bottomIncluded=magnet.anchorBottom;center=magnet.bounds.center();if(leftIncluded){newX=center.x}else{if(rightIncluded){newX=bounds.width()-(oldBounds.width()-center.x)}else{newX=center.x*widthDelta}}if(topIncluded){newY=center.y}else{if(bottomIncluded){newY=bounds.height()-(oldBounds.height()-center.y)}else{newY=center.y*heightDelta}}if(center.x!==newX||center.y!==newY){magnet.bounds.centerMoveTo(newX,newY)}});this.getLabels().each(function(label){if(!label.isAnchorLeft()){if(label.isAnchorRight()){label.setX(bounds.width()-(oldBounds.width()-label.oldX))}else{label.setX((label.position?label.position.x:label.x)*widthDelta)}}if(!label.isAnchorTop()){if(label.isAnchorBottom()){label.setY(bounds.height()-(oldBounds.height()-label.oldY))}else{label.setY((label.position?label.position.y:label.y)*heightDelta)}}if(label.position){if(!label.isOriginAnchorLeft()){if(label.isOriginAnchorRight()){label.setOriginX(bounds.width()-(oldBounds.width()-label.oldX))}else{label.setOriginX(label.x*widthDelta)}}if(!label.isOriginAnchorTop()){if(label.isOriginAnchorBottom()){label.setOriginY(bounds.height()-(oldBounds.height()-label.oldY))}else{label.setOriginY(label.y*heightDelta)}}}});var docker=this.dockers[0];if(docker){docker.bounds.unregisterCallback(this._dockerChangedCallback);if(!this._dockerUpdated){docker.bounds.centerMoveTo(this.bounds.center());this._dockerUpdated=false}docker.update();docker.bounds.registerCallback(this._dockerChangedCallback)}this.isResized=false}this.refresh();this.isChanged=false;this._oldBounds=this.bounds.clone()}this.children.each(function(value){if(!(value instanceof ORYX.Core.Controls.Docker)){value._update()}});if(this.dockers.length>0&&!this.dockers.first().getDockedShape()){this.dockers.each(function(docker){docker.bounds.centerMoveTo(this.bounds.center())}.bind(this))}},refresh:function(){arguments.callee.$.refresh.apply(this,arguments);var x=this.bounds.upperLeft().x;var y=this.bounds.upperLeft().y;this.node.firstChild.setAttributeNS(null,"transform","translate("+x+", "+y+")");this.node.childNodes[1].childNodes[1].setAttributeNS(null,"transform","translate("+x+", "+y+")");this._svgShapes.each(function(svgShape){svgShape.update()})},_dockerChanged:function(){var docker=this.dockers[0];this.bounds.centerMoveTo(docker.bounds.center());this._dockerUpdated=true},_initSVGShapes:function(svgNode){var svgShapes=[];try{var svgShape=new ORYX.Core.SVG.SVGShape(svgNode);svgShapes.push(svgShape)}catch(e){}if(svgNode.hasChildNodes()){for(var i=0;i0){next.dockers.first().setDockedShape(this)}}}}).bind(this));if(this.dockers.length===1){var dockerPos;dockerPos=data.find(function(entry){return(entry.prefix+"-"+entry.name==="oryx-dockers")});if(dockerPos){var points=dockerPos.value.replace(/,/g," ").split(" ").without("").without("#");if(points.length===2&&this.dockers[0].getDockedShape()){this.dockers[0].setReferencePoint({x:parseFloat(points[0]),y:parseFloat(points[1])})}else{this.dockers[0].bounds.centerMoveTo(parseFloat(points[0]),parseFloat(points[1]))}}}},_init:function(svgDocument){arguments.callee.$._init.apply(this,arguments);var svgNode=svgDocument.getElementsByTagName("g")[0];var attributeTitle=svgDocument.ownerDocument.createAttribute("title");attributeTitle.nodeValue=this.getStencil().title();svgNode.setAttributeNode(attributeTitle);var attributeId=svgDocument.ownerDocument.createAttribute("id");attributeId.nodeValue=this.id;svgNode.setAttributeNode(attributeId);var stencilTargetNode=this.node.childNodes[0].childNodes[0];svgNode=stencilTargetNode.appendChild(svgNode);this.addEventHandlers(svgNode.parentNode);var minSizeAttr=svgNode.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"minimumSize");if(minSizeAttr){minSizeAttr=minSizeAttr.replace("/,/g"," ");var minSizeValues=minSizeAttr.split(" ");minSizeValues=minSizeValues.without("");if(minSizeValues.length>1){this.minimumSize={width:parseFloat(minSizeValues[0]),height:parseFloat(minSizeValues[1])}}else{this.minimumSize={width:1,height:1}}}var maxSizeAttr=svgNode.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"maximumSize");if(maxSizeAttr){maxSizeAttr=maxSizeAttr.replace("/,/g"," ");var maxSizeValues=maxSizeAttr.split(" ");maxSizeValues=maxSizeValues.without("");if(maxSizeValues.length>1){this.maximumSize={width:parseFloat(maxSizeValues[0]),height:parseFloat(maxSizeValues[1])}}}if(this.minimumSize&&this.maximumSize&&(this.minimumSize.width>this.maximumSize.width||this.minimumSize.height>this.maximumSize.height)){throw this+": Minimum Size must be greater than maxiumSize."}this._svgShapes=this._initSVGShapes(svgNode);var upperLeft={x:undefined,y:undefined};var lowerRight={x:undefined,y:undefined};var me=this;this._svgShapes.each(function(svgShape){upperLeft.x=(upperLeft.x!==undefined)?Math.min(upperLeft.x,svgShape.x):svgShape.x;upperLeft.y=(upperLeft.y!==undefined)?Math.min(upperLeft.y,svgShape.y):svgShape.y;lowerRight.x=(lowerRight.x!==undefined)?Math.max(lowerRight.x,svgShape.x+svgShape.width):svgShape.x+svgShape.width;lowerRight.y=(lowerRight.y!==undefined)?Math.max(lowerRight.y,svgShape.y+svgShape.height):svgShape.y+svgShape.height;if(svgShape.isHorizontallyResizable){me.isHorizontallyResizable=true;me.isResizable=true}if(svgShape.isVerticallyResizable){me.isVerticallyResizable=true;me.isResizable=true}if(svgShape.anchorTop&&svgShape.anchorBottom){me.isVerticallyResizable=true;me.isResizable=true}if(svgShape.anchorLeft&&svgShape.anchorRight){me.isHorizontallyResizable=true;me.isResizable=true}});this._svgShapes.each(function(svgShape){svgShape.x-=upperLeft.x;svgShape.y-=upperLeft.y;svgShape.update()});var offsetX=upperLeft.x;var offsetY=upperLeft.y;lowerRight.x-=offsetX;lowerRight.y-=offsetY;upperLeft.x=0;upperLeft.y=0;if(lowerRight.x===0){lowerRight.x=1}if(lowerRight.y===0){lowerRight.y=1}this._oldBounds.set(upperLeft,lowerRight);this.bounds.set(upperLeft,lowerRight);var magnets=svgDocument.getElementsByTagNameNS(ORYX.CONFIG.NAMESPACE_ORYX,"magnets");if(magnets&&magnets.length>0){magnets=$A(magnets[0].getElementsByTagNameNS(ORYX.CONFIG.NAMESPACE_ORYX,"magnet"));var me=this;magnets.each(function(magnetElem){var magnet=new ORYX.Core.Controls.Magnet({eventHandlerCallback:me.eventHandlerCallback});var cx=parseFloat(magnetElem.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"cx"));var cy=parseFloat(magnetElem.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"cy"));magnet.bounds.centerMoveTo({x:cx-offsetX,y:cy-offsetY});var anchors=magnetElem.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"anchors");if(anchors){anchors=anchors.replace("/,/g"," ");anchors=anchors.split(" ").without("");for(var i=0;i0){dockerElem=dockerElem[0];var docker=this.createDocker();var cx=parseFloat(dockerElem.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"cx"));var cy=parseFloat(dockerElem.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"cy"));docker.bounds.centerMoveTo({x:cx-offsetX,y:cy-offsetY});var anchors=dockerElem.getAttributeNS(ORYX.CONFIG.NAMESPACE_ORYX,"anchors");if(anchors){anchors=anchors.replace("/,/g"," ");anchors=anchors.split(" ").without("");for(var i=0;iy){y=lr}});var bounds=this.bounds;var boundsChanged=false;if(this.minimumSize){var minHeight=this.minimumSize.height;if(yminHeight&&minHeight>this.forcedHeight){bounds.set(bounds.upperLeft().x,bounds.upperLeft().y,bounds.lowerRight().x,bounds.upperLeft().y+minHeight);boundsChanged=true}else{if(y>minHeight&&bounds.height()!=y&&y>this.forcedHeight){bounds.set(bounds.upperLeft().x,bounds.upperLeft().y,bounds.lowerRight().x,bounds.upperLeft().y+y);boundsChanged=true}else{if(bounds.height()>this.forcedHeight&&this.forcedHeight>0){bounds.set(bounds.upperLeft().x,bounds.upperLeft().y,bounds.lowerRight().x,bounds.upperLeft().y+this.forcedHeight);boundsChanged=true}}}}if(boundsChanged){if(this.facade.getCanvas()!=null){this.facade.getCanvas().update()}if(this.facade.getSelection().member(this)){var selectedNow=this.facade.getSelection();this.facade.setSelection([]);this.facade.setSelection(selectedNow)}}},createDocker:function(){var docker=new ORYX.Core.Controls.Docker({eventHandlerCallback:this.eventHandlerCallback});docker.bounds.registerCallback(this._dockerChangedCallback);this.dockers.push(docker);docker.parent=this;docker.bounds.registerCallback(this._changedCallback);return docker},toString:function(){return this._stencil.title()+" "+this.id}};ORYX.Core.Node=ORYX.Core.Shape.extend(ORYX.Core.Node);NAMESPACE_SVG="http://www.w3.org/2000/svg";NAMESPACE_ORYX="http://www.b3mn.org/oryx";if(!ORYX){var ORYX={}}if(!ORYX.Core){ORYX.Core={}}ORYX.Core.Edge={construct:function(options,stencil,facade){arguments.callee.$.construct.apply(this,arguments);this.isMovable=true;this.isSelectable=true;this._dockerUpdated=false;this._markers=new Hash();this._paths=[];this._interactionPaths=[];this._dockersByPath=new Hash();this._markersByPath=new Hash();this.attachedNodePositionData=new Hash();var stencilNode=this.node.childNodes[0].childNodes[0];stencilNode=ORYX.Editor.graft("http://www.w3.org/2000/svg",stencilNode,["g",{"pointer-events":"painted"}]);this.addEventHandlers(stencilNode.parentNode);this._oldBounds=this.bounds.clone();this._init(this._stencil.view());if(stencil instanceof Array){this.deserialize(stencil)}},_update:function(force){if(this._dockerUpdated||this.isChanged||force){this.dockers.invoke("update");if(false&&(this.bounds.width()===0||this.bounds.height()===0)){var width=this.bounds.width();var height=this.bounds.height();this.bounds.extend({x:width===0?2:0,y:height===0?2:0});this.bounds.moveBy({x:width===0?-1:0,y:height===0?-1:0})}var upL=this.bounds.upperLeft();var oldUpL=this._oldBounds.upperLeft();var oldWidth=this._oldBounds.width()===0?this.bounds.width():this._oldBounds.width();var oldHeight=this._oldBounds.height()===0?this.bounds.height():this._oldBounds.height();var diffX=upL.x-oldUpL.x;var diffY=upL.y-oldUpL.y;var diffWidth=(this.bounds.width()/oldWidth)||1;var diffHeight=(this.bounds.height()/oldHeight)||1;this.dockers.each((function(docker){docker.bounds.unregisterCallback(this._dockerChangedCallback);if(!this._dockerUpdated){docker.bounds.moveBy(diffX,diffY);if(diffWidth!==1||diffHeight!==1){var relX=docker.bounds.upperLeft().x-upL.x;var relY=docker.bounds.upperLeft().y-upL.y;docker.bounds.moveTo(upL.x+relX*diffWidth,upL.y+relY*diffHeight)
}}docker.update();docker.bounds.registerCallback(this._dockerChangedCallback)}).bind(this));if(this._dockerUpdated){var a=this.dockers.first().bounds.center();var b=this.dockers.first().bounds.center();this.dockers.each((function(docker){var center=docker.bounds.center();a.x=Math.min(a.x,center.x);a.y=Math.min(a.y,center.y);b.x=Math.max(b.x,center.x);b.y=Math.max(b.y,center.y)}).bind(this));this.bounds.set(Object.clone(a),Object.clone(b))}upL=this.bounds.upperLeft();oldUpL=this._oldBounds.upperLeft();diffWidth=(this.bounds.width()/(oldWidth||this.bounds.width()));diffHeight=(this.bounds.height()/(oldHeight||this.bounds.height()));diffX=upL.x-oldUpL.x;diffY=upL.y-oldUpL.y;this.getLabels().each(function(label){if(label.getReferencePoint()){var ref=label.getReferencePoint();var from=ref.segment.from,to=ref.segment.to;if(!from||!from.parent||!to||!to.parent){return}var fromPosition=from.bounds.center(),toPosition=to.bounds.center();if(fromPosition.x===ref.segment.fromPosition.x&&fromPosition.y===ref.segment.fromPosition.y&&toPosition.x===ref.segment.toPosition.x&&toPosition.y===ref.segment.toPosition.y&&!ref.dirty){return}if(!this.parent.initializingShapes){var oldDistance=ORYX.Core.Math.getDistanceBetweenTwoPoints(ref.segment.fromPosition,ref.segment.toPosition,ref.intersection);var newIntersection=ORYX.Core.Math.getPointBetweenTwoPoints(fromPosition,toPosition,isNaN(oldDistance)?0.5:oldDistance);var oiv=ORYX.Core.Math.getOrthogonalIdentityVector(fromPosition,toPosition);var isHor=Math.abs(oiv.y)===1,isVer=Math.abs(oiv.x)===1;oiv.x*=ref.distance;oiv.y*=ref.distance;oiv.x+=newIntersection.x;oiv.y+=newIntersection.y;var mx=isHor&&ref.orientation&&(ref.iorientation||ref.orientation).endsWith("r")?-label.getWidth():0;var my=isVer&&ref.orientation&&(ref.iorientation||ref.orientation).startsWith("l")?-label.getHeight()+2:0;label.setX(oiv.x+mx);label.setY(oiv.y+my);this.updateReferencePointOfLabel(label,newIntersection,from,to)}else{var oiv=ORYX.Core.Math.getOrthogonalIdentityVector(fromPosition,toPosition);oiv.x*=ref.distance;oiv.y*=ref.distance;oiv.x+=ref.intersection.x;oiv.y+=ref.intersection.y;label.setX(oiv.x);label.setY(oiv.y);ref.segment.fromPosition=fromPosition;ref.segment.toPosition=toPosition}return}if(label.position&&!this.parent.initializingShapes){var x=label.position.x+(diffX*(diffWidth||1));if(x>this.bounds.lowerRight().x){x+=this.bounds.width()-(this.bounds.width()/(diffWidth||1))}var y=label.position.y+(diffY*(diffHeight||1));if(y>this.bounds.lowerRight().y){y+=this.bounds.height()-(this.bounds.height()/(diffHeight||1))}label.setX(x);label.setY(y);return}switch(label.getEdgePosition()){case"starttop":var angle=this._getAngle(this.dockers[0],this.dockers[1]);var pos=this.dockers.first().bounds.center();if(angle<=90||angle>270){label.horizontalAlign("left");label.verticalAlign("bottom");label.x=pos.x+label.getOffsetTop();label.y=pos.y-label.getOffsetTop();label.rotate(360-angle,pos)}else{label.horizontalAlign("right");label.verticalAlign("bottom");label.x=pos.x-label.getOffsetTop();label.y=pos.y-label.getOffsetTop();label.rotate(180-angle,pos)}break;case"startmiddle":var angle=this._getAngle(this.dockers[0],this.dockers[1]);var pos=this.dockers.first().bounds.center();if(angle<=90||angle>270){label.horizontalAlign("left");label.verticalAlign("bottom");label.x=pos.x+2;label.y=pos.y+4;label.rotate(360-angle,pos)}else{label.horizontalAlign("right");label.verticalAlign("bottom");label.x=pos.x+1;label.y=pos.y+4;label.rotate(180-angle,pos)}break;case"startbottom":var angle=this._getAngle(this.dockers[0],this.dockers[1]);var pos=this.dockers.first().bounds.center();if(angle<=90||angle>270){label.horizontalAlign("left");label.verticalAlign("top");label.x=pos.x+label.getOffsetBottom();label.y=pos.y+label.getOffsetBottom();label.rotate(360-angle,pos)}else{label.horizontalAlign("right");label.verticalAlign("top");label.x=pos.x-label.getOffsetBottom();label.y=pos.y+label.getOffsetBottom();label.rotate(180-angle,pos)}break;case"midtop":var numOfDockers=this.dockers.length;if(numOfDockers%2==0){var angle=this._getAngle(this.dockers[numOfDockers/2-1],this.dockers[numOfDockers/2]);var pos1=this.dockers[numOfDockers/2-1].bounds.center();var pos2=this.dockers[numOfDockers/2].bounds.center();var pos={x:(pos1.x+pos2.x)/2,y:(pos1.y+pos2.y)/2};label.horizontalAlign("center");label.verticalAlign("bottom");label.x=pos.x;label.y=pos.y-label.getOffsetTop();if(angle<=90||angle>270){label.rotate(360-angle,pos)}else{label.rotate(180-angle,pos)}}else{var index=parseInt(numOfDockers/2);var angle=this._getAngle(this.dockers[index],this.dockers[index+1]);var pos=this.dockers[index].bounds.center();if(angle<=90||angle>270){label.horizontalAlign("left");label.verticalAlign("bottom");label.x=pos.x+label.getOffsetTop();label.y=pos.y-label.getOffsetTop();label.rotate(360-angle,pos)}else{label.horizontalAlign("right");label.verticalAlign("bottom");label.x=pos.x-label.getOffsetTop();label.y=pos.y-label.getOffsetTop();label.rotate(180-angle,pos)
}}break;case"midbottom":var numOfDockers=this.dockers.length;if(numOfDockers%2==0){var angle=this._getAngle(this.dockers[numOfDockers/2-1],this.dockers[numOfDockers/2]);var pos1=this.dockers[numOfDockers/2-1].bounds.center();var pos2=this.dockers[numOfDockers/2].bounds.center();var pos={x:(pos1.x+pos2.x)/2,y:(pos1.y+pos2.y)/2};label.horizontalAlign("center");label.verticalAlign("top");label.x=pos.x;label.y=pos.y+label.getOffsetTop();if(angle<=90||angle>270){label.rotate(360-angle,pos)}else{label.rotate(180-angle,pos)}}else{var index=parseInt(numOfDockers/2);var angle=this._getAngle(this.dockers[index],this.dockers[index+1]);var pos=this.dockers[index].bounds.center();if(angle<=90||angle>270){label.horizontalAlign("left");label.verticalAlign("top");label.x=pos.x+label.getOffsetBottom();label.y=pos.y+label.getOffsetBottom();label.rotate(360-angle,pos)}else{label.horizontalAlign("right");label.verticalAlign("top");label.x=pos.x-label.getOffsetBottom();label.y=pos.y+label.getOffsetBottom();label.rotate(180-angle,pos)}}break;case"endtop":var length=this.dockers.length;var angle=this._getAngle(this.dockers[length-2],this.dockers[length-1]);var pos=this.dockers.last().bounds.center();if(angle<=90||angle>270){label.horizontalAlign("right");label.verticalAlign("bottom");label.x=pos.x-label.getOffsetTop();label.y=pos.y-label.getOffsetTop();label.rotate(360-angle,pos)}else{label.horizontalAlign("left");label.verticalAlign("bottom");label.x=pos.x+label.getOffsetTop();label.y=pos.y-label.getOffsetTop();label.rotate(180-angle,pos)}break;case"endbottom":var length=this.dockers.length;var angle=this._getAngle(this.dockers[length-2],this.dockers[length-1]);var pos=this.dockers.last().bounds.center();if(angle<=90||angle>270){label.horizontalAlign("right");label.verticalAlign("top");label.x=pos.x-label.getOffsetBottom();label.y=pos.y+label.getOffsetBottom();label.rotate(360-angle,pos)}else{label.horizontalAlign("left");label.verticalAlign("top");label.x=pos.x+label.getOffsetBottom();label.y=pos.y+label.getOffsetBottom();label.rotate(180-angle,pos)}break}}.bind(this));this.children.each(function(value){if(value instanceof ORYX.Core.Node){this.calculatePositionOfAttachedChildNode.call(this,value)}}.bind(this));this.refreshAttachedNodes();this.refresh();this.isChanged=false;this._dockerUpdated=false;this._oldBounds=this.bounds.clone()}var userAgent=navigator.userAgent;if(navigator.appVersion.indexOf("MSIE 10")!==-1||(userAgent.indexOf("Trident")!==-1&&userAgent.indexOf("rv:11")!==-1)){this.node.parentNode.insertBefore(this.node,this.node)}},movePointToUpperLeftOfNode:function(point,bounds){point.x-=bounds.width()/2;point.y-=bounds.height()/2},refreshAttachedNodes:function(){this.attachedNodePositionData.values().each(function(nodeData){var startPoint=nodeData.segment.docker1.bounds.center();var endPoint=nodeData.segment.docker2.bounds.center();this.relativizePoint(startPoint);this.relativizePoint(endPoint);var newNodePosition=new Object();newNodePosition.x=startPoint.x+nodeData.relativDistanceFromDocker1*(endPoint.x-startPoint.x);newNodePosition.y=startPoint.y+nodeData.relativDistanceFromDocker1*(endPoint.y-startPoint.y);this.movePointToUpperLeftOfNode(newNodePosition,nodeData.node.bounds);nodeData.node.bounds.moveTo(newNodePosition);nodeData.node._update()}.bind(this))},calculatePositionOfAttachedChildNode:function(node){var position=new Object();position.x=0;position.y=0;if(!this.attachedNodePositionData[node.getId()]){this.attachedNodePositionData[node.getId()]=new Object();this.attachedNodePositionData[node.getId()].relativDistanceFromDocker1=0;this.attachedNodePositionData[node.getId()].node=node;this.attachedNodePositionData[node.getId()].segment=new Object();this.findEdgeSegmentForNode(node)}else{if(node.isChanged){this.findEdgeSegmentForNode(node)}}},findEdgeSegmentForNode:function(node){var length=this.dockers.length;var smallestDistance=undefined;for(i=1;i0){var x=this.bounds.upperLeft().x;var y=this.bounds.upperLeft().y;this.node.firstChild.childNodes[1].setAttributeNS(null,"transform","translate("+x+", "+y+")")}},getIntersectionPoint:function(){var length=Math.floor(this.dockers.length/2);return ORYX.Core.Math.midPoint(this.dockers[length-1].bounds.center(),this.dockers[length].bounds.center())},isBoundsIncluded:function(bounds){var dockers=this.dockers,size=dockers.length;return dockers.any(function(docker,i){if(i==size-1){return false}var a=docker.bounds.center();var b=dockers[i+1].bounds.center();return ORYX.Core.Math.isRectOverLine(a.x,a.y,b.x,b.y,bounds.a.x,bounds.a.y,bounds.b.x,bounds.b.y)})},isPointIncluded:function(pointX,pointY){var isbetweenAB=this.absoluteBounds().isIncluded(pointX,pointY,ORYX.CONFIG.OFFSET_EDGE_BOUNDS);var isPointIncluded=undefined;if(isbetweenAB&&this.dockers.length>0){var i=0;var point1,point2;do{point1=this.dockers[i].bounds.center();point2=this.dockers[++i].bounds.center();isPointIncluded=ORYX.Core.Math.isPointInLine(pointX,pointY,point1.x,point1.y,point2.x,point2.y,ORYX.CONFIG.OFFSET_EDGE_BOUNDS)}while(!isPointIncluded&&i=ref.segment.fromIndex&&index<=ref.segment.toIndex){var segment=this.findSegment(ref.intersection);if(!segment){segment.fromDocker=ref.segment.fromIndex>=(this.dockers.length/2)?this.dockers[0]:this.dockers[this.dockers.length-2];segment.toDocker=this.dockers[this.dockers.indexOf(from)+1]}var fromPosition=segment.fromDocker.bounds.center(),toPosition=segment.toDocker.bounds.center();var intersection=ORYX.Core.Math.getPointOfIntersectionPointLine(fromPosition,toPosition,ref.intersection,true);this.updateReferencePointOfLabel(label,intersection,segment.fromDocker,segment.toDocker,true)}}.bind(this));this.refreshAttachedNodes()},getAttachedNodePositionDataForSegment:function(startDocker,endDocker){if(!((startDocker instanceof ORYX.Core.Controls.Docker)&&(endDocker instanceof ORYX.Core.Controls.Docker))){return[]}var elementsOfSegment=this.attachedNodePositionData.findAll(function(nodePositionData){return nodePositionData.value.segment.docker1===startDocker&&nodePositionData.value.segment.docker2===endDocker});if(!elementsOfSegment){return[]}return elementsOfSegment},remove:function(shape){arguments.callee.$.remove.apply(this,arguments);if(this.attachedNodePositionData[shape.getId()]){delete this.attachedNodePositionData[shape.getId()]}if(shape instanceof ORYX.Core.Controls.Docker){this.handleChildShapesAfterRemoveDocker(shape)}},updateReferencePointOfLabel:function(label,intersection,from,to,dirty){if(!label.getReferencePoint()||!label.isVisible){return}var ref=label.getReferencePoint();if(ref.orientation&&ref.orientation!=="ce"){var angle=this._getAngle(from,to);if(ref.distance>=0){if(angle==0){label.horizontalAlign("left");label.verticalAlign("bottom")}else{if(angle>0&&angle<90){label.horizontalAlign("right");label.verticalAlign("bottom")}else{if(angle==90){label.horizontalAlign("right");label.verticalAlign("top")}else{if(angle>90&&angle<180){label.horizontalAlign("right");label.verticalAlign("top")}else{if(angle==180){label.horizontalAlign("left");label.verticalAlign("top")}else{if(angle>180&&angle<270){label.horizontalAlign("left");label.verticalAlign("top")}else{if(angle==270){label.horizontalAlign("left");label.verticalAlign("top")}else{if(angle>270&&angle<=360){label.horizontalAlign("left");label.verticalAlign("bottom")}}}}}}}}}else{if(angle==0){label.horizontalAlign("left");label.verticalAlign("top")}else{if(angle>0&&angle<90){label.horizontalAlign("left");label.verticalAlign("top")}else{if(angle==90){label.horizontalAlign("left");label.verticalAlign("top")}else{if(angle>90&&angle<180){label.horizontalAlign("left");label.verticalAlign("bottom")}else{if(angle==180){label.horizontalAlign("left");label.verticalAlign("bottom")}else{if(angle>180&&angle<270){label.horizontalAlign("right");label.verticalAlign("bottom")}else{if(angle==270){label.horizontalAlign("right");label.verticalAlign("top")}else{if(angle>270&&angle<=360){label.horizontalAlign("right");label.verticalAlign("top")}}}}}}}}}ref.iorientation=ref.iorientation||ref.orientation;ref.orientation=(label.verticalAlign()=="top"?"u":"l")+(label.horizontalAlign()=="left"?"l":"r")}label.setReferencePoint(jQuery.extend({},{intersection:intersection,segment:{from:from,fromIndex:this.dockers.indexOf(from),fromPosition:from.bounds.center(),to:to,toIndex:this.dockers.indexOf(to),toPosition:to.bounds.center()},dirty:dirty||false},ref))},handleChildShapesAfterRemoveDocker:function(docker){if(!(docker instanceof ORYX.Core.Controls.Docker)){return}this.attachedNodePositionData.each(function(nodePositionData){if(nodePositionData.value.segment.docker1===docker){var index=this.dockers.indexOf(nodePositionData.value.segment.docker2);if(index==-1){return}nodePositionData.value.segment.docker1=this.dockers[index-1]}else{if(nodePositionData.value.segment.docker2===docker){var index=this.dockers.indexOf(nodePositionData.value.segment.docker1);if(index==-1){return}nodePositionData.value.segment.docker2=this.dockers[index+1]}}}.bind(this));this.getLabels().each(function(label){var ref=label.getReferencePoint();if(!ref){return}var from=ref.segment.from;
var to=ref.segment.to;if(from!==docker&&to!==docker){return}var segment=this.findSegment(ref.intersection);if(!segment){from=segment.fromDocker;to=segment.toDocker}else{from=from===docker?this.dockers[this.dockers.indexOf(to)-1]:from;to=this.dockers[this.dockers.indexOf(from)+1]}var intersection=ORYX.Core.Math.getPointOfIntersectionPointLine(from.bounds.center(),to.bounds.center(),ref.intersection,true);this.updateReferencePointOfLabel(label,intersection,from,to,true)}.bind(this));this.refreshAttachedNodes()},addDocker:function(position,exDocker){var lastDocker;var result;this._dockersByPath.any((function(pair){return pair.value.any((function(docker,index){if(!lastDocker){lastDocker=docker;return false}else{var point1=lastDocker.bounds.center();var point2=docker.bounds.center();var additionalIEZoom=1;if(!isNaN(screen.logicalXDPI)&&!isNaN(screen.systemXDPI)){var ua=navigator.userAgent;if(ua.indexOf("MSIE")>=0){var zoom=Math.round((screen.deviceXDPI/screen.logicalXDPI)*100);if(zoom!==100){additionalIEZoom=zoom/100}}}if(additionalIEZoom!==1){position.x=position.x/additionalIEZoom;position.y=position.y/additionalIEZoom}if(ORYX.Core.Math.isPointInLine(position.x,position.y,point1.x,point1.y,point2.x,point2.y,10)){var path=this._paths.find(function(path){return path.id===pair.key});if(path){var allowAttr=path.getAttributeNS(NAMESPACE_ORYX,"allowDockers");if(allowAttr&&allowAttr.toLowerCase()==="no"){return true}}var newDocker=(exDocker)?exDocker:this.createDocker(this.dockers.indexOf(lastDocker)+1,position);newDocker.bounds.centerMoveTo(position);if(exDocker){this.add(newDocker,this.dockers.indexOf(lastDocker)+1)}result=newDocker;return true}else{lastDocker=docker;return false}}}).bind(this))}).bind(this));return result},removeDocker:function(docker){if(this.dockers.length>2&&!(this.dockers.first()===docker)){this._dockersByPath.any((function(pair){if(pair.value.member(docker)){if(docker===pair.value.last()){return true}else{this.remove(docker);this._dockersByPath[pair.key]=pair.value.without(docker);this.isChanged=true;this._dockerChanged();return true}}return false}).bind(this))}},removeUnusedDockers:function(){var marked=$H({});this.dockers.each(function(docker,i){if(i==0||i==this.dockers.length-1){return}var previous=this.dockers[i-1];if(marked.values().indexOf(previous)!=-1&&this.dockers[i-2]){previous=this.dockers[i-2]}var next=this.dockers[i+1];var cp=previous.getDockedShape()&&previous.referencePoint?previous.getAbsoluteReferencePoint():previous.bounds.center();var cn=next.getDockedShape()&&next.referencePoint?next.getAbsoluteReferencePoint():next.bounds.center();var cd=docker.bounds.center();if(ORYX.Core.Math.isPointInLine(cd.x,cd.y,cp.x,cp.y,cn.x,cn.y,1)){marked[i]=docker}}.bind(this));marked.each(function(docker){this.removeDocker(docker.value)}.bind(this));if(marked.values().length>0){this._update(true)}return marked},_init:function(svgDocument){arguments.callee.$._init.apply(this,arguments);var minPointX,minPointY,maxPointX,maxPointY;var defs=svgDocument.getElementsByTagNameNS(NAMESPACE_SVG,"defs");if(defs.length>0){defs=defs[0];var markerElements=$A(defs.getElementsByTagNameNS(NAMESPACE_SVG,"marker"));var marker;var me=this;markerElements.each(function(markerElement){try{marker=new ORYX.Core.SVG.SVGMarker(markerElement.cloneNode(true));me._markers[marker.id]=marker;var textElements=$A(marker.element.getElementsByTagNameNS(NAMESPACE_SVG,"text"));var label;textElements.each(function(textElement){label=new ORYX.Core.SVG.Label({textElement:textElement,shapeId:this.id});me._labels[label.id]=label})}catch(e){}})}var gs=svgDocument.getElementsByTagNameNS(NAMESPACE_SVG,"g");if(gs.length<=0){throw"Edge: No g element found."}var g=gs[0];g.setAttributeNS(null,"id",null);var isFirst=true;$A(g.childNodes).each((function(path,index){if(ORYX.Editor.checkClassType(path,SVGPathElement)){path=path.cloneNode(false);var pathId=this.id+"_"+index;path.setAttributeNS(null,"id",pathId);this._paths.push(path);var markersByThisPath=[];var markerUrl=path.getAttributeNS(null,"marker-start");if(markerUrl&&markerUrl!==""){markerUrl=markerUrl.strip();markerUrl=markerUrl.replace(/^url\(#/,"");var markerStartId=this.getValidMarkerId(markerUrl);path.setAttributeNS(null,"marker-start","url(#"+markerStartId+")");markersByThisPath.push(this._markers[markerStartId])}markerUrl=path.getAttributeNS(null,"marker-mid");if(markerUrl&&markerUrl!==""){markerUrl=markerUrl.strip();markerUrl=markerUrl.replace(/^url\(#/,"");var markerMidId=this.getValidMarkerId(markerUrl);path.setAttributeNS(null,"marker-mid","url(#"+markerMidId+")");markersByThisPath.push(this._markers[markerMidId])}markerUrl=path.getAttributeNS(null,"marker-end");if(markerUrl&&markerUrl!==""){markerUrl=markerUrl.strip();var markerEndId=this.getValidMarkerId(markerUrl);path.setAttributeNS(null,"marker-end","url(#"+markerEndId+")");markersByThisPath.push(this._markers[markerEndId])}this._markersByPath[pathId]=markersByThisPath;var parser=new PathParser();var handler=new ORYX.Core.SVG.PointsPathHandler();
parser.setHandler(handler);parser.parsePath(path);if(handler.points.length<4){throw"Edge: Path has to have two or more points specified."}this._dockersByPath[pathId]=[];for(var i=0;i0){var docker=new ORYX.Core.Controls.Docker({eventHandlerCallback:this.eventHandlerCallback});docker.bounds.centerMoveTo(x,y);docker.bounds.registerCallback(this._dockerChangedCallback);this.add(docker,this.dockers.length);if(minPointX){minPointX=Math.min(x,minPointX);minPointY=Math.min(y,minPointY)}else{minPointX=x;minPointY=y}if(maxPointX){maxPointX=Math.max(x,maxPointX);maxPointY=Math.max(y,maxPointY)}else{maxPointX=x;maxPointY=y}}}isFirst=false}}).bind(this));this.bounds.set(minPointX,minPointY,maxPointX,maxPointY);if(false&&(this.bounds.width()===0||this.bounds.height()===0)){var width=this.bounds.width();var height=this.bounds.height();this.bounds.extend({x:width===0?2:0,y:height===0?2:0});this.bounds.moveBy({x:width===0?-1:0,y:height===0?-1:0})}this._oldBounds=this.bounds.clone();this._paths.reverse();var paths=[];this._paths.each((function(path){paths.push(this.node.childNodes[0].childNodes[0].childNodes[0].appendChild(path))}).bind(this));this._paths=paths;this._paths.each((function(path){var iPath=path.cloneNode(false);iPath.setAttributeNS(null,"id",undefined);iPath.setAttributeNS(null,"stroke-width",10);iPath.setAttributeNS(null,"visibility","hidden");iPath.setAttributeNS(null,"stroke-dasharray",null);iPath.setAttributeNS(null,"stroke","black");iPath.setAttributeNS(null,"fill","none");iPath.setAttributeNS(null,"title",this.getStencil().title());this._interactionPaths.push(this.node.childNodes[0].childNodes[0].childNodes[0].appendChild(iPath))}).bind(this));this._paths.reverse();this._interactionPaths.reverse();var textElems=svgDocument.getElementsByTagNameNS(ORYX.CONFIG.NAMESPACE_SVG,"text");$A(textElems).each((function(textElem){var label=new ORYX.Core.SVG.Label({textElement:textElem,shapeId:this.id});this.node.childNodes[0].childNodes[0].appendChild(label.node);this._labels[label.id]=label;label.registerOnChange(this.layout.bind(this))}).bind(this));this.propertiesChanged.each(function(pair){pair.value=true})},getValidMarkerId:function(markerUrl){if(markerUrl.indexOf('url("#')>=0){var rawId=markerUrl.replace(/^url\(\"#/,"").replace(/\"\)$/,"");return this.id+rawId}else{markerUrl=markerUrl.replace(/^url\(#/,"");return this.id.concat(markerUrl.replace(/\)$/,""))}},addMarkers:function(defs){this._markers.each(function(marker){if(!defs.ownerDocument.getElementById(marker.value.id)){marker.value.element=defs.appendChild(marker.value.element)}})},removeMarkers:function(){var svgElement=this.node.ownerSVGElement;if(svgElement){var defs=svgElement.getElementsByTagNameNS(NAMESPACE_SVG,"defs");if(defs.length>0){defs=defs[0];this._markers.each(function(marker){var foundMarker=defs.ownerDocument.getElementById(marker.value.id);if(foundMarker){marker.value.element=defs.removeChild(marker.value.element)}})}}},_dockerChanged:function(){this._dockerUpdated=true},serialize:function(){var result=arguments.callee.$.serialize.apply(this);var value="";this._dockersByPath.each((function(pair){pair.value.each(function(docker){var position=docker.getDockedShape()&&docker.referencePoint?docker.referencePoint:docker.bounds.center();value=value.concat(position.x+" "+position.y+" ")});value+=" # "}).bind(this));result.push({name:"dockers",prefix:"oryx",value:value,type:"literal"});var lastDocker=this.dockers.last();var target=lastDocker.getDockedShape();if(target){result.push({name:"target",prefix:"raziel",value:"#"+ERDF.__stripHashes(target.resourceId),type:"resource"})}try{var serializeEvent=this.getStencil().serialize();if(serializeEvent.type){serializeEvent.shape=this;serializeEvent.data=result;serializeEvent.result=undefined;serializeEvent.forceExecution=true;this._delegateEvent(serializeEvent);if(serializeEvent.result){result=serializeEvent.result}}}catch(e){}return result},deserialize:function(data){try{var deserializeEvent=this.getStencil().deserialize();if(deserializeEvent.type){deserializeEvent.shape=this;deserializeEvent.data=data;deserializeEvent.result=undefined;deserializeEvent.forceExecution=true;this._delegateEvent(deserializeEvent);if(deserializeEvent.result){data=deserializeEvent.result}}}catch(e){}var target=data.find(function(ser){return(ser.prefix+"-"+ser.name)=="raziel-target"});var targetShape;if(target){targetShape=this.getCanvas().getChildShapeByResourceId(target.value)}var outgoing=data.findAll(function(ser){return(ser.prefix+"-"+ser.name)=="raziel-outgoing"});outgoing.each((function(obj){if(!this.parent){return}var next=this.getCanvas().getChildShapeByResourceId(obj.value);if(next){if(next==targetShape){this.dockers.last().setDockedShape(next);this.dockers.last().setReferencePoint({x:next.bounds.width()/2,y:next.bounds.height()/2})}else{if(next instanceof ORYX.Core.Edge){next.dockers.first().setDockedShape(this)}}}}).bind(this));
var oryxDockers=data.find(function(obj){return(obj.prefix==="oryx"&&obj.name==="dockers")});if(oryxDockers){var dataByPath=oryxDockers.value.split("#").without("").without(" ");dataByPath.each((function(data,index){var values=data.replace(/,/g," ").split(" ").without("");if(values.length%2===0){var path=this._paths[index];if(path){if(index===0){while(this._dockersByPath[path.id].length>2){this.removeDocker(this._dockersByPath[path.id][1])}}else{while(this._dockersByPath[path.id].length>1){this.removeDocker(this._dockersByPath[path.id][0])}}var dockersByPath=this._dockersByPath[path.id];if(index===0){var x=parseFloat(values.shift());var y=parseFloat(values.shift());if(dockersByPath.first().getDockedShape()){dockersByPath.first().setReferencePoint({x:x,y:y})}else{dockersByPath.first().bounds.centerMoveTo(x,y)}}y=parseFloat(values.pop());x=parseFloat(values.pop());if(dockersByPath.last().getDockedShape()){dockersByPath.last().setReferencePoint({x:x,y:y})}else{dockersByPath.last().bounds.centerMoveTo(x,y)}for(var i=0;i'+serializedData:serializedData;return serializedData}catch(error){return -1}},openXMLWindow:function(content){var win=window.open("data:application/xml,"+encodeURIComponent(content),"_blank","resizable=yes,width=600,height=600,toolbar=0,scrollbars=yes")},openDownloadWindow:function(filename,content){var win=window.open("");if(win!=null){win.document.open();win.document.write("");var submitForm=win.document.createElement("form");win.document.body.appendChild(submitForm);var createHiddenElement=function(name,value){var newElement=document.createElement("input");newElement.name=name;newElement.type="hidden";newElement.value=value;return newElement};submitForm.appendChild(createHiddenElement("download",content));submitForm.appendChild(createHiddenElement("file",filename));submitForm.method="POST";win.document.write("");win.document.close();submitForm.action=ORYX.PATH+"/download";submitForm.submit()}},getSerializedDOM:function(){var serializedDOM=DataManager.serializeDOM(this.facade);serializedDOM=''+''+''+''+''+''+''+''+''+""+serializedDOM+"";
return serializedDOM},enableReadOnlyMode:function(){this.facade.disableEvent(ORYX.CONFIG.EVENT_MOUSEDOWN);this._stopSelectionChange=function(){if(this.facade.getSelection().length>0){this.facade.setSelection([])}};this.facade.registerOnEvent(ORYX.CONFIG.EVENT_SELECTION_CHANGED,this._stopSelectionChange.bind(this))},disableReadOnlyMode:function(){this.facade.enableEvent(ORYX.CONFIG.EVENT_MOUSEDOWN);if(this._stopSelectionChange){this.facade.unregisterOnEvent(ORYX.CONFIG.EVENT_SELECTION_CHANGED,this._stopSelectionChange.bind(this));this._stopSelectionChange=undefined}},getRDFFromDOM:function(){try{var xsl="";source=ORYX.PATH+"lib/extract-rdf.xsl";new Ajax.Request(source,{asynchronous:false,method:"get",onSuccess:function(transport){xsl=transport.responseText}.bind(this),onFailure:(function(transport){ORYX.Log.error("XSL load failed"+transport)}).bind(this)});var domParser=new DOMParser();var xmlObject=domParser.parseFromString(this.getSerializedDOM(),"text/xml");var xslObject=domParser.parseFromString(xsl,"text/xml");var xsltProcessor=new XSLTProcessor();xsltProcessor.importStylesheet(xslObject);var result=xsltProcessor.transformToFragment(xmlObject,document);var serializer=new XMLSerializer();return serializer.serializeToString(result)}catch(e){console.log("error serializing "+e);return""}},isStencilSetExtensionLoaded:function(stencilSetExtensionNamespace){return this.facade.getStencilSets().values().any(function(ss){return ss.extensions().keys().any(function(extensionKey){return extensionKey==stencilSetExtensionNamespace}.bind(this))}.bind(this))},doLayout:function(shapes){if(this.facade.raiseEvent){this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_LAYOUT,shapes:shapes})}else{this.facade.handleEvents({type:ORYX.CONFIG.EVENT_LAYOUT,shapes:shapes})}},layoutEdges:function(node,allEdges,offset){if(!this.facade.isExecutingCommands()){return}var Command=ORYX.Core.Command.extend({construct:function(edges,node,offset,plugin){this.edges=edges;this.node=node;this.plugin=plugin;this.offset=offset;var center=node.absoluteXY();this.ulo={x:center.x-offset.x,y:center.y-offset.y}},execute:function(){if(this.changes){this.executeAgain();return}else{this.changes=[];this.edges.each(function(edge){this.changes.push({edge:edge,oldDockerPositions:edge.dockers.map(function(r){return r.bounds.center()})})}.bind(this))}this.edges.findAll(function(r){return r.dockers.length>2}.bind(this)).each(function(edge){if(edge.dockers.first().getDockedShape()===this.node){var second=edge.dockers[1];if(this.align(second.bounds,edge.dockers.first())){second.update()}}else{if(edge.dockers.last().getDockedShape()===this.node){var beforeLast=edge.dockers[edge.dockers.length-2];if(this.align(beforeLast.bounds,edge.dockers.last())){beforeLast.update()}}}edge._update(true);edge.removeUnusedDockers();if(this.isBendPointIncluded(edge)){this.plugin.doLayout(edge);return}}.bind(this));this.edges.each(function(edge){if(edge.dockers.length==2){var p1=edge.dockers.first().getAbsoluteReferencePoint()||edge.dockers.first().bounds.center();var p2=edge.dockers.last().getAbsoluteReferencePoint()||edge.dockers.first().bounds.center();if(Math.abs(-Math.abs(p1.x-p2.x)+Math.abs(this.offset.x))<2||Math.abs(-Math.abs(p1.y-p2.y)+Math.abs(this.offset.y))<2){this.plugin.doLayout(edge)}}}.bind(this));this.edges.each(function(edge,i){this.changes[i].dockerPositions=edge.dockers.map(function(r){return r.bounds.center()})}.bind(this))},align:function(bounds,refDocker){var abRef=refDocker.getAbsoluteReferencePoint()||refDocker.bounds.center();var xdif=bounds.center().x-abRef.x;var ydif=bounds.center().y-abRef.y;if(Math.abs(-Math.abs(xdif)+Math.abs(this.offset.x))<3&&this.offset.xs===undefined){bounds.moveBy({x:-xdif,y:0})}if(Math.abs(-Math.abs(ydif)+Math.abs(this.offset.y))<3&&this.offset.ys===undefined){bounds.moveBy({y:-ydif,x:0})}if(this.offset.xs!==undefined||this.offset.ys!==undefined){var absPXY=refDocker.getDockedShape().absoluteXY();xdif=bounds.center().x-(absPXY.x+((abRef.x-absPXY.x)/this.offset.xs));ydif=bounds.center().y-(absPXY.y+((abRef.y-absPXY.y)/this.offset.ys));if(Math.abs(-Math.abs(xdif)+Math.abs(this.offset.x))<3){bounds.moveBy({x:-(bounds.center().x-abRef.x),y:0})}if(Math.abs(-Math.abs(ydif)+Math.abs(this.offset.y))<3){bounds.moveBy({y:-(bounds.center().y-abRef.y),x:0})}}},isBendPointIncluded:function(edge){var ab=edge.dockers.first().getDockedShape();var bb=edge.dockers.last().getDockedShape();if(ab){ab=ab.absoluteBounds();ab.widen(5)}if(bb){bb=bb.absoluteBounds();bb.widen(20)}return edge.dockers.any(function(docker,i){var c=docker.bounds.center();return i!=0&&i!=edge.dockers.length-1&&((ab&&ab.isIncluded(c))||(bb&&bb.isIncluded(c)))})},removeAllDocker:function(edge){edge.dockers.slice(1,edge.dockers.length-1).each(function(docker){edge.removeDocker(docker)})},executeAgain:function(){this.changes.each(function(change){this.removeAllDocker(change.edge);change.dockerPositions.each(function(pos,i){if(i==0||i==change.dockerPositions.length-1){return}var docker=change.edge.createDocker(undefined,pos);
docker.bounds.centerMoveTo(pos);docker.update()}.bind(this));change.edge._update(true)}.bind(this))},rollback:function(){this.changes.each(function(change){this.removeAllDocker(change.edge);change.oldDockerPositions.each(function(pos,i){if(i==0||i==change.oldDockerPositions.length-1){return}var docker=change.edge.createDocker(undefined,pos);docker.bounds.centerMoveTo(pos);docker.update()}.bind(this));change.edge._update(true)}.bind(this))}});this.facade.executeCommands([new Command(allEdges,node,offset,this)])}});if(!ORYX){var ORYX={}}if(!ORYX.Plugins){ORYX.Plugins={}}ORYX.Plugins.AbstractLayouter=ORYX.Plugins.AbstractPlugin.extend({layouted:[],construct:function(facade){arguments.callee.$.construct.apply(this,arguments);this.facade.registerOnEvent(ORYX.CONFIG.EVENT_LAYOUT,this._initLayout.bind(this))},isIncludedInLayout:function(shape){if(!(this.layouted instanceof Array)){this.layouted=[this.layouted].compact()}if(this.layouted.length<=0){return true}return this.layouted.any(function(s){if(typeof s=="string"){return shape.getStencil().id().include(s)}else{return shape instanceof s}})},_initLayout:function(event){var shapes=[event.shapes].flatten().compact();var toLayout=shapes.findAll(function(shape){return this.isIncludedInLayout(shape)}.bind(this));if(toLayout.length>0){this.layout(toLayout)}},layout:function(shapes){throw new Error("Layouter has to implement the layout function.")}});if(!ORYX.Plugins){ORYX.Plugins=new Object()}ORYX.Plugins.Edit=Clazz.extend({construct:function(facade){this.facade=facade;this.clipboard=new ORYX.Plugins.Edit.ClipBoard();this.facade.offer({name:ORYX.I18N.Edit.cut,description:ORYX.I18N.Edit.cutDesc,icon:ORYX.PATH+"images/cut.png",keyCodes:[{metaKeys:[ORYX.CONFIG.META_KEY_META_CTRL],keyCode:88,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.callEdit.bind(this,this.editCut),group:ORYX.I18N.Edit.group,index:1,minShape:1});this.facade.offer({name:ORYX.I18N.Edit.copy,description:ORYX.I18N.Edit.copyDesc,icon:ORYX.PATH+"images/page_copy.png",keyCodes:[{metaKeys:[ORYX.CONFIG.META_KEY_META_CTRL],keyCode:67,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.callEdit.bind(this,this.editCopy,[true,false]),group:ORYX.I18N.Edit.group,index:2,minShape:1});this.facade.offer({name:ORYX.I18N.Edit.paste,description:ORYX.I18N.Edit.pasteDesc,icon:ORYX.PATH+"images/page_paste.png",keyCodes:[{metaKeys:[ORYX.CONFIG.META_KEY_META_CTRL],keyCode:86,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.callEdit.bind(this,this.editPaste),isEnabled:this.clipboard.isOccupied.bind(this.clipboard),group:ORYX.I18N.Edit.group,index:3,minShape:0,maxShape:0});this.facade.offer({name:ORYX.I18N.Edit.del,description:ORYX.I18N.Edit.delDesc,icon:ORYX.PATH+"images/cross.png",keyCodes:[{metaKeys:[ORYX.CONFIG.META_KEY_META_CTRL],keyCode:8,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN},{keyCode:46,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.callEdit.bind(this,this.editDelete),group:ORYX.I18N.Edit.group,index:4,minShape:1})},callEdit:function(fn,args){window.setTimeout(function(){fn.apply(this,(args instanceof Array?args:[]))}.bind(this),1)},handleMouseDown:function(event){if(this._controlPressed){this._controlPressed=false;this.editCopy();this.editPaste();event.forceExecution=true;this.facade.raiseEvent(event,this.clipboard.shapesAsJson)}},getAllShapesToConsider:function(shapes){var shapesToConsider=[];var childShapesToConsider=[];shapes.each(function(shape){isChildShapeOfAnother=shapes.any(function(s2){return s2.hasChildShape(shape)});if(isChildShapeOfAnother){return}shapesToConsider.push(shape);if(shape instanceof ORYX.Core.Node){var attached=shape.getOutgoingNodes();attached=attached.findAll(function(a){return !shapes.include(a)});shapesToConsider=shapesToConsider.concat(attached)}childShapesToConsider=childShapesToConsider.concat(shape.getChildShapes(true))}.bind(this));var edgesToConsider=this.facade.getCanvas().getChildEdges().select(function(edge){if(shapesToConsider.include(edge)){return false}if(edge.getAllDockedShapes().size()===0){return false}return edge.getAllDockedShapes().all(function(shape){return shape instanceof ORYX.Core.Edge||childShapesToConsider.include(shape)})});shapesToConsider=shapesToConsider.concat(edgesToConsider);return shapesToConsider},editCut:function(){this.editCopy(false,true);this.editDelete(true);return false},editCopy:function(will_update,useNoOffset){var selection=this.facade.getSelection();if(selection.length==0){return}this.clipboard.refresh(selection,this.getAllShapesToConsider(selection),this.facade.getCanvas().getStencil().stencilSet().namespace(),useNoOffset);if(will_update){this.facade.updateSelection()}},editPaste:function(){var canvas={childShapes:this.clipboard.shapesAsJson,stencilset:{namespace:this.clipboard.SSnamespace}};jQuery.extend(canvas,ORYX.Core.AbstractShape.JSONHelper);var childShapeResourceIds=canvas.getChildShapes(true).pluck("resourceId");var outgoings={};var htPlugins=this.facade.getLoadedPluginByName("ORYX.Plugins.HtPlugins");
canvas.eachChild(function(shape,parent){if(shape.stencil&&shape.stencil.id&&shape.properties){var max=htPlugins.getMaxNumberOfType(shape.stencil.id);if(shape.properties.overrideid){shape.properties.overrideid=shape.properties.overrideid.replace(/^(.*)\d+$/,"$1"+max)}if(shape.properties.name){shape.properties.name=shape.properties.name.replace(/^(.*)\d+$/,"$1"+max)}}shape.outgoing=shape.outgoing.select(function(out){return childShapeResourceIds.include(out.resourceId)});shape.outgoing.each(function(out){if(!outgoings[out.resourceId]){outgoings[out.resourceId]=[]}outgoings[out.resourceId].push(shape)});return shape}.bind(this),true,true);canvas.eachChild(function(shape,parent){if(shape.target&&!(childShapeResourceIds.include(shape.target.resourceId))){shape.target=undefined;shape.targetRemoved=true}if(shape.dockers&&shape.dockers.length>=1&&shape.dockers[0].getDocker&&((shape.dockers[0].getDocker().getDockedShape()&&!childShapeResourceIds.include(shape.dockers[0].getDocker().getDockedShape().resourceId))||!shape.getShape().dockers[0].getDockedShape()&&!outgoings[shape.resourceId])){shape.sourceRemoved=true}return shape}.bind(this),true,true);canvas.eachChild(function(shape,parent){if(this.clipboard.useOffset){shape.bounds={lowerRight:{x:shape.bounds.lowerRight.x+ORYX.CONFIG.COPY_MOVE_OFFSET,y:shape.bounds.lowerRight.y+ORYX.CONFIG.COPY_MOVE_OFFSET},upperLeft:{x:shape.bounds.upperLeft.x+ORYX.CONFIG.COPY_MOVE_OFFSET,y:shape.bounds.upperLeft.y+ORYX.CONFIG.COPY_MOVE_OFFSET}}}if(shape.dockers){shape.dockers=shape.dockers.map(function(docker,i){if((shape.targetRemoved===true&&i==shape.dockers.length-1&&docker.getDocker)||(shape.sourceRemoved===true&&i==0&&docker.getDocker)){docker=docker.getDocker().bounds.center()}if((i==0&&docker.getDocker instanceof Function&&shape.sourceRemoved!==true&&(docker.getDocker().getDockedShape()||((outgoings[shape.resourceId]||[]).length>0&&(!(shape.getShape() instanceof ORYX.Core.Node)||outgoings[shape.resourceId][0].getShape() instanceof ORYX.Core.Node))))||(i==shape.dockers.length-1&&docker.getDocker instanceof Function&&shape.targetRemoved!==true&&(docker.getDocker().getDockedShape()||shape.target))){return{x:docker.x,y:docker.y,getDocker:docker.getDocker}}else{if(this.clipboard.useOffset){return{x:docker.x+ORYX.CONFIG.COPY_MOVE_OFFSET,y:docker.y+ORYX.CONFIG.COPY_MOVE_OFFSET,getDocker:docker.getDocker}}else{return{x:docker.x,y:docker.y,getDocker:docker.getDocker}}}}.bind(this))}else{if(shape.getShape() instanceof ORYX.Core.Node&&shape.dockers&&shape.dockers.length>0&&(!shape.dockers.first().getDocker||shape.sourceRemoved===true||!(shape.dockers.first().getDocker().getDockedShape()||outgoings[shape.resourceId]))){shape.dockers=shape.dockers.map(function(docker,i){if((shape.sourceRemoved===true&&i==0&&docker.getDocker)){docker=docker.getDocker().bounds.center()}if(this.clipboard.useOffset){return{x:docker.x+ORYX.CONFIG.COPY_MOVE_OFFSET,y:docker.y+ORYX.CONFIG.COPY_MOVE_OFFSET,getDocker:docker.getDocker}}else{return{x:docker.x,y:docker.y,getDocker:docker.getDocker}}}.bind(this))}}return shape}.bind(this),false,true);this.clipboard.useOffset=true;this.facade.importJSON(canvas)},editDelete:function(){var selection=this.facade.getSelection();var clipboard=new ORYX.Plugins.Edit.ClipBoard();clipboard.refresh(selection,this.getAllShapesToConsider(selection));var command=new ORYX.Plugins.Edit.DeleteCommand(clipboard,this.facade);this.facade.executeCommands([command])}});ORYX.Plugins.Edit.ClipBoard=Clazz.extend({construct:function(){this.shapesAsJson=[];this.selection=[];this.SSnamespace="";this.useOffset=true},isOccupied:function(){return this.shapesAsJson.length>0},refresh:function(selection,shapes,namespace,useNoOffset){this.selection=selection;this.SSnamespace=namespace;this.outgoings={};this.parents={};this.targets={};this.useOffset=useNoOffset!==true;this.shapesAsJson=shapes.map(function(shape){var s=shape.toJSON();s.parent={resourceId:shape.getParentShape().resourceId};s.parentIndex=shape.getParentShape().getChildShapes().indexOf(shape);return s})}});ORYX.Plugins.Edit.DeleteCommand=ORYX.Core.Command.extend({construct:function(clipboard,facade){this.clipboard=clipboard;this.shapesAsJson=clipboard.shapesAsJson;this.facade=facade;this.dockers=this.shapesAsJson.map(function(shapeAsJson){var shape=shapeAsJson.getShape();var incomingDockers=shape.getIncomingShapes().map(function(s){return s.getDockers().last()});var outgoingDockers=shape.getOutgoingShapes().map(function(s){return s.getDockers().first()});var dockers=shape.getDockers().concat(incomingDockers,outgoingDockers).compact().map(function(docker){return{object:docker,referencePoint:docker.referencePoint,dockedShape:docker.getDockedShape()}});return dockers}).flatten()},execute:function(){this.shapesAsJson.each(function(shapeAsJson){this.facade.deleteShape(shapeAsJson.getShape())}.bind(this));this.facade.setSelection([]);this.facade.getCanvas().update();this.facade.updateSelection()},rollback:function(){this.shapesAsJson.each(function(shapeAsJson){var shape=shapeAsJson.getShape();
var parent=this.facade.getCanvas().getChildShapeByResourceId(shapeAsJson.parent.resourceId)||this.facade.getCanvas();parent.add(shape,shape.parentIndex)}.bind(this));this.dockers.each(function(d){d.object.setDockedShape(d.dockedShape);d.object.setReferencePoint(d.referencePoint)}.bind(this));this.facade.setSelection(this.selectedShapes);this.facade.getCanvas().update();this.facade.updateSelection()}});if(!ORYX.Plugins){ORYX.Plugins=new Object()}ORYX.Plugins.View={facade:undefined,construct:function(facade,ownPluginData){this.facade=facade;this.zoomLevel=1;this.maxFitToScreenLevel=1.5;this.minZoomLevel=0.1;this.maxZoomLevel=2.5;this.diff=5;if(ownPluginData!==undefined&&ownPluginData!==null){ownPluginData.properties.each(function(property){if(property.zoomLevel){this.zoomLevel=Number(1)}if(property.maxFitToScreenLevel){this.maxFitToScreenLevel=Number(property.maxFitToScreenLevel)}if(property.minZoomLevel){this.minZoomLevel=Number(property.minZoomLevel)}if(property.maxZoomLevel){this.maxZoomLevel=Number(property.maxZoomLevel)}}.bind(this))}this.facade.offer({"name":ORYX.I18N.View.zoomIn,"functionality":this.zoom.bind(this,[1+ORYX.CONFIG.ZOOM_OFFSET]),"group":ORYX.I18N.View.group,"icon":ORYX.PATH+"images/magnifier_zoom_in.png","description":ORYX.I18N.View.zoomInDesc,"index":1,"minShape":0,"maxShape":0,"isEnabled":function(){return this.zoomLevel20?offsetTop-20:0;canvas.node.parentNode.parentNode.style.marginTop=offsetTop+"px";offsetTop+=5;canvas.getHTMLContainer().style.top=offsetTop+"px";var newScrollTop=scrollNode.scrollTop-Math.round((canvas.getHTMLContainer().parentNode.getHeight()-newHeight)/2)+this.diff;var newScrollLeft=scrollNode.scrollLeft-Math.round((canvas.getHTMLContainer().parentNode.getWidth()-newWidth)/2)+this.diff;canvas.setSize({width:newWidth,height:newHeight},true);canvas.node.setAttributeNS(null,"transform","scale("+this.zoomLevel+")");this.facade.updateSelection();scrollNode.scrollTop=newScrollTop;scrollNode.scrollLeft=newScrollLeft;canvas.zoomLevel=this.zoomLevel},zoomFitToModel:function(){var scrollNode=this.facade.getCanvas().getHTMLContainer().parentNode.parentNode;var visibleHeight=scrollNode.getHeight()-30;var visibleWidth=scrollNode.getWidth()-30;var nodes=this.facade.getCanvas().getChildShapes();if(!nodes||nodes.length<1){return false}var bounds=nodes[0].absoluteBounds().clone();nodes.each(function(node){bounds.include(node.absoluteBounds().clone())});var scaleFactorWidth=visibleWidth/bounds.width();var scaleFactorHeight=visibleHeight/bounds.height();var zoomFactor=scaleFactorHeightthis.maxFitToScreenLevel){zoomFactor=this.maxFitToScreenLevel}this.setAFixZoomLevel(zoomFactor);scrollNode.scrollTop=Math.round(bounds.upperLeft().y*this.zoomLevel)-5;scrollNode.scrollLeft=Math.round(bounds.upperLeft().x*this.zoomLevel)-5},_checkSize:function(){var canvasParent=this.facade.getCanvas().getHTMLContainer().parentNode;var minForCanvas=Math.min((canvasParent.parentNode.getWidth()/canvasParent.getWidth()),(canvasParent.parentNode.getHeight()/canvasParent.getHeight()));return 1.05>minForCanvas},_checkZoomLevelRange:function(){if(this.zoomLevelthis.maxZoomLevel){this.zoomLevel=this.maxZoomLevel}}};ORYX.Plugins.View=Clazz.extend(ORYX.Plugins.View);if(!Signavio){var Signavio={}}if(!Signavio.Core){Signavio.Core={}}Signavio.Core.Version="1.0";if(!Signavio){var Signavio=new Object()}if(!Signavio.Plugins){Signavio.Plugins=new Object()}if(!Signavio.Plugins.Utils){Signavio.Plugins.Utils=new Object()
}if(!Signavio.Helper){Signavio.Helper=new Object()}new function(){ORYX.Editor.provideId=function(){var res=[],hex="0123456789ABCDEF";for(var i=0;i<36;i++){res[i]=Math.floor(Math.random()*16)}res[14]=4;res[19]=(res[19]&3)|8;for(var i=0;i<36;i++){res[i]=hex[res[i]]}res[8]=res[13]=res[18]=res[23]="-";return"sid-"+res.join("")}}();if(!ORYX.Plugins){ORYX.Plugins=new Object()}ORYX.Plugins.Loading={construct:function(facade){this.facade=facade;this.node=ORYX.Editor.graft("http://www.w3.org/1999/xhtml",this.facade.getCanvas().getHTMLContainer().parentNode,["div",{"class":"LoadingIndicator"},""]);this.facade.registerOnEvent(ORYX.CONFIG.EVENT_LOADING_ENABLE,this.enableLoading.bind(this));this.facade.registerOnEvent(ORYX.CONFIG.EVENT_LOADING_DISABLE,this.disableLoading.bind(this));this.facade.registerOnEvent(ORYX.CONFIG.EVENT_LOADING_STATUS,this.showStatus.bind(this));this.disableLoading()},enableLoading:function(options){if(options.text){this.node.innerHTML=options.text+"..."}else{this.node.innerHTML=ORYX.I18N.Loading.waiting}this.node.removeClassName("StatusIndicator");this.node.addClassName("LoadingIndicator");this.node.style.display="block";var pos=this.facade.getCanvas().rootNode.parentNode.parentNode.parentNode.parentNode;this.node.style.top=pos.offsetTop+"px";this.node.style.left=pos.offsetLeft+"px"},disableLoading:function(){this.node.style.display="none"},showStatus:function(options){if(options.text){this.node.innerHTML=options.text;this.node.addClassName("StatusIndicator");this.node.removeClassName("LoadingIndicator");this.node.style.display="block";var pos=this.facade.getCanvas().rootNode.parentNode.parentNode.parentNode.parentNode;this.node.style.top=pos.offsetTop+"px";this.node.style.left=pos.offsetLeft+"px";var tout=options.timeout?options.timeout:2000;window.setTimeout((function(){this.disableLoading()}).bind(this),tout)}}};ORYX.Plugins.Loading=Clazz.extend(ORYX.Plugins.Loading);if(!ORYX.Plugins){ORYX.Plugins=new Object()}ORYX.Plugins.CanvasResize=Clazz.extend({construct:function(facade){this.facade=facade;new ORYX.Plugins.CanvasResizeButton(this.facade.getCanvas(),"N",this.resize.bind(this));new ORYX.Plugins.CanvasResizeButton(this.facade.getCanvas(),"W",this.resize.bind(this));new ORYX.Plugins.CanvasResizeButton(this.facade.getCanvas(),"E",this.resize.bind(this));new ORYX.Plugins.CanvasResizeButton(this.facade.getCanvas(),"S",this.resize.bind(this));window.setTimeout(function(){jQuery(window).trigger("resize")})},resize:function(position,shrink){resizeCanvas=function(position,extentionSize,facade){var canvas=facade.getCanvas();var b=canvas.bounds;var scrollNode=facade.getCanvas().getHTMLContainer().parentNode.parentNode;if(position=="E"||position=="W"){canvas.setSize({width:(b.width()+extentionSize)*canvas.zoomLevel,height:(b.height())*canvas.zoomLevel})}else{if(position=="S"||position=="N"){canvas.setSize({width:(b.width())*canvas.zoomLevel,height:(b.height()+extentionSize)*canvas.zoomLevel})}}if(position=="N"||position=="W"){var move=position=="N"?{x:0,y:extentionSize}:{x:extentionSize,y:0};canvas.getChildNodes(false,function(shape){shape.bounds.moveBy(move)});var edges=canvas.getChildEdges().findAll(function(edge){return edge.getAllDockedShapes().length>0});var dockers=edges.collect(function(edge){return edge.dockers.findAll(function(docker){return !docker.getDockedShape()})}).flatten();dockers.each(function(docker){docker.bounds.moveBy(move)})}else{if(position=="S"){scrollNode.scrollTop+=extentionSize}else{if(position=="E"){scrollNode.scrollLeft+=extentionSize}}}jQuery(window).trigger("resize");canvas.update();facade.updateSelection()};var commandClass=ORYX.Core.Command.extend({construct:function(position,extentionSize,facade){this.position=position;this.extentionSize=extentionSize;this.facade=facade},execute:function(){resizeCanvas(this.position,this.extentionSize,this.facade)},rollback:function(){resizeCanvas(this.position,-this.extentionSize,this.facade)},update:function(){}});var extentionSize=ORYX.CONFIG.CANVAS_RESIZE_INTERVAL;if(shrink){extentionSize=-extentionSize}var command=new commandClass(position,extentionSize,this.facade);this.facade.executeCommands([command])}});ORYX.Plugins.CanvasResizeButton=Clazz.extend({construct:function(canvas,position,callback){this.canvas=canvas;var parentNode=canvas.getHTMLContainer().parentNode;window.myParent=parentNode;var actualScrollNode=jQuery("#canvasSection")[0];var scrollNode=actualScrollNode;var canvasNode=jQuery("#canvasSection").find(".ORYX_Editor")[0];var svgRootNode=canvasNode.children[0];var iconClass="glyphicon glyphicon-chevron-";var iconClassShrink="glyphicon glyphicon-chevron-";if(position=="N"){iconClass+="up";iconClassShrink+="down"}else{if(position=="S"){iconClass+="down";iconClassShrink+="up"}else{if(position=="E"){iconClass+="right";iconClassShrink+="left"}else{if(position=="W"){iconClass+="left";iconClassShrink+="right"}}}}var idGrow="canvas-shrink-"+position;var idShrink="canvas-grow-"+position;var buttonGrow=ORYX.Editor.graft("http://www.w3.org/1999/xhtml",parentNode,["div",{"class":"canvas_resize_indicator canvas_resize_indicator_grow"+" "+position,"id":idGrow,"title":ORYX.I18N.RESIZE.tipGrow+ORYX.I18N.RESIZE[position]},["i",{"class":iconClass}]]);
var buttonShrink=ORYX.Editor.graft("http://www.w3.org/1999/xhtml",parentNode,["div",{"class":"canvas_resize_indicator canvas_resize_indicator_shrink"+" "+position,"id":idShrink,"title":ORYX.I18N.RESIZE.tipShrink+ORYX.I18N.RESIZE[position]},["i",{"class":iconClassShrink}]]);var offSetWidth=60;var isOverOffset=function(event){var isOverButton=event.target.id.indexOf("canvas-shrink")!=-1||event.target.id.indexOf("canvas-grow")!=-1||event.target.parentNode.id.indexOf("canvas-shrink")!=-1||event.target.parentNode.id.indexOf("canvas-grow")!=-1;if(isOverButton){if(event.target.id==idGrow||event.target.id==idShrink||event.target.parentNode.id==idGrow||event.target.parentNode.id==idShrink){return true}else{return false}}if(event.target!=parentNode&&event.target!=scrollNode&&event.target!=scrollNode.firstChild&&event.target!=svgRootNode&&event.target!=scrollNode){return false}var X=event.offsetX!==undefined?event.offsetX:event.layerX;var Y=event.offsetY!==undefined?event.offsetY:event.layerY;var canvasOffset=0;if(canvasNode.clientWidthORYX.CONFIG.CANVAS_MIN_HEIGHT)){buttonShrink.show()}else{if(position=="E"&&(w-ORYX.CONFIG.CANVAS_RESIZE_INTERVAL>ORYX.CONFIG.CANVAS_MIN_WIDTH)){buttonShrink.show()}else{if(position=="S"&&(h-ORYX.CONFIG.CANVAS_RESIZE_INTERVAL>ORYX.CONFIG.CANVAS_MIN_HEIGHT)){buttonShrink.show()}else{if(position=="W"&&(w-ORYX.CONFIG.CANVAS_RESIZE_INTERVAL>ORYX.CONFIG.CANVAS_MIN_WIDTH)){buttonShrink.show()}else{buttonShrink.hide()}}}}}).bind(this);var hideButtons=function(){buttonGrow.hide();buttonShrink.hide()};parentNode.parentNode.addEventListener(ORYX.CONFIG.EVENT_MOUSEMOVE,function(event){if(isOverOffset(event)){showButtons()}else{hideButtons()}},false);buttonGrow.addEventListener(ORYX.CONFIG.EVENT_MOUSEOVER,function(event){showButtons()},true);buttonShrink.addEventListener(ORYX.CONFIG.EVENT_MOUSEOVER,function(event){showButtons()},true);parentNode.parentNode.addEventListener(ORYX.CONFIG.EVENT_MOUSEOUT,function(event){hideButtons()},true);hideButtons();buttonGrow.addEventListener("click",function(){callback(position);showButtons()},true);buttonShrink.addEventListener("click",function(){callback(position,true);showButtons()},true)}});if(!ORYX.Plugins){ORYX.Plugins=new Object()}ORYX.Plugins.RenameShapes=Clazz.extend({facade:undefined,construct:function(facade){this.facade=facade;this.facade.registerOnEvent(ORYX.CONFIG.EVENT_CANVAS_SCROLL,this.hideField.bind(this));this.facade.registerOnEvent(ORYX.CONFIG.EVENT_DBLCLICK,this.actOnDBLClick.bind(this));this.facade.offer({keyCodes:[{keyCode:113,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.renamePerF2.bind(this)});document.documentElement.addEventListener(ORYX.CONFIG.EVENT_MOUSEDOWN,this.hide.bind(this),true)},renamePerF2:function(){var selectedShapes=this.facade.getSelection();this.actOnDBLClick(undefined,selectedShapes.first())},actOnDBLClick:function(evt,shape){if(!(shape instanceof ORYX.Core.Shape)){return}this.destroy();var props=shape.getStencil().properties().findAll(function(item){return(item.refToView()&&item.refToView().length>0&&item.directlyEditable())});props=props.findAll(function(item){return !item.readonly()&&(item.type()==ORYX.CONFIG.TYPE_STRING||item.type()==ORYX.CONFIG.TYPE_EXPRESSION||item.type()==ORYX.CONFIG.TYPE_DATASOURCE)});var allRefToViews=props.collect(function(prop){return prop.refToView()}).flatten().compact();var labels=shape.getLabels().findAll(function(label){return allRefToViews.any(function(toView){return label.id.endsWith(toView)})});if(labels.length==0){return}var nearestLabel=labels.length<=1?labels[0]:null;if(!nearestLabel){nearestLabel=labels.find(function(label){return label.node==evt.target||label.node==evt.target.parentNode});if(!nearestLabel){var evtCoord=this.facade.eventCoordinates(evt);var additionalIEZoom=1;if(!isNaN(screen.logicalXDPI)&&!isNaN(screen.systemXDPI)){var ua=navigator.userAgent;if(ua.indexOf("MSIE")>=0){var zoom=Math.round((screen.deviceXDPI/screen.logicalXDPI)*100);if(zoom!==100){additionalIEZoom=zoom/100}}}if(additionalIEZoom!==1){evtCoord.x=evtCoord.x/additionalIEZoom;evtCoord.y=evtCoord.y/additionalIEZoom}evtCoord.y+=$("editor-header").clientHeight-$("canvasSection").scrollTop-5;if(KISBPM.HEADER_CONFIG.showAppTitle==false){evtCoord.y+=61}evtCoord.x-=$("canvasSection").scrollLeft;var trans=this.facade.getCanvas().rootNode.lastChild.getScreenCTM();evtCoord.x*=trans.a;evtCoord.y*=trans.d;
var diff=labels.collect(function(label){var center=this.getCenterPosition(evt);var len=Math.sqrt(Math.pow(center.x-evtCoord.x,2)+Math.pow(center.y-evtCoord.y,2));return{diff:len,label:label}}.bind(this));diff.sort(function(a,b){return a.diff>b.diff});nearestLabel=diff[0].label}}var prop=props.find(function(item){return item.refToView().any(function(toView){return nearestLabel.id==shape.id+toView})});var width=Math.min(Math.max(100,shape.bounds.width()),200);var center=this.getCenterPosition(evt);center.x-=(width/2);var propId=prop.prefix()+"-"+prop.id();var textInput=document.createElement("textarea");textInput.id="shapeTextInput";textInput.style.position="absolute";textInput.style.width=width+"px";textInput.style.left=(center.x<10)?10:center.x+"px";textInput.style.top=(center.y-15)+"px";textInput.className="x-form-textarea x-form-field x_form_text_set_absolute";textInput.value=shape.properties[propId];this.oldValueText=shape.properties[propId];document.getElementById("canvasSection").appendChild(textInput);this.shownTextField=textInput;this.updateValueFunction=function(newValue,oldValue){var currentEl=shape;var facade=this.facade;if(oldValue!=newValue){var commandClass=ORYX.Core.Command.extend({construct:function(){this.el=currentEl;this.propId=propId;this.oldValue=oldValue;this.newValue=newValue;this.facade=facade},execute:function(){this.el.setProperty(this.propId,this.newValue);this.facade.setSelection([this.el]);this.facade.getCanvas().update();this.facade.updateSelection()},rollback:function(){this.el.setProperty(this.propId,this.oldValue);this.facade.setSelection([this.el]);this.facade.getCanvas().update();this.facade.updateSelection()}});var command=new commandClass();this.facade.executeCommands([command]);this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_SELECTION_CHANGED,elements:[shape],force:true,triggerByRaise:true})}}.bind(this);jQuery("#shapeTextInput").focus();jQuery("#shapeTextInput").autogrow();this.facade.disableEvent(ORYX.CONFIG.EVENT_KEYDOWN)},getCenterPosition:function(event){if(!event){return{x:0,y:0}}var offset=jQuery("#canvasSection").parent().offset();return{x:event.clientX-offset.left-60,y:event.clientY-offset.top-5}},hide:function(e){if(this.shownTextField&&(!e||e.target!==this.shownTextField)){var newValue=this.shownTextField.value;if(newValue!==this.oldValueText){this.updateValueFunction(newValue,this.oldValueText)}this.destroy()}},hideField:function(e){if(this.shownTextField){this.destroy()}},destroy:function(e){var textInputComp=jQuery("#shapeTextInput");if(textInputComp){textInputComp.remove();delete this.shownTextField;this.facade.enableEvent(ORYX.CONFIG.EVENT_KEYDOWN)}}});if(!ORYX.Plugins){ORYX.Plugins=new Object()}ORYX.Plugins.ProcessLink=Clazz.extend({facade:undefined,construct:function(facade){this.facade=facade;this.facade.registerOnEvent(ORYX.CONFIG.EVENT_PROPERTY_CHANGED,this.propertyChanged.bind(this))},propertyChanged:function(option,node){if(option.name!=="oryx-refuri"||!node instanceof ORYX.Core.Node){return}if(option.value&&option.value.length>0&&option.value!="undefined"){this.show(node,option.value)}else{this.hide(node)}},show:function(shape,url){var link=ORYX.Editor.graft("http://www.w3.org/2000/svg",null,["a",{"target":"_blank"},["path",{"stroke-width":1,"stroke":"#00DD00","fill":"#00AA00","d":"M3,3 l0,-2.5 l7.5,0 l0,-2.5 l7.5,4.5 l-7.5,3.5 l0,-2.5 l-8,0","line-captions":"round"}]]);var link=ORYX.Editor.graft("http://www.w3.org/2000/svg",null,["a",{"target":"_blank"},["path",{"style":"fill:#92BFFC;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-width:0.72","d":"M0 1.44 L0 15.05 L11.91 15.05 L11.91 5.98 L7.37 1.44 L0 1.44 Z"}],["path",{"style":"stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-width:0.72;fill:none;","transform":"translate(7.5, -8.5)","d":"M0 10.51 L0 15.05 L4.54 15.05"}],["path",{"style":"fill:#f28226;stroke:#000000;stroke-linecap:round;stroke-linejoin:round;stroke-width:0.72","transform":"translate(-3, -1)","d":"M0 8.81 L0 13.06 L5.95 13.06 L5.95 15.05 A50.2313 50.2313 -175.57 0 0 10.77 11.08 A49.9128 49.9128 -1.28 0 0 5.95 6.54 L5.95 8.81 L0 8.81 Z"}],]);link.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",url);this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_OVERLAY_SHOW,id:"arissupport.urlref_"+shape.id,shapes:[shape],node:link,nodePosition:"SE"})},hide:function(shape){this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_OVERLAY_HIDE,id:"arissupport.urlref_"+shape.id})}});Array.prototype.insertFrom=function(from,to){to=Math.max(0,to);from=Math.min(Math.max(0,from),this.length-1);var el=this[from];var old=this.without(el);var newA=old.slice(0,to);newA.push(el);if(old.length>to){newA=newA.concat(old.slice(to))}return newA};if(!ORYX.Plugins){ORYX.Plugins=new Object()}ORYX.Plugins.Arrangement=ORYX.Plugins.AbstractPlugin.extend({facade:undefined,construct:function(facade){this.facade=facade;this.facade.offer({"name":ORYX.I18N.Arrangement.am,"functionality":this.alignShapes.bind(this,[ORYX.CONFIG.EDITOR_ALIGN_MIDDLE]),"group":ORYX.I18N.Arrangement.groupA,"icon":ORYX.PATH+"images/shape_align_middle.png","description":ORYX.I18N.Arrangement.amDesc,"index":1,"minShape":2});
this.facade.offer({"name":ORYX.I18N.Arrangement.ac,"functionality":this.alignShapes.bind(this,[ORYX.CONFIG.EDITOR_ALIGN_CENTER]),"group":ORYX.I18N.Arrangement.groupA,"icon":ORYX.PATH+"images/shape_align_center.png","description":ORYX.I18N.Arrangement.acDesc,"index":2,"minShape":2});this.facade.offer({"name":ORYX.I18N.Arrangement.as,"functionality":this.alignShapes.bind(this,[ORYX.CONFIG.EDITOR_ALIGN_SIZE]),"group":ORYX.I18N.Arrangement.groupA,"icon":ORYX.PATH+"images/shape_align_size.png","description":ORYX.I18N.Arrangement.asDesc,"index":3,"minShape":2});this.facade.registerOnEvent(ORYX.CONFIG.EVENT_ARRANGEMENT_TOP,this.setZLevel.bind(this,this.setToTop));this.facade.registerOnEvent(ORYX.CONFIG.EVENT_ARRANGEMENT_BACK,this.setZLevel.bind(this,this.setToBack));this.facade.registerOnEvent(ORYX.CONFIG.EVENT_ARRANGEMENT_FORWARD,this.setZLevel.bind(this,this.setForward));this.facade.registerOnEvent(ORYX.CONFIG.EVENT_ARRANGEMENT_BACKWARD,this.setZLevel.bind(this,this.setBackward))},onSelectionChanged:function(elemnt){var selection=this.facade.getSelection();if(selection.length===1&&selection[0] instanceof ORYX.Core.Edge){this.setToTop(selection)}},setZLevel:function(callback,event){var zLevelCommand=ORYX.Core.Command.extend({construct:function(callback,elements,facade){this.callback=callback;this.elements=elements;this.elAndIndex=elements.map(function(el){return{el:el,previous:el.parent.children[el.parent.children.indexOf(el)-1]}});this.facade=facade},execute:function(){this.callback(this.elements);this.facade.setSelection(this.elements)},rollback:function(){var sortedEl=this.elAndIndex.sortBy(function(el){var value=el.el;var t=$A(value.node.parentNode.childNodes);return t.indexOf(value.node)});for(var i=0;imaxSize.width){newBounds.a.x=shape.bounds.upperLeft().x-(maxSize.width-shape.bounds.width())/2;newBounds.b.x=shape.bounds.lowerRight().x+(maxSize.width-shape.bounds.width())/2}if(this.maxHeight>maxSize.height){newBounds.a.y=shape.bounds.upperLeft().y-(maxSize.height-shape.bounds.height())/2;newBounds.b.y=shape.bounds.lowerRight().y+(maxSize.height-shape.bounds.height())/2}shape.bounds.set(newBounds)},execute:function(){this.elements.each(function(shape,index){this.orgPos[index]=shape.bounds.upperLeft();var relBounds=this.bounds.clone();var newCoordinates;if(shape.parent&&!(shape.parent instanceof ORYX.Core.Canvas)){var upL=shape.parent.absoluteBounds().upperLeft();relBounds.moveBy(-upL.x,-upL.y)}switch(this.way){case ORYX.CONFIG.EDITOR_ALIGN_BOTTOM:newCoordinates={x:shape.bounds.upperLeft().x,y:relBounds.b.y-shape.bounds.height()};break;case ORYX.CONFIG.EDITOR_ALIGN_MIDDLE:newCoordinates={x:shape.bounds.upperLeft().x,y:(relBounds.a.y+relBounds.b.y-shape.bounds.height())/2};break;case ORYX.CONFIG.EDITOR_ALIGN_TOP:newCoordinates={x:shape.bounds.upperLeft().x,y:relBounds.a.y};break;case ORYX.CONFIG.EDITOR_ALIGN_LEFT:newCoordinates={x:relBounds.a.x,y:shape.bounds.upperLeft().y};break;case ORYX.CONFIG.EDITOR_ALIGN_CENTER:newCoordinates={x:(relBounds.a.x+relBounds.b.x-shape.bounds.width())/2,y:shape.bounds.upperLeft().y};break;case ORYX.CONFIG.EDITOR_ALIGN_RIGHT:newCoordinates={x:relBounds.b.x-shape.bounds.width(),y:shape.bounds.upperLeft().y};break;case ORYX.CONFIG.EDITOR_ALIGN_SIZE:if(shape.isResizable){this.orgPos[index]={a:shape.bounds.upperLeft(),b:shape.bounds.lowerRight()};this.setBounds(shape,shape.maximumSize)}break}if(newCoordinates){var offset={x:shape.bounds.upperLeft().x-newCoordinates.x,y:shape.bounds.upperLeft().y-newCoordinates.y};shape.bounds.moveTo(newCoordinates);this.plugin.layoutEdges(shape,shape.getAllDockedShapes(),offset)}}.bind(this))},rollback:function(){this.elements.each(function(shape,index){if(this.way==ORYX.CONFIG.EDITOR_ALIGN_SIZE){if(shape.isResizable){shape.bounds.set(this.orgPos[index])}}else{shape.bounds.moveTo(this.orgPos[index])}}.bind(this))}});var command=new commandClass(elements,bounds,maxHeight,maxWidth,parseInt(way),this);this.facade.executeCommands([command])}});if(!ORYX.Plugins){ORYX.Plugins=new Object()}ORYX.Plugins.Save=Clazz.extend({facade:undefined,processURI:undefined,changeSymbol:"*",construct:function(facade){this.facade=facade;document.addEventListener("keydown",function(e){if(e.ctrlKey&&e.keyCode===83){Event.stop(e)}},false);window.onbeforeunload=this.onUnLoad.bind(this);this.changeDifference=0;this.facade.registerOnEvent(ORYX.CONFIG.EVENT_UNDO_EXECUTE,function(){this.changeDifference++;this.updateTitle()}.bind(this));this.facade.registerOnEvent(ORYX.CONFIG.EVENT_EXECUTE_COMMANDS,function(){this.changeDifference++;this.updateTitle()}.bind(this));this.facade.registerOnEvent(ORYX.CONFIG.EVENT_SAVED,function(){this.changeDifference=0;this.updateTitle()}.bind(this));this.facade.registerOnEvent(ORYX.CONFIG.EVENT_UNDO_ROLLBACK,function(){this.changeDifference--;this.updateTitle()}.bind(this));this.hasChanges=this._hasChanges.bind(this)},updateTitle:function(){var value=window.document.title||document.getElementsByTagName("title")[0].childNodes[0].nodeValue;if(this.changeDifference===0&&value.startsWith(this.changeSymbol)){window.document.title=value.slice(1)}else{if(this.changeDifference!==0&&!value.startsWith(this.changeSymbol)){window.document.title=this.changeSymbol+""+value}}},_hasChanges:function(){return this.changeDifference!==0||(this.facade.getModelMetaData()["new"]&&this.facade.getCanvas().getChildShapes().size()>0)},onUnLoad:function(){if(this._hasChanges()){return ORYX.I18N.Save.unsavedData}}});if(!ORYX.Plugins){ORYX.Plugins=new Object()}ORYX.Plugins.DragDropResize=ORYX.Plugins.AbstractPlugin.extend({construct:function(facade){this.facade=facade;this.currentShapes=[];this.toMoveShapes=[];this.distPoints=[];this.isResizing=false;this.dragEnable=false;this.dragIntialized=false;this.edgesMovable=true;this.offSetPosition={x:0,y:0};this.faktorXY={x:1,y:1};this.containmentParentNode;this.isAddingAllowed=false;this.isAttachingAllowed=false;this.callbackMouseMove=this.handleMouseMove.bind(this);this.callbackMouseUp=this.handleMouseUp.bind(this);var containerNode=this.facade.getCanvas().getSvgContainer();this.selectedRect=new ORYX.Plugins.SelectedRect(containerNode);if(ORYX.CONFIG.SHOW_GRIDLINE){this.vLine=new ORYX.Plugins.GridLine(containerNode,ORYX.Plugins.GridLine.DIR_VERTICAL);this.hLine=new ORYX.Plugins.GridLine(containerNode,ORYX.Plugins.GridLine.DIR_HORIZONTAL)}containerNode=this.facade.getCanvas().getHTMLContainer();
this.scrollNode=this.facade.getCanvas().rootNode.parentNode.parentNode;this.resizerSE=new ORYX.Plugins.Resizer(containerNode,"southeast",this.facade);this.resizerSE.registerOnResize(this.onResize.bind(this));this.resizerSE.registerOnResizeEnd(this.onResizeEnd.bind(this));this.resizerSE.registerOnResizeStart(this.onResizeStart.bind(this));this.resizerNW=new ORYX.Plugins.Resizer(containerNode,"northwest",this.facade);this.resizerNW.registerOnResize(this.onResize.bind(this));this.resizerNW.registerOnResizeEnd(this.onResizeEnd.bind(this));this.resizerNW.registerOnResizeStart(this.onResizeStart.bind(this));this.facade.registerOnEvent(ORYX.CONFIG.EVENT_MOUSEDOWN,this.handleMouseDown.bind(this))},handleMouseDown:function(event,uiObj){if(!this.dragBounds||!this.currentShapes.member(uiObj)||!this.toMoveShapes.length){return}this.dragEnable=true;this.dragIntialized=true;this.edgesMovable=true;var a=this.facade.getCanvas().node.getScreenCTM();this.faktorXY.x=a.a;this.faktorXY.y=a.d;var eventX=Event.pointerX(event);var eventY=Event.pointerY(event);var upL=this.dragBounds.upperLeft();this.offSetPosition={x:eventX-(upL.x*this.faktorXY.x),y:eventY-(upL.y*this.faktorXY.y)};this.offsetScroll={x:this.scrollNode.scrollLeft,y:this.scrollNode.scrollTop};document.documentElement.addEventListener(ORYX.CONFIG.EVENT_MOUSEMOVE,this.callbackMouseMove,false);document.documentElement.addEventListener(ORYX.CONFIG.EVENT_MOUSEUP,this.callbackMouseUp,true);return},handleMouseUp:function(event){this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,highlightId:"dragdropresize.contain"});this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,highlightId:"dragdropresize.attached"});if(this.dragEnable){if(!this.dragIntialized){this.afterDrag();if(this.isAttachingAllowed&&this.toMoveShapes.length==1&&this.toMoveShapes[0] instanceof ORYX.Core.Node&&this.toMoveShapes[0].dockers.length>0){var position=this.facade.eventCoordinates(event);var docker=this.toMoveShapes[0].dockers[0];var dockCommand=ORYX.Core.Command.extend({construct:function(docker,position,newDockedShape,facade){this.docker=docker;this.newPosition=position;this.newDockedShape=newDockedShape;this.newParent=newDockedShape.parent||facade.getCanvas();this.oldPosition=docker.parent.bounds.center();this.oldDockedShape=docker.getDockedShape();this.oldParent=docker.parent.parent||facade.getCanvas();this.facade=facade;if(this.oldDockedShape){this.oldPosition=docker.parent.absoluteBounds().center()}},execute:function(){this.dock(this.newDockedShape,this.newParent,this.newPosition);this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_ARRANGEMENT_TOP,excludeCommand:true})},rollback:function(){this.dock(this.oldDockedShape,this.oldParent,this.oldPosition)},dock:function(toDockShape,parent,pos){parent.add(this.docker.parent);this.docker.setDockedShape(undefined);this.docker.bounds.centerMoveTo(pos);this.docker.setDockedShape(toDockShape);this.facade.setSelection([this.docker.parent]);this.facade.getCanvas().update();this.facade.updateSelection()}});var commands=[new dockCommand(docker,position,this.containmentParentNode,this.facade)];this.facade.executeCommands(commands)}else{if(this.isAddingAllowed){this.refreshSelectedShapes()}}this.facade.updateSelection();this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_DRAGDROP_END})}if(this.vLine){this.vLine.hide()}if(this.hLine){this.hLine.hide()}}this.dragEnable=false;document.documentElement.removeEventListener(ORYX.CONFIG.EVENT_MOUSEUP,this.callbackMouseUp,true);document.documentElement.removeEventListener(ORYX.CONFIG.EVENT_MOUSEMOVE,this.callbackMouseMove,false);return},handleMouseMove:function(event){if(!this.dragEnable){return}if(this.dragIntialized){this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_DRAGDROP_START});this.dragIntialized=false;this.resizerSE.hide();this.resizerNW.hide();this._onlyEdges=this.currentShapes.all(function(currentShape){return(currentShape instanceof ORYX.Core.Edge)});this.beforeDrag();this._currentUnderlyingNodes=[]}var position={x:Event.pointerX(event)-this.offSetPosition.x,y:Event.pointerY(event)-this.offSetPosition.y};position.x-=this.offsetScroll.x-this.scrollNode.scrollLeft;position.y-=this.offsetScroll.y-this.scrollNode.scrollTop;var modifierKeyPressed=event.shiftKey||event.ctrlKey;if(ORYX.CONFIG.GRID_ENABLED&&!modifierKeyPressed){position=this.snapToGrid(position)}else{if(this.vLine){this.vLine.hide()}if(this.hLine){this.hLine.hide()}}position.x/=this.faktorXY.x;position.y/=this.faktorXY.y;position.x=Math.max(0,position.x);position.y=Math.max(0,position.y);var c=this.facade.getCanvas();position.x=Math.min(c.bounds.width()-this.dragBounds.width(),position.x);position.y=Math.min(c.bounds.height()-this.dragBounds.height(),position.y);this.dragBounds.moveTo(position);this.resizeRectangle(this.dragBounds);this.isAttachingAllowed=false;var eventCoordinates=this.facade.eventCoordinates(event);var additionalIEZoom=1;if(!isNaN(screen.logicalXDPI)&&!isNaN(screen.systemXDPI)){var ua=navigator.userAgent;if(ua.indexOf("MSIE")>=0){var zoom=Math.round((screen.deviceXDPI/screen.logicalXDPI)*100);
if(zoom!==100){additionalIEZoom=zoom/100}}}if(additionalIEZoom!==1){eventCoordinates.x=eventCoordinates.x/additionalIEZoom;eventCoordinates.y=eventCoordinates.y/additionalIEZoom}var underlyingNodes=$A(this.facade.getCanvas().getAbstractShapesAtPosition(eventCoordinates));var checkIfAttachable=this.toMoveShapes.length==1&&this.toMoveShapes[0] instanceof ORYX.Core.Node&&this.toMoveShapes[0].dockers.length>0;checkIfAttachable=checkIfAttachable&&underlyingNodes.length!=1;if(!checkIfAttachable&&underlyingNodes.length===this._currentUnderlyingNodes.length&&underlyingNodes.all(function(node,index){return this._currentUnderlyingNodes[index]===node}.bind(this))){return}else{if(this._onlyEdges){this.isAddingAllowed=true;this.containmentParentNode=this.facade.getCanvas()}else{var options={event:event,underlyingNodes:underlyingNodes,checkIfAttachable:checkIfAttachable};this.checkRules(options)}}this._currentUnderlyingNodes=underlyingNodes.reverse();if(this.isAttachingAllowed){this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_SHOW,highlightId:"dragdropresize.attached",elements:[this.containmentParentNode],style:ORYX.CONFIG.SELECTION_HIGHLIGHT_STYLE_RECTANGLE,color:ORYX.CONFIG.SELECTION_VALID_COLOR})}else{this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,highlightId:"dragdropresize.attached"})}if(!this.isAttachingAllowed){if(this.isAddingAllowed){this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_SHOW,highlightId:"dragdropresize.contain",elements:[this.containmentParentNode],color:ORYX.CONFIG.SELECTION_VALID_COLOR})}else{this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_SHOW,highlightId:"dragdropresize.contain",elements:[this.containmentParentNode],color:ORYX.CONFIG.SELECTION_INVALID_COLOR})}}else{this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,highlightId:"dragdropresize.contain"})}return},checkRules:function(options){var event=options.event;var underlyingNodes=options.underlyingNodes;var checkIfAttachable=options.checkIfAttachable;var noEdges=options.noEdges;this.containmentParentNode=underlyingNodes.reverse().find((function(node){return(node instanceof ORYX.Core.Canvas)||(((node instanceof ORYX.Core.Node)||((node instanceof ORYX.Core.Edge)&&!noEdges))&&(!(this.currentShapes.member(node)||this.currentShapes.any(function(shape){return(shape.children.length>0&&shape.getChildNodes(true).member(node))}))))}).bind(this));if(checkIfAttachable){this.isAttachingAllowed=this.facade.getRules().canConnect({sourceShape:this.containmentParentNode,edgeShape:this.toMoveShapes[0],targetShape:this.toMoveShapes[0]});if(this.isAttachingAllowed){var point=this.facade.eventCoordinates(event);this.isAttachingAllowed=this.containmentParentNode.isPointOverOffset(point.x,point.y)}}if(!this.isAttachingAllowed){this.isAddingAllowed=this.toMoveShapes.all((function(currentShape){if(currentShape instanceof ORYX.Core.Edge||currentShape instanceof ORYX.Core.Controls.Docker||this.containmentParentNode===currentShape.parent){return true}else{if(this.containmentParentNode!==currentShape){if(!(this.containmentParentNode instanceof ORYX.Core.Edge)||!noEdges){if(this.facade.getRules().canContain({containingShape:this.containmentParentNode,containedShape:currentShape})){return true}}}}return false}).bind(this))}if(!this.isAttachingAllowed&&!this.isAddingAllowed&&(this.containmentParentNode instanceof ORYX.Core.Edge)){options.noEdges=true;options.underlyingNodes.reverse();this.checkRules(options)}},refreshSelectedShapes:function(){if(!this.dragBounds){return}var upL=this.dragBounds.upperLeft();var oldUpL=this.oldDragBounds.upperLeft();var offset={x:upL.x-oldUpL.x,y:upL.y-oldUpL.y};var commands=[new ORYX.Core.Command.Move(this.toMoveShapes,offset,this.containmentParentNode,this.currentShapes,this)];if(this._undockedEdgesCommand instanceof ORYX.Core.Command){commands.unshift(this._undockedEdgesCommand)}this.facade.executeCommands(commands);if(this.dragBounds){this.oldDragBounds=this.dragBounds.clone()}},onResize:function(bounds){if(!this.dragBounds){return}this.dragBounds=bounds;this.isResizing=true;this.resizeRectangle(this.dragBounds)},onResizeStart:function(){this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_RESIZE_START})},onResizeEnd:function(){if(!(this.currentShapes instanceof Array)||this.currentShapes.length<=0){return}if(this.isResizing){var commandClass=ORYX.Core.Command.extend({construct:function(shape,newBounds,plugin){this.shape=shape;this.oldBounds=shape.bounds.clone();this.newBounds=newBounds;this.plugin=plugin},execute:function(){this.shape.bounds.set(this.newBounds.a,this.newBounds.b);this.update(this.getOffset(this.oldBounds,this.newBounds))},rollback:function(){this.shape.bounds.set(this.oldBounds.a,this.oldBounds.b);this.update(this.getOffset(this.newBounds,this.oldBounds))},getOffset:function(b1,b2){return{x:b2.a.x-b1.a.x,y:b2.a.y-b1.a.y,xs:b2.width()/b1.width(),ys:b2.height()/b1.height()}},update:function(offset){this.shape.getLabels().each(function(label){label.changed()});var allEdges=[].concat(this.shape.getIncomingShapes()).concat(this.shape.getOutgoingShapes()).findAll(function(r){return r instanceof ORYX.Core.Edge
}.bind(this));this.plugin.layoutEdges(this.shape,allEdges,offset);this.plugin.facade.setSelection([this.shape]);this.plugin.facade.getCanvas().update();this.plugin.facade.updateSelection()}});var bounds=this.dragBounds.clone();var shape=this.currentShapes[0];if(shape.parent){var parentPosition=shape.parent.absoluteXY();bounds.moveBy(-parentPosition.x,-parentPosition.y)}var command=new commandClass(shape,bounds,this);this.facade.executeCommands([command]);this.isResizing=false;this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_RESIZE_END})}},beforeDrag:function(){var undockEdgeCommand=ORYX.Core.Command.extend({construct:function(moveShapes){this.dockers=moveShapes.collect(function(shape){return shape instanceof ORYX.Core.Controls.Docker?{docker:shape,dockedShape:shape.getDockedShape(),refPoint:shape.referencePoint}:undefined}).compact()},execute:function(){this.dockers.each(function(el){el.docker.setDockedShape(undefined)})},rollback:function(){this.dockers.each(function(el){el.docker.setDockedShape(el.dockedShape);el.docker.setReferencePoint(el.refPoint)})}});this._undockedEdgesCommand=new undockEdgeCommand(this.toMoveShapes);this._undockedEdgesCommand.execute()},hideAllLabels:function(shape){shape.getLabels().each(function(label){label.hide()});shape.getAllDockedShapes().each(function(dockedShape){var labels=dockedShape.getLabels();if(labels.length>0){labels.each(function(label){label.hide()})}});shape.getChildren().each((function(value){if(value instanceof ORYX.Core.Shape){this.hideAllLabels(value)}}).bind(this))},afterDrag:function(){},showAllLabels:function(shape){for(var i=0;i0){labels.each(function(label){label.show()})}}for(var i=0;i2&&hasF&&hasL){this.toMoveShapes=this.toMoveShapes.concat(dks.findAll(function(el,index){return index>0&&indexthis.aspectRatio){offset.x=this.aspectRatio*(this.bounds.height()+offset.y)-this.bounds.width()}else{if(newAspectRatiothis.maxSize.width){offset.x=-(this.maxSize.width-this.bounds.width());if(this.aspectRatio){offset.y=this.aspectRatio*offset.x}}if(this.bounds.width()-offset.xthis.maxSize.height){offset.y=-(this.maxSize.height-this.bounds.height());if(this.aspectRatio){offset.x=offset.y/this.aspectRatio}}if(this.bounds.height()-offset.ythis.maxSize.width){offset.x=this.maxSize.width-this.bounds.width();if(this.aspectRatio){offset.y=this.aspectRatio*offset.x}}if(this.bounds.width()+offset.xthis.maxSize.height){offset.y=this.maxSize.height-this.bounds.height();if(this.aspectRatio){offset.x=offset.y/this.aspectRatio}}if(this.bounds.height()+offset.ythis.maxSize.width){this.bounds.set(upL.x,upL.y,upL.x+this.maxSize.width,upL.y+this.bounds.height())}if(this.bounds.height()>this.maxSize.height){this.bounds.set(upL.x,upL.y,upL.x+this.bounds.width(),upL.y+this.maxSize.height)}var a=this.canvasNode.getScreenCTM();upL.x*=a.a;upL.y*=a.d;var additionalIEZoom=1;if(!isNaN(screen.logicalXDPI)&&!isNaN(screen.systemXDPI)){var ua=navigator.userAgent;if(ua.indexOf("MSIE")>=0){var zoom=Math.round((screen.deviceXDPI/screen.logicalXDPI)*100);if(zoom!==100){additionalIEZoom=zoom/100}}}if(additionalIEZoom===1){upL.y=upL.y-jQuery("#canvasSection").offset().top+a.f;upL.x=upL.x-jQuery("#canvasSection").offset().left+a.e}else{var canvasOffsetLeft=jQuery("#canvasSection").offset().left;var canvasScrollLeft=jQuery("#canvasSection").scrollLeft();var canvasScrollTop=jQuery("#canvasSection").scrollTop();var offset=a.e-(canvasOffsetLeft*additionalIEZoom);var additionaloffset=0;if(offset>10){additionaloffset=(offset/additionalIEZoom)-offset}upL.y=upL.y-(jQuery("#canvasSection").offset().top*additionalIEZoom)+((canvasScrollTop*additionalIEZoom)-canvasScrollTop)+a.f;
upL.x=upL.x-(canvasOffsetLeft*additionalIEZoom)+additionaloffset+((canvasScrollLeft*additionalIEZoom)-canvasScrollLeft)+a.e}if(this.orientation==="northwest"){upL.x-=13;upL.y-=13}else{upL.x+=(a.a*this.bounds.width())+3;upL.y+=(a.d*this.bounds.height())+3}this.position=upL;this.node.style.left=this.position.x+"px";this.node.style.top=this.position.y+"px"}});ORYX.Core.Command.Move=ORYX.Core.Command.extend({construct:function(moveShapes,offset,parent,selectedShapes,plugin){this.moveShapes=moveShapes;this.selectedShapes=selectedShapes;this.offset=offset;this.plugin=plugin;this.newParents=moveShapes.collect(function(t){return parent||t.parent});this.oldParents=moveShapes.collect(function(shape){return shape.parent});this.dockedNodes=moveShapes.findAll(function(shape){return shape instanceof ORYX.Core.Node&&shape.dockers.length==1}).collect(function(shape){return{docker:shape.dockers[0],dockedShape:shape.dockers[0].getDockedShape(),refPoint:shape.dockers[0].referencePoint}})},execute:function(){this.dockAllShapes();this.move(this.offset);this.addShapeToParent(this.newParents);this.selectCurrentShapes();this.plugin.facade.getCanvas().update();this.plugin.facade.updateSelection()},rollback:function(){var offset={x:-this.offset.x,y:-this.offset.y};this.move(offset);this.addShapeToParent(this.oldParents);this.dockAllShapes(true);this.selectCurrentShapes();this.plugin.facade.getCanvas().update();this.plugin.facade.updateSelection()},move:function(offset,doLayout){for(var i=0;ii||this.moveShapes.indexOf(r.dockers.last().getDockedShape())>i}.bind(this));for(var j=0;j=0){var zoom=Math.round((screen.deviceXDPI/screen.logicalXDPI)*100);if(zoom!==100){additionalIEZoom=zoom/100}}}if(additionalIEZoom!==1){eventCoordinates.x=eventCoordinates.x/additionalIEZoom;eventCoordinates.y=eventCoordinates.y/additionalIEZoom}if((!this.isStartDocker&&!this.isEndDocker)||!this.docker.isDocked()){this.docker.setDockedShape(undefined);this.docker.bounds.centerMoveTo(eventCoordinates);this.dockerParent._update()}else{this.outerDockerNotMoved=true}var option={movedCallback:this.dockerMoved.bind(this),upCallback:this.dockerMovedFinished.bind(this)};this.startEventPos=eventCoordinates;ORYX.Core.UIEnableDrag(event,uiObj,option)}},dockerMoved:function(event){this.outerDockerNotMoved=false;var snapToMagnet=undefined;if(this.docker.parent){if(this.isStartDocker||this.isEndDocker){var evPos=this.facade.eventCoordinates(event);var additionalIEZoom=1;if(!isNaN(screen.logicalXDPI)&&!isNaN(screen.systemXDPI)){var ua=navigator.userAgent;if(ua.indexOf("MSIE")>=0){var zoom=Math.round((screen.deviceXDPI/screen.logicalXDPI)*100);if(zoom!==100){additionalIEZoom=zoom/100}}}if(additionalIEZoom!==1){evPos.x=evPos.x/additionalIEZoom;evPos.y=evPos.y/additionalIEZoom}if(this.docker.isDocked()){var distanceDockerPointer=ORYX.Core.Math.getDistancePointToPoint(evPos,this.initialDockerPosition);if(distanceDockerPointerMath.abs(center.x-dockerCenter.x)?center.x-dockerCenter.x:nearestX;nearestY=Math.abs(nearestY)>Math.abs(center.y-dockerCenter.y)?center.y-dockerCenter.y:nearestY}).bind(this));if(Math.abs(nearestX)0?this.position.x:this.position.x+this.size.width,y:this.size.height>0?this.position.y:this.position.y+this.size.height};var b={x:a.x+Math.abs(this.size.width),y:a.y+Math.abs(this.size.height)};var additionalIEZoom=1;if(!isNaN(screen.logicalXDPI)&&!isNaN(screen.systemXDPI)){var ua=navigator.userAgent;if(ua.indexOf("MSIE")>=0){var zoom=Math.round((screen.deviceXDPI/screen.logicalXDPI)*100);if(zoom!==100){additionalIEZoom=zoom/100}}}if(additionalIEZoom===1){a.x=a.x-(corrSVG.e-jQuery("#canvasSection").offset().left);a.y=a.y-(corrSVG.f-jQuery("#canvasSection").offset().top);b.x=b.x-(corrSVG.e-jQuery("#canvasSection").offset().left);b.y=b.y-(corrSVG.f-jQuery("#canvasSection").offset().top)}else{var canvasOffsetLeft=jQuery("#canvasSection").offset().left;var canvasScrollLeft=jQuery("#canvasSection").scrollLeft();var canvasScrollTop=jQuery("#canvasSection").scrollTop();var offset=a.e-(canvasOffsetLeft*additionalIEZoom);var additionaloffset=0;if(offset>10){additionaloffset=(offset/additionalIEZoom)-offset}a.x=a.x-(corrSVG.e-(canvasOffsetLeft*additionalIEZoom)+additionaloffset+((canvasScrollLeft*additionalIEZoom)-canvasScrollLeft));a.y=a.y-(corrSVG.f-(jQuery("#canvasSection").offset().top*additionalIEZoom)+((canvasScrollTop*additionalIEZoom)-canvasScrollTop));b.x=b.x-(corrSVG.e-(canvasOffsetLeft*additionalIEZoom)+additionaloffset+((canvasScrollLeft*additionalIEZoom)-canvasScrollLeft));b.y=b.y-(corrSVG.f-(jQuery("#canvasSection").offset().top*additionalIEZoom)+((canvasScrollTop*additionalIEZoom)-canvasScrollTop))}a.x/=corrSVG.a;a.y/=corrSVG.d;b.x/=corrSVG.a;b.y/=corrSVG.d;var elements=this.facade.getCanvas().getChildShapes(true).findAll(function(value){var absBounds=value.absoluteBounds();
var bA=absBounds.upperLeft();var bB=absBounds.lowerRight();if(bA.x>a.x&&bA.y>a.y&&bB.x0){this.setAttributesByStyle(node,options);this.show(node)}else{this.hide(node)}}},hideHighlight:function(options){if(options&&options.highlightId&&this.highlightNodes[options.highlightId]){this.hide(this.highlightNodes[options.highlightId])}},hide:function(node){node.setAttributeNS(null,"display","none")},show:function(node){node.setAttributeNS(null,"display","")},setAttributesByStyle:function(node,options){if(options.style&&options.style==ORYX.CONFIG.SELECTION_HIGHLIGHT_STYLE_RECTANGLE){var bo=options.elements[0].absoluteBounds();var strWidth=options.strokewidth?options.strokewidth:ORYX.CONFIG.BORDER_OFFSET;node.setAttributeNS(null,"d",this.getPathRectangle(bo.a,bo.b,strWidth));node.setAttributeNS(null,"stroke",options.color?options.color:ORYX.CONFIG.SELECTION_HIGHLIGHT_COLOR);node.setAttributeNS(null,"stroke-opacity",options.opacity?options.opacity:0.2);node.setAttributeNS(null,"stroke-width",strWidth)}else{if(options.elements.length==1&&options.elements[0] instanceof ORYX.Core.Edge&&options.highlightId!="selection"){var path=this.getPathEdge(options.elements[0].dockers);if(path&&path.length>0){node.setAttributeNS(null,"d",path)}node.setAttributeNS(null,"stroke",options.color?options.color:ORYX.CONFIG.SELECTION_HIGHLIGHT_COLOR);node.setAttributeNS(null,"stroke-opacity",options.opacity?options.opacity:0.2);node.setAttributeNS(null,"stroke-width",ORYX.CONFIG.OFFSET_EDGE_BOUNDS)}else{var path=this.getPathByElements(options.elements);if(path&&path.length>0){node.setAttributeNS(null,"d",path)}node.setAttributeNS(null,"stroke",options.color?options.color:ORYX.CONFIG.SELECTION_HIGHLIGHT_COLOR);node.setAttributeNS(null,"stroke-opacity",options.opacity?options.opacity:1);node.setAttributeNS(null,"stroke-width",options.strokewidth?options.strokewidth:2)}}},getPathByElements:function(elements){if(!elements||elements.length<=0){return undefined}var padding=ORYX.CONFIG.SELECTED_AREA_PADDING;var path="";elements.each((function(element){if(!element){return}var bounds=element.absoluteBounds();bounds.widen(padding);var a=bounds.upperLeft();var b=bounds.lowerRight();path=path+this.getPath(a,b)}).bind(this));return path},getPath:function(a,b){return this.getPathCorners(a,b)},getPathCorners:function(a,b){var size=ORYX.CONFIG.SELECTION_HIGHLIGHT_SIZE;var path="";path=path+"M"+a.x+" "+(a.y+size)+" l0 -"+size+" l"+size+" 0 ";path=path+"M"+a.x+" "+(b.y-size)+" l0 "+size+" l"+size+" 0 ";path=path+"M"+b.x+" "+(b.y-size)+" l0 "+size+" l-"+size+" 0 ";path=path+"M"+b.x+" "+(a.y+size)+" l0 -"+size+" l-"+size+" 0 ";return path},getPathRectangle:function(a,b,strokeWidth){var size=ORYX.CONFIG.SELECTION_HIGHLIGHT_SIZE;var path="";var offset=strokeWidth/2;path=path+"M"+(a.x+offset)+" "+(a.y);path=path+" L"+(a.x+offset)+" "+(b.y-offset);path=path+" L"+(b.x-offset)+" "+(b.y-offset);path=path+" L"+(b.x-offset)+" "+(a.y+offset);path=path+" L"+(a.x+offset)+" "+(a.y+offset);return path},getPathEdge:function(edgeDockers){var length=edgeDockers.length;var path="M"+edgeDockers[0].bounds.center().x+" "+edgeDockers[0].bounds.center().y;for(i=1;i1){this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_SHOW,highlightId:"selection",elements:event.elements.without(event.subSelection),color:ORYX.CONFIG.SELECTION_HIGHLIGHT_COLOR,opacity:!event.subSelection?this.opacityFull:this.opacityLow});if(event.subSelection){this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_SHOW,highlightId:"subselection",elements:[event.subSelection],color:ORYX.CONFIG.SELECTION_HIGHLIGHT_COLOR,opacity:this.opacityFull})}else{this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,highlightId:"subselection"})}}else{this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,highlightId:"selection"});this.facade.raiseEvent({type:ORYX.CONFIG.EVENT_HIGHLIGHT_HIDE,highlightId:"subselection"})}}});if(!ORYX.Plugins){ORYX.Plugins=new Object()}ORYX.Plugins.Overlay=Clazz.extend({facade:undefined,styleNode:undefined,construct:function(facade){this.facade=facade;this.changes=[];this.facade.registerOnEvent(ORYX.CONFIG.EVENT_OVERLAY_SHOW,this.show.bind(this));this.facade.registerOnEvent(ORYX.CONFIG.EVENT_OVERLAY_HIDE,this.hide.bind(this));this.styleNode=document.createElement("style");this.styleNode.setAttributeNS(null,"type","text/css");document.getElementsByTagName("head")[0].appendChild(this.styleNode)},show:function(options){if(!options||!options.shapes||!options.shapes instanceof Array||!options.id||!options.id instanceof String||options.id.length==0){return}if(options.attributes){options.shapes.each(function(el){if(!el instanceof ORYX.Core.Shape){return}this.setAttributes(el.node,options.attributes)}.bind(this))}var isSVG=true;try{isSVG=options.node&&options.node instanceof SVGElement}catch(e){}if(options.node&&isSVG){options["_temps"]=[];options.shapes.each(function(el,index){if(!el instanceof ORYX.Core.Shape){return}var _temp={};_temp.svg=options.dontCloneNode?options.node:options.node.cloneNode(true);el.node.firstChild.appendChild(_temp.svg);if(el instanceof ORYX.Core.Edge&&!options.nodePosition){options["nodePosition"]="START"}if(options.nodePosition){var b=el.bounds;var p=options.nodePosition.toUpperCase();if(el instanceof ORYX.Core.Node&&p=="START"){p="NW"}else{if(el instanceof ORYX.Core.Node&&p=="END"){p="SE"}else{if(el instanceof ORYX.Core.Edge&&p=="START"){b=el.getDockers().first().bounds}else{if(el instanceof ORYX.Core.Edge&&p=="END"){b=el.getDockers().last().bounds}}}}_temp.callback=function(){var x=0;var y=0;if(p=="NW"){}else{if(p=="N"){x=b.width()/2}else{if(p=="NE"){x=b.width()}else{if(p=="E"){x=b.width();y=b.height()/2}else{if(p=="SE"){x=b.width();y=b.height()}else{if(p=="S"){x=b.width()/2;y=b.height()}else{if(p=="SW"){y=b.height()}else{if(p=="W"){y=b.height()/2}else{if(p=="START"||p=="END"){x=b.width()/2;y=b.height()/2}else{return}}}}}}}}}if(el instanceof ORYX.Core.Edge){x+=b.upperLeft().x;y+=b.upperLeft().y}_temp.svg.setAttributeNS(null,"transform","translate("+x+", "+y+")")}.bind(this);_temp.element=el;_temp.callback();b.registerCallback(_temp.callback)}options._temps.push(_temp)}.bind(this))}if(!this.changes[options.id]){this.changes[options.id]=[]}this.changes[options.id].push(options)},hide:function(options){if(!options||!options.id||!options.id instanceof String||options.id.length==0||!this.changes[options.id]){return}this.changes[options.id].each(function(option){option.shapes.each(function(el,index){if(!el instanceof ORYX.Core.Shape){return}this.deleteAttributes(el.node)}.bind(this));if(option._temps){option._temps.each(function(tmp){if(tmp.svg&&tmp.svg.parentNode){tmp.svg.parentNode.removeChild(tmp.svg)}if(tmp.callback&&tmp.element){tmp.element.bounds.unregisterCallback(tmp.callback)}}.bind(this))}}.bind(this));this.changes[options.id]=null},setAttributes:function(node,attributes){var childs=this.getAllChilds(node.firstChild.firstChild);var ids=[];childs.each(function(e){ids.push($A(e.attributes).findAll(function(attr){return attr.nodeValue.startsWith("url(#")}))});ids=ids.flatten().compact();ids=ids.collect(function(s){return s.nodeValue}).uniq();ids=ids.collect(function(s){return s.slice(5,s.length-1)});ids.unshift(node.id+" .me");var attr=$H(attributes);var attrValue=attr.toJSON().gsub(",",";").gsub('"',"");var attrMarkerValue=attributes.stroke?attrValue.slice(0,attrValue.length-1)+"; fill:"+attributes.stroke+";}":attrValue;var attrTextValue;if(attributes.fill){var copyAttr=Object.clone(attributes);copyAttr.fill="black";attrTextValue=$H(copyAttr).toJSON().gsub(",",";").gsub('"',"")}csstags=ids.collect(function(s,i){return"#"+s+" * "+(!i?attrValue:attrMarkerValue)+""+(attrTextValue?" #"+s+" text * "+attrTextValue:"")});var s=csstags.join(" ")+"\n";this.styleNode.appendChild(document.createTextNode(s))},deleteAttributes:function(node){var delEl=$A(this.styleNode.childNodes).findAll(function(e){return e.textContent.include("#"+node.id)
});delEl.each(function(el){el.parentNode.removeChild(el)})},getAllChilds:function(node){var childs=$A(node.childNodes);$A(node.childNodes).each(function(e){childs.push(this.getAllChilds(e))}.bind(this));return childs.flatten()}});if(!ORYX.Plugins){ORYX.Plugins=new Object()}ORYX.Plugins.KeysMove=ORYX.Plugins.AbstractPlugin.extend({facade:undefined,construct:function(facade){this.facade=facade;this.copyElements=[];this.facade.offer({keyCodes:[{metaKeys:[ORYX.CONFIG.META_KEY_META_CTRL],keyCode:65,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.selectAll.bind(this)});this.facade.offer({keyCodes:[{metaKeys:[ORYX.CONFIG.META_KEY_META_CTRL],keyCode:ORYX.CONFIG.KEY_CODE_LEFT,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.move.bind(this,ORYX.CONFIG.KEY_CODE_LEFT,false)});this.facade.offer({keyCodes:[{keyCode:ORYX.CONFIG.KEY_CODE_LEFT,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.move.bind(this,ORYX.CONFIG.KEY_CODE_LEFT,true)});this.facade.offer({keyCodes:[{metaKeys:[ORYX.CONFIG.META_KEY_META_CTRL],keyCode:ORYX.CONFIG.KEY_CODE_RIGHT,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.move.bind(this,ORYX.CONFIG.KEY_CODE_RIGHT,false)});this.facade.offer({keyCodes:[{keyCode:ORYX.CONFIG.KEY_CODE_RIGHT,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.move.bind(this,ORYX.CONFIG.KEY_CODE_RIGHT,true)});this.facade.offer({keyCodes:[{metaKeys:[ORYX.CONFIG.META_KEY_META_CTRL],keyCode:ORYX.CONFIG.KEY_CODE_UP,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.move.bind(this,ORYX.CONFIG.KEY_CODE_UP,false)});this.facade.offer({keyCodes:[{keyCode:ORYX.CONFIG.KEY_CODE_UP,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.move.bind(this,ORYX.CONFIG.KEY_CODE_UP,true)});this.facade.offer({keyCodes:[{metaKeys:[ORYX.CONFIG.META_KEY_META_CTRL],keyCode:ORYX.CONFIG.KEY_CODE_DOWN,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.move.bind(this,ORYX.CONFIG.KEY_CODE_DOWN,false)});this.facade.offer({keyCodes:[{keyCode:ORYX.CONFIG.KEY_CODE_DOWN,keyAction:ORYX.CONFIG.KEY_ACTION_DOWN}],functionality:this.move.bind(this,ORYX.CONFIG.KEY_CODE_DOWN,true)})},selectAll:function(e){Event.stop(e.event);this.facade.setSelection(this.facade.getCanvas().getChildShapes(true))},move:function(key,far,e){Event.stop(e.event);var distance=far?20:5;var selection=this.facade.getSelection();var currentSelection=this.facade.getSelection();var p={x:0,y:0};switch(key){case ORYX.CONFIG.KEY_CODE_LEFT:p.x=-1*distance;break;case ORYX.CONFIG.KEY_CODE_RIGHT:p.x=distance;break;case ORYX.CONFIG.KEY_CODE_UP:p.y=-1*distance;break;case ORYX.CONFIG.KEY_CODE_DOWN:p.y=distance;break}selection=selection.findAll(function(shape){if(shape instanceof ORYX.Core.Node&&shape.dockers.length==1&&selection.include(shape.dockers.first().getDockedShape())){return false}var s=shape.parent;do{if(selection.include(s)){return false}}while(s=s.parent);return true});var edgesMovable=true;var onlyEdgesSelected=selection.all(function(shape){if(shape instanceof ORYX.Core.Edge){if(shape.isDocked()){edgesMovable=false}return true}return false});if(onlyEdgesSelected&&!edgesMovable){return}selection=selection.map(function(shape){if(shape instanceof ORYX.Core.Node){return shape}else{if(shape instanceof ORYX.Core.Edge){var dockers=shape.dockers;if(selection.include(shape.dockers.first().getDockedShape())){dockers=dockers.without(shape.dockers.first())}if(selection.include(shape.dockers.last().getDockedShape())){dockers=dockers.without(shape.dockers.last())}return dockers}else{return null}}}).flatten().compact();if(selection.size()>0){var selectionBounds=[this.facade.getCanvas().bounds.lowerRight().x,this.facade.getCanvas().bounds.lowerRight().y,0,0];selection.each(function(s){selectionBounds[0]=Math.min(selectionBounds[0],s.bounds.upperLeft().x);selectionBounds[1]=Math.min(selectionBounds[1],s.bounds.upperLeft().y);selectionBounds[2]=Math.max(selectionBounds[2],s.bounds.lowerRight().x);selectionBounds[3]=Math.max(selectionBounds[3],s.bounds.lowerRight().y)});if(selectionBounds[0]+p.x<0){p.x=-selectionBounds[0]}if(selectionBounds[1]+p.y<0){p.y=-selectionBounds[1]}if(selectionBounds[2]+p.x>this.facade.getCanvas().bounds.lowerRight().x){p.x=this.facade.getCanvas().bounds.lowerRight().x-selectionBounds[2]}if(selectionBounds[3]+p.y>this.facade.getCanvas().bounds.lowerRight().y){p.y=this.facade.getCanvas().bounds.lowerRight().y-selectionBounds[3]}if(p.x!=0||p.y!=0){var commands=[new ORYX.Core.Command.Move(selection,p,null,currentSelection,this)];this.facade.executeCommands(commands)}}},getUndockedCommant:function(shapes){var undockEdgeCommand=ORYX.Core.Command.extend({construct:function(moveShapes){this.dockers=moveShapes.collect(function(shape){return shape instanceof ORYX.Core.Controls.Docker?{docker:shape,dockedShape:shape.getDockedShape(),refPoint:shape.referencePoint}:undefined}).compact()},execute:function(){this.dockers.each(function(el){el.docker.setDockedShape(undefined)})},rollback:function(){this.dockers.each(function(el){el.docker.setDockedShape(el.dockedShape);
el.docker.setReferencePoint(el.refPoint)})}});command=new undockEdgeCommand(shapes);command.execute();return command},});if(!ORYX.Plugins){ORYX.Plugins={}}if(!ORYX.Plugins.Layouter){ORYX.Plugins.Layouter={}}new function(){ORYX.Plugins.Layouter.EdgeLayouter=ORYX.Plugins.AbstractLayouter.extend({layouted:["http://b3mn.org/stencilset/bpmn1.1#SequenceFlow","http://b3mn.org/stencilset/bpmn1.1#MessageFlow","http://b3mn.org/stencilset/timjpdl3#SequenceFlow","http://b3mn.org/stencilset/jbpm4#SequenceFlow","http://b3mn.org/stencilset/bpmn2.0#MessageFlow","http://b3mn.org/stencilset/bpmn2.0#SequenceFlow","http://b3mn.org/stencilset/bpmn2.0choreography#MessageFlow","http://b3mn.org/stencilset/bpmn2.0choreography#SequenceFlow","http://b3mn.org/stencilset/bpmn2.0conversation#ConversationLink","http://b3mn.org/stencilset/epc#ControlFlow","http://www.signavio.com/stencilsets/processmap#ProcessLink","http://www.signavio.com/stencilsets/organigram#connection"],layout:function(edges){edges.each(function(edge){this.doLayout(edge)}.bind(this))},doLayout:function(edge){var from=edge.getIncomingNodes()[0];var to=edge.getOutgoingNodes()[0];if(!from||!to){return}var positions=this.getPositions(from,to,edge);if(positions.length>0){this.setDockers(edge,positions[0].a,positions[0].b)}},getPositions:function(from,to,edge){var ab=from.absoluteBounds();var bb=to.absoluteBounds();var a=ab.center();var b=bb.center();var am=ab.midPoint();var bm=bb.midPoint();var first=Object.clone(edge.dockers.first().referencePoint);var last=Object.clone(edge.dockers.last().referencePoint);var aFirst=edge.dockers.first().getAbsoluteReferencePoint();var aLast=edge.dockers.last().getAbsoluteReferencePoint();if(Math.abs(aFirst.x-aLast.x)<1||Math.abs(aFirst.y-aLast.y)<1){return[]}var m={};m.x=a.xb.x)})}if(!ab.isIncluded(a.x,m.y)&&!bb.isIncluded(b.x,m.y)){positions.push({a:{x:a.x+off(first,am,"x"),y:m.y},b:{x:b.x+off(last,bm,"x"),y:m.y},z:this.getWeight(from,"b",to,"t",edge,a.y>b.y)})}return positions.sort(function(a,b){return a.zcenter2.x&&Math.abs(center1.y-center2.y)<2;case"b":return Math.abs(center1.x-center2.x)<2&¢er1.y>center2.y;case"l":return center1.x0&&pools.length>0){selection=selection.without.apply(selection,unselectLanes);selection=selection.concat(pools);this.facade.setSelection(selection.uniq())}}},handleShapeRemove:function(option){var sh=option.shape;var parent=option.parent;if(sh instanceof ORYX.Core.Node&&sh.getStencil().idWithoutNs()==="Lane"&&this.facade.isExecutingCommands()){var pool=this.getParentPool(parent);if(pool&&pool.parent){var isLeafFn=function(leaf){return !leaf.getChildNodes().any(function(r){return r.getStencil().idWithoutNs()==="Lane"})};var isLeaf=isLeafFn(sh);var parentHasMoreLanes=parent.getChildNodes().any(function(r){return r.getStencil().idWithoutNs()==="Lane"});if(isLeaf&&parentHasMoreLanes){var command=new ResizeLanesCommand(sh,parent,pool,this);this.facade.executeCommands([command])}else{if(!isLeaf&&!this.facade.getSelection().any(function(select){return select instanceof ORYX.Core.Node&&select.getStencil().idWithoutNs()==="Lane"&&select.isParent(sh)&&isLeafFn(select)})){var Command=ORYX.Core.Command.extend({construct:function(shape,facade){this.children=shape.getChildNodes(true);this.facade=facade},execute:function(){this.children.each(function(child){child.bounds.moveBy(30,0)})},rollback:function(){this.children.each(function(child){child.bounds.moveBy(-30,0)})}});this.facade.executeCommands([new Command(sh,this.facade)])}else{if(isLeaf&&!parentHasMoreLanes&&parent==pool){parent.add(sh)}}}}}},hashedSubProcesses:{},hashChildShapes:function(shape){var children=shape.getChildNodes();children.each(function(child){if(this.hashedSubProcesses[child.id]){this.hashedSubProcesses[child.id]=child.absoluteXY();this.hashedSubProcesses[child.id].width=child.bounds.width();this.hashedSubProcesses[child.id].height=child.bounds.height();this.hashChildShapes(child)}}.bind(this))},handleSubProcess:function(option){var sh=option.shape;if(!this.hashedSubProcesses[sh.id]){this.hashedSubProcesses[sh.id]=sh.absoluteXY();this.hashedSubProcesses[sh.id].width=sh.bounds.width();this.hashedSubProcesses[sh.id].height=sh.bounds.height();return}var offset=sh.absoluteXY();offset.x-=this.hashedSubProcesses[sh.id].x;offset.y-=this.hashedSubProcesses[sh.id].y;var resized=this.hashedSubProcesses[sh.id].width!==sh.bounds.width()||this.hashedSubProcesses[sh.id].height!==sh.bounds.height();this.hashedSubProcesses[sh.id]=sh.absoluteXY();this.hashedSubProcesses[sh.id].width=sh.bounds.width();this.hashedSubProcesses[sh.id].height=sh.bounds.height();this.hashChildShapes(sh);if(this.facade.isExecutingCommands()&&!resized){this.moveChildDockers(sh,offset)}},moveChildDockers:function(shape,offset){if(!offset.x&&!offset.y){return}var children=shape.getChildNodes(true);var dockers=children.map(function(node){return[].concat(node.getIncomingShapes()).concat(node.getOutgoingShapes())}).flatten().uniq().map(function(edge){return edge.dockers.length>2?edge.dockers.slice(1,edge.dockers.length-1):[]}).flatten();var abs=shape.absoluteBounds();abs.moveBy(-offset.x,-offset.y);var obj={};dockers.each(function(docker){if(docker.isChanged){return}var off=Object.clone(offset);if(!abs.isIncluded(docker.bounds.center())){var index=docker.parent.dockers.indexOf(docker);
var size=docker.parent.dockers.length;var from=docker.parent.getSource();var to=docker.parent.getTarget();var bothAreIncluded=children.include(from)&&children.include(to);if(!bothAreIncluded){var previousIsOver=index!==0?abs.isIncluded(docker.parent.dockers[index-1].bounds.center()):false;var nextIsOver=index!==size-1?abs.isIncluded(docker.parent.dockers[index+1].bounds.center()):false;if(!previousIsOver&&!nextIsOver){return}var ref=docker.parent.dockers[previousIsOver?index-1:index+1];if(Math.abs(-Math.abs(ref.bounds.center().x-docker.bounds.center().x))<2){off.y=0}else{if(Math.abs(-Math.abs(ref.bounds.center().y-docker.bounds.center().y))<2){off.x=0}else{return}}}}obj[docker.getId()]={docker:docker,offset:off}});this.facade.executeCommands([new ORYX.Core.MoveDockersCommand(obj)])},handleDockerDocked:function(options){var namespace=this.getNamespace();var edge=options.parent;var edgeSource=options.target;if(edge.getStencil().id()===namespace+"SequenceFlow"){var isGateway=edgeSource.getStencil().groups().find(function(group){if(group=="Gateways"){return group}});if(!isGateway&&(edge.properties["oryx-conditiontype"]=="Expression")){edge.setProperty("oryx-showdiamondmarker",true)}else{edge.setProperty("oryx-showdiamondmarker",false)}this.facade.getCanvas().update()}},handlePropertyChanged:function(option){var namespace=this.getNamespace();var shapes=option.elements;var propertyKey=option.key;var propertyValue=option.value;var changed=false;shapes.each(function(shape){if((shape.getStencil().id()===namespace+"SequenceFlow")&&(propertyKey==="oryx-conditiontype")){if(propertyValue!="Expression"){shape.setProperty("oryx-showdiamondmarker",false)}else{var incomingShapes=shape.getIncomingShapes();if(!incomingShapes){shape.setProperty("oryx-showdiamondmarker",true)}var incomingGateway=incomingShapes.find(function(aShape){var foundGateway=aShape.getStencil().groups().find(function(group){if(group=="Gateways"){return group}});if(foundGateway){return foundGateway}});if(!incomingGateway){shape.setProperty("oryx-showdiamondmarker",true)}else{shape.setProperty("oryx-showdiamondmarker",false)}}changed=true}}.bind(this));if(changed){this.facade.getCanvas().update()}},hashedPoolPositions:{},hashedLaneDepth:{},hashedBounds:{},hashedPositions:{},handleLayoutPool:function(event){var pool=event.shape;var selection=this.facade.getSelection();var currentShape=selection.include(pool)?pool:selection.first();currentShape=currentShape||pool;this.currentPool=pool;if(!(currentShape.getStencil().id().endsWith("Pool")||currentShape.getStencil().id().endsWith("Lane"))){return}if(currentShape!==pool&&!currentShape.isParent(pool)&&!this.hashedBounds[pool.id][currentShape.id]){return}if(!this.hashedBounds[pool.id]){this.hashedBounds[pool.id]={}}var lanes=this.getLanes(pool);if(lanes.length<=0){return}var allLanes=this.getLanes(pool,true),hp;var considerForDockers=allLanes.clone();var hashedPositions=$H({});allLanes.each(function(lane){hashedPositions[lane.id]=lane.bounds.upperLeft()});if(lanes.length===1&&this.getLanes(lanes.first()).length<=0){lanes.first().setProperty("oryx-showcaption",lanes.first().properties["oryx-name"].trim().length>0);var rect=lanes.first().node.getElementsByTagName("rect");rect[0].setAttributeNS(null,"display","none")}else{allLanes.invoke("setProperty","oryx-showcaption",true);allLanes.each(function(lane){var rect=lane.node.getElementsByTagName("rect");rect[0].removeAttributeNS(null,"display")})}var deletedLanes=[];var addedLanes=[];var i=-1;while(++i0){currentShape=addedLanes.first()}var resourceIds=$H(this.hashedBounds[pool.id]).keys();var i=-1;while(++i0||addedLanes.length>0){if(addedLanes.length===1&&this.getLanes(addedLanes[0].parent).length===1){height=this.adjustHeight(lanes,addedLanes[0].parent)}else{height=this.updateHeight(pool)}width=this.adjustWidth(lanes,pool.bounds.width());pool.update()}else{if(pool==currentShape){if(selection.length===1&&this.isResized(pool,this.hashedPoolPositions[pool.id])){var oldXY=this.hashedPoolPositions[pool.id].upperLeft();var xy=pool.bounds.upperLeft();var scale=0;if(this.shouldScale(pool)){var old=this.hashedPoolPositions[pool.id];scale=old.height()/pool.bounds.height()}this.adjustLanes(pool,allLanes,oldXY.x-xy.x,oldXY.y-xy.y,scale)}height=this.adjustHeight(lanes,undefined,pool.bounds.height());width=this.adjustWidth(lanes,pool.bounds.width())}else{if(selection.length===1&&this.isResized(currentShape,this.hashedBounds[pool.id][currentShape.id])){var oldXY=this.hashedBounds[pool.id][currentShape.id].upperLeft();var xy=currentShape.absoluteXY();x=oldXY.x-xy.x;y=oldXY.y-xy.y;if(x||y){considerForDockers=considerForDockers.without(currentShape);
this.adjustLanes(pool,this.getAllExcludedLanes(pool,currentShape),x,0)}var childLanes=this.getLanes(currentShape,true);if(childLanes.length>0){if(this.shouldScale(currentShape)){var old=this.hashedBounds[pool.id][currentShape.id];var scale=old.height()/currentShape.bounds.height();this.adjustLanes(pool,childLanes,x,y,scale)}else{this.adjustLanes(pool,childLanes,x,y,0)}}}var changes=allLanes.map(function(lane){return{shape:lane,bounds:lane.bounds.clone()}});height=this.adjustHeight(lanes,currentShape);this.checkForChanges(allLanes,changes);width=this.adjustWidth(lanes,currentShape.bounds.width()+(this.getDepth(currentShape,pool)*30))}}this.setDimensions(pool,width,height,x,y);if(this.facade.isExecutingCommands()&&(deletedLanes.length===0||addedLanes.length!==0)){this.updateDockers(considerForDockers,pool);if(this.hashedPositions[pool.id]&&this.hashedPositions[pool.id].keys().any(function(key,i){return(allLanes[i]||{}).id!==key})){var LanesHasBeenReordered=ORYX.Core.Command.extend({construct:function(originPosition,newPosition,lanes,plugin,poolId){this.originPosition=Object.clone(originPosition);this.newPosition=Object.clone(newPosition);this.lanes=lanes;this.plugin=plugin;this.pool=poolId},execute:function(){if(!this.executed){this.executed=true;this.lanes.each(function(lane){if(this.newPosition[lane.id]){lane.bounds.moveTo(this.newPosition[lane.id])}}.bind(this));this.plugin.hashedPositions[this.pool]=Object.clone(this.newPosition)}},rollback:function(){this.lanes.each(function(lane){if(this.originPosition[lane.id]){lane.bounds.moveTo(this.originPosition[lane.id])}}.bind(this));this.plugin.hashedPositions[this.pool]=Object.clone(this.originPosition)}});var hp2=$H({});allLanes.each(function(lane){hp2[lane.id]=lane.bounds.upperLeft()});var command=new LanesHasBeenReordered(hashedPositions,hp2,allLanes,this,pool.id);this.facade.executeCommands([command])}}this.hashedBounds[pool.id]={};this.hashedPositions[pool.id]=hashedPositions;var i=-1;while(++i1||childLanes.any(function(lane){return this.shouldScale(lane)}.bind(this))},checkForChanges:function(lanes,changes){if(this.facade.isExecutingCommands()&&changes.any(function(change){return change.shape.bounds.toString()!==change.bounds.toString()})){var Command=ORYX.Core.Command.extend({construct:function(changes){this.oldState=changes;this.newState=changes.map(function(s){return{shape:s.shape,bounds:s.bounds.clone()}})},execute:function(){if(this.executed){this.applyState(this.newState)}this.executed=true},rollback:function(){this.applyState(this.oldState)},applyState:function(state){state.each(function(s){s.shape.bounds.set(s.bounds.upperLeft(),s.bounds.lowerRight())})}});this.facade.executeCommands([new Command(changes)])}},isResized:function(shape,bounds){if(!bounds||!shape){return false}var oldB=bounds;return Math.round(oldB.width()-shape.bounds.width())!==0||Math.round(oldB.height()-shape.bounds.height())!==0},adjustLanes:function(pool,lanes,x,y,scale){scale=scale||0;lanes.each(function(l){l.getChildNodes().each(function(child){if(!child.getStencil().id().endsWith("Lane")){var cy=scale?child.bounds.center().y-(child.bounds.center().y/scale):-y;child.bounds.moveBy((x||0),-cy);if(scale&&child.getStencil().id().endsWith("Subprocess")){this.moveChildDockers(child,{x:(0),y:-cy})}}}.bind(this));this.hashedBounds[pool.id][l.id].moveBy(-(x||0),!scale?-y:0);if(scale){l.isScaled=true}}.bind(this))},getAllExcludedLanes:function(parent,lane){var lanes=[];parent.getChildNodes().each(function(shape){if((!lane||shape!==lane)&&shape.getStencil().id().endsWith("Lane")){lanes.push(shape);lanes=lanes.concat(this.getAllExcludedLanes(shape,lane))}}.bind(this));return lanes},forceToUpdateLane:function(lane){if(lane.bounds.height()!==lane._svgShapes[0].height){lane.isChanged=true;lane.isResized=true;lane._update()}},getDepth:function(child,parent){var i=0;while(child&&child.parent&&child!==parent){child=child.parent;++i}return i},updateDepth:function(lane,fromDepth,toDepth){var xOffset=(fromDepth-toDepth)*30;lane.getChildNodes().each(function(shape){shape.bounds.moveBy(xOffset,0);[].concat(children[j].getIncomingShapes()).concat(children[j].getOutgoingShapes())})},setDimensions:function(shape,width,height,x,y){var isLane=shape.getStencil().id().endsWith("Lane");shape.bounds.set(isLane?30:(shape.bounds.a.x-(x||0)),isLane?shape.bounds.a.y:(shape.bounds.a.y-(y||0)),width?shape.bounds.a.x+width-(isLane?30:(x||0)):shape.bounds.b.x,height?shape.bounds.a.y+height-(isLane?0:(y||0)):shape.bounds.b.y)},setLanePosition:function(shape,y){shape.bounds.moveTo(30,y)
},adjustWidth:function(lanes,width){(lanes||[]).each(function(lane){this.setDimensions(lane,width);this.adjustWidth(this.getLanes(lane),width-30)}.bind(this));return width},adjustHeight:function(lanes,changedLane,propagateHeight){var oldHeight=0;if(!changedLane&&propagateHeight){var i=-1;while(++ibuy?1:0)}var above=auybuy&&aly>bly;var slightlyAboveBottom=auy=bly&&oaly=buy&&alybuy&&aly<=bly&&oaly>obly;var slightlyBelowTop=auy<=buy&&aly>bly&&oauy>obuy;return(above||slightlyAboveBottom||slightlyAboveTop?-1:(below||slightlyBelowBottom||slightlyBelowTop?1:0))}.bind(this));return lanes},getNamespace:function(){if(!this.namespace){var stencilsets=this.facade.getStencilSets();if(stencilsets.keys()){this.namespace=stencilsets.keys()[0]}else{return undefined}}return this.namespace}};var ResizeLanesCommand=ORYX.Core.Command.extend({construct:function(shape,parent,pool,plugin){this.facade=plugin.facade;this.plugin=plugin;this.shape=shape;this.changes;this.pool=pool;this.parent=parent;this.shapeChildren=[];this.shape.getChildShapes().each(function(childShape){this.shapeChildren.push({shape:childShape,bounds:{a:{x:childShape.bounds.a.x,y:childShape.bounds.a.y},b:{x:childShape.bounds.b.x,y:childShape.bounds.b.y}}})}.bind(this));this.shapeUpperLeft=this.shape.bounds.upperLeft();this.parentHeight=this.parent.bounds.height()},getLeafLanes:function(lane){var childLanes=this.plugin.getLanes(lane).map(function(child){return this.getLeafLanes(child)}.bind(this)).flatten();return childLanes.length>0?childLanes:[lane]},findNewLane:function(){var lanes=this.plugin.getLanes(this.parent);var leafLanes=this.getLeafLanes(this.parent);this.lane=leafLanes.find(function(l){return l.bounds.upperLeft().y>=this.shapeUpperLeft.y}.bind(this))||leafLanes.last();this.laneUpperLeft=this.lane.bounds.upperLeft()},execute:function(){if(this.changes){this.executeAgain();return}if(!this.lane){this.findNewLane()}if(this.lane){var laUpL=this.laneUpperLeft;var shUpL=this.shapeUpperLeft;var depthChange=this.plugin.getDepth(this.lane,this.parent)-1;this.changes=$H({});if(laUpL.y>=shUpL.y){this.lane.getChildShapes().each(function(childShape){if(!this.changes[childShape.getId()]){this.changes[childShape.getId()]=this.computeChanges(childShape,this.lane,this.lane,this.shape.bounds.height())}childShape.bounds.moveBy(0,this.shape.bounds.height())}.bind(this));this.plugin.hashChildShapes(this.lane);this.shapeChildren.each(function(shapeChild){shapeChild.shape.bounds.set(shapeChild.bounds);shapeChild.shape.bounds.moveBy((shUpL.x-30)-(depthChange*30),0);if(!this.changes[shapeChild.shape.getId()]){this.changes[shapeChild.shape.getId()]=this.computeChanges(shapeChild.shape,this.shape,this.lane,0)}this.lane.add(shapeChild.shape)}.bind(this));this.lane.bounds.moveBy(0,shUpL.y-laUpL.y)}else{if(shUpL.y>laUpL.y){this.shapeChildren.each(function(shapeChild){shapeChild.shape.bounds.set(shapeChild.bounds);shapeChild.shape.bounds.moveBy((shUpL.x-30)-(depthChange*30),this.lane.bounds.height());if(!this.changes[shapeChild.shape.getId()]){this.changes[shapeChild.shape.getId()]=this.computeChanges(shapeChild.shape,this.shape,this.lane,0)}this.lane.add(shapeChild.shape)}.bind(this))}}}var oldHeight=this.lane.bounds.height();var newHeight=this.lane.length===1?this.parentHeight:this.lane.bounds.height()+this.shape.bounds.height();this.setHeight(newHeight,oldHeight,this.parent,this.parentHeight,true);this.plugin.getLanes(this.parent).each(function(childLane){if(!this.changes[childLane.getId()]&&childLane!==this.lane&&childLane!==this.shape){this.changes[childLane.getId()]=this.computeChanges(childLane,this.parent,this.parent,0)}}.bind(this));this.update()},setHeight:function(newHeight,oldHeight,parent,parentHeight,store){this.plugin.setDimensions(this.lane,this.lane.bounds.width(),newHeight);this.plugin.hashedBounds[this.pool.id][this.lane.id]=this.lane.absoluteBounds();this.plugin.adjustHeight(this.plugin.getLanes(parent),this.lane);if(store===true){this.changes[this.shape.getId()]=this.computeChanges(this.shape,parent,parent,0,oldHeight,newHeight)}this.plugin.setDimensions(parent,parent.bounds.width(),parentHeight);if(parent!==this.pool){this.plugin.setDimensions(this.pool,this.pool.bounds.width(),this.pool.bounds.height()+(newHeight-oldHeight))}},update:function(){this.plugin.hashedBounds[this.pool.id]["REMOVED"]=true},rollback:function(){var laUpL=this.laneUpperLeft;var shUpL=this.shapeUpperLeft;this.changes.each(function(pair){var parent=pair.value.oldParent;var shape=pair.value.shape;var parentHeight=pair.value.parentHeight;var oldHeight=pair.value.oldHeight;var newHeight=pair.value.newHeight;if(shape.getStencil().id().endsWith("Lane")){shape.bounds.moveTo(pair.value.oldPosition)
}if(oldHeight){this.setHeight(oldHeight,newHeight,parent,parent.bounds.height()+(oldHeight-newHeight));if(laUpL.y>=shUpL.y){this.lane.bounds.moveBy(0,this.shape.bounds.height()-1)}}else{parent.add(shape);shape.bounds.moveTo(pair.value.oldPosition)}}.bind(this))},executeAgain:function(){this.changes.each(function(pair){var parent=pair.value.newParent;var shape=pair.value.shape;var newHeight=pair.value.newHeight;var oldHeight=pair.value.oldHeight;if(newHeight){var laUpL=this.laneUpperLeft.y;var shUpL=this.shapeUpperLeft.y;if(laUpL>=shUpL){this.lane.bounds.moveBy(0,shUpL-laUpL)}this.setHeight(newHeight,oldHeight,parent,parent.bounds.height()+(newHeight-oldHeight))}else{parent.add(shape);shape.bounds.moveTo(pair.value.newPosition)}}.bind(this));this.update()},computeChanges:function(shape,oldParent,parent,yOffset,oldHeight,newHeight){oldParent=this.changes[shape.getId()]?this.changes[shape.getId()].oldParent:oldParent;var oldPosition=this.changes[shape.getId()]?this.changes[shape.getId()].oldPosition:shape.bounds.upperLeft();var sUl=shape.bounds.upperLeft();var pos={x:sUl.x,y:sUl.y+yOffset};var changes={shape:shape,parentHeight:oldParent.bounds.height(),oldParent:oldParent,oldPosition:oldPosition,oldHeight:oldHeight,newParent:parent,newPosition:pos,newHeight:newHeight};return changes}});ORYX.Plugins.BPMN2_0=ORYX.Plugins.AbstractPlugin.extend(ORYX.Plugins.BPMN2_0)}();