diff --git a/data/maps.xsd b/data/maps.xsd
index 59fa397..53fb356 100644
a
|
b
|
|
623 | 623 | <xs:element name="terms-of-use-url" minOccurs="0" maxOccurs="1" type="xs:string" /> |
624 | 624 | <!-- The ISO 3166 country code --> |
625 | 625 | <xs:element name="country-code" minOccurs="0" maxOccurs="1" type="tns:iso3166" /> |
| 626 | <!-- A base64-encoded image that is displayed as menu/toolbar icon --> |
| 627 | <xs:element name="icon-base64" minOccurs="0" maxOccurs="1" type="xs:string" /> |
626 | 628 | </xs:all> |
627 | 629 | </xs:complexType> |
628 | 630 | </xs:element> |
diff --git a/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java b/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java
index cb7c034..cc26148 100644
a
|
b
|
public class AttributionSupport {
|
24 | 24 | private Image attrImage; |
25 | 25 | private String attrTermsText; |
26 | 26 | private String attrTermsUrl; |
| 27 | private static final int MAX_IMAGE_SIZE = 80; |
27 | 28 | public static final Font ATTR_FONT = new Font("Arial", Font.PLAIN, 10); |
28 | 29 | public static final Font ATTR_LINK_FONT; |
29 | 30 | |
… |
… |
public class AttributionSupport {
|
42 | 43 | boolean requireAttr = source.requiresAttribution(); |
43 | 44 | if (requireAttr) { |
44 | 45 | attrImage = source.getAttributionImage(); |
| 46 | if(attrImage!=null) |
| 47 | System.out.println(attrImage.getWidth(null)); |
| 48 | if (attrImage != null |
| 49 | && (attrImage.getWidth(null) > MAX_IMAGE_SIZE |
| 50 | || attrImage.getHeight(null) > MAX_IMAGE_SIZE)) { |
| 51 | attrImage = attrImage.getScaledInstance(MAX_IMAGE_SIZE, MAX_IMAGE_SIZE, Image.SCALE_SMOOTH); |
| 52 | } |
45 | 53 | attrTermsText = source.getTermsOfUseText(); |
46 | 54 | attrTermsUrl = source.getTermsOfUseURL(); |
47 | 55 | if (attrTermsUrl != null && attrTermsText == null) { |
diff --git a/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java b/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
index 95cccca..7d40cf6 100644
a
|
b
|
package org.openstreetmap.josm.actions;
|
3 | 3 | |
4 | 4 | import static org.openstreetmap.josm.tools.I18n.tr; |
5 | 5 | |
| 6 | import java.awt.Image; |
6 | 7 | import java.awt.event.ActionEvent; |
7 | | |
| 8 | import javax.swing.Action; |
| 9 | import javax.swing.ImageIcon; |
8 | 10 | import javax.swing.JOptionPane; |
9 | | |
10 | 11 | import org.openstreetmap.josm.Main; |
11 | 12 | import org.openstreetmap.josm.data.imagery.ImageryInfo; |
12 | 13 | import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; |
13 | 14 | import org.openstreetmap.josm.gui.layer.ImageryLayer; |
| 15 | import sun.misc.BASE64Decoder; |
14 | 16 | |
15 | 17 | public class AddImageryLayerAction extends JosmAction implements AdaptableAction { |
16 | 18 | |
| 19 | private static final int MAX_ICON_SIZE = 24; |
17 | 20 | private final ImageryInfo info; |
18 | 21 | |
19 | 22 | public AddImageryLayerAction(ImageryInfo info) { |
20 | | super(info.getMenuName(), /* ICON */"imagery_menu", tr("Add imagery layer {0}",info.getName()), null, false, false); |
| 23 | super(info.getMenuName(), |
| 24 | /* ICON */ "imagery_menu", |
| 25 | tr("Add imagery layer {0}", info.getName()), |
| 26 | null, false, false); |
21 | 27 | putValue("toolbar", "imagery_" + info.getToolbarName()); |
22 | 28 | this.info = info; |
23 | 29 | installAdapters(); |
| 30 | |
| 31 | /* add toolbar icon from attribution image */ |
| 32 | try { |
| 33 | ImageIcon i = null; |
| 34 | if (info.getIconBase64() != null) { |
| 35 | i = new ImageIcon(new BASE64Decoder().decodeBuffer(info.getIconBase64())); |
| 36 | if (i.getIconHeight() > MAX_ICON_SIZE || i.getIconWidth() > MAX_ICON_SIZE) { |
| 37 | i = new ImageIcon(i.getImage().getScaledInstance(MAX_ICON_SIZE, MAX_ICON_SIZE, Image.SCALE_SMOOTH)); |
| 38 | } |
| 39 | putValue(Action.SMALL_ICON, i); |
| 40 | } else if (info.getAttributionImage() != null) { |
| 41 | i = new ImageIcon(info.getAttributionImage()); |
| 42 | } |
| 43 | if (i != null) { |
| 44 | if (i.getIconHeight() > MAX_ICON_SIZE || i.getIconWidth() > MAX_ICON_SIZE) { |
| 45 | i = new ImageIcon(i.getImage().getScaledInstance(MAX_ICON_SIZE, MAX_ICON_SIZE, Image.SCALE_SMOOTH)); |
| 46 | } |
| 47 | putValue(Action.SMALL_ICON, i); |
| 48 | } |
| 49 | } catch (Exception ex) { |
| 50 | throw new RuntimeException(ex.getMessage(), ex); |
| 51 | } |
24 | 52 | } |
25 | 53 | |
26 | 54 | @Override |
… |
… |
public class AddImageryLayerAction extends JosmAction implements AdaptableAction
|
52 | 80 | setEnabled(false); |
53 | 81 | } |
54 | 82 | } |
55 | | } |
| 83 | } |
| 84 | No newline at end of file |
diff --git a/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java b/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
index 955d94e..59170ab 100644
a
|
b
|
public class ImageryInfo implements Comparable<ImageryInfo>, Attributed {
|
84 | 84 | private String termsOfUseText; |
85 | 85 | private String termsOfUseURL; |
86 | 86 | private String countryCode = ""; |
| 87 | private String iconBase64; |
87 | 88 | |
88 | 89 | /** auxiliary class to save an ImageryInfo object in the preferences */ |
89 | 90 | public static class ImageryPreferenceEntry { |
… |
… |
public class ImageryInfo implements Comparable<ImageryInfo>, Attributed {
|
105 | 106 | @pref String bounds; |
106 | 107 | @pref String shapes; |
107 | 108 | @pref String projections; |
| 109 | @pref String iconBase64; |
108 | 110 | |
109 | 111 | public ImageryPreferenceEntry() { |
110 | 112 | } |
… |
… |
public class ImageryInfo implements Comparable<ImageryInfo>, Attributed {
|
125 | 127 | max_zoom = i.defaultMaxZoom; |
126 | 128 | min_zoom = i.defaultMinZoom; |
127 | 129 | cookies = i.cookies; |
| 130 | iconBase64 = i.iconBase64; |
128 | 131 | if (i.bounds != null) { |
129 | 132 | bounds = i.bounds.encodeAsString(","); |
130 | 133 | String shapesString = ""; |
… |
… |
public class ImageryInfo implements Comparable<ImageryInfo>, Attributed {
|
218 | 221 | termsOfUseText = e.terms_of_use_text; |
219 | 222 | termsOfUseURL = e.terms_of_use_url; |
220 | 223 | countryCode = e.country_code; |
| 224 | iconBase64 = e.iconBase64; |
221 | 225 | } |
222 | 226 | |
223 | 227 | public ImageryInfo(Collection<String> list) { |
… |
… |
public class ImageryInfo implements Comparable<ImageryInfo>, Attributed {
|
284 | 288 | this.termsOfUseText = i.termsOfUseText; |
285 | 289 | this.termsOfUseURL = i.termsOfUseURL; |
286 | 290 | this.serverProjections = i.serverProjections; |
| 291 | this.iconBase64 = i.iconBase64; |
287 | 292 | } |
288 | 293 | |
289 | 294 | @Override |
… |
… |
public class ImageryInfo implements Comparable<ImageryInfo>, Attributed {
|
514 | 519 | this.countryCode = countryCode; |
515 | 520 | } |
516 | 521 | |
| 522 | public String getIconBase64() { |
| 523 | return iconBase64; |
| 524 | } |
| 525 | |
| 526 | public void setIconBase64(String iconBase64) { |
| 527 | this.iconBase64 = iconBase64; |
| 528 | } |
| 529 | |
517 | 530 | /** |
518 | 531 | * Get the projections supported by the server. Only relevant for |
519 | 532 | * WMS-type ImageryInfo at the moment. |
diff --git a/src/org/openstreetmap/josm/io/imagery/ImageryReader.java b/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
index acdec59..97e0a06 100644
a
|
b
|
public class ImageryReader {
|
129 | 129 | "terms-of-use-text", |
130 | 130 | "terms-of-use-url", |
131 | 131 | "country-code", |
| 132 | "icon-base64", |
132 | 133 | }).contains(qName)) { |
133 | 134 | newState = State.ENTRY_ATTRIBUTE; |
134 | 135 | } else if (qName.equals("bounds")) { |
… |
… |
public class ImageryReader {
|
259 | 260 | entry.setTermsOfUseURL(accumulator.toString()); |
260 | 261 | } else if (qName.equals("country-code")) { |
261 | 262 | entry.setCountryCode(accumulator.toString()); |
| 263 | } else if (qName.equals("icon-base64")) { |
| 264 | entry.setIconBase64(accumulator.toString()); |
262 | 265 | } else { |
263 | 266 | } |
264 | 267 | break; |