-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path180.html
91 lines (91 loc) · 15.3 KB
/
180.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<html><head><title>MouseHandler.java</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="sourcestyles.css" />
</head><body link="blue" vlink="blue">
<h3>File: /Users/shatabdi/Education/GitHub/se450_project/src/view/adapter/MouseHandler.java</h3>
<SCRIPT>
defaultStatus = "File: /Users/shatabdi/Education/GitHub/se450_project/src/view/adapter/MouseHandler.java";
top.document.title = "MouseHandler.java";
</SCRIPT>
<pre><span class="default"></span><a name="1"><font size=-1>1 </font></a><span class="default"></span><span class="keyword">package </span><span class="default">view.<a href="dictionary_V.html#158">adapter</a>;</span>
<a name="2"><font size=-1>2 </font></a><span class="default"></span>
<a name="3"><font size=-1>3 </font></a><span class="default"></span><span class="keyword">import </span><span class="default">java.<a href="dictionary_J.html#152">awt</a>.<a href="dictionary_J.html#214">Point</a>;</span>
<a name="4"><font size=-1>4 </font></a><span class="default"></span><span class="keyword">import </span><span class="default">java.awt.<a href="dictionary_J.html#215">event</a>.<a href="dictionary_J.html#182">MouseEvent</a>;</span>
<a name="5"><font size=-1>5 </font></a><span class="default"></span>
<a name="6"><font size=-1>6 </font></a><span class="default"></span><span class="keyword">import </span><span class="default">model.<a href="dictionary_M.html#45">interfaces</a>.<a href="dictionary_M.html#43">IApplicationState</a>;</span>
<a name="7"><font size=-1>7 </font></a><span class="default"></span><span class="keyword">import </span><span class="default">view.<a href="dictionary_V.html#10">interfaces</a>.<a href="dictionary_V.html#98">PaintCanvasBase</a>;</span>
<a name="8"><font size=-1>8 </font></a><span class="default"></span>
<a name="9"><font size=-1>9 </font></a><span class="default"></span><span class="keyword">public class <a href="dictionary_V.html#183">MouseHandler</a> extends </span><span class="default">java.awt.<a href="dictionary_J.html#215">event</a>.<a href="dictionary_J.html#181">MouseAdapter</a> {</span>
<a name="10"><font size=-1>10 </font></a><span class="default"></span>
<a name="11"><font size=-1>11 </font></a><span class="default"> </span><span class="keyword">private <a href="dictionary_M.html#43">IApplicationState</a> <a href="dictionary_V.html#206">applicationState</a></span><span class="default">;</span>
<a name="12"><font size=-1>12 </font></a><span class="default"> </span><span class="keyword">private <a href="dictionary_V.html#98">PaintCanvasBase</a> <a href="dictionary_V.html#207">canvasBase</a></span><span class="default">;</span>
<a name="13"><font size=-1>13 </font></a><span class="default"> </span><span class="keyword">private <a href="dictionary_J.html#214">Point</a> <a href="dictionary_V.html#210">end</a></span><span class="default">;</span>
<a name="14"><font size=-1>14 </font></a><span class="default"> </span><span class="keyword">private boolean <a href="dictionary_V.html#211">mouseDragged</a> </span><span class="default">= </span><span class="keyword">false</span><span class="default">;</span>
<a name="15"><font size=-1>15 </font></a><span class="default"> </span><span class="keyword">private <a href="dictionary_V.html#216">MoveMouseAdapter</a> <a href="dictionary_V.html#212">moveMouseAdapter</a> </span><span class="default">= </span><span class="keyword">null</span><span class="default">;</span>
<a name="16"><font size=-1>16 </font></a><span class="default"> </span><span class="keyword">private <a href="dictionary_J.html#214">Point</a> <a href="dictionary_V.html#213">start</a></span><span class="default">;</span>
<a name="17"><font size=-1>17 </font></a><span class="default"> </span><span class="keyword">private int <a href="dictionary_V.html#208">dragX</a> </span><span class="default">= </span><span class="number">0</span><span class="default">;</span>
<a name="18"><font size=-1>18 </font></a><span class="default"></span>
<a name="19"><font size=-1>19 </font></a><span class="default"> </span><span class="keyword">private int <a href="dictionary_V.html#209">dragY</a> </span><span class="default">= </span><span class="number">0</span><span class="default">;</span>
<a name="20"><font size=-1>20 </font></a><span class="default"></span>
<a name="21"><font size=-1>21 </font></a><span class="default"> </span><span class="keyword">public <a href="dictionary_V.html#184">MouseHandler</a></span><span class="default">(<a href="dictionary_V.html#98">PaintCanvasBase</a> <a href="dictionary_V.html#186">canvasBase</a>, <a href="dictionary_M.html#43">IApplicationState</a> <a href="dictionary_V.html#185">appState</a>) {</span>
<a name="22"><font size=-1>22 </font></a><span class="default"> </span><span class="keyword">this</span><span class="default">.<a href="dictionary_V.html#207">canvasBase</a> = <a href="dictionary_V.html#186">canvasBase</a>;</span>
<a name="23"><font size=-1>23 </font></a><span class="default"> </span><span class="keyword">this</span><span class="default">.<a href="dictionary_V.html#206">applicationState</a> = <a href="dictionary_V.html#185">appState</a>;</span>
<a name="24"><font size=-1>24 </font></a><span class="default"> }</span>
<a name="25"><font size=-1>25 </font></a><span class="default"></span>
<a name="26"><font size=-1>26 </font></a><span class="default"> @<a href="dictionary_O.html#14">Override</a></span>
<a name="27"><font size=-1>27 </font></a><span class="default"> </span><span class="keyword">public void <a href="dictionary_V.html#187">mouseDragged</a></span><span class="default">(<a href="dictionary_J.html#182">MouseEvent</a> <a href="dictionary_V.html#193">e</a>) {</span>
<a name="28"><font size=-1>28 </font></a><span class="default"></span>
<a name="29"><font size=-1>29 </font></a><span class="default"> <a href="dictionary_V.html#211">mouseDragged</a> = </span><span class="keyword">true</span><span class="default">;</span>
<a name="30"><font size=-1>30 </font></a><span class="default"> </span><span class="keyword">int <a href="dictionary_V.html#191">currentX</a> </span><span class="default">= <a href="dictionary_V.html#193">e</a>.<a href="dictionary_G.html#188">getX</a>();</span>
<a name="31"><font size=-1>31 </font></a><span class="default"> </span><span class="keyword">int <a href="dictionary_V.html#192">currentY</a> </span><span class="default">= <a href="dictionary_V.html#193">e</a>.<a href="dictionary_G.html#189">getY</a>();</span>
<a name="32"><font size=-1>32 </font></a><span class="default"></span>
<a name="33"><font size=-1>33 </font></a><span class="default"> </span><span class="keyword">if </span><span class="default">(<a href="dictionary_V.html#206">applicationState</a>.<a href="dictionary_M.html#221">getActiveMouseMode</a>().<a href="dictionary_N.html#190">name</a>().<a href="dictionary_E.html#126">equals</a>(<a href="dictionary_V.html#218">Messages</a>.<a href="dictionary_V.html#222">getString</a>(</span><span class="string">"MouseHandler.0"</span><span class="default">))) { </span><span class="comment">//$NON-NLS-1$</span>
<a name="34"><font size=-1>34 </font></a><span class="comment"> </span><span class="keyword">int <a href="dictionary_V.html#195">translateXX</a> </span><span class="default">= <a href="dictionary_V.html#191">currentX</a> - <a href="dictionary_V.html#208">dragX</a>;</span>
<a name="35"><font size=-1>35 </font></a><span class="default"> </span><span class="keyword">int <a href="dictionary_V.html#196">translateYY</a> </span><span class="default">= <a href="dictionary_V.html#192">currentY</a> - <a href="dictionary_V.html#209">dragY</a>;</span>
<a name="36"><font size=-1>36 </font></a><span class="default"> <a href="dictionary_J.html#214">Point</a> <a href="dictionary_V.html#194">transformPos</a> = </span><span class="keyword">new <a href="dictionary_J.html#214">Point</a></span><span class="default">(<a href="dictionary_V.html#195">translateXX</a>, <a href="dictionary_V.html#196">translateYY</a>);</span>
<a name="37"><font size=-1>37 </font></a><span class="default"></span>
<a name="38"><font size=-1>38 </font></a><span class="default"> <a href="dictionary_V.html#208">dragX</a> = <a href="dictionary_V.html#191">currentX</a>;</span>
<a name="39"><font size=-1>39 </font></a><span class="default"> <a href="dictionary_V.html#209">dragY</a> = <a href="dictionary_V.html#192">currentY</a>;</span>
<a name="40"><font size=-1>40 </font></a><span class="default"></span>
<a name="41"><font size=-1>41 </font></a><span class="default"> <a href="dictionary_V.html#212">moveMouseAdapter</a> = </span><span class="keyword">new <a href="dictionary_V.html#223">MoveMouseAdapter</a></span><span class="default">(<a href="dictionary_V.html#213">start</a>, <a href="dictionary_V.html#194">transformPos</a>, <a href="dictionary_V.html#207">canvasBase</a>);</span>
<a name="42"><font size=-1>42 </font></a><span class="default"> <a href="dictionary_V.html#212">moveMouseAdapter</a>.<a href="dictionary_V.html#224">update</a>();</span>
<a name="43"><font size=-1>43 </font></a><span class="default"> }</span>
<a name="44"><font size=-1>44 </font></a><span class="default"> }</span>
<a name="45"><font size=-1>45 </font></a><span class="default"></span>
<a name="46"><font size=-1>46 </font></a><span class="default"> @<a href="dictionary_O.html#14">Override</a></span>
<a name="47"><font size=-1>47 </font></a><span class="default"> </span><span class="keyword">public void <a href="dictionary_V.html#197">mousePressed</a></span><span class="default">(<a href="dictionary_J.html#182">MouseEvent</a> <a href="dictionary_V.html#199">e</a>) {</span>
<a name="48"><font size=-1>48 </font></a><span class="default"> <a href="dictionary_V.html#213">start</a> = <a href="dictionary_V.html#199">e</a>.<a href="dictionary_G.html#198">getPoint</a>();</span>
<a name="49"><font size=-1>49 </font></a><span class="default"> <a href="dictionary_V.html#210">end</a> = <a href="dictionary_V.html#199">e</a>.<a href="dictionary_G.html#198">getPoint</a>();</span>
<a name="50"><font size=-1>50 </font></a><span class="default"> <a href="dictionary_V.html#208">dragX</a> = <a href="dictionary_V.html#199">e</a>.<a href="dictionary_G.html#188">getX</a>();</span>
<a name="51"><font size=-1>51 </font></a><span class="default"> <a href="dictionary_V.html#209">dragY</a> = <a href="dictionary_V.html#199">e</a>.<a href="dictionary_G.html#189">getY</a>();</span>
<a name="52"><font size=-1>52 </font></a><span class="default"> <a href="dictionary_V.html#211">mouseDragged</a> = </span><span class="keyword">false</span><span class="default">;</span>
<a name="53"><font size=-1>53 </font></a><span class="default"></span>
<a name="54"><font size=-1>54 </font></a><span class="default"> }</span>
<a name="55"><font size=-1>55 </font></a><span class="default"></span>
<a name="56"><font size=-1>56 </font></a><span class="default"> @<a href="dictionary_O.html#14">Override</a></span>
<a name="57"><font size=-1>57 </font></a><span class="default"> </span><span class="keyword">public void <a href="dictionary_V.html#200">mouseReleased</a></span><span class="default">(<a href="dictionary_J.html#182">MouseEvent</a> <a href="dictionary_V.html#204">e</a>) {</span>
<a name="58"><font size=-1>58 </font></a><span class="default"> <a href="dictionary_V.html#210">end</a> = <a href="dictionary_V.html#204">e</a>.<a href="dictionary_G.html#198">getPoint</a>();</span>
<a name="59"><font size=-1>59 </font></a><span class="default"> <a href="dictionary_V.html#217">MouseMode</a> <a href="dictionary_V.html#205">mouseMode</a> = </span><span class="keyword">null</span><span class="default">;</span>
<a name="60"><font size=-1>60 </font></a><span class="default"></span>
<a name="61"><font size=-1>61 </font></a><span class="default"> </span><span class="keyword">switch </span><span class="default">(<a href="dictionary_V.html#206">applicationState</a>.<a href="dictionary_M.html#221">getActiveMouseMode</a>()) {</span>
<a name="62"><font size=-1>62 </font></a><span class="default"> </span><span class="keyword">case <a href="dictionary_D.html#201">DRAW</a></span><span class="default">:</span>
<a name="63"><font size=-1>63 </font></a><span class="default"> <a href="dictionary_V.html#205">mouseMode</a> = </span><span class="keyword">new <a href="dictionary_V.html#225">DrawMouseAdapter</a></span><span class="default">(<a href="dictionary_V.html#213">start</a>, <a href="dictionary_V.html#210">end</a>, <a href="dictionary_V.html#207">canvasBase</a>, <a href="dictionary_V.html#206">applicationState</a>);</span>
<a name="64"><font size=-1>64 </font></a><span class="default"> </span><span class="keyword">break</span><span class="default">;</span>
<a name="65"><font size=-1>65 </font></a><span class="default"> </span><span class="keyword">case <a href="dictionary_S.html#203">SELECT</a></span><span class="default">:</span>
<a name="66"><font size=-1>66 </font></a><span class="default"> <a href="dictionary_V.html#205">mouseMode</a> = </span><span class="keyword">new <a href="dictionary_V.html#226">SelectMouseAdapter</a></span><span class="default">(<a href="dictionary_V.html#213">start</a>, <a href="dictionary_V.html#210">end</a>, <a href="dictionary_V.html#207">canvasBase</a>);</span>
<a name="67"><font size=-1>67 </font></a><span class="default"> </span><span class="keyword">break</span><span class="default">;</span>
<a name="68"><font size=-1>68 </font></a><span class="default"> </span><span class="keyword">case <a href="dictionary_M.html#202">MOVE</a></span><span class="default">:</span>
<a name="69"><font size=-1>69 </font></a><span class="default"> </span><span class="keyword">if </span><span class="default">(<a href="dictionary_V.html#211">mouseDragged</a> && <a href="dictionary_V.html#212">moveMouseAdapter</a> != </span><span class="keyword">null</span><span class="default">) {</span>
<a name="70"><font size=-1>70 </font></a><span class="default"> <a href="dictionary_V.html#212">moveMouseAdapter</a>.<a href="dictionary_V.html#227">releasePosition</a>(<a href="dictionary_V.html#210">end</a>);</span>
<a name="71"><font size=-1>71 </font></a><span class="default"> }</span>
<a name="72"><font size=-1>72 </font></a><span class="default"></span>
<a name="73"><font size=-1>73 </font></a><span class="default"> </span><span class="keyword">break</span><span class="default">;</span>
<a name="74"><font size=-1>74 </font></a><span class="default"> }</span>
<a name="75"><font size=-1>75 </font></a><span class="default"></span>
<a name="76"><font size=-1>76 </font></a><span class="default"> </span><span class="keyword">if </span><span class="default">(<a href="dictionary_V.html#205">mouseMode</a> != </span><span class="keyword">null</span><span class="default">) {</span>
<a name="77"><font size=-1>77 </font></a><span class="default"> <a href="dictionary_V.html#205">mouseMode</a>.<a href="dictionary_V.html#228">update</a>();</span>
<a name="78"><font size=-1>78 </font></a><span class="default"> }</span>
<a name="79"><font size=-1>79 </font></a><span class="default"> }</span>
<a name="80"><font size=-1>80 </font></a><span class="default">}</span>
<a name="81"><font size=-1>81 </font></a><span class="default"></span>
</pre></body></html>