Changeset 6690 in josm
- Timestamp:
- 2014-01-15T15:47:45+01:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r6364 r6690 31 31 public class ImageryInfo implements Comparable<ImageryInfo>, Attributed { 32 32 33 /** 34 * Type of imagery entry. 35 */ 33 36 public enum ImageryType { 37 /** A WMS (Web Map Service) entry. **/ 34 38 WMS("wms"), 39 /** A TMS (Tile Map Service) entry. **/ 35 40 TMS("tms"), 41 /** An HTML proxy (previously used for Yahoo imagery) entry. **/ 36 42 HTML("html"), 43 /** TMS entry for Microsoft Bing. */ 37 44 BING("bing"), 45 /** TMS entry for Russian company <a href="https://wiki.openstreetmap.org/wiki/WikiProject_Russia/kosmosnimki">ScanEx</a>. **/ 38 46 SCANEX("scanex"), 47 /** A WMS endpoint entry only stores the WMS server info, without layer, which are chosen later by the user. **/ 39 48 WMS_ENDPOINT("wms_endpoint"); 40 49 41 private String urlString; 42 43 ImageryType(String urlString) { 44 this.urlString = urlString; 45 } 46 47 public String getUrlString() { 48 return urlString; 49 } 50 51 public static ImageryType fromUrlString(String s) { 50 private final String typeString; 51 52 private ImageryType(String urlString) { 53 this.typeString = urlString; 54 } 55 56 /** 57 * Returns the unique string identifying this type. 58 * @return the unique string identifying this type 59 * @since 6690 60 */ 61 public final String getTypeString() { 62 return typeString; 63 } 64 65 /** 66 * Returns the imagery type from the given type string. 67 * @param s The type string 68 * @return the imagery type matching the given type string 69 */ 70 public static ImageryType fromString(String s) { 52 71 for (ImageryType type : ImageryType.values()) { 53 if (type.get UrlString().equals(s)) {72 if (type.getTypeString().equals(s)) { 54 73 return type; 55 74 } … … 59 78 } 60 79 80 /** 81 * Multi-polygon bounds for imagery backgrounds. 82 * Used to display imagery coverage in preferences and to determine relevant imagery entries based on edit location. 83 */ 61 84 public static class ImageryBounds extends Bounds { 85 86 /** 87 * Constructs a new {@code ImageryBounds} from string. 88 * @param asString The string containing the list of shapes defining this bounds 89 * @param separator The shape separator in the given string, usually a comma 90 */ 62 91 public ImageryBounds(String asString, String separator) { 63 92 super(asString, separator); … … 66 95 private List<Shape> shapes = new ArrayList<Shape>(); 67 96 68 public void addShape(Shape shape) { 97 /** 98 * Adds a new shape to this bounds. 99 * @param shape The shape to add 100 */ 101 public final void addShape(Shape shape) { 69 102 this.shapes.add(shape); 70 103 } 71 104 72 public void setShapes(List<Shape> shapes) { 105 /** 106 * Sets the list of shapes defining this bounds. 107 * @param shapes The list of shapes defining this bounds. 108 */ 109 public final void setShapes(List<Shape> shapes) { 73 110 this.shapes = shapes; 74 111 } 75 112 76 public List<Shape> getShapes() { 113 /** 114 * Returns the list of shapes defining this bounds. 115 * @return The list of shapes defining this bounds 116 */ 117 public final List<Shape> getShapes() { 77 118 return shapes; 78 119 } … … 125 166 // when adding a field, also adapt the ImageryInfo(ImageryInfo) constructor 126 167 127 /** auxiliary class to save an ImageryInfo object in the preferences */ 168 /** 169 * Auxiliary class to save an {@link ImageryInfo} object in the preferences. 170 */ 128 171 public static class ImageryPreferenceEntry { 129 172 @pref String name; … … 148 191 149 192 /** 150 * Constructs a new {@code ImageryPreferenceEntry}.193 * Constructs a new empty WMS {@code ImageryPreferenceEntry}. 151 194 */ 152 195 public ImageryPreferenceEntry() { 153 196 } 154 197 198 /** 199 * Constructs a new {@code ImageryPreferenceEntry} from a given {@code ImageryInfo}. 200 * @param i The corresponding imagery info 201 */ 155 202 public ImageryPreferenceEntry(ImageryInfo i) { 156 203 name = i.name; 157 type = i.imageryType.get UrlString();204 type = i.imageryType.getTypeString(); 158 205 url = i.url; 159 206 pixel_per_eastnorth = i.pixelPerDegree; … … 202 249 203 250 /** 204 * Constructs a new {@code ImageryInfo}.251 * Constructs a new WMS {@code ImageryInfo}. 205 252 */ 206 253 public ImageryInfo() { 207 254 } 208 255 256 /** 257 * Constructs a new WMS {@code ImageryInfo} with a given name. 258 * @param name The entry name 259 */ 209 260 public ImageryInfo(String name) { 210 261 this.name=name; 211 262 } 212 263 264 /** 265 * Constructs a new WMS {@code ImageryInfo} with given name and extended URL. 266 * @param name The entry name 267 * @param url The entry extended URL 268 */ 213 269 public ImageryInfo(String name, String url) { 214 270 this.name=name; … … 216 272 } 217 273 274 /** 275 * Constructs a new WMS {@code ImageryInfo} with given name, extended and EULA URLs. 276 * @param name The entry name 277 * @param url The entry URL 278 * @param eulaAcceptanceRequired The EULA URL 279 */ 218 280 public ImageryInfo(String name, String url, String eulaAcceptanceRequired) { 219 281 this.name=name; … … 222 284 } 223 285 224 public ImageryInfo(String name, String url, String eulaAcceptanceRequired, String cookies) {225 this.name=name;226 setExtendedUrl(url);227 this.cookies=cookies;228 this.eulaAcceptanceRequired = eulaAcceptanceRequired;229 }230 231 286 public ImageryInfo(String name, String url, String type, String eulaAcceptanceRequired, String cookies) { 232 287 this.name=name; 233 288 setExtendedUrl(url); 234 ImageryType t = ImageryType.from UrlString(type);289 ImageryType t = ImageryType.fromString(type); 235 290 this.cookies=cookies; 236 291 this.eulaAcceptanceRequired = eulaAcceptanceRequired; … … 240 295 } 241 296 242 public ImageryInfo(String name, String url, String cookies, double pixelPerDegree) { 243 this.name=name; 244 setExtendedUrl(url); 245 this.cookies=cookies; 246 this.pixelPerDegree=pixelPerDegree; 247 } 248 297 /** 298 * Constructs a new {@code ImageryInfo} from an imagery preference entry. 299 * @param e The imagery preference entry 300 */ 249 301 public ImageryInfo(ImageryPreferenceEntry e) { 250 302 CheckParameterUtil.ensureParameterNotNull(e.name, "name"); … … 254 306 cookies = e.cookies; 255 307 eulaAcceptanceRequired = e.eula; 256 imageryType = ImageryType.from UrlString(e.type);308 imageryType = ImageryType.fromString(e.type); 257 309 if (imageryType == null) throw new IllegalArgumentException("unknown type"); 258 310 pixelPerDegree = e.pixel_per_eastnorth; … … 284 336 } 285 337 338 /** 339 * Constructs a new {@code ImageryInfo} from an existing one. 340 * @param i The other imagery info 341 */ 286 342 public ImageryInfo(ImageryInfo i) { 287 343 this.name = i.name; … … 338 394 339 395 @Override 340 public int compareTo(ImageryInfo in) 341 { 396 public int compareTo(ImageryInfo in) { 342 397 int i = countryCode.compareTo(in.countryCode); 343 398 if (i == 0) { … … 353 408 } 354 409 355 public boolean equalsBaseValues(ImageryInfo in) 356 { 410 public boolean equalsBaseValues(ImageryInfo in) { 357 411 return url.equals(in.url); 358 412 } … … 362 416 } 363 417 418 /** 419 * Sets the maximum zoom level. 420 * @param defaultMaxZoom The maximum zoom level 421 */ 364 422 public void setDefaultMaxZoom(int defaultMaxZoom) { 365 423 this.defaultMaxZoom = defaultMaxZoom; 366 424 } 367 425 426 /** 427 * Sets the minimum zoom level. 428 * @param defaultMinZoom The minimum zoom level 429 */ 368 430 public void setDefaultMinZoom(int defaultMinZoom) { 369 431 this.defaultMinZoom = defaultMinZoom; 370 432 } 371 433 434 /** 435 * Sets the imagery polygonial bounds. 436 * @param b The imagery bounds (non-rectangular) 437 */ 372 438 public void setBounds(ImageryBounds b) { 373 439 this.bounds = b; 374 440 } 375 441 442 /** 443 * Returns the imagery polygonial bounds. 444 * @return The imagery bounds (non-rectangular) 445 */ 376 446 public ImageryBounds getBounds() { 377 447 return bounds; … … 441 511 } 442 512 513 /** 514 * Sets the extended URL of this entry. 515 * @param url Entry extended URL containing in addition of service URL, its type and min/max zoom info 516 */ 443 517 public void setExtendedUrl(String url) { 444 518 CheckParameterUtil.ensureParameterNotNull(url); … … 451 525 defaultMinZoom = 0; 452 526 for (ImageryType type : ImageryType.values()) { 453 Matcher m = Pattern.compile(type.get UrlString()+"(?:\\[(?:(\\d+),)?(\\d+)\\])?:(.*)").matcher(url);527 Matcher m = Pattern.compile(type.getTypeString()+"(?:\\[(?:(\\d+),)?(\\d+)\\])?:(.*)").matcher(url); 454 528 if (m.matches()) { 455 529 this.url = m.group(3); … … 479 553 } 480 554 555 /** 556 * Returns the entry name. 557 * @return The entry name 558 */ 481 559 public String getName() { 482 560 return this.name; 483 561 } 484 562 563 /** 564 * Sets the entry name. 565 * @param name The entry name 566 */ 485 567 public void setName(String name) { 486 568 this.name = name; 487 569 } 488 570 571 /** 572 * Returns the entry URL. 573 * @return The entry URL 574 */ 489 575 public String getUrl() { 490 576 return this.url; 491 577 } 492 578 579 /** 580 * Sets the entry URL. 581 * @param url The entry URL 582 */ 493 583 public void setUrl(String url) { 494 584 this.url = url; 495 585 } 496 586 587 /** 588 * Determines if this entry is enabled by default. 589 * @return {@code true} if this entry is enabled by default, {@code false} otherwise 590 */ 497 591 public boolean isDefaultEntry() { 498 592 return defaultEntry; 499 593 } 500 594 595 /** 596 * Sets the default state of this entry. 597 * @param defaultEntry {@code true} if this entry has to be enabled by default, {@code false} otherwise 598 */ 501 599 public void setDefaultEntry(boolean defaultEntry) { 502 600 this.defaultEntry = defaultEntry; … … 511 609 } 512 610 611 /** 612 * Returns the maximum zoom level. 613 * @return The maximum zoom level 614 */ 513 615 public int getMaxZoom() { 514 616 return this.defaultMaxZoom; 515 617 } 516 618 619 /** 620 * Returns the minimum zoom level. 621 * @return The minimum zoom level 622 */ 517 623 public int getMinZoom() { 518 624 return this.defaultMinZoom; 519 625 } 520 626 627 /** 628 * Returns the EULA acceptance URL, if any. 629 * @return The URL to an EULA text that has to be accepted before use, or {@code null} 630 */ 521 631 public String getEulaAcceptanceRequired() { 522 632 return eulaAcceptanceRequired; 523 633 } 524 634 635 /** 636 * Sets the EULA acceptance URL. 637 * @param eulaAcceptanceRequired The URL to an EULA text that has to be accepted before use 638 */ 525 639 public void setEulaAcceptanceRequired(String eulaAcceptanceRequired) { 526 640 this.eulaAcceptanceRequired = eulaAcceptanceRequired; 527 641 } 528 642 643 /** 644 * Returns the ISO 3166-1-alpha-2 country code. 645 * @return The country code (2 letters) 646 */ 529 647 public String getCountryCode() { 530 648 return countryCode; 531 649 } 532 650 651 /** 652 * Sets the ISO 3166-1-alpha-2 country code. 653 * @param countryCode The country code (2 letters) 654 */ 533 655 public void setCountryCode(String countryCode) { 534 656 this.countryCode = countryCode; 535 657 } 536 658 659 /** 660 * Returns the entry icon. 661 * @return The entry icon 662 */ 537 663 public String getIcon() { 538 664 return icon; 539 665 } 540 666 667 /** 668 * Sets the entry icon. 669 * @param icon The entry icon 670 */ 541 671 public void setIcon(String icon) { 542 672 this.icon = icon; … … 559 689 } 560 690 691 /** 692 * Returns the extended URL, containing in addition of service URL, its type and min/max zoom info. 693 * @return The extended URL 694 */ 561 695 public String getExtendedUrl() { 562 return imageryType.get UrlString() + (defaultMaxZoom != 0696 return imageryType.getTypeString() + (defaultMaxZoom != 0 563 697 ? "["+(defaultMinZoom != 0 ? defaultMinZoom+",":"")+defaultMaxZoom+"]" : "") + ":" + url; 564 698 } 565 699 566 public String getToolbarName() 567 { 700 public String getToolbarName() { 568 701 String res = name; 569 702 if(pixelPerDegree != 0.0) { … … 573 706 } 574 707 575 public String getMenuName() 576 { 708 public String getMenuName() { 577 709 String res = name; 578 710 if(pixelPerDegree != 0.0) { … … 582 714 } 583 715 584 public boolean hasAttribution() 585 { 716 /** 717 * Determines if this entry requires attribution. 718 * @return {@code true} if some attribution text has to be displayed, {@code false} otherwise 719 */ 720 public boolean hasAttribution() { 586 721 return attributionText != null; 587 722 } 588 723 589 public void copyAttribution(ImageryInfo i) 590 { 724 /** 725 * Copies attribution from another {@code ImageryInfo}. 726 * @param i The other imagery info to get attribution from 727 */ 728 public void copyAttribution(ImageryInfo i) { 591 729 this.attributionImage = i.attributionImage; 592 730 this.attributionImageURL = i.attributionImageURL; … … 598 736 599 737 /** 600 * Applies the attribution from this object to a TMSTileSource. 738 * Applies the attribution from this object to a tile source. 739 * @param s The tile source 601 740 */ 602 741 public void setAttribution(AbstractTileSource s) { … … 636 775 } 637 776 777 /** 778 * Returns the imagery type. 779 * @return The imagery type 780 */ 638 781 public ImageryType getImageryType() { 639 782 return imageryType; 640 783 } 641 784 785 /** 786 * Sets the imagery type. 787 * @param imageryType The imagery type 788 */ 642 789 public void setImageryType(ImageryType imageryType) { 643 790 this.imageryType = imageryType; … … 647 794 * Returns true if this layer's URL is matched by one of the regular 648 795 * expressions kept by the current OsmApi instance. 796 * @return {@code true} is this entry is blacklisted, {@code false} otherwise 649 797 */ 650 798 public boolean isBlacklisted() { -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r6529 r6690 525 525 ImageryInfo info = defaultModel.getRow(line); 526 526 527 // Check if an entry with exactly the same values already 528 // exists 527 // Check if an entry with exactly the same values already exists 529 528 for (int j = 0; j < activeModel.getRowCount(); j++) { 530 529 if (info.equalsBaseValues(activeModel.getRow(j))) { … … 572 571 */ 573 572 public class ImageryLayerTableModel extends DefaultTableModel { 573 /** 574 * Constructs a new {@code ImageryLayerTableModel}. 575 */ 574 576 public ImageryLayerTableModel() { 575 577 setColumnIdentifiers(new String[] { tr("Menu Name"), tr("Imagery URL")}); 576 578 } 577 579 580 /** 581 * Returns the imagery info at the given row number. 582 * @param row The row number 583 * @return The imagery info at the given row number 584 */ 578 585 public ImageryInfo getRow(int row) { 579 586 return layerInfo.getLayers().get(row); 580 587 } 581 588 589 /** 590 * Adds a new imagery info as the last row. 591 * @param i The imagery info to add 592 */ 582 593 public void addRow(ImageryInfo i) { 583 594 layerInfo.add(i); … … 636 647 */ 637 648 public class ImageryDefaultLayerTableModel extends DefaultTableModel { 649 /** 650 * Constructs a new {@code ImageryDefaultLayerTableModel}. 651 */ 638 652 public ImageryDefaultLayerTableModel() { 639 653 setColumnIdentifiers(new String[]{"", tr("Menu Name (Default)"), tr("Imagery URL (Default)")}); 640 654 } 641 655 656 /** 657 * Returns the imagery info at the given row number. 658 * @param row The row number 659 * @return The imagery info at the given row number 660 */ 642 661 public ImageryInfo getRow(int row) { 643 662 return layerInfo.getDefaultLayers().get(row); … … 834 853 } 835 854 855 /** 856 * Initializes imagery preferences. 857 */ 836 858 public static void initialize() { 837 859 ImageryLayerInfo.instance.clear(); -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r6650 r6690 206 206 boolean found = false; 207 207 for (ImageryType type : ImageryType.values()) { 208 if (equal(accumulator.toString(), type.get UrlString())) {208 if (equal(accumulator.toString(), type.getTypeString())) { 209 209 entry.setImageryType(type); 210 210 found = true; -
trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java
r6536 r6690 123 123 @Override 124 124 public String apply(ImageryInfo.ImageryType x) { 125 return x.get UrlString();125 return x.getTypeString(); 126 126 } 127 127 }));
Note:
See TracChangeset
for help on using the changeset viewer.