source: josm/trunk/src/org/openstreetmap/josm/io/session/ImagerySessionExporter.java@ 7050

Last change on this file since 7050 was 6070, checked in by stoecker, 11 years ago

see #8853 remove tabs, trailing spaces, windows line ends, strange characters

File size: 2.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io.session;
3
4import java.awt.Component;
5import java.awt.GridBagLayout;
6import java.io.IOException;
7import java.util.Collection;
8import java.util.Collections;
9import java.util.Map;
10
11import javax.swing.JCheckBox;
12import javax.swing.JLabel;
13import javax.swing.JPanel;
14import javax.swing.SwingConstants;
15
16import org.openstreetmap.josm.data.Preferences;
17import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryPreferenceEntry;
18import org.openstreetmap.josm.gui.layer.ImageryLayer;
19import org.openstreetmap.josm.gui.layer.Layer;
20import org.openstreetmap.josm.gui.layer.TMSLayer;
21import org.openstreetmap.josm.gui.layer.WMSLayer;
22import org.openstreetmap.josm.io.session.SessionWriter.ExportSupport;
23import org.openstreetmap.josm.tools.GBC;
24import org.w3c.dom.Element;
25
26/**
27 * Session exporter for TMSLayer and WMSLayer.
28 */
29public class ImagerySessionExporter implements SessionLayerExporter {
30
31 private ImageryLayer layer;
32 private JCheckBox export;
33
34 public ImagerySessionExporter(ImageryLayer layer) {
35 this.layer = layer;
36 }
37
38 public ImagerySessionExporter(TMSLayer layer) {
39 this((ImageryLayer) layer);
40 }
41
42 public ImagerySessionExporter(WMSLayer layer) {
43 this((ImageryLayer) layer);
44 }
45
46 @Override
47 public Collection<Layer> getDependencies() {
48 return Collections.emptySet();
49 }
50
51 @Override
52 public Component getExportPanel() {
53 final JPanel p = new JPanel(new GridBagLayout());
54 export = new JCheckBox();
55 export.setSelected(true);
56 final JLabel lbl = new JLabel(layer.getName(), layer.getIcon(), SwingConstants.LEFT);
57 lbl.setToolTipText(layer.getToolTipText());
58 p.add(export, GBC.std());
59 p.add(lbl, GBC.std());
60 p.add(GBC.glue(1,0), GBC.std().fill(GBC.HORIZONTAL));
61 return p;
62 }
63
64 @Override
65 public boolean shallExport() {
66 return export.isSelected();
67 }
68
69 @Override
70 public boolean requiresZip() {
71 return false;
72 }
73
74 @Override
75 public Element export(ExportSupport support) throws IOException {
76 Element layerElem = support.createElement("layer");
77 layerElem.setAttribute("type", "imagery");
78 layerElem.setAttribute("version", "0.1");
79 ImageryPreferenceEntry e = new ImageryPreferenceEntry(layer.getInfo());
80 Map<String,String> data = Preferences.serializeStruct(e, ImageryPreferenceEntry.class);
81 for (Map.Entry<String,String> entry : data.entrySet()) {
82 Element attrElem = support.createElement(entry.getKey());
83 layerElem.appendChild(attrElem);
84 attrElem.appendChild(support.createTextNode(entry.getValue()));
85 }
86 return layerElem;
87 }
88
89}
Note: See TracBrowser for help on using the repository browser.