1 package cz.cuni.amis.pogamut.emohawk.agent.module.sensomotoric;
2
3
4
5
6
7
8
9 public class Emoticon {
10
11 private static EmoticonBubbleType DEFAULT_BUBBLE = EmoticonBubbleType.BUBBLE_THOUGHT_CENTER;
12
13 private EmoticonType leftEmoticon;
14
15 private EmoticonType centerEmoticon;
16
17 private EmoticonType rightEmoticon;
18
19 private EmoticonBubbleType bubble;
20
21
22
23
24
25
26 private int emoticonCount = 0;
27
28 public EmoticonBubbleType getBubble() {
29 return bubble;
30 }
31
32 public EmoticonType getCenterEmoticon() {
33 return centerEmoticon;
34 }
35
36 public EmoticonType getLeftEmoticon() {
37 return leftEmoticon;
38 }
39
40 public EmoticonType getRightEmoticon() {
41 return rightEmoticon;
42 }
43
44 public int getEmoticonCount() {
45 return emoticonCount;
46 }
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61 public EmoticonType[] getEmoticonTypes() {
62 switch(getEmoticonCount()) {
63 case 0:
64 return new EmoticonType[0];
65
66 case 1:
67 return new EmoticonType[]{getCenterEmoticon()};
68
69 case 2:
70 return new EmoticonType[]{getLeftEmoticon(), getRightEmoticon()};
71
72 case 3:
73 return new EmoticonType[]{getLeftEmoticon(), getCenterEmoticon(), getRightEmoticon()};
74
75 default:
76 throw new RuntimeException("Emoticon returned wrong emoticon count = " + getEmoticonCount() + " !!!");
77 }
78
79 }
80
81
82
83
84
85
86
87
88 public Emoticon(EmoticonType leftEmoticon, EmoticonType centerEmoticon, EmoticonType rightEmoticon, EmoticonBubbleType bubble) {
89 this.leftEmoticon = leftEmoticon;
90 this.centerEmoticon = centerEmoticon;
91 this.rightEmoticon = rightEmoticon;
92 if (leftEmoticon != null && rightEmoticon != null && centerEmoticon != null && leftEmoticon != EmoticonType.NONE && rightEmoticon != EmoticonType.NONE && centerEmoticon != EmoticonType.NONE)
93 emoticonCount = 3;
94 else if (leftEmoticon != null && rightEmoticon != null && leftEmoticon != EmoticonType.NONE && rightEmoticon != EmoticonType.NONE)
95 emoticonCount = 2;
96 else if (centerEmoticon != null && centerEmoticon != EmoticonType.NONE)
97 emoticonCount = 1;
98 this.bubble = bubble;
99 if (bubble == null || bubble == EmoticonBubbleType.NONE)
100 bubble = DEFAULT_BUBBLE;
101 }
102
103
104
105
106
107
108 public Emoticon(EmoticonType centerEmoticon, EmoticonBubbleType bubble) {
109 this.centerEmoticon = centerEmoticon;
110 if (centerEmoticon != null && centerEmoticon != EmoticonType.NONE)
111 emoticonCount = 1;
112 this.bubble = bubble;
113 if (bubble == null || bubble == EmoticonBubbleType.NONE)
114 bubble = DEFAULT_BUBBLE;
115 }
116
117
118
119
120
121
122
123
124 public Emoticon(EmoticonType leftEmoticon, EmoticonType rightEmoticon, EmoticonBubbleType bubble) {
125 this.leftEmoticon = leftEmoticon;
126 this.rightEmoticon = rightEmoticon;
127 if (leftEmoticon != null && rightEmoticon != null && leftEmoticon != EmoticonType.NONE && rightEmoticon != EmoticonType.NONE)
128 emoticonCount = 2;
129 this.bubble = bubble;
130 if (bubble == null || bubble == EmoticonBubbleType.NONE)
131 bubble = DEFAULT_BUBBLE;
132 }
133
134 @Override
135 public boolean equals(Object obj) {
136 if (obj == null) {
137 return false;
138 }
139 if (getClass() != obj.getClass()) {
140 return false;
141 }
142 final Emoticon other = (Emoticon) obj;
143 if (this.leftEmoticon != other.leftEmoticon) {
144 return false;
145 }
146 if (this.centerEmoticon != other.centerEmoticon) {
147 return false;
148 }
149 if (this.rightEmoticon != other.rightEmoticon) {
150 return false;
151 }
152 if (this.bubble != other.bubble) {
153 return false;
154 }
155 if (this.emoticonCount != other.emoticonCount) {
156 return false;
157 }
158 return true;
159 }
160
161 @Override
162 public int hashCode() {
163 int hash = 5;
164 hash = 11 * hash + (this.leftEmoticon != null ? this.leftEmoticon.hashCode() : 0);
165 hash = 11 * hash + (this.centerEmoticon != null ? this.centerEmoticon.hashCode() : 0);
166 hash = 11 * hash + (this.rightEmoticon != null ? this.rightEmoticon.hashCode() : 0);
167 hash = 11 * hash + (this.bubble != null ? this.bubble.hashCode() : 0);
168 hash = 11 * hash + this.emoticonCount;
169 return hash;
170 }
171
172 @Override
173 public String toString() {
174 return "Emoticon[left=" + leftEmoticon + ", center=" + centerEmoticon + ", right=" + rightEmoticon + ", bubble=" + bubble + "]";
175 }
176
177 }