Changeset 16872 in osm for applications/editors/josm
- Timestamp:
- 2009-08-05T11:56:29+02:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/wmsplugin
- Files:
-
- 4 edited
-
build.xml (modified) (5 diffs)
-
src/wmsplugin/GeorefImage.java (modified) (1 diff)
-
src/wmsplugin/WMSAdjustAction.java (modified) (8 diffs)
-
src/wmsplugin/WMSGrabber.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/build.xml
r16860 r16872 1 <!-- 2 ** This is a template build file for a JOSM plugin. 3 ** 4 ** Maintaining versions 5 ** ==================== 6 ** see README.template 7 ** 8 ** Usage 9 ** ===== 10 ** To build it run 11 ** 12 ** > ant dist 13 ** 14 ** To install the generated plugin locally (in your default plugin directory) run 15 ** 16 ** > ant install 17 ** 18 ** To build against the core in ../../core, create a correct manifest and deploy to 19 ** SVN, run 20 ** - set the property commit.message 21 ** - set the property josm.reference.release to lowest JOSM release number this 22 ** plugin build is compatible with 23 ** > ant deploy 24 ** 25 ** 26 --> 1 27 <project name="wmsplugin" default="dist" basedir="."> 2 28 <property name="josm" location="../../core/dist/josm-custom.jar"/> … … 5 31 <property name="plugin.jar" value="${plugin.dist.dir}/${ant.project.name}.jar"/> 6 32 <property name="ant.build.javac.target" value="1.5"/> 33 <property name="commit.message" value="fixing JOSM issue #3186" /> 34 <property name="josm.reference.release" value="1914" /> 35 7 36 <target name="init"> 8 37 <mkdir dir="${plugin.build.dir}"/> … … 16 45 </target> 17 46 <target name="dist" depends="compile,revision"> 47 <echo message="building ${plugin.jar} with version ${version.entry.commit.revision} for JOSM version ${josm.reference.release} "/> 18 48 <copy todir="${plugin.build.dir}/images"> 19 49 <fileset dir="images"/> … … 26 56 <attribute name="Plugin-Description" value="Display georeferenced images as background in JOSM (WMS servers, Yahoo, ...)."/> 27 57 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/WMSPlugin"/> 28 <attribute name="Plugin-Mainversion" value=" 1908"/>58 <attribute name="Plugin-Mainversion" value="${josm.reference.release}"/> 29 59 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/> 30 60 <attribute name="de_Plugin-Link" value="http://wiki.openstreetmap.org/wiki/DE:JOSM/Plugins/WMSPlugin"/> … … 55 85 <copy file="${plugin.jar}" todir="${josm.plugins.dir}"/> 56 86 </target> 87 88 <target name="core-info"> 89 <exec append="false" output="core.info.xml" executable="svn" failifexecutionfails="false"> 90 <env key="LANG" value="C"/> 91 <arg value="info"/> 92 <arg value="--xml"/> 93 <arg value="../../core"/> 94 </exec> 95 <xmlproperty file="core.info.xml" prefix="coreversion" keepRoot="true" collapseAttributes="true"/> 96 <echo>Building against core revision ${coreversion.info.entry.revision} ...</echo> 97 <delete file="core.info.xml" /> 98 </target> 99 100 101 <target name="commit-current"> 102 <echo>Commiting the plugin source ...</echo> 103 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false"> 104 <env key="LANG" value="C"/> 105 <arg value="commit"/> 106 <arg value="-m "${commit.message}""/> 107 <arg value="."/> 108 </exec> 109 </target> 110 111 112 <target name="update-current"> 113 <echo>Updating basedir ...</echo> 114 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false"> 115 <env key="LANG" value="C"/> 116 <arg value="up"/> 117 <arg value="."/> 118 </exec> 119 <echo>Updating ${plugin.jar} ...</echo> 120 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false"> 121 <env key="LANG" value="C"/> 122 <arg value="up"/> 123 <arg value="${plugin.jar}"/> 124 </exec> 125 </target> 126 127 <target name="commit-dist"> 128 <echo>Commiting ${plugin.jar} ...</echo> 129 <exec append="true" output="svn.log" executable="svn" failifexecutionfails="false"> 130 <env key="LANG" value="C"/> 131 <arg value="commit"/> 132 <arg value="-m "${commit.message}""/> 133 <arg value="${plugin.jar}"/> 134 </exec> 135 </target> 136 137 <target name="deploy" depends="core-info,commit-current,update-current,clean,dist,commit-dist"> 138 </target> 57 139 </project> -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/GeorefImage.java
r16781 r16872 1 1 package wmsplugin; 2 2 3 import java.awt.Color;4 3 import java.awt.Dimension; 5 4 import java.awt.Graphics; -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSAdjustAction.java
r16781 r16872 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.awt.Component; 5 6 import java.awt.Cursor; 7 import java.awt.GridBagLayout; 6 8 import java.awt.event.MouseEvent; 7 9 import java.awt.event.MouseListener; 8 10 import java.awt.event.MouseMotionListener; 11 import java.util.List; 12 13 import javax.swing.DefaultComboBoxModel; 14 import javax.swing.DefaultListCellRenderer; 15 import javax.swing.Icon; 16 import javax.swing.JComboBox; 17 import javax.swing.JLabel; 18 import javax.swing.JList; 19 import javax.swing.JOptionPane; 20 import javax.swing.JPanel; 9 21 10 22 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.gui.MapFrame;12 23 import org.openstreetmap.josm.actions.mapmode.MapMode; 13 24 import org.openstreetmap.josm.data.coor.EastNorth; 25 import org.openstreetmap.josm.gui.ExtendedDialog; 26 import org.openstreetmap.josm.gui.MapFrame; 27 import org.openstreetmap.josm.gui.OptionPaneUtil; 28 import org.openstreetmap.josm.gui.layer.Layer; 29 import org.openstreetmap.josm.tools.GBC; 14 30 import org.openstreetmap.josm.tools.ImageProvider; 15 import org.openstreetmap.josm.gui.layer.Layer;16 31 17 32 … … 20 35 21 36 GeorefImage selectedImage; 22 WMSLayer selectedLayer;23 37 boolean mouseDown; 24 38 EastNorth prevEastNorth; 39 private WMSLayer adjustingLayer; 25 40 26 41 public WMSAdjustAction(MapFrame mapFrame) { … … 30 45 } 31 46 47 48 32 49 @Override public void enterMode() { 33 super.enterMode(); 50 super.enterMode(); 51 if (!hasWMSLayersToAdjust()) { 52 warnNoWMSLayers(); 53 return; 54 } 55 List<WMSLayer> wmsLayers = Main.map.mapView.getLayersOfType(WMSLayer.class); 56 if (wmsLayers.size() == 1) { 57 adjustingLayer = wmsLayers.get(0); 58 } else { 59 adjustingLayer = (WMSLayer)askAdjustLayer(Main.map.mapView.getLayersOfType(WMSLayer.class)); 60 } 61 if (adjustingLayer == null) 62 return; 63 if (!adjustingLayer.isVisible()) { 64 adjustingLayer.setVisible(true); 65 } 34 66 Main.map.mapView.addMouseListener(this); 35 67 Main.map.mapView.addMouseMotionListener(this); … … 40 72 Main.map.mapView.removeMouseListener(this); 41 73 Main.map.mapView.removeMouseMotionListener(this); 74 adjustingLayer = null; 42 75 } 43 76 … … 46 79 return; 47 80 48 Layer layer=Main.map.mapView.getActiveLayer(); 49 if (layer.isVisible() && layer instanceof WMSLayer) { 81 if (adjustingLayer.isVisible()) { 50 82 prevEastNorth=Main.map.mapView.getEastNorth(e.getX(),e.getY()); 51 selectedLayer = ((WMSLayer)layer); 52 selectedImage = selectedLayer.findImage(prevEastNorth); 83 selectedImage = adjustingLayer.findImage(prevEastNorth); 53 84 if(selectedImage!=null) { 54 85 Main.map.mapView.setCursor … … 62 93 EastNorth eastNorth= 63 94 Main.map.mapView.getEastNorth(e.getX(),e.getY()); 64 selectedLayer.displace(95 adjustingLayer.displace( 65 96 eastNorth.east()-prevEastNorth.east(), 66 97 eastNorth.north()-prevEastNorth.north() … … 76 107 selectedImage = null; 77 108 prevEastNorth = null; 78 selectedLayer = null;79 109 } 80 110 … … 99 129 return (l instanceof WMSLayer) && l.isVisible(); 100 130 } 131 132 /** 133 * the list cell renderer used to render layer list entries 134 * 135 */ 136 static public class LayerListCellRenderer extends DefaultListCellRenderer { 137 138 protected boolean isActiveLayer(Layer layer) { 139 if (Main.map == null) 140 return false; 141 if (Main.map.mapView == null) 142 return false; 143 return Main.map.mapView.getActiveLayer() == layer; 144 } 145 146 @Override 147 public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, 148 boolean cellHasFocus) { 149 Layer layer = (Layer) value; 150 JLabel label = (JLabel) super.getListCellRendererComponent(list, layer.getName(), index, isSelected, 151 cellHasFocus); 152 Icon icon = layer.getIcon(); 153 label.setIcon(icon); 154 label.setToolTipText(layer.getToolTipText()); 155 return label; 156 } 157 } 158 159 /** 160 * Prompts the user with a list of WMS layers which can be adjusted 161 * 162 * @param adjustableLayers the list of adjustable layers 163 * @return the selected layer; null, if no layer was selected 164 */ 165 protected Layer askAdjustLayer(List<? extends Layer> adjustableLayers) { 166 JComboBox layerList = new JComboBox(); 167 layerList.setRenderer(new LayerListCellRenderer()); 168 layerList.setModel(new DefaultComboBoxModel(adjustableLayers.toArray())); 169 layerList.setSelectedIndex(0); 170 171 JPanel pnl = new JPanel(); 172 pnl.setLayout(new GridBagLayout()); 173 pnl.add(new JLabel(tr("Please select the WMS layer to adjust.")), GBC.eol()); 174 pnl.add(layerList, GBC.eol()); 175 176 int decision = new ExtendedDialog(Main.parent, tr("Select WMS layer"), pnl, new String[] { tr("Start adjusting"), 177 tr("Cancel") }, new String[] { "mapmode/adjustwms", "cancel" }).getValue(); 178 if (decision != 1) 179 return null; 180 Layer adjustLayer = (Layer) layerList.getSelectedItem(); 181 return adjustLayer; 182 } 183 184 /** 185 * Displays a warning message if there are no WMS layers to adjust 186 * 187 */ 188 protected void warnNoWMSLayers() { 189 OptionPaneUtil.showMessageDialog( 190 Main.parent, 191 tr("There are currently no WMS layer to adjust."), 192 tr("No layers to adjust"), 193 JOptionPane.WARNING_MESSAGE 194 ); 195 } 196 197 /** 198 * Replies true if there is at least one WMS layer 199 * 200 * @return true if there is at least one WMS layer 201 */ 202 protected boolean hasWMSLayersToAdjust() { 203 if (Main.map == null) return false; 204 if (Main.map.mapView == null) return false; 205 return ! Main.map.mapView.getLayersOfType(WMSLayer.class).isEmpty(); 206 } 207 208 209 210 @Override 211 protected void updateEnabledState() { 212 setEnabled(hasWMSLayersToAdjust()); 213 } 101 214 } -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java
r16781 r16872 14 14 import java.text.DecimalFormat; 15 15 import java.text.DecimalFormatSymbols; 16 import java.text.MessageFormat;17 16 import java.text.NumberFormat; 18 17 import java.util.Locale; … … 27 26 import org.openstreetmap.josm.data.coor.EastNorth; 28 27 import org.openstreetmap.josm.data.coor.LatLon; 29 import org.openstreetmap.josm.data.projection.Epsg4326;30 28 import org.openstreetmap.josm.data.projection.Mercator; 31 29 import org.openstreetmap.josm.gui.MapView;
Note:
See TracChangeset
for help on using the changeset viewer.
