source: josm/trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPaintSettings.java@ 9099

Last change on this file since 9099 was 9099, checked in by bastiK, 8 years ago

mapcss partial fill: move threshold parameter ([9063]) into the mapcss style
(new property fill-extent-threshold)

  • add support for this parameter when area is unclosed
  • smaller extent for unclosed areas

(see #12104)

  • Property svn:eol-style set to native
File size: 11.0 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.data.osm.visitor.paint;
3
4import java.awt.Color;
5
6import org.openstreetmap.josm.Main;
7import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
8import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
9
10/**
11 * Global mappaint settings.
12 * @since 2675
13 */
14public final class MapPaintSettings implements PreferenceChangedListener {
15
16 /** The unique instance **/
17 public static final MapPaintSettings INSTANCE = new MapPaintSettings();
18
19 private boolean useRealWidth;
20 /** Preference: should directional arrows be displayed */
21 private boolean showDirectionArrow;
22 /** Preference: should arrows for oneways be displayed */
23 private boolean showOnewayArrow;
24 /** Preference: default width for ways segments */
25 private int defaultSegmentWidth;
26 /** Preference: should the segment numbers of ways be displayed */
27 private boolean showOrderNumber;
28 /** Preference: should only the last arrow of a way be displayed */
29 private boolean showHeadArrowOnly;
30 private int showNamesDistance;
31 private int useStrokesDistance;
32 private int showIconsDistance;
33 /** Preference: size of selected nodes */
34 private int selectedNodeSize;
35 /** Preference: size of multiply connected nodes */
36 private int connectionNodeSize;
37 /** Preference: size of unselected nodes */
38 private int unselectedNodeSize;
39 /** Preference: size of tagged nodes */
40 private int taggedNodeSize;
41 /** Preference: should selected nodes be filled */
42 private boolean fillSelectedNode;
43 /** Preference: should unselected nodes be filled */
44 private boolean fillUnselectedNode;
45 /** Preference: should tagged nodes be filled */
46 private boolean fillTaggedNode;
47 /** Preference: should multiply connected nodes be filled */
48 private boolean fillConnectionNode;
49 /** Preference: should only the data area outline be drawn */
50 private boolean outlineOnly;
51 /** Color Preference for selected objects */
52 private Color selectedColor;
53 private Color relationSelectedColor;
54 /** Color Preference for hightlighted objects */
55 private Color highlightColor;
56 /** Color Preference for inactive objects */
57 private Color inactiveColor;
58 /** Color Preference for nodes */
59 private Color nodeColor;
60 /** Color Preference for tagged nodes */
61 private Color taggedColor;
62 /** Color Preference for multiply connected nodes */
63 private Color connectionColor;
64 /** Color Preference for tagged and multiply connected nodes */
65 private Color taggedConnectionColor;
66
67 private MapPaintSettings() {
68 load();
69 Main.pref.addPreferenceChangeListener(this);
70 }
71
72 private void load() {
73 showDirectionArrow = Main.pref.getBoolean("draw.segment.direction", false);
74 showOnewayArrow = Main.pref.getBoolean("draw.oneway", true);
75 useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth", false);
76 defaultSegmentWidth = Main.pref.getInteger("mappaint.segment.default-width", 2);
77
78 selectedColor = PaintColors.SELECTED.get();
79 relationSelectedColor = PaintColors.RELATIONSELECTED.get();
80 highlightColor = PaintColors.HIGHLIGHT.get();
81 inactiveColor = PaintColors.INACTIVE.get();
82 nodeColor = PaintColors.NODE.get();
83 taggedColor = PaintColors.TAGGED.get();
84 connectionColor = PaintColors.CONNECTION.get();
85 if (taggedColor != nodeColor) {
86 taggedConnectionColor = taggedColor;
87 } else {
88 taggedConnectionColor = connectionColor;
89 }
90
91 showOrderNumber = Main.pref.getBoolean("draw.segment.order_number", false);
92 showHeadArrowOnly = Main.pref.getBoolean("draw.segment.head_only", false);
93
94 showNamesDistance = Main.pref.getInteger("mappaint.shownames", 10000000);
95 useStrokesDistance = Main.pref.getInteger("mappaint.strokes", 10000000);
96 showIconsDistance = Main.pref.getInteger("mappaint.showicons", 10000000);
97
98 selectedNodeSize = Main.pref.getInteger("mappaint.node.selected-size", 5);
99 unselectedNodeSize = Main.pref.getInteger("mappaint.node.unselected-size", 3);
100 connectionNodeSize = Main.pref.getInteger("mappaint.node.connection-size", 5);
101 taggedNodeSize = Main.pref.getInteger("mappaint.node.tagged-size", 3);
102 fillSelectedNode = Main.pref.getBoolean("mappaint.node.fill-selected", true);
103 fillUnselectedNode = Main.pref.getBoolean("mappaint.node.fill-unselected", false);
104 fillTaggedNode = Main.pref.getBoolean("mappaint.node.fill-tagged", true);
105 fillConnectionNode = Main.pref.getBoolean("mappaint.node.fill-connection", false);
106
107 outlineOnly = Main.pref.getBoolean("draw.data.area_outline_only", false);
108 }
109
110 @Override
111 public void preferenceChanged(PreferenceChangeEvent e) {
112 load();
113 }
114
115 /**
116 * Determines if the real width of ways should be used
117 * @return {@code true} if the real width of ways should be used
118 */
119 public boolean isUseRealWidth() {
120 return useRealWidth;
121 }
122
123 /**
124 * Determines if directional arrows should be displayed
125 * @return {@code true} if directional arrows should be displayed
126 */
127 public boolean isShowDirectionArrow() {
128 return showDirectionArrow;
129 }
130
131 /**
132 * Determines if arrows for oneways should be displayed
133 * @return {@code true} if arrows for oneways should be displayed
134 */
135 public boolean isShowOnewayArrow() {
136 return showOnewayArrow;
137 }
138
139 /**
140 * Returns color for selected objects (nodes and ways)
141 * @return color for selected objects
142 */
143 public Color getSelectedColor() {
144 return selectedColor;
145 }
146
147 /**
148 * Returns color for selected objects (nodes and ways) with a given alpha
149 * @param alpha alpha component in the range 0-255
150 * @return color for selected objects
151 */
152 public Color getSelectedColor(int alpha) {
153 return new Color(selectedColor.getRGB() & 0x00ffffff | (alpha << 24), true);
154 }
155
156 /**
157 * Returns default width for ways segments
158 * @return default width for ways segments
159 */
160 public int getDefaultSegmentWidth() {
161 return defaultSegmentWidth;
162 }
163
164 /**
165 * Returns color for selected relations
166 * @return color for selected relations
167 */
168 public Color getRelationSelectedColor() {
169 return relationSelectedColor;
170 }
171
172 /**
173 * Returns color for selected relations with a given alpha
174 * @param alpha alpha component in the range 0-255
175 * @return color for selected relations
176 */
177 public Color getRelationSelectedColor(int alpha) {
178 return new Color(relationSelectedColor.getRGB() & 0x00ffffff | (alpha << 24), true);
179 }
180
181 /**
182 * Returns color for hightlighted objects
183 * @return color for hightlighted objects
184 */
185 public Color getHighlightColor() {
186 return highlightColor;
187 }
188
189 /**
190 * Returns color for inactive objects
191 * @return color for inactive objects
192 */
193 public Color getInactiveColor() {
194 return inactiveColor;
195 }
196
197 /**
198 * Returns color for nodes
199 * @return color for nodes
200 */
201 public Color getNodeColor() {
202 return nodeColor;
203 }
204
205 /**
206 * Returns color for tagged nodes
207 * @return color for tagged nodes
208 */
209 public Color getTaggedColor() {
210 return taggedColor;
211 }
212
213 /**
214 * Returns color for multiply connected nodes
215 * @return color for multiply connected nodes
216 */
217 public Color getConnectionColor() {
218 return connectionColor;
219 }
220
221 /**
222 * Returns color for tagged and multiply connected nodes
223 * @return color for tagged and multiply connected nodes
224 */
225 public Color getTaggedConnectionColor() {
226 return taggedConnectionColor;
227 }
228
229 /**
230 * Determines if the segment numbers of ways should be displayed
231 * @return {@code true} if the segment numbers of ways should be displayed
232 */
233 public boolean isShowOrderNumber() {
234 return showOrderNumber;
235 }
236
237 /**
238 * Specifies if only the last arrow of a way should be displayed
239 * @param showHeadArrowOnly {@code true} if only the last arrow of a way should be displayed
240 */
241 public void setShowHeadArrowOnly(boolean showHeadArrowOnly) {
242 this.showHeadArrowOnly = showHeadArrowOnly;
243 }
244
245 /**
246 * Determines if only the last arrow of a way should be displayed
247 * @return {@code true} if only the last arrow of a way should be displayed
248 */
249 public boolean isShowHeadArrowOnly() {
250 return showHeadArrowOnly;
251 }
252
253 /**
254 * Returns the distance at which names should be drawn
255 * @return the distance at which names should be drawn
256 */
257 public int getShowNamesDistance() {
258 return showNamesDistance;
259 }
260
261 /**
262 * Returns the distance at which strokes should be used
263 * @return the distance at which strokes should be used
264 */
265 public int getUseStrokesDistance() {
266 return useStrokesDistance;
267 }
268
269 /**
270 * Returns the distance at which icons should be drawn
271 * @return the distance at which icons should be drawn
272 */
273 public int getShowIconsDistance() {
274 return showIconsDistance;
275 }
276
277 /**
278 * Returns the size of selected nodes
279 * @return the size of selected nodes
280 */
281 public int getSelectedNodeSize() {
282 return selectedNodeSize;
283 }
284
285 /**
286 * Returns the size of multiply connected nodes
287 * @return the size of multiply connected nodes
288 */
289 public int getConnectionNodeSize() {
290 return connectionNodeSize;
291 }
292
293 /**
294 * Returns the size of unselected nodes
295 * @return the size of unselected nodes
296 */
297 public int getUnselectedNodeSize() {
298 return unselectedNodeSize;
299 }
300
301 /**
302 * Returns the size of tagged nodes
303 * @return the size of tagged nodes
304 */
305 public int getTaggedNodeSize() {
306 return taggedNodeSize;
307 }
308
309 /**
310 * Determines if selected nodes should be filled
311 * @return {@code true} if selected nodes should be filled
312 */
313 public boolean isFillSelectedNode() {
314 return fillSelectedNode;
315 }
316
317 /**
318 * Determines if unselected nodes should be filled
319 * @return {@code true} if unselected nodes should be filled
320 */
321 public boolean isFillUnselectedNode() {
322 return fillUnselectedNode;
323 }
324
325 /**
326 * Determines if multiply connected nodes should be filled
327 * @return {@code true} if multiply connected nodes should be filled
328 */
329 public boolean isFillConnectionNode() {
330 return fillConnectionNode;
331 }
332
333 /**
334 * Determines if tagged nodes should be filled
335 * @return {@code true} if tagged nodes should be filled
336 */
337 public boolean isFillTaggedNode() {
338 return fillTaggedNode;
339 }
340
341 /**
342 * Determines if only the data area outline should be drawn
343 * @return {@code true} if only the data area outline should be drawn
344 */
345 public boolean isOutlineOnly() {
346 return outlineOnly;
347 }
348}
Note: See TracBrowser for help on using the repository browser.