1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.data.osm.visitor.paint;
|
---|
3 |
|
---|
4 | import java.awt.Color;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.Main;
|
---|
7 | import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
|
---|
8 | import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
|
---|
9 |
|
---|
10 | public final class MapPaintSettings implements PreferenceChangedListener {
|
---|
11 |
|
---|
12 | public static final MapPaintSettings INSTANCE = new MapPaintSettings();
|
---|
13 |
|
---|
14 | private boolean useRealWidth;
|
---|
15 | /** Preference: should directional arrows be displayed */
|
---|
16 | private boolean showDirectionArrow;
|
---|
17 | /** Preference: should arrows for oneways be displayed */
|
---|
18 | private boolean showOnewayArrow;
|
---|
19 | private int defaultSegmentWidth;
|
---|
20 | /** Preference: should the segment numbers of ways be displayed */
|
---|
21 | private boolean showOrderNumber;
|
---|
22 | /** Preference: should only the last arrow of a way be displayed */
|
---|
23 | private boolean showHeadArrowOnly;
|
---|
24 | private int showNamesDistance;
|
---|
25 | private int useStrokesDistance;
|
---|
26 | private int showIconsDistance;
|
---|
27 | /** Preference: size of selected nodes */
|
---|
28 | private int selectedNodeSize;
|
---|
29 | /** Preference: size of multiply connected nodes */
|
---|
30 | private int connectionNodeSize;
|
---|
31 | /** Preference: size of unselected nodes */
|
---|
32 | private int unselectedNodeSize;
|
---|
33 | /** Preference: size of tagged nodes */
|
---|
34 | private int taggedNodeSize;
|
---|
35 | /** Preference: should selected nodes be filled */
|
---|
36 | private boolean fillSelectedNode;
|
---|
37 | /** Preference: should unselected nodes be filled */
|
---|
38 | private boolean fillUnselectedNode;
|
---|
39 | /** Preference: should tagged nodes be filled */
|
---|
40 | private boolean fillTaggedNode;
|
---|
41 | /** Preference: should multiply connected nodes be filled */
|
---|
42 | private boolean fillConnectionNode;
|
---|
43 | private boolean outlineOnly;
|
---|
44 | /** Color Preference for selected objects */
|
---|
45 | private Color selectedColor;
|
---|
46 | private Color relationSelectedColor;
|
---|
47 | /** Color Preference for hightlighted objects */
|
---|
48 | private Color highlightColor;
|
---|
49 | /** Color Preference for inactive objects */
|
---|
50 | private Color inactiveColor;
|
---|
51 | /** Color Preference for nodes */
|
---|
52 | private Color nodeColor;
|
---|
53 | /** Color Preference for tagged nodes */
|
---|
54 | private Color taggedColor;
|
---|
55 | /** Color Preference for multiply connected nodes */
|
---|
56 | private Color connectionColor;
|
---|
57 | /** Color Preference for tagged and multiply connected nodes */
|
---|
58 | private Color taggedConnectionColor;
|
---|
59 |
|
---|
60 | private MapPaintSettings() {
|
---|
61 | load();
|
---|
62 | Main.pref.addPreferenceChangeListener(this);
|
---|
63 | }
|
---|
64 |
|
---|
65 | private void load() {
|
---|
66 | showDirectionArrow = Main.pref.getBoolean("draw.segment.direction", false);
|
---|
67 | showOnewayArrow = Main.pref.getBoolean("draw.oneway", true);
|
---|
68 | useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth", false);
|
---|
69 | defaultSegmentWidth = Main.pref.getInteger("mappaint.segment.default-width", 2);
|
---|
70 |
|
---|
71 | selectedColor = PaintColors.SELECTED.get();
|
---|
72 | relationSelectedColor = PaintColors.RELATIONSELECTED.get();
|
---|
73 | highlightColor = PaintColors.HIGHLIGHT.get();
|
---|
74 | inactiveColor = PaintColors.INACTIVE.get();
|
---|
75 | nodeColor = PaintColors.NODE.get();
|
---|
76 | taggedColor = PaintColors.TAGGED.get();
|
---|
77 | connectionColor = PaintColors.CONNECTION.get();
|
---|
78 | if (taggedColor != nodeColor) {
|
---|
79 | taggedConnectionColor = taggedColor;
|
---|
80 | } else {
|
---|
81 | taggedConnectionColor = connectionColor;
|
---|
82 | }
|
---|
83 |
|
---|
84 |
|
---|
85 | showOrderNumber = Main.pref.getBoolean("draw.segment.order_number", false);
|
---|
86 | showHeadArrowOnly = Main.pref.getBoolean("draw.segment.head_only", false);
|
---|
87 |
|
---|
88 | showNamesDistance = Main.pref.getInteger("mappaint.shownames", 10000000);
|
---|
89 | useStrokesDistance = Main.pref.getInteger("mappaint.strokes", 10000000);
|
---|
90 | showIconsDistance = Main.pref.getInteger("mappaint.showicons", 10000000);
|
---|
91 |
|
---|
92 | selectedNodeSize = Main.pref.getInteger("mappaint.node.selected-size", 5);
|
---|
93 | unselectedNodeSize = Main.pref.getInteger("mappaint.node.unselected-size", 3);
|
---|
94 | connectionNodeSize = Main.pref.getInteger("mappaint.node.connection-size", 5);
|
---|
95 | taggedNodeSize = Main.pref.getInteger("mappaint.node.tagged-size", 3);
|
---|
96 | fillSelectedNode = Main.pref.getBoolean("mappaint.node.fill-selected", true);
|
---|
97 | fillUnselectedNode = Main.pref.getBoolean("mappaint.node.fill-unselected", false);
|
---|
98 | fillTaggedNode = Main.pref.getBoolean("mappaint.node.fill-tagged", true);
|
---|
99 | fillConnectionNode = Main.pref.getBoolean("mappaint.node.fill-connection", false);
|
---|
100 |
|
---|
101 | outlineOnly = Main.pref.getBoolean("draw.data.area_outline_only", false);
|
---|
102 |
|
---|
103 | }
|
---|
104 |
|
---|
105 | @Override
|
---|
106 | public void preferenceChanged(PreferenceChangeEvent e) {
|
---|
107 | load();
|
---|
108 | }
|
---|
109 |
|
---|
110 | public boolean isUseRealWidth() {
|
---|
111 | return useRealWidth;
|
---|
112 | }
|
---|
113 |
|
---|
114 | public boolean isShowDirectionArrow() {
|
---|
115 | return showDirectionArrow;
|
---|
116 | }
|
---|
117 |
|
---|
118 | public boolean isShowOnewayArrow() {
|
---|
119 | return showOnewayArrow;
|
---|
120 | }
|
---|
121 |
|
---|
122 | public Color getSelectedColor() {
|
---|
123 | return selectedColor;
|
---|
124 | }
|
---|
125 |
|
---|
126 | public int getDefaultSegmentWidth() {
|
---|
127 | return defaultSegmentWidth;
|
---|
128 | }
|
---|
129 |
|
---|
130 | public Color getSelectedColor(int alpha) {
|
---|
131 | return new Color(selectedColor.getRGB() & 0x00ffffff | (alpha << 24), true);
|
---|
132 | }
|
---|
133 |
|
---|
134 | public Color getRelationSelectedColor() {
|
---|
135 | return relationSelectedColor;
|
---|
136 | }
|
---|
137 |
|
---|
138 | public Color getRelationSelectedColor(int alpha) {
|
---|
139 | return new Color(relationSelectedColor.getRGB() & 0x00ffffff | (alpha << 24), true);
|
---|
140 | }
|
---|
141 |
|
---|
142 | public Color getHighlightColor() {
|
---|
143 | return highlightColor;
|
---|
144 | }
|
---|
145 |
|
---|
146 | public Color getInactiveColor() {
|
---|
147 | return inactiveColor;
|
---|
148 | }
|
---|
149 |
|
---|
150 | public Color getNodeColor() {
|
---|
151 | return nodeColor;
|
---|
152 | }
|
---|
153 |
|
---|
154 | public Color getTaggedColor() {
|
---|
155 | return taggedColor;
|
---|
156 | }
|
---|
157 |
|
---|
158 | public Color getConnectionColor() {
|
---|
159 | return connectionColor;
|
---|
160 | }
|
---|
161 |
|
---|
162 | public Color getTaggedConnectionColor() {
|
---|
163 | return taggedConnectionColor;
|
---|
164 | }
|
---|
165 |
|
---|
166 | public boolean isShowOrderNumber() {
|
---|
167 | return showOrderNumber;
|
---|
168 | }
|
---|
169 |
|
---|
170 | public void setShowHeadArrowOnly(boolean showHeadArrowOnly) {
|
---|
171 | this.showHeadArrowOnly = showHeadArrowOnly;
|
---|
172 | }
|
---|
173 |
|
---|
174 | public boolean isShowHeadArrowOnly() {
|
---|
175 | return showHeadArrowOnly;
|
---|
176 | }
|
---|
177 |
|
---|
178 | public int getShowNamesDistance() {
|
---|
179 | return showNamesDistance;
|
---|
180 | }
|
---|
181 |
|
---|
182 | public int getUseStrokesDistance() {
|
---|
183 | return useStrokesDistance;
|
---|
184 | }
|
---|
185 |
|
---|
186 | public int getShowIconsDistance() {
|
---|
187 | return showIconsDistance;
|
---|
188 | }
|
---|
189 |
|
---|
190 | public int getSelectedNodeSize() {
|
---|
191 | return selectedNodeSize;
|
---|
192 | }
|
---|
193 |
|
---|
194 | public int getConnectionNodeSize() {
|
---|
195 | return connectionNodeSize;
|
---|
196 | }
|
---|
197 |
|
---|
198 | public int getUnselectedNodeSize() {
|
---|
199 | return unselectedNodeSize;
|
---|
200 | }
|
---|
201 |
|
---|
202 | public int getTaggedNodeSize() {
|
---|
203 | return taggedNodeSize;
|
---|
204 | }
|
---|
205 |
|
---|
206 | public boolean isFillSelectedNode() {
|
---|
207 | return fillSelectedNode;
|
---|
208 | }
|
---|
209 |
|
---|
210 | public boolean isFillUnselectedNode() {
|
---|
211 | return fillUnselectedNode;
|
---|
212 | }
|
---|
213 |
|
---|
214 | public boolean isFillConnectionNode() {
|
---|
215 | return fillConnectionNode;
|
---|
216 | }
|
---|
217 |
|
---|
218 | public boolean isFillTaggedNode() {
|
---|
219 | return fillTaggedNode;
|
---|
220 | }
|
---|
221 |
|
---|
222 | public boolean isOutlineOnly() {
|
---|
223 | return outlineOnly;
|
---|
224 | }
|
---|
225 | }
|
---|