28 import org.eclipse.swt.widgets.MessageBox; |
28 import org.eclipse.swt.widgets.MessageBox; |
29 import org.eclipse.swt.widgets.Shell; |
29 import org.eclipse.swt.widgets.Shell; |
30 |
30 |
31 public class DataMiningPalette { |
31 public class DataMiningPalette { |
32 |
32 |
33 private Map<Object, RGB> palette = new HashMap<Object, RGB>(); |
33 private transient final Map<Object, RGB> palette = new HashMap<Object, RGB>(); |
34 |
34 |
35 private boolean haveEntry(Object entry) { |
35 private boolean haveEntry(Object entry) { |
36 return palette.containsKey(entry); |
36 return palette.containsKey(entry); |
37 } |
37 } |
38 |
38 |
39 private boolean haveColor(RGB color) { |
39 private boolean haveColor(final RGB color) { |
40 return palette.containsValue(color); |
40 return palette.containsValue(color); |
41 } |
41 } |
42 |
42 |
43 private void add(Object entry, RGB color) { |
43 private void add(final Object entry, final RGB color) { |
44 palette.put(entry, color); |
44 palette.put(entry, color); |
45 } |
45 } |
46 |
46 |
47 private void update(Object entry, RGB color) { |
47 private void update(final Object entry, final RGB color) { |
48 palette.remove(entry); |
48 palette.remove(entry); |
49 palette.put(entry, color); |
49 palette.put(entry, color); |
50 } |
50 } |
51 |
51 |
52 private RGB hsv2rgb(int hue, double saturation, double value) { |
52 private RGB hsv2rgb(int hue, double saturation, double value) { |
53 |
53 |
54 if (hue >= 360) |
54 if (hue >= 360){ |
55 hue %= 360; |
55 hue %= 360; |
|
56 } |
56 int Hi = (hue / 60) % 6; |
57 int Hi = (hue / 60) % 6; |
57 double f = (double) hue / (double) 60 - Hi; |
58 double f = (double) hue / (double) 60 - Hi; |
58 |
59 |
59 int p = (int) ((value * (1 - saturation)) * 255); |
60 int p = (int) ((value * (1 - saturation)) * 255); |
60 int q = (int) ((value * (1 - f * saturation)) * 255); |
61 int q = (int) ((value * (1 - f * saturation)) * 255); |
139 int indexG = (index / 6) % 6; |
140 int indexG = (index / 6) % 6; |
140 int indexB = (index / 36) % 6; |
141 int indexB = (index / 36) % 6; |
141 |
142 |
142 RGB myRGB = new RGB(channelValue[indexR], channelValue[indexG], channelValue[indexB]); |
143 RGB myRGB = new RGB(channelValue[indexR], channelValue[indexG], channelValue[indexB]); |
143 |
144 |
144 if (haveColor(myRGB)) |
145 if (haveColor(myRGB)){ |
145 continue; |
146 continue; |
146 |
147 } |
147 add(entry, myRGB); |
148 add(entry, myRGB); |
148 |
149 |
149 if (!entryListItr.hasNext()) |
150 if (!entryListItr.hasNext()) |
150 return; |
151 return; |
151 else |
152 else |