Skip to content

Commit af1c2c1

Browse files
committed
CSSTUDIO-3196 Change the semantics of colors defined to be equal to other colors: a color defined to be equal to another color is now an alias for the other color.
1 parent ee5b1d5 commit af1c2c1

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/display/model/src/main/java/org/csstudio/display/builder/model/persist/NamedWidgetColors.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import java.util.Collection;
1111
import java.util.Collections;
12+
import java.util.HashSet;
1213
import java.util.LinkedHashMap;
1314
import java.util.Map;
1415
import java.util.Optional;
@@ -133,6 +134,15 @@ void define(final NamedWidgetColor color)
133134
colors.put(color.getName(), color);
134135
}
135136

137+
/** Define a name to point to a named color
138+
* @param name Name of the color
139+
* @param color Named color
140+
*/
141+
void define(String name, final NamedWidgetColor color)
142+
{
143+
colors.put(name, color);
144+
}
145+
136146
/** Get named color
137147
* @param name Name of the color
138148
* @return Named color, if known
@@ -156,7 +166,7 @@ public NamedWidgetColor resolve(final NamedWidgetColor color)
156166
*/
157167
public Collection<NamedWidgetColor> getColors()
158168
{
159-
return Collections.unmodifiableCollection(colors.values());
169+
return Collections.unmodifiableSet(new HashSet<>(colors.values()));
160170
}
161171

162172
@Override
@@ -168,7 +178,7 @@ protected void parse ( final String name, final String value ) throws Exception
168178

169179
NamedWidgetColor namedColor = optionalColor.get();
170180

171-
define(new NamedWidgetColor(name, namedColor.getRed(), namedColor.getGreen(), namedColor.getBlue(), namedColor.getAlpha()));
181+
define(name, namedColor);
172182

173183
} else {
174184

0 commit comments

Comments
 (0)