-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1040.html
58 lines (58 loc) · 11 KB
/
1040.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
<html><head><title>ShapeFactory.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/model/factory/ShapeFactory.java</h3>
<SCRIPT>
defaultStatus = "File: /Users/shatabdi/Education/GitHub/se450_project/src/model/factory/ShapeFactory.java";
top.document.title = "ShapeFactory.java";
</SCRIPT>
<pre><span class="default"></span><a name="1"><font size=-1>1 </font></a><span class="default"></span><span class="comment">// Project starter code</span>
<a name="2"><font size=-1>2 </font></a><span class="comment">// Static Factory pattern, write in report</span>
<a name="3"><font size=-1>3 </font></a><span class="comment"></span><span class="keyword">package </span><span class="default">model.<a href="dictionary_M.html#344">factory</a>;</span>
<a name="4"><font size=-1>4 </font></a><span class="default"></span>
<a name="5"><font size=-1>5 </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#294">BasicStroke</a>;</span>
<a name="6"><font size=-1>6 </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#111">Graphics2D</a>;</span>
<a name="7"><font size=-1>7 </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="8"><font size=-1>8 </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#149">Shape</a>;</span>
<a name="9"><font size=-1>9 </font></a><span class="default"></span>
<a name="10"><font size=-1>10 </font></a><span class="default"></span><span class="keyword">import <a href="dictionary_M.html#20">model</a></span><span class="default">.<a href="dictionary_M.html#390">Ellipse</a>;</span>
<a name="11"><font size=-1>11 </font></a><span class="default"></span><span class="keyword">import <a href="dictionary_M.html#20">model</a></span><span class="default">.<a href="dictionary_M.html#341">GeometricShape</a>;</span>
<a name="12"><font size=-1>12 </font></a><span class="default"></span><span class="keyword">import <a href="dictionary_M.html#20">model</a></span><span class="default">.<a href="dictionary_M.html#112">Rectangle</a>;</span>
<a name="13"><font size=-1>13 </font></a><span class="default"></span><span class="keyword">import <a href="dictionary_M.html#20">model</a></span><span class="default">.<a href="dictionary_M.html#793">Triangle</a>;</span>
<a name="14"><font size=-1>14 </font></a><span class="default"></span><span class="keyword">import </span><span class="default">model.<a href="dictionary_M.html#157">strategy</a>.<a href="dictionary_M.html#956">ShapeShadingStrategy</a>;</span>
<a name="15"><font size=-1>15 </font></a><span class="default"></span><span class="keyword">import </span><span class="default">model.<a href="dictionary_M.html#157">strategy</a>.<a href="dictionary_M.html#154">ShapeTypeStrategy</a>;</span>
<a name="16"><font size=-1>16 </font></a><span class="default"></span><span class="keyword">import </span><span class="default">view.<a href="dictionary_V.html#3">Enum</a>.<a href="dictionary_V.html#40">ShapeColor</a>;</span>
<a name="17"><font size=-1>17 </font></a><span class="default"></span><span class="keyword">import </span><span class="default">view.<a href="dictionary_V.html#3">Enum</a>.ShapeShadingType;</span>
<a name="18"><font size=-1>18 </font></a><span class="default"></span><span class="keyword">import </span><span class="default">view.<a href="dictionary_V.html#3">Enum</a>.ShapeType;</span>
<a name="19"><font size=-1>19 </font></a><span class="default"></span>
<a name="20"><font size=-1>20 </font></a><span class="default"></span><span class="keyword">public class <a href="dictionary_M.html#342">ShapeFactory</a> </span><span class="default">{</span>
<a name="21"><font size=-1>21 </font></a><span class="default"></span>
<a name="22"><font size=-1>22 </font></a><span class="default"> </span><span class="keyword">public static <a href="dictionary_M.html#956">ShapeShadingStrategy</a> <a href="dictionary_M.html#957">combine</a></span><span class="default">(ShapeShadingType <a href="dictionary_M.html#1045">shapeShadingType</a>, <a href="dictionary_V.html#40">ShapeColor</a> <a href="dictionary_M.html#1042">primaryColor</a>,</span>
<a name="23"><font size=-1>23 </font></a><span class="default"> <a href="dictionary_V.html#40">ShapeColor</a> <a href="dictionary_M.html#1043">secondaryColor</a>, <a href="dictionary_J.html#149">Shape</a> <a href="dictionary_M.html#1044">shape</a>, <a href="dictionary_J.html#111">Graphics2D</a> <a href="dictionary_M.html#1041">g2</a>, <a href="dictionary_J.html#294">BasicStroke</a> <a href="dictionary_M.html#1046">str</a>) {</span>
<a name="24"><font size=-1>24 </font></a><span class="default"> </span><span class="keyword">return new <a href="dictionary_M.html#1058">ShapeShadingStrategy</a></span><span class="default">(<a href="dictionary_M.html#1045">shapeShadingType</a>, <a href="dictionary_M.html#1042">primaryColor</a>, <a href="dictionary_M.html#1043">secondaryColor</a>, <a href="dictionary_M.html#1044">shape</a>, <a href="dictionary_M.html#1041">g2</a>, <a href="dictionary_M.html#1046">str</a>);</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"></span>
<a name="27"><font size=-1>27 </font></a><span class="default"> </span><span class="keyword">public static <a href="dictionary_J.html#149">Shape</a> <a href="dictionary_M.html#348">createShape</a></span><span class="default">(<a href="dictionary_M.html#341">GeometricShape</a> <a href="dictionary_M.html#1050">geometricShape</a>) {</span>
<a name="28"><font size=-1>28 </font></a><span class="default"> ShapeType <a href="dictionary_M.html#1052">shapeType</a> = <a href="dictionary_M.html#1050">geometricShape</a>.<a href="dictionary_M.html#714">getShapeType</a>();</span>
<a name="29"><font size=-1>29 </font></a><span class="default"> </span><span class="keyword">int <a href="dictionary_M.html#1054">shapeXcoord</a> </span><span class="default">= <a href="dictionary_M.html#1050">geometricShape</a>.<a href="dictionary_M.html#715">getShapeXcoord</a>();</span>
<a name="30"><font size=-1>30 </font></a><span class="default"> </span><span class="keyword">int <a href="dictionary_M.html#1055">shapeYcoord</a> </span><span class="default">= <a href="dictionary_M.html#1050">geometricShape</a>.<a href="dictionary_M.html#716">getShapeYcoord</a>();</span>
<a name="31"><font size=-1>31 </font></a><span class="default"> </span><span class="keyword">int <a href="dictionary_M.html#1057">width</a> </span><span class="default">= <a href="dictionary_M.html#1050">geometricShape</a>.<a href="dictionary_M.html#719">getWidth</a>();</span>
<a name="32"><font size=-1>32 </font></a><span class="default"> </span><span class="keyword">int <a href="dictionary_M.html#1051">height</a> </span><span class="default">= <a href="dictionary_M.html#1050">geometricShape</a>.<a href="dictionary_M.html#709">getHeight</a>();</span>
<a name="33"><font size=-1>33 </font></a><span class="default"> <a href="dictionary_J.html#214">Point</a> <a href="dictionary_M.html#1056">startPoint</a> = <a href="dictionary_M.html#1050">geometricShape</a>.<a href="dictionary_M.html#717">getStartPoint</a>();</span>
<a name="34"><font size=-1>34 </font></a><span class="default"> <a href="dictionary_J.html#214">Point</a> <a href="dictionary_M.html#1049">endPoint</a> = <a href="dictionary_M.html#1050">geometricShape</a>.<a href="dictionary_M.html#708">getEndPoint</a>();</span>
<a name="35"><font size=-1>35 </font></a><span class="default"></span>
<a name="36"><font size=-1>36 </font></a><span class="default"> <a href="dictionary_M.html#154">ShapeTypeStrategy</a> <a href="dictionary_M.html#1053">shapeTypeStrategy</a> = </span><span class="keyword">null</span><span class="default">;</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"> </span><span class="keyword">if </span><span class="default">(<a href="dictionary_M.html#1052">shapeType</a>.<a href="dictionary_E.html#126">equals</a>(ShapeType.<a href="dictionary_R.html#296">RECTANGLE</a>)) {</span>
<a name="39"><font size=-1>39 </font></a><span class="default"> <a href="dictionary_M.html#1053">shapeTypeStrategy</a> = </span><span class="keyword">new <a href="dictionary_M.html#113">Rectangle</a></span><span class="default">(<a href="dictionary_M.html#1054">shapeXcoord</a>, <a href="dictionary_M.html#1055">shapeYcoord</a>, <a href="dictionary_M.html#1057">width</a>, <a href="dictionary_M.html#1051">height</a>);</span>
<a name="40"><font size=-1>40 </font></a><span class="default"> } </span><span class="keyword">else if </span><span class="default">(<a href="dictionary_M.html#1052">shapeType</a>.<a href="dictionary_E.html#126">equals</a>(ShapeType.<a href="dictionary_E.html#1047">ELLIPSE</a>)) {</span>
<a name="41"><font size=-1>41 </font></a><span class="default"> <a href="dictionary_M.html#1053">shapeTypeStrategy</a> = </span><span class="keyword">new <a href="dictionary_M.html#391">Ellipse</a></span><span class="default">(<a href="dictionary_M.html#1054">shapeXcoord</a>, <a href="dictionary_M.html#1055">shapeYcoord</a>, <a href="dictionary_M.html#1057">width</a>, <a href="dictionary_M.html#1051">height</a>);</span>
<a name="42"><font size=-1>42 </font></a><span class="default"> } </span><span class="keyword">else if </span><span class="default">(<a href="dictionary_M.html#1052">shapeType</a>.<a href="dictionary_E.html#126">equals</a>(ShapeType.<a href="dictionary_T.html#1048">TRIANGLE</a>)) {</span>
<a name="43"><font size=-1>43 </font></a><span class="default"> <a href="dictionary_M.html#1053">shapeTypeStrategy</a> = </span><span class="keyword">new <a href="dictionary_M.html#794">Triangle</a></span><span class="default">(<a href="dictionary_M.html#1056">startPoint</a>, <a href="dictionary_M.html#1049">endPoint</a>);</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><span class="keyword">return <a href="dictionary_M.html#1053">shapeTypeStrategy</a></span><span class="default">.<a href="dictionary_M.html#159">createShapeType</a>();</span>
<a name="46"><font size=-1>46 </font></a><span class="default"> }</span>
<a name="47"><font size=-1>47 </font></a><span class="default">}</span>
<a name="48"><font size=-1>48 </font></a><span class="default"></span>
</pre></body></html>