- Timestamp:
- 2014-05-14T00:51:20+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 1 deleted
- 6 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java
r7112 r7119 36 36 import org.openstreetmap.josm.data.osm.history.HistoryWay; 37 37 import org.openstreetmap.josm.gui.tagging.TaggingPreset; 38 import org.openstreetmap.josm.gui.tagging.TaggingPresetNameTemplateList; 38 39 import org.openstreetmap.josm.tools.AlphanumComparator; 39 40 import org.openstreetmap.josm.tools.I18n; 40 import org.openstreetmap.josm.tools.TaggingPresetNameTemplateList;41 41 import org.openstreetmap.josm.tools.Utils; 42 42 import org.openstreetmap.josm.tools.Utils.Function; -
trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java
r7005 r7119 67 67 import org.openstreetmap.josm.io.imagery.WMSRequest; 68 68 69 70 69 /** 71 70 * This is a layer that grabs the current screen from an WMS server. The data … … 156 155 private boolean isInvalidUrlConfirmed = false; 157 156 157 /** 158 * Constructs a new {@code WMSLayer}. 159 */ 158 160 public WMSLayer() { 159 161 this(new ImageryInfo(tr("Blank Layer"))); … … 338 340 339 341 attribution.paintAttribution(g, mv.getWidth(), mv.getHeight(), null, null, 0, this); 340 341 342 } 342 343 … … 453 454 GeorefImage img = images[modulo(x,dax)][modulo(y,day)]; 454 455 if (!img.paint(g, mv, x, y, leftEdge, bottomEdge)) { 455 WMSRequest request = new WMSRequest(x, y, info.getPixelPerDegree(), real, true); 456 addRequest(request); 456 addRequest(new WMSRequest(x, y, info.getPixelPerDegree(), real, true)); 457 457 areaToCache.add(new ProjectionBounds(getEastNorth(x, y), getEastNorth(x + 1, y + 1))); 458 458 } else if (img.getState() == State.PARTLY_IN_CACHE && autoDownloadEnabled) { 459 WMSRequest request = new WMSRequest(x, y, info.getPixelPerDegree(), real, false); 460 addRequest(request); 459 addRequest(new WMSRequest(x, y, info.getPixelPerDegree(), real, false)); 461 460 areaToCache.add(new ProjectionBounds(getEastNorth(x, y), getEastNorth(x + 1, y + 1))); 462 461 } … … 658 657 659 658 public class DownloadAction extends AbstractAction { 659 /** 660 * Constructs a new {@code DownloadAction}. 661 */ 660 662 public DownloadAction() { 661 663 super(tr("Download visible tiles")); … … 776 778 777 779 public class ReloadErrorTilesAction extends AbstractAction { 780 /** 781 * Constructs a new {@code ReloadErrorTilesAction}. 782 */ 778 783 public ReloadErrorTilesAction() { 779 784 super(tr("Reload erroneous tiles")); … … 797 802 798 803 public class ToggleAlphaAction extends AbstractAction implements LayerAction { 804 /** 805 * Constructs a new {@code ToggleAlphaAction}. 806 */ 799 807 public ToggleAlphaAction() { 800 808 super(tr("Alpha channel")); … … 815 823 Main.map.mapView.repaint(); 816 824 } 825 817 826 @Override 818 827 public Component createMenuComponent() { … … 821 830 return item; 822 831 } 832 823 833 @Override 824 834 public boolean supportLayers(List<Layer> layers) { … … 827 837 } 828 838 829 830 839 public class ToggleAutoResolutionAction extends AbstractAction implements LayerAction { 840 841 /** 842 * Constructs a new {@code ToggleAutoResolutionAction}. 843 */ 831 844 public ToggleAutoResolutionAction() { 832 845 super(tr("Automatically change resolution")); … … 858 871 */ 859 872 public class BookmarkWmsAction extends AbstractAction { 873 /** 874 * Constructs a new {@code BookmarkWmsAction}. 875 */ 860 876 public BookmarkWmsAction() { 861 877 super(tr("Set WMS Bookmark")); -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetMenu.java
r7005 r7119 8 8 import java.awt.Point; 9 9 import java.awt.event.ActionEvent; 10 import java.io.Serializable; 10 11 import java.util.ArrayList; 11 12 import java.util.Collections; 13 import java.util.Comparator; 12 14 import java.util.List; 13 15 … … 19 21 20 22 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.tools. PresetTextComparator;23 import org.openstreetmap.josm.tools.AlphanumComparator; 22 24 23 25 public class TaggingPresetMenu extends TaggingPreset { 24 public JMenu menu = null; // set by TaggingPresetPreferences 25 26 public JMenu menu = null; // set by TaggingPresets 27 28 private static class PresetTextComparator implements Comparator<JMenuItem>, Serializable { 29 @Override 30 public int compare(JMenuItem o1, JMenuItem o2) { 31 if (Main.main.menu.presetSearchAction.equals(o1.getAction())) 32 return -1; 33 else if (Main.main.menu.presetSearchAction.equals(o2.getAction())) 34 return 1; 35 else 36 return AlphanumComparator.getInstance().compare(o1.getText(), o2.getText()); 37 } 38 } 39 26 40 @Override 27 41 public void setDisplayName() { … … 67 81 } 68 82 } 69 83 70 84 /** 71 85 * Sorts the menu items using the translated item text -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetNameTemplateList.java
r7116 r7119 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm. tools;2 package org.openstreetmap.josm.gui.tagging; 3 3 4 4 import java.util.Collection; … … 9 9 import org.openstreetmap.josm.Main; 10 10 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 import org.openstreetmap.josm.gui.tagging.TaggingPreset;12 import org.openstreetmap.josm.gui.tagging.TaggingPresetListener;13 import org.openstreetmap.josm.gui.tagging.TaggingPresetType;14 import org.openstreetmap.josm.gui.tagging.TaggingPresets;15 11 16 12 /** -
trunk/src/org/openstreetmap/josm/io/Compression.java
r7089 r7119 60 60 switch (this) { 61 61 case BZIP2: 62 return FileImporter.getBZip2InputStream(in);62 return Utils.getBZip2InputStream(in); 63 63 case GZIP: 64 return FileImporter.getGZipInputStream(in);64 return Utils.getGZipInputStream(in); 65 65 case ZIP: 66 return FileImporter.getZipInputStream(in);66 return Utils.getZipInputStream(in); 67 67 case NONE: 68 68 default: -
trunk/src/org/openstreetmap/josm/io/FileImporter.java
r7089 r7119 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.io.BufferedInputStream;7 6 import java.io.File; 8 7 import java.io.IOException; 9 import java.io.InputStream;10 import java.nio.charset.StandardCharsets;11 8 import java.util.List; 12 import java.util.zip.GZIPInputStream;13 import java.util.zip.ZipEntry;14 import java.util.zip.ZipInputStream;15 9 16 10 import javax.swing.JOptionPane; 17 11 18 import org.apache.tools.bzip2.CBZip2InputStream;19 12 import org.openstreetmap.josm.Main; 20 13 import org.openstreetmap.josm.actions.ExtensionFileFilter; … … 138 131 } 139 132 140 public static CBZip2InputStream getBZip2InputStream(InputStream in) throws IOException {141 if (in == null) {142 return null;143 }144 BufferedInputStream bis = new BufferedInputStream(in);145 int b = bis.read();146 if (b != 'B')147 throw new IOException(tr("Invalid bz2 file."));148 b = bis.read();149 if (b != 'Z')150 throw new IOException(tr("Invalid bz2 file."));151 return new CBZip2InputStream(bis, /* see #9537 */ true);152 }153 154 public static GZIPInputStream getGZipInputStream(InputStream in) throws IOException {155 if (in == null) {156 return null;157 }158 return new GZIPInputStream(in);159 }160 161 public static ZipInputStream getZipInputStream(InputStream in) throws IOException {162 if (in == null) {163 return null;164 }165 ZipInputStream zis = new ZipInputStream(in, StandardCharsets.UTF_8);166 // Positions the stream at the beginning of first entry167 ZipEntry ze = zis.getNextEntry();168 if (ze != null && Main.isDebugEnabled()) {169 Main.debug("Zip entry: "+ze.getName());170 }171 return zis;172 }173 174 133 /** 175 134 * Returns the enabled state of this {@code FileImporter}. When enabled, it is listed and usable in "File->Open" dialog. -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r7083 r7119 45 45 import java.util.regex.Pattern; 46 46 import java.util.zip.GZIPInputStream; 47 import java.util.zip.ZipEntry; 47 48 import java.util.zip.ZipFile; 49 import java.util.zip.ZipInputStream; 48 50 49 51 import org.apache.tools.bzip2.CBZip2InputStream; 50 52 import org.openstreetmap.josm.Main; 51 53 import org.openstreetmap.josm.data.Version; 52 import org.openstreetmap.josm.io.FileImporter;53 54 54 55 /** … … 665 666 public static InputStream openURLAndDecompress(final URL url, final boolean decompress) throws IOException { 666 667 final URLConnection connection = setupURLConnection(url.openConnection()); 667 if (decompress && "application/x-gzip".equals(connection.getHeaderField("Content-Type"))) { 668 return new GZIPInputStream(connection.getInputStream()); 669 } else if (decompress && "application/x-bzip2".equals(connection.getHeaderField("Content-Type"))) { 670 return FileImporter.getBZip2InputStream(new BufferedInputStream(connection.getInputStream())); 671 } else { 672 return connection.getInputStream(); 673 } 668 final InputStream in = connection.getInputStream(); 669 if (decompress) { 670 switch (connection.getHeaderField("Content-Type")) { 671 case "application/zip": 672 return getZipInputStream(in); 673 case "application/x-gzip": 674 return getGZipInputStream(in); 675 case "application/x-bzip2": 676 return getBZip2InputStream(in); 677 } 678 } 679 return in; 680 } 681 682 /** 683 * Returns a Bzip2 input stream wrapping given input stream. 684 * @param in The raw input stream 685 * @return a Bzip2 input stream wrapping given input stream, or {@code null} if {@code in} is {@code null} 686 * @throws IOException if the given input stream does not contain valid BZ2 header 687 * @since 7119 688 */ 689 public static CBZip2InputStream getBZip2InputStream(InputStream in) throws IOException { 690 if (in == null) { 691 return null; 692 } 693 BufferedInputStream bis = new BufferedInputStream(in); 694 int b = bis.read(); 695 if (b != 'B') 696 throw new IOException(tr("Invalid bz2 file.")); 697 b = bis.read(); 698 if (b != 'Z') 699 throw new IOException(tr("Invalid bz2 file.")); 700 return new CBZip2InputStream(bis, /* see #9537 */ true); 701 } 702 703 /** 704 * Returns a Gzip input stream wrapping given input stream. 705 * @param in The raw input stream 706 * @return a Gzip input stream wrapping given input stream, or {@code null} if {@code in} is {@code null} 707 * @throws IOException if an I/O error has occurred 708 * @since 7119 709 */ 710 public static GZIPInputStream getGZipInputStream(InputStream in) throws IOException { 711 if (in == null) { 712 return null; 713 } 714 return new GZIPInputStream(in); 715 } 716 717 /** 718 * Returns a Zip input stream wrapping given input stream. 719 * @param in The raw input stream 720 * @return a Zip input stream wrapping given input stream, or {@code null} if {@code in} is {@code null} 721 * @throws IOException if an I/O error has occurred 722 * @since 7119 723 */ 724 public static ZipInputStream getZipInputStream(InputStream in) throws IOException { 725 if (in == null) { 726 return null; 727 } 728 ZipInputStream zis = new ZipInputStream(in, StandardCharsets.UTF_8); 729 // Positions the stream at the beginning of first entry 730 ZipEntry ze = zis.getNextEntry(); 731 if (ze != null && Main.isDebugEnabled()) { 732 Main.debug("Zip entry: "+ze.getName()); 733 } 734 return zis; 674 735 } 675 736
Note:
See TracChangeset
for help on using the changeset viewer.