<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
.KEYW {color: yellow;}
.COMM {color: #bbb; font-style: italic;}
.NUMB {color: #393;}
.STRN {color: #393;}
.REGX {color: #339;}
.NAME {color: white;}
.PUNC {color: #5ca29c;}
.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
</style></head><body><pre><span class='line'> 1</span> <span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">global</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT"> </span><span class="COMM">// BEGIN CLOSURE</span><span class="WHIT">
<span class='line'> 2</span>
<span class='line'> 3</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">Joint</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">global.Joint</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 4</span> </span><span class="WHIT"> </span><span class="NAME">Element</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Joint.dia.Element</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 5</span>
<span class='line'> 6</span> </span><span class="COMM">/**
<span class='line'> 7</span> * @name Joint.dia.pn
<span class='line'> 8</span> * @namespace Holds functionality related to Petri net diagrams.
<span class='line'> 9</span> */</span><span class="WHIT">
<span class='line'> 10</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Joint.dia.pn</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 11</span>
<span class='line'> 12</span> </span><span class="COMM">/**
<span class='line'> 13</span> * Predefined arrow.
<span class='line'> 14</span> * @name Joint.dia.pn.arrow
<span class='line'> 15</span> * @memberOf Joint.dia.pn
<span class='line'> 16</span> * @example p1.joint(e2, Joint.dia.pn.arrow);
<span class='line'> 17</span> */</span><span class="WHIT">
<span class='line'> 18</span> </span><span class="NAME">pn.arrow</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 19</span> </span><span class="WHIT"> </span><span class="NAME">startArrow</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">type</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"none"</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 20</span> </span><span class="WHIT"> </span><span class="NAME">endArrow</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="NAME">type</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"basic"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">size</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">5</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 21</span> </span><span class="NAME">attrs</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">"stroke-dasharray"</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"none"</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 22</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 23</span>
<span class='line'> 24</span> </span><span class="COMM">/**
<span class='line'> 25</span> * Petri net place.
<span class='line'> 26</span> * @name Place.create
<span class='line'> 27</span> * @methodOf Joint.dia.pn
<span class='line'> 28</span> * @param {Object} properties
<span class='line'> 29</span> * @param {Object} properties.position Position of the place (e.g. {x: 50, y: 100}).
<span class='line'> 30</span> * @param {Number} [properties.radius] Radius of the circle of the place.
<span class='line'> 31</span> * @param {Number} [properties.tokenRadius] Radius of the tokens of the place.
<span class='line'> 32</span> * @param {Number} [properties.tokens] Number of tokens.
<span class='line'> 33</span> * @param {String} [properties.label] The name of the place.
<span class='line'> 34</span> * @param {Object} [properties.attrs] SVG attributes of the appearance of the place.
<span class='line'> 35</span> * @param {Object} [properties.tokenAttrs] SVG attributes of the appearance of the token circles.
<span class='line'> 36</span> * @example
<span class='line'> 37</span> var p1 = Joint.dia.pn.Place.create({
<span class='line'> 38</span> position: {x: 120, y: 70},
<span class='line'> 39</span> radius: 25,
<span class='line'> 40</span> tokenRadius: 4,
<span class='line'> 41</span> tokens: 3,
<span class='line'> 42</span> label: "p1",
<span class='line'> 43</span> attrs: {
<span class='line'> 44</span> stroke: "blue"
<span class='line'> 45</span> },
<span class='line'> 46</span> tokenAttrs: {
<span class='line'> 47</span> fill: "red"
<span class='line'> 48</span> }
<span class='line'> 49</span> });
<span class='line'> 50</span> */</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="NAME">pn.Place</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Element.extend</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT"> </span><span class="NAME">object</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"Place"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 53</span> </span><span class="WHIT"> </span><span class="NAME">module</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"pn"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 54</span> </span><span class="WHIT"> </span><span class="NAME">init</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">properties</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 55</span> </span><span class="WHIT"> </span><span class="COMM">// options</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Joint.DeepSupplement</span><span class="PUNC">(</span><span class="NAME">this.properties</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">properties</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="WHIT"> </span><span class="NAME">radius</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">20</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT"> </span><span class="NAME">tokenRadius</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT"> </span><span class="NAME">tokens</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="WHIT"> </span><span class="NAME">attrs</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">fill</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'white'</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT"> </span><span class="NAME">tokenAttrs</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">fill</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'black'</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT"> </span><span class="COMM">// wrapper</span><span class="WHIT">
<span class='line'> 64</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">paper</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.paper</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 65</span> </span><span class="WHIT"> </span><span class="NAME">this.setWrapper</span><span class="PUNC">(</span><span class="NAME">paper.circle</span><span class="PUNC">(</span><span class="NAME">p.position.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.position.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.radius</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="NAME">p.attrs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT"> </span><span class="COMM">// inner</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">strut</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// px</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT"> </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.tokens</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 70</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 71</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 72</span> </span><span class="WHIT"> </span><span class="NAME">this.addInner</span><span class="PUNC">(</span><span class="NAME">paper.circle</span><span class="PUNC">(</span><span class="NAME">p.position.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.position.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.tokenRadius</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="NAME">p.tokenAttrs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 73</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 74</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 75</span> </span><span class="WHIT"> </span><span class="NAME">this.addInner</span><span class="PUNC">(</span><span class="NAME">paper.circle</span><span class="PUNC">(</span><span class="NAME">p.position.x</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.tokenRadius</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.position.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.tokenRadius</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="NAME">p.tokenAttrs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 76</span> </span><span class="WHIT"> </span><span class="NAME">this.addInner</span><span class="PUNC">(</span><span class="NAME">paper.circle</span><span class="PUNC">(</span><span class="NAME">p.position.x</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.tokenRadius</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.position.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.tokenRadius</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="NAME">p.tokenAttrs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> </span><span class="WHIT"> </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="NUMB">3</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 79</span> </span><span class="WHIT"> </span><span class="NAME">this.addInner</span><span class="PUNC">(</span><span class="NAME">paper.circle</span><span class="PUNC">(</span><span class="NAME">p.position.x</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.tokenRadius</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">strut</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.position.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.tokenRadius</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="NAME">p.tokenAttrs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT"> </span><span class="NAME">this.addInner</span><span class="PUNC">(</span><span class="NAME">paper.circle</span><span class="PUNC">(</span><span class="NAME">p.position.x</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.tokenRadius</span><span class="WHIT"> </span><span class="PUNC">*</span><span class="WHIT"> </span><span class="NUMB">2</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">strut</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.position.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.tokenRadius</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="NAME">p.tokenAttrs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT"> </span><span class="NAME">this.addInner</span><span class="PUNC">(</span><span class="NAME">paper.circle</span><span class="PUNC">(</span><span class="NAME">p.position.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.position.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.tokenRadius</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="NAME">p.tokenAttrs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT"> </span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'> 84</span> </span><span class="WHIT"> </span><span class="NAME">this.addInner</span><span class="PUNC">(</span><span class="NAME">paper.text</span><span class="PUNC">(</span><span class="NAME">p.position.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.position.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.tokens.toString</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 85</span> </span><span class="WHIT"> </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 86</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 87</span> </span><span class="WHIT"> </span><span class="COMM">// label</span><span class="WHIT">
<span class='line'> 88</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.label</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 89</span> </span><span class="WHIT"> </span><span class="NAME">this.addInner</span><span class="PUNC">(</span><span class="NAME">paper.text</span><span class="PUNC">(</span><span class="NAME">p.position.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.position.y</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NAME">p.radius</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.label</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="WHIT"> </span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NAME">this.inner.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">translate</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NAME">this.inner.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getBBox</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">height</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 91</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT"> </span><span class="NAME">zoom</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT"> </span><span class="COMM">// @todo tokens must move accordingly</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.inner.length</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT"> </span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">scale.apply</span><span class="PUNC">(</span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.label</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT"> </span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NAME">this.inner.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">remove</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bb</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.wrapper.getBBox</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT"> </span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NAME">this.inner.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.paper.text</span><span class="PUNC">(</span><span class="NAME">bb.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">bb.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.properties.label</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT"> </span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NAME">this.inner.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">translate</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NAME">this.inner.length</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getBBox</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">height</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>105</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>106</span>
<span class='line'>107</span> </span><span class="COMM">/**
<span class='line'>108</span> * Petri net event.
<span class='line'>109</span> * @name Event.create
<span class='line'>110</span> * @methodOf Joint.dia.pn
<span class='line'>111</span> * @param {Object} properties
<span class='line'>112</span> * @param {Object} properties.rect Bounding box of the event (e.g. {x: 50, y: 100, width: 30, height: 100}).
<span class='line'>113</span> * @param {String} [properties.label] The name of the event.
<span class='line'>114</span> * @param {Object} [properties.attrs] SVG attributes of the appearance of the event.
<span class='line'>115</span> * @example
<span class='line'>116</span> var p1 = Joint.dia.pn.Event.create({
<span class='line'>117</span> rect: {x: 120, y: 70, width: 50, height: 7},
<span class='line'>118</span> label: "e1",
<span class='line'>119</span> attrs: {
<span class='line'>120</span> stroke: "blue",
<span class='line'>121</span> fill: "yellow"
<span class='line'>122</span> }
<span class='line'>123</span> });
<span class='line'>124</span> */</span><span class="WHIT">
<span class='line'>125</span> </span><span class="NAME">pn.Event</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Element.extend</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT"> </span><span class="NAME">object</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"Event"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT"> </span><span class="NAME">module</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">"pn"</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>128</span> </span><span class="WHIT"> </span><span class="NAME">init</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">properties</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="COMM">// options</span><span class="WHIT">
<span class='line'>130</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">p</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">Joint.DeepSupplement</span><span class="PUNC">(</span><span class="NAME">this.properties</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">properties</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>131</span> </span><span class="WHIT"> </span><span class="NAME">attrs</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT"> </span><span class="NAME">fill</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'black'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">stroke</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="STRN">'black'</span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>132</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="COMM">// wrapper</span><span class="WHIT">
<span class='line'>134</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">paper</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.paper</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT"> </span><span class="NAME">this.setWrapper</span><span class="PUNC">(</span><span class="NAME">paper.rect</span><span class="PUNC">(</span><span class="NAME">p.rect.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.rect.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.rect.width</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.rect.height</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">attr</span><span class="PUNC">(</span><span class="NAME">p.attrs</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">p.label</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT"> </span><span class="NAME">this.addInner</span><span class="PUNC">(</span><span class="NAME">paper.text</span><span class="PUNC">(</span><span class="NAME">p.rect.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.rect.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">p.label</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT"> </span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">translate</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getBBox</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">height</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>140</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>141</span> </span><span class="WHIT"> </span><span class="NAME">zoom</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">this.properties.label</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>143</span> </span><span class="WHIT"> </span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">remove</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">bb</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.wrapper.getBBox</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">this.paper.text</span><span class="PUNC">(</span><span class="NAME">bb.x</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">bb.y</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">this.properties.label</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>146</span> </span><span class="WHIT"> </span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">translate</span><span class="PUNC">(</span><span class="NUMB">0</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NAME">this.inner</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">getBBox</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">height</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>149</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>150</span>
<span class='line'>151</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="COMM">// END CLOSURE</span><span class="WHIT">
<span class='line'>152</span> </span></pre></body></html>