Last change
on this file since 9600 was 8510, checked in by Don-vip, 9 years ago |
checkstyle: enable relevant whitespace checks and fix them
|
-
Property svn:eol-style
set to
native
|
File size:
1.4 KB
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.preferences;
|
---|
3 |
|
---|
4 | import java.awt.Color;
|
---|
5 | import java.util.Locale;
|
---|
6 |
|
---|
7 | import org.openstreetmap.josm.Main;
|
---|
8 | import org.openstreetmap.josm.data.Preferences.ColorKey;
|
---|
9 |
|
---|
10 | /**
|
---|
11 | * A property containing a {@link Color} value.
|
---|
12 | * @since 5464
|
---|
13 | */
|
---|
14 | public class ColorProperty extends AbstractProperty<Color> implements ColorKey {
|
---|
15 |
|
---|
16 | private final String name;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Constructs a new {@code ColorProperty}.
|
---|
20 | * @param colName The color name
|
---|
21 | * @param defaultValue The default value
|
---|
22 | */
|
---|
23 | public ColorProperty(String colName, Color defaultValue) {
|
---|
24 | super(getColorKey(colName), defaultValue);
|
---|
25 | this.name = colName;
|
---|
26 | }
|
---|
27 |
|
---|
28 | @Override
|
---|
29 | public Color get() {
|
---|
30 | return Main.pref.getColor(this);
|
---|
31 | }
|
---|
32 |
|
---|
33 | @Override
|
---|
34 | public boolean put(Color value) {
|
---|
35 | return Main.pref.putColor(getColorKey(name), value);
|
---|
36 | }
|
---|
37 |
|
---|
38 | /**
|
---|
39 | * Replies the color key used in JOSM preferences for this property.
|
---|
40 | * @param colName The color name
|
---|
41 | * @return The color key for this property
|
---|
42 | */
|
---|
43 | public static String getColorKey(String colName) {
|
---|
44 | return colName == null ? null : colName.toLowerCase(Locale.ENGLISH).replaceAll("[^a-z0-9]+", ".");
|
---|
45 | }
|
---|
46 |
|
---|
47 | @Override
|
---|
48 | public String getColorName() {
|
---|
49 | return name;
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Override
|
---|
53 | public String getSpecialName() {
|
---|
54 | return null;
|
---|
55 | }
|
---|
56 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.