Changeset 8395 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2015-05-19T00:05:33+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java
r8393 r8395 277 277 if (playingUrl != command.url() || 278 278 stateChange != State.PAUSED || 279 offset != 0) 280 { 279 offset != 0) { 281 280 if (audioInputStream != null) { 282 281 Utils.close(audioInputStream); -
trunk/src/org/openstreetmap/josm/tools/Diff.java
r8378 r8395 170 170 bd[bdiagoff + bmid] = xlim; 171 171 172 for (int c = 1;; ++c) 173 { 172 for (int c = 1;; ++c) { 174 173 int d; /* Active diagonal. */ 175 174 boolean big_snake = false; … … 186 185 --fmax; 187 186 } 188 for (d = fmax; d >= fmin; d -= 2) 189 { 187 for (d = fmax; d >= fmin; d -= 2) { 190 188 int x, y, oldx, tlo = fd[fdiagoff + d - 1], thi = fd[fdiagoff + d + 1]; 191 189 … … 204 202 } 205 203 fd[fdiagoff + d] = x; 206 if (odd && bmin <= d && d <= bmax && bd[bdiagoff + d] <= fd[fdiagoff + d]) 207 { 204 if (odd && bmin <= d && d <= bmax && bd[bdiagoff + d] <= fd[fdiagoff + d]) { 208 205 cost = 2 * c - 1; 209 206 return d; … … 222 219 --bmax; 223 220 } 224 for (d = bmax; d >= bmin; d -= 2) 225 { 221 for (d = bmax; d >= bmin; d -= 2) { 226 222 int x, y, oldx, tlo = bd[bdiagoff + d - 1], thi = bd[bdiagoff + d + 1]; 227 223 … … 240 236 } 241 237 bd[bdiagoff + d] = x; 242 if (!odd && fmin <= d && d <= fmax && bd[bdiagoff + d] <= fd[fdiagoff + d]) 243 { 238 if (!odd && fmin <= d && d <= fmax && bd[bdiagoff + d] <= fd[fdiagoff + d]) { 244 239 cost = 2 * c; 245 240 return d; … … 255 250 of changes, the algorithm is linear in the file size. */ 256 251 257 if (c > 200 && big_snake && heuristic) 258 { 252 if (c > 200 && big_snake && heuristic) { 259 253 int best = 0; 260 254 int bestpos = -1; 261 255 262 for (d = fmax; d >= fmin; d -= 2) 263 { 256 for (d = fmax; d >= fmin; d -= 2) { 264 257 int dd = d - fmid; 265 258 int x = fd[fdiagoff + d]; 266 259 int y = x - d; 267 260 int v = (x - xoff) * 2 - dd; 268 if (v > 12 * (c + (dd < 0 ? -dd : dd))) 269 { 261 if (v > 12 * (c + (dd < 0 ? -dd : dd))) { 270 262 if (v > best 271 263 && xoff + SNAKE_LIMIT <= x && x < xlim 272 && yoff + SNAKE_LIMIT <= y && y < ylim) 273 { 264 && yoff + SNAKE_LIMIT <= y && y < ylim) { 274 265 /* We have a good enough best diagonal. 275 266 now insist that it end with a significant snake. */ … … 277 268 278 269 for (k = 1; xvec[x - k] == yvec[y - k]; k++) 279 if (k == SNAKE_LIMIT) 280 { 270 if (k == SNAKE_LIMIT) { 281 271 best = v; 282 272 bestpos = d; … … 286 276 } 287 277 } 288 if (best > 0) 289 { 278 if (best > 0) { 290 279 cost = 2 * c - 1; 291 280 return bestpos; … … 293 282 294 283 best = 0; 295 for (d = bmax; d >= bmin; d -= 2) 296 { 284 for (d = bmax; d >= bmin; d -= 2) { 297 285 int dd = d - bmid; 298 286 int x = bd[bdiagoff + d]; 299 287 int y = x - d; 300 288 int v = (xlim - x) * 2 + dd; 301 if (v > 12 * (c + (dd < 0 ? -dd : dd))) 302 { 289 if (v > 12 * (c + (dd < 0 ? -dd : dd))) { 303 290 if (v > best 304 291 && xoff < x && x <= xlim - SNAKE_LIMIT 305 && yoff < y && y <= ylim - SNAKE_LIMIT) 306 { 292 && yoff < y && y <= ylim - SNAKE_LIMIT) { 307 293 /* We have a good enough best diagonal. 308 294 now insist that it end with a significant snake. */ … … 310 296 311 297 for (k = 0; xvec[x + k] == yvec[y + k]; k++) 312 if (k == SNAKE_LIMIT) 313 { 298 if (k == SNAKE_LIMIT) { 314 299 best = v; 315 300 bestpos = d; … … 319 304 } 320 305 } 321 if (best > 0) 322 { 306 if (best > 0) { 323 307 cost = 2 * c - 1; 324 308 return bestpos; … … 371 355 Let's verify that this is true. */ 372 356 throw new IllegalArgumentException("Empty subsequence"); 373 else 374 { 357 else { 375 358 /* Use that point to split this problem into two subproblems. */ 376 359 compareseq (xoff, b, yoff, b - d); … … 425 408 public Change build_script( 426 409 final boolean[] changed0,int len0, 427 final boolean[] changed1,int len1) 428 { 410 final boolean[] changed1,int len1) { 429 411 Change script = null; 430 412 int i0 = 0, i1 = 0; … … 459 441 public Change build_script( 460 442 final boolean[] changed0,int len0, 461 final boolean[] changed1,int len1) 462 { 443 final boolean[] changed1,int len1) { 463 444 Change script = null; 464 445 int i0 = len0, i1 = len1; 465 446 466 while (i0 >= 0 || i1 >= 0) 467 { 468 if (changed0[i0] || changed1[i1]) 469 { 447 while (i0 >= 0 || i1 >= 0) { 448 if (changed0[i0] || changed1[i1]) { 470 449 int line0 = i0, line1 = i1; 471 450 … … 670 649 } 671 650 672 for (int i = 0; i < end; i++) 673 { 651 for (int i = 0; i < end; i++) { 674 652 int nmatch; 675 653 if (equivs[i] == 0) { … … 694 672 final int end = bufferedLines; 695 673 696 for (int i = 0; i < end; i++) 697 { 674 for (int i = 0; i < end; i++) { 698 675 /* Cancel provisional discards not in middle of run of discards. */ 699 676 if (discards[i] == 2) { 700 677 discards[i] = 0; 701 } else if (discards[i] != 0) 702 { 678 } else if (discards[i] != 0) { 703 679 /* We have found a nonprovisional discard. */ 704 680 int j; … … 708 684 /* Find end of this run of discardable lines. 709 685 Count how many are provisionally discardable. */ 710 for (j = i; j < end; j++) 711 { 686 for (j = i; j < end; j++) { 712 687 if (discards[j] == 0) { 713 688 break; … … 811 786 int j = 0; 812 787 for (int i = 0; i < end; ++i) 813 if (noDiscards || discards[i] == 0) 814 { 788 if (noDiscards || discards[i] == 0) { 815 789 undiscarded[j] = equivs[i]; 816 790 realindexes[j++] = i; … … 853 827 @param f the file being compared against 854 828 */ 855 856 829 void shift_boundaries(FileData f) { 857 830 final boolean[] changed = changedFlag; … … 863 836 int other_preceding = -1; 864 837 865 for (;;) 866 { 838 for (;;) { 867 839 int start, end, other_start; 868 840 … … 870 842 Also keep track of the corresponding point in the other file. */ 871 843 872 while (i < i_end && !changed[1+i]) 873 { 844 while (i < i_end && !changed[1+i]) { 874 845 while (other_changed[1+j++]) { 875 846 /* Non-corresponding lines in the other file … … 887 858 other_start = j; 888 859 889 for (;;) 890 { 860 for (;;) { 891 861 /* Now find the end of this run of changes. */ 892 862 … … 905 875 Only because the previous run was shifted here. */ 906 876 907 if (end != i_end 908 && equivs[start] == equivs[end] 909 && !other_changed[1+j] 910 && !((preceding >= 0 && start == preceding) 911 || (other_preceding >= 0 912 && other_start == other_preceding))) 913 { 877 if (end != i_end && equivs[start] == equivs[end] && !other_changed[1+j] 878 && !((preceding >= 0 && start == preceding) || (other_preceding >= 0 && other_start == other_preceding))) { 914 879 changed[1+end++] = true; 915 880 changed[1+start++] = false; -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r8393 r8395 601 601 if ((newPoint.getEastNorth().getY() < point.getEastNorth().getY()) == (point.getEastNorth().getY() <= oldPoint.getEastNorth().getY()) 602 602 && (point.getEastNorth().getX() - p1.getEastNorth().getX()) * (p2.getEastNorth().getY() - p1.getEastNorth().getY()) 603 < (p2.getEastNorth().getX() - p1.getEastNorth().getX()) * (point.getEastNorth().getY() - p1.getEastNorth().getY())) 604 { 603 < (p2.getEastNorth().getX() - p1.getEastNorth().getX()) * (point.getEastNorth().getY() - p1.getEastNorth().getY())) { 605 604 inside = !inside; 606 605 } … … 638 637 } 639 638 640 protected static double calcX(Node p1){ 639 protected static double calcX(Node p1) { 641 640 double lat1, lon1, lat2, lon2; 642 641 double dlon, dlat; -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r8393 r8395 935 935 return svg == null ? null : new ImageResource(svg); 936 936 case OTHER: 937 while(size > 0) 938 { 937 while(size > 0) { 939 938 int l = is.read(buf, offs, size); 940 939 offs += l; -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r8380 r8395 253 253 public static List<Shortcut> listAll() { 254 254 List<Shortcut> l = new ArrayList<>(); 255 for(Shortcut c : shortcuts.values()) 256 { 257 if(!"core:none".equals(c.shortText)) { 255 for (Shortcut c : shortcuts.values()) { 256 if (!"core:none".equals(c.shortText)) { 258 257 l.add(c); 259 258 }
Note:
See TracChangeset
for help on using the changeset viewer.