Changeset 6830 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2014-02-10T00:51:53+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java
r6380 r6830 19 19 * Creates and controls a separate audio player thread. 20 20 * 21 * @author David Earl <david@frankieandshadow.com>21 * @author David Earl <david@frankieandshadow.com> 22 22 * @since 547 23 23 */ … … 124 124 * @param url The resource to play, which must be a WAV file or stream 125 125 * @param seconds The number of seconds into the audio to start playing 126 * @param speed Rate at which audio playes (1.0 = real time, >1 is faster)126 * @param speed Rate at which audio playes (1.0 = real time, > 1 is faster) 127 127 * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format 128 128 */ -
trunk/src/org/openstreetmap/josm/tools/AudioUtil.java
r6380 r6830 14 14 * Utils functions for audio. 15 15 * 16 * @author David Earl <david@frankieandshadow.com>16 * @author David Earl <david@frankieandshadow.com> 17 17 * @since 1462 18 18 */ … … 22 22 // Hide default constructor for utils classes 23 23 } 24 24 25 25 /** 26 26 * Returns calibrated length of recording in seconds. -
trunk/src/org/openstreetmap/josm/tools/ColorHelper.java
r6740 r6830 5 5 6 6 /** 7 * Helper to convert from color to htmlstring and back7 * Helper to convert from color to HTML string and back. 8 8 */ 9 9 public final class ColorHelper { … … 12 12 // Hide default constructor for utils classes 13 13 } 14 14 15 15 /** 16 16 * Returns the {@code Color} for the given HTML code. … … 55 55 * Returns the HTML color code (6 or 8 digit). 56 56 * @param col The color to convert 57 * @param withAlpha if {@code true} and alpha value <255, return 8-digit color code, else always 6-digit57 * @param withAlpha if {@code true} and alpha value < 255, return 8-digit color code, else always 6-digit 58 58 * @return the HTML color code (6 or 8 digit) 59 59 * @since 6655 -
trunk/src/org/openstreetmap/josm/tools/Diff.java
r6296 r6830 57 57 and <code>hashcode</code> methods for the objects compared. 58 58 <p> 59 The basic algorithm is described in: < /br>59 The basic algorithm is described in: <br> 60 60 "An O(ND) Difference Algorithm and its Variations", Eugene Myers, 61 61 Algorithmica Vol. 1 No. 2, 1986, p 251. … … 589 589 } 590 590 591 @Override 591 592 public String toString() { 592 593 String s = String.format("%d -%d +%d %d",line0,deleted,inserted,line1); … … 830 831 realindexes = new int[buffered_lines]; 831 832 } 832 833 833 834 FileData(Object[] data, Map<Object,Integer> h) { 834 835 this(data.length); -
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r6643 r6830 38 38 @SuppressWarnings("CallToThreadDumpStack") 39 39 public final class ExceptionUtil { 40 40 41 41 private ExceptionUtil() { 42 42 // Hide default constructor for utils classes … … 697 697 698 698 /** 699 * Replaces some HTML reserved characters ( <, > and &) by their equivalent entity (<, > and &);699 * Replaces some HTML reserved characters (<, > and &) by their equivalent entity (&lt;, &gt; and &amp;); 700 700 * @param s The unescaped string 701 701 * @return The escaped string -
trunk/src/org/openstreetmap/josm/tools/ExifReader.java
r6643 r6830 31 31 // Hide default constructor for utils classes 32 32 } 33 33 34 34 /** 35 35 * Returns the date/time from the given JPEG file. … … 70 70 * Returns the image orientation of the given JPEG file. 71 71 * @param filename The JPEG file to read 72 * @return The image orientation as an {@code int}. Default value is 1. Possible values are listed in EXIF spec as follows:<br> 73 * < ul>1.The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.</ul>74 * < ul>2.The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.</ul>75 * < ul>3.The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.</ul>76 * < ul>4.The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.</ul>77 * < ul>5.The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.</ul>78 * < ul>6.The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.</ul>79 * < ul>7.The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.</ul>80 * < ul>8.The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.</ul>72 * @return The image orientation as an {@code int}. Default value is 1. Possible values are listed in EXIF spec as follows:<br><ol> 73 * <li>The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side.</li> 74 * <li>The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side.</li> 75 * <li>The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side.</li> 76 * <li>The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side.</li> 77 * <li>The 0th row is the visual left-hand side of the image, and the 0th column is the visual top.</li> 78 * <li>The 0th row is the visual right-hand side of the image, and the 0th column is the visual top.</li> 79 * <li>The 0th row is the visual right-hand side of the image, and the 0th column is the visual bottom.</li> 80 * <li>The 0th row is the visual left-hand side of the image, and the 0th column is the visual bottom.</li></ol> 81 81 * @see <a href="http://www.impulseadventure.com/photo/exif-orientation.html">http://www.impulseadventure.com/photo/exif-orientation.html</a> 82 82 * @see <a href="http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto">http://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto</a> … … 133 133 return null; 134 134 } 135 135 136 136 /** 137 137 * Returns the direction of the given JPEG file. … … 152 152 return null; 153 153 } 154 154 155 155 /** 156 156 * Returns the direction of the given EXIF GPS directory. … … 176 176 double min = components[1].doubleValue(); 177 177 double sec = components[2].doubleValue(); 178 178 179 179 if (Double.isNaN(deg) && Double.isNaN(min) && Double.isNaN(sec)) 180 180 throw new IllegalArgumentException(); 181 181 182 182 value = (Double.isNaN(deg) ? 0 : deg + (Double.isNaN(min) ? 0 : (min / 60)) + (Double.isNaN(sec) ? 0 : (sec / 3600))); 183 183 184 184 if (dirGps.getString(gpsTagRef).charAt(0) == cRef) { 185 185 value = -value; -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r6607 r6830 37 37 */ 38 38 public final class Geometry { 39 39 40 40 private Geometry() { 41 41 // Hide default constructor for utils classes 42 42 } 43 43 44 44 public enum PolygonIntersection {FIRST_INSIDE_SECOND, SECOND_INSIDE_FIRST, OUTSIDE, CROSSING} 45 45 … … 771 771 * Tests if the polygon formed by {@code nodes} is inside the multipolygon {@code multiPolygon}. The nullable argument 772 772 * {@code isOuterWayAMatch} allows to decide if the immediate {@code outer} way of the multipolygon is a match. 773 * <p />773 * <p> 774 774 * If {@code nodes} contains exactly one element, then it is checked whether that one node is inside the multipolygon. 775 775 */ -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r6796 r6830 32 32 */ 33 33 public final class I18n { 34 34 35 35 private I18n() { 36 36 // Hide default constructor for utils classes 37 37 } 38 38 39 39 private enum PluralMode { MODE_NOTONE, MODE_NONE, MODE_GREATERONE, 40 40 MODE_CS/*, MODE_AR*/, MODE_PL/*, MODE_RO*/, MODE_RU, MODE_SK/*, MODE_SL*/} … … 135 135 * These strings are collected by a script that runs on the source code files. 136 136 * After translation, the localizations are distributed with the main program. 137 * <br />137 * <br> 138 138 * For example, {@code tr("JOSM''s default value is ''{0}''.", val)}. 139 * <br />139 * <br> 140 140 * Use {@link #trn} for distinguishing singular from plural text, i.e., 141 141 * do not use {@code tr(size == 1 ? "singular" : "plural")} nor … … 207 207 * Translates some text for the current locale and distinguishes between 208 208 * {@code singularText} and {@code pluralText} depending on {@code n}. 209 * <br />209 * <br> 210 210 * For instance, {@code trn("There was an error!", "There were errors!", i)} or 211 211 * {@code trn("Found {0} error in {1}!", "Found {0} errors in {1}!", i, Integer.toString(i), url)}. -
trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java
r6643 r6830 85 85 * Openstreetmap.org changed it's URL scheme in August 2013, which breaks the URL parsing. 86 86 * The following function, called by the old parse function if necessary, provides parsing new URLs 87 * the new URLs follow the scheme http://www.openstreetmap.org/#map=18/51.71873/8.76164&layers=CN 87 * the new URLs follow the scheme http://www.openstreetmap.org/#map=18/51.71873/8.76164&layers=CN 88 88 * @param url string for parsing 89 89 * @return Bounds if hashurl, {@code null} otherwise … … 294 294 * @param zoom zoom depth of display 295 295 * @return link to display that area in OSM map 296 * 296 * 297 297 * @since 6453 298 298 */ -
trunk/src/org/openstreetmap/josm/tools/PlatformHook.java
r6443 r6830 11 11 */ 12 12 public interface PlatformHook { 13 13 14 14 /** 15 15 * The preStartupHook will be called extremly early. It is … … 47 47 * shortuts from this hook, but only "systemCuts"! 48 48 * 49 * BTW: SystemCuts should be named "system: <whatever>",49 * BTW: SystemCuts should be named "system:<whatever>", 50 50 * and it'd be best if sou'd recycle the names already used 51 51 * by the Windows and OSX hooks. Especially the later has … … 69 69 * Another reason not to use the implementation in the *nix 70 70 * hook are LAFs that don't understand HTML, such as the OSX LAFs. 71 * 72 * @param name Tooltip text to display 71 * 72 * @param name Tooltip text to display 73 73 * @param sc Shortcut associated (to display accelerator between parenthesis) 74 74 * @return Full tooltip text (name + accelerator) -
trunk/src/org/openstreetmap/josm/tools/TextTagParser.java
r6362 r6830 28 28 */ 29 29 public final class TextTagParser { 30 30 31 31 // properties need JOSM restart to apply, modified rarely enough 32 32 protected static final int MAX_KEY_LENGTH = Main.pref.getInteger("tags.paste.max-key-length", 50); … … 34 34 protected static final String KEY_PATTERN = Main.pref.get("tags.paste.tag-pattern", "[0-9a-zA-Z:_]*"); 35 35 protected static final int MAX_VALUE_LENGTH = 255; 36 36 37 37 private TextTagParser() { 38 38 // Hide default constructor for utils classes 39 39 } 40 40 41 41 public static class TextAnalyzer { 42 42 boolean quotesStarted = false; … … 52 52 n = data.length(); 53 53 } 54 54 55 55 /** 56 56 * Read tags from "Free format" … … 72 72 return tags; 73 73 } 74 74 75 75 private String parseString(String stopChars) { 76 76 char[] stop = stopChars.toCharArray(); … … 95 95 pos++; 96 96 break; 97 } else if (!quotesStarted && (Arrays.binarySearch(stop, c)>=0)) { 97 } else if (!quotesStarted && (Arrays.binarySearch(stop, c)>=0)) { 98 98 // stop-symbol found 99 99 pos++; … … 110 110 return res.trim(); 111 111 } 112 112 113 113 private void skipSign() { 114 114 char c; … … 155 155 156 156 /** 157 * Try to find tag-value pairs in given text 157 * Try to find tag-value pairs in given text 158 158 * @param text - text in which tags are looked for 159 159 * @param splitRegex - text is splitted into parts with this delimiter … … 175 175 v = unescape(v); 176 176 if (k==null || v==null) return null; 177 } 177 } 178 178 tags.put(k,v); 179 179 } else { … … 185 185 } else { 186 186 return null; 187 } 188 } 189 187 } 188 } 189 190 190 public static Map<String,String> getValidatedTagsFromText(String buf) { 191 191 Map<String,String> tags = readTagsFromText(buf); 192 192 return validateTags(tags) ? tags : null; 193 193 } 194 194 195 195 /** 196 196 * Apply different methods to extract tag-value pairs from arbitrary text … … 198 198 * @return null if no format is suitable 199 199 */ 200 200 201 201 public static Map<String,String> readTagsFromText(String buf) { 202 202 Map<String,String> tags; 203 203 204 204 // Format 205 205 // tag1\tval1\ntag2\tval2\n … … 209 209 210 210 // Format 211 // a=b \n c=d \n "a b"=hello 211 // a=b \n c=d \n "a b"=hello 212 212 // SORRY: "a=b" = c is not supported fror now, only first = will be considered 213 213 // a = "b=c" is OK … … 216 216 // try format t1=v1\n t2=v2\n ... 217 217 if (tags!=null) return tags; 218 218 219 219 // JSON-format 220 220 String bufJson = buf.trim(); 221 221 // trim { }, if there are any 222 222 if (bufJson.startsWith("{") && bufJson.endsWith("}") ) bufJson = bufJson.substring(1,bufJson.length()-1); 223 tags = readTagsByRegexp(bufJson, "[\\s]*,[\\s]*", 223 tags = readTagsByRegexp(bufJson, "[\\s]*,[\\s]*", 224 224 "[\\s]*(\\\".*?[^\\\\]\\\")"+"[\\s]*:[\\s]*"+"(\\\".*?[^\\\\]\\\")[\\s]*", true); 225 225 if (tags!=null) return tags; 226 226 227 // Free format 227 // Free format 228 228 // a 1 "b" 2 c=3 d 4 e "5" 229 229 TextAnalyzer parser = new TextAnalyzer(buf); … … 234 234 /** 235 235 * Check tags for correctness and display warnings if needed 236 * @param tags - map key- >value to check236 * @param tags - map key->value to check 237 237 * @return true if the tags should be pasted 238 238 */ … … 265 265 return true; 266 266 } 267 267 268 268 private static int warning(String text, String data, String code) { 269 269 ExtendedDialog ed = new ExtendedDialog( … … 304 304 tr("Warning"), 305 305 new String[]{tr("Ok"), tr("Clear buffer")}); 306 306 307 307 ed.setButtonIcons(new String[]{"ok.png", "dialogs/delete.png"}); 308 308 309 309 ed.setContent(p); 310 310 ed.setDefaultButton(1); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6823 r6830 261 261 262 262 /** 263 * convert float range 0 <= x <= 1 to integer range 0..255263 * convert float range 0 <= x <= 1 to integer range 0..255 264 264 * when dealing with colors and color alpha value 265 265 * @return null if val is null, the corresponding int if val is in the … … 275 275 276 276 /** 277 * convert integer range 0..255 to float range 0 <= x <= 1277 * convert integer range 0..255 to float range 0 <= x <= 1 278 278 * when dealing with colors and color alpha value 279 279 */ … … 317 317 318 318 /** 319 * Simple file copy function that will overwrite the target file.<br />319 * Simple file copy function that will overwrite the target file.<br> 320 320 * Taken from <a href="http://www.rgagnon.com/javadetails/java-0064.html">this article</a> (CC-NC-BY-SA) 321 321 * @param in The source file … … 526 526 * Topological sort. 527 527 * 528 * @param dependencies contains mappings (key - >value). In the final list of sorted objects, the key will come528 * @param dependencies contains mappings (key -> value). In the final list of sorted objects, the key will come 529 529 * after the value. (In other words, the key depends on the value(s).) 530 530 * There must not be cyclic dependencies. … … 836 836 * @param elapsedTime The duration in milliseconds 837 837 * @return A human readable string for the given duration 838 * @throws IllegalArgumentException if elapsedTime is <0838 * @throws IllegalArgumentException if elapsedTime is < 0 839 839 * @since 6354 840 840 */ … … 867 867 /** 868 868 * Returns a human readable representation of a list of positions. 869 * <p />869 * <p> 870 870 * For instance, {@code [1,5,2,6,7} yields "1-2,5-7 871 871 * @param positionList a list of positions
Note:
See TracChangeset
for help on using the changeset viewer.