File: /Users/shatabdi/Education/GitHub/se450_project/src/view/adapter/ColorAdapter.java

1     //adopted from AdapterDemo
2     package view.adapter;
3     
4     import java.awt.Color;
5     import java.io.Serializable;
6     
7     import view.Enum.ShapeColor;
8     
9     public class ColorAdapter implements Serializable {
10     	static java.awt.Color color;
11     	static ShapeColor shapeColor;
12     
13     	public static Color getColor(ShapeColor shapeColor) {
14     		switch (shapeColor) {
15     		case BLUE:
16     			color = Color.blue;
17     			break;
18     		case BLACK:
19     			color = Color.black;
20     			break;
21     		case CYAN:
22     			color = Color.CYAN;
23     			break;
24     		case DARK_GRAY:
25     			color = Color.DARK_GRAY;
26     			break;
27     		case GRAY:
28     			color = Color.GRAY;
29     			break;
30     		case GREEN:
31     			color = Color.GREEN;
32     			break;
33     		case LIGHT_GRAY:
34     			color = Color.LIGHT_GRAY;
35     			break;
36     		case MAGENTA:
37     			color = Color.MAGENTA;
38     			break;
39     		case ORANGE:
40     			color = Color.ORANGE;
41     			break;
42     		case RED:
43     			color = Color.RED;
44     			break;
45     		case PINK:
46     			color = Color.PINK;
47     			break;
48     		case WHITE:
49     			color = Color.WHITE;
50     			break;
51     		case YELLOW:
52     			color = Color.YELLOW;
53     			break;
54     		}
55     		return color;
56     	}
57     
58     	public static ShapeColor getShapeColor(Color myColor) {
59     		if (myColor.equals(Color.BLUE))
60     			shapeColor = ShapeColor.BLUE;
61     
62     		else if (myColor.equals(Color.BLACK))
63     			shapeColor = ShapeColor.BLACK;
64     
65     		else if (myColor.equals(Color.CYAN))
66     			shapeColor = ShapeColor.CYAN;
67     
68     		else if (myColor.equals(Color.DARK_GRAY))
69     			shapeColor = ShapeColor.DARK_GRAY;
70     
71     		else if (myColor.equals(Color.GRAY))
72     			shapeColor = ShapeColor.GRAY;
73     
74     		else if (myColor.equals(Color.GREEN))
75     			shapeColor = ShapeColor.GREEN;
76     
77     		else if (myColor.equals(Color.MAGENTA))
78     			shapeColor = ShapeColor.MAGENTA;
79     
80     		else if (myColor.equals(Color.ORANGE))
81     			shapeColor = ShapeColor.ORANGE;
82     
83     		else if (myColor.equals(Color.RED))
84     			shapeColor = ShapeColor.RED;
85     
86     		else if (myColor.equals(Color.PINK))
87     			shapeColor = ShapeColor.PINK;
88     
89     		return shapeColor;
90     	}
91     
92     	public ColorAdapter(ShapeColor shapeColor) {
93     		ColorAdapter.shapeColor = shapeColor;
94     
95     	}
96     
97     }
98