Changeset 27760 in osm for applications/editors/josm/plugins/graphview
- Timestamp:
- 2012-02-14T21:43:28+01:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/graphview/src/org/openstreetmap/josm/plugins/graphview/plugin/preferences/GraphViewPreferences.java
r26481 r27760 1 1 package org.openstreetmap.josm.plugins.graphview.plugin.preferences; 2 3 import static org.openstreetmap.josm.tools.I18n.marktr; 2 4 3 5 import static org.openstreetmap.josm.plugins.graphview.core.property.VehiclePropertyTypes.AXLELOAD; … … 234 236 currentColorScheme = new PreferencesColorScheme(this); 235 237 236 nodeColor = Color.WHITE;237 segmentColor = Color.WHITE;238 arrowheadFillColor = Color.BLACK;239 240 238 separateDirections = false; 241 239 … … 262 260 } 263 261 264 Main.pref.put("graphview .defaultNodeColor", createColorString(nodeColor));265 Main.pref.put("graphview .defaultSegmentColor", createColorString(segmentColor));266 Main.pref.put("graphview .defaultArrowheadCoreColor", createColorString(arrowheadFillColor));262 Main.pref.putColor(marktr("graphview default node"), Color.WHITE); 263 Main.pref.putColor(marktr("graphview default segment"), Color.WHITE); 264 Main.pref.putColor(marktr("graphview arrowhead core"), Color.BLACK); 267 265 268 266 Main.pref.put("graphview.separateDirections", separateDirections); … … 274 272 private void readPreferences() { 275 273 276 if (Main.pref. hasKey("graphview.parameterBookmarks")) {274 if (!Main.pref.get("graphview.parameterBookmarks").isEmpty()) { 277 275 String bookmarksString = Main.pref.get("graphview.parameterBookmarks"); 278 276 parameterBookmarks = parseAccessParameterBookmarksString(bookmarksString); 279 277 } 280 278 281 if (Main.pref. hasKey("graphview.activeBookmark")) {279 if (!Main.pref.get("graphview.activeBookmark").isEmpty()) { 282 280 currentParameterBookmarkName = Main.pref.get("graphview.activeBookmark"); 283 281 } … … 289 287 useInternalRulesets = Main.pref.getBoolean("graphview.useInternalRulesets", true); 290 288 291 if (Main.pref. hasKey("graphview.rulesetFolder")) {289 if (!Main.pref.get("graphview.rulesetFolder").isEmpty()) { 292 290 String dirString = Main.pref.get("graphview.rulesetFolder"); 293 291 rulesetFolder = new File(dirString); 294 292 } 295 if (Main.pref. hasKey("graphview.rulesetFile")) {293 if (!Main.pref.get("graphview.rulesetFile").isEmpty()) { 296 294 String fileString = Main.pref.get("graphview.rulesetFile"); 297 295 currentRulesetFile = new File(fileString); 298 296 } 299 297 300 if (Main.pref. hasKey("graphview.rulesetResource")) {298 if (!Main.pref.get("graphview.rulesetResource").isEmpty()) { 301 299 String rulesetString = Main.pref.get("graphview.rulesetResource"); 302 300 //get the enum value for the string … … 310 308 } 311 309 312 if (Main.pref.hasKey("graphview.defaultNodeColor")) { 313 Color color = parseColorString(Main.pref.get("graphview.defaultNodeColor")); 314 if (color != null) { 315 nodeColor = color; 316 } 317 } 318 if (Main.pref.hasKey("graphview.defaultSegmentColor")) { 319 Color color = parseColorString(Main.pref.get("graphview.defaultSegmentColor")); 320 if (color != null) { 321 segmentColor = color; 322 } 323 } 324 if (Main.pref.hasKey("graphview.defaultArrowheadCoreColor")) { 325 Color color = parseColorString(Main.pref.get("graphview.defaultArrowheadCoreColor")); 326 if (color != null) { 327 arrowheadFillColor = color; 328 } 329 } 330 310 nodeColor = Main.pref.getColor(marktr("graphview default node"), Color.WHITE); 311 segmentColor = Main.pref.getColor(marktr("graphview default segment"), Color.WHITE); 312 arrowheadFillColor = Main.pref.getColor(marktr("graphview arrowhead core"), Color.BLACK); 331 313 separateDirections = Main.pref.getBoolean("graphview.separateDirections", false); 332 314 … … 503 485 } 504 486 } 505 506 private static final Pattern COLOR_PATTERN =507 Pattern.compile("^(\\d{1,3}),\\s*(\\d{1,3}),\\s*(\\d{1,3})$");508 509 private String createColorString(Color color) {510 return color.getRed() + ", " + color.getGreen() + ", " + color.getBlue();511 }512 513 private Color parseColorString(String string) {514 Matcher matcher = COLOR_PATTERN.matcher(string);515 if (!matcher.matches()) {516 return null;517 } else {518 int r = Integer.parseInt(matcher.group(1));519 int g = Integer.parseInt(matcher.group(2));520 int b = Integer.parseInt(matcher.group(3));521 return new Color(r, g, b);522 }523 }524 525 487 }
Note:
See TracChangeset
for help on using the changeset viewer.