Changeset 8260 in josm for trunk/src/org/openstreetmap/josm/gui/util
- Timestamp:
- 2015-04-25T14:00:05+02:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/util/RotationAngle.java
r8251 r8260 41 41 */ 42 42 public static RotationAngle buildStaticRotation(final String string) { 43 final Pattern radiansPattern = Pattern.compile("(\\d+\\.?\\d*)\\s*(rad)?");44 final Pattern degreesPattern = Pattern.compile("(\\d+\\.?\\d*)\\s*(deg|°)");45 final Pattern gradianPattern = Pattern.compile("(\\d+\\.?\\d*)\\s*(grad)");46 final Pattern turnPattern = Pattern.compile("(\\d+\\.?\\d*)\\s*(turn)");47 43 final double value; 48 Matcher matcher; 49 if ((matcher = radiansPattern.matcher(string)).matches()) { 50 value = Double.parseDouble(matcher.group(1)); 51 } else if ((matcher = degreesPattern.matcher(string)).matches()) { 52 value = Math.toRadians(Double.parseDouble(matcher.group(1))); 53 } else if ((matcher = gradianPattern.matcher(string)).matches()) { 54 value = Double.parseDouble(matcher.group(1)) / 200 * Math.PI; 55 } else if ((matcher = turnPattern.matcher(string)).matches()) { 56 value = Double.parseDouble(matcher.group(1)) * 2 * Math.PI; 57 } else { 58 try { 59 value = parseCardinalRotation(string); 60 } catch (IllegalArgumentException ignore) { 61 throw new IllegalArgumentException("Invalid string: " + string); 62 } 44 try { 45 value = parseCardinalRotation(string); 46 } catch (IllegalArgumentException ignore) { 47 throw new IllegalArgumentException("Invalid string: " + string); 63 48 } 64 49 return buildStaticRotation(value);
Note:
See TracChangeset
for help on using the changeset viewer.