Changeset 5808 in josm
- Timestamp:
- 2013-03-29T09:31:36+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/ImageryAdjustAction.java
r5460 r5808 145 145 return; 146 146 oldMapMode = Main.map.mapMode; 147 layer.enableOffsetServer(false);148 147 super.actionPerformed(e); 149 148 } -
trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
r5513 r5808 26 26 import javax.swing.JPopupMenu; 27 27 import javax.swing.JSeparator; 28 import javax.swing.SwingUtilities;29 28 30 29 import org.openstreetmap.josm.Main; 31 30 import org.openstreetmap.josm.actions.ImageryAdjustAction; 32 31 import org.openstreetmap.josm.data.ProjectionBounds; 33 import org.openstreetmap.josm.data.coor.EastNorth;34 32 import org.openstreetmap.josm.data.imagery.ImageryInfo; 35 33 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; … … 38 36 import org.openstreetmap.josm.data.preferences.IntegerProperty; 39 37 import org.openstreetmap.josm.gui.MenuScroller; 40 import org.openstreetmap.josm.io.imagery.OffsetServer;41 import org.openstreetmap.josm.io.imagery.OsmosnimkiOffsetServer;42 38 import org.openstreetmap.josm.tools.ImageProvider; 43 39 … … 66 62 protected int sharpenLevel; 67 63 68 protected boolean offsetServerSupported;69 protected boolean offsetServerUsed;70 protected OffsetServerThread offsetServerThread;71 72 64 private final ImageryAdjustAction adjustAction = new ImageryAdjustAction(this); 73 private final AbstractAction useServerOffsetAction = new AbstractAction(tr("(use server offset)")) {74 @Override75 public void actionPerformed(ActionEvent e) {76 enableOffsetServer(true);77 }78 };79 80 protected OffsetServerThread createoffsetServerThread() {81 return new OffsetServerThread(new OsmosnimkiOffsetServer(82 OsmosnimkiOffsetServer.PROP_SERVER_URL.get()));83 }84 65 85 66 public ImageryLayer(ImageryInfo info) { … … 94 75 } 95 76 this.sharpenLevel = PROP_SHARPEN_LEVEL.get(); 96 if (OffsetServer.PROP_SERVER_ENABLED.get()) {97 offsetServerThread = createoffsetServerThread();98 offsetServerThread.start();99 }100 77 } 101 78 … … 164 141 public void actionPerformed(ActionEvent ev) { 165 142 setOffset(b.dx, b.dy); 166 enableOffsetServer(false);167 143 Main.main.menu.imageryMenu.refreshOffsetMenu(); 168 144 Main.map.repaint(); … … 183 159 public boolean supportLayers(List<Layer> layers) { 184 160 return false; 185 }186 }187 188 public void enableOffsetServer(boolean enable) {189 offsetServerUsed = enable;190 if (offsetServerUsed && !offsetServerThread.isAlive()) {191 offsetServerThread = createoffsetServerThread();192 offsetServerThread.start();193 161 } 194 162 } … … 202 170 public JComponent getOffsetMenuItem(JComponent subMenu) { 203 171 JMenuItem adjustMenuItem = new JMenuItem(adjustAction); 204 if (OffsetBookmark.allBookmarks.isEmpty() && !offsetServerSupported) return adjustMenuItem;172 if (OffsetBookmark.allBookmarks.isEmpty()) return adjustMenuItem; 205 173 206 174 subMenu.add(adjustMenuItem); 207 if (offsetServerSupported) {208 JCheckBoxMenuItem item = new JCheckBoxMenuItem(useServerOffsetAction);209 if (offsetServerUsed) {210 item.setSelected(true);211 }212 subMenu.add(item);213 }214 175 subMenu.add(new JSeparator()); 215 176 boolean hasBookmarks = false; … … 220 181 } 221 182 JCheckBoxMenuItem item = new JCheckBoxMenuItem(new ApplyOffsetAction(b)); 222 if (b.dx == dx && b.dy == dy && !offsetServerUsed) {183 if (b.dx == dx && b.dy == dy) { 223 184 item.setSelected(true); 224 185 } … … 235 196 } 236 197 } 237 return (hasBookmarks || offsetServerSupported)? subMenu : adjustMenuItem;198 return hasBookmarks ? subMenu : adjustMenuItem; 238 199 } 239 200 … … 265 226 } 266 227 267 protected class OffsetServerThread extends Thread {268 OffsetServer offsetServer;269 EastNorth oldCenter = new EastNorth(Double.NaN, Double.NaN);270 271 public OffsetServerThread(OffsetServer offsetServer) {272 this.offsetServer = offsetServer;273 setDaemon(true);274 }275 276 private void updateOffset() {277 if (Main.map == null || Main.map.mapView == null) return;278 EastNorth center = Main.map.mapView.getCenter();279 if (center.equals(oldCenter)) return;280 oldCenter = center;281 282 EastNorth offset = offsetServer.getOffset(getInfo(), center);283 if (offset != null) {284 setOffset(offset.east(),offset.north());285 }286 }287 288 @Override289 public void run() {290 if (!offsetServerSupported) {291 if (!offsetServer.isLayerSupported(info)) return;292 offsetServerSupported = true;293 }294 offsetServerUsed = true;295 SwingUtilities.invokeLater(new Runnable() {296 @Override297 public void run() {298 Main.main.menu.imageryMenu.refreshOffsetMenu();299 }300 });301 try {302 while (offsetServerUsed) {303 updateOffset();304 Thread.sleep(1000);305 }306 } catch (InterruptedException e) {307 }308 offsetServerUsed = false;309 }310 }311 312 228 /* (non-Javadoc) 313 229 * @see org.openstreetmap.josm.gui.layer.Layer#destroy() -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/CommonSettingsPanel.java
r5465 r5808 10 10 11 11 import javax.swing.JButton; 12 import javax.swing.JCheckBox;13 12 import javax.swing.JColorChooser; 14 13 import javax.swing.JLabel; … … 16 15 import javax.swing.JPanel; 17 16 import javax.swing.JSlider; 18 import javax.swing.JTextField;19 import javax.swing.event.ChangeEvent;20 import javax.swing.event.ChangeListener;21 17 22 18 import org.openstreetmap.josm.gui.layer.ImageryLayer; 23 19 import org.openstreetmap.josm.gui.widgets.JosmComboBox; 24 import org.openstreetmap.josm.io.imagery.OffsetServer;25 import org.openstreetmap.josm.io.imagery.OsmosnimkiOffsetServer;26 20 import org.openstreetmap.josm.tools.ColorHelper; 27 21 import org.openstreetmap.josm.tools.GBC; … … 37 31 private final JSlider fadeAmount = new JSlider(0, 100); 38 32 private final JosmComboBox sharpen; 39 private final JCheckBox useOffsetServer;40 private final JTextField offsetServerUrl;41 33 42 34 /** … … 80 72 add(GBC.glue(5, 0), GBC.std().fill(GBC.HORIZONTAL)); 81 73 add(this.sharpen, GBC.eol().fill(GBC.HORIZONTAL)); 82 83 this.useOffsetServer = new JCheckBox(tr("Use offset server: "));84 this.offsetServerUrl = new JTextField();85 this.useOffsetServer.addChangeListener(new ChangeListener() {86 @Override87 public void stateChanged(ChangeEvent e) {88 offsetServerUrl.setEnabled(useOffsetServer.isSelected());89 }90 });91 offsetServerUrl.setEnabled(useOffsetServer.isSelected());92 add(this.useOffsetServer, GBC.eol().fill(GBC.HORIZONTAL));93 add(this.offsetServerUrl, GBC.eol().fill(GBC.HORIZONTAL));94 74 } 95 75 … … 103 83 this.fadeAmount.setValue(ImageryLayer.PROP_FADE_AMOUNT.get()); 104 84 this.sharpen.setSelectedIndex(Math.max(0, Math.min(2, ImageryLayer.PROP_SHARPEN_LEVEL.get()))); 105 this.useOffsetServer.setSelected(OffsetServer.PROP_SERVER_ENABLED.get());106 this.offsetServerUrl.setText(OsmosnimkiOffsetServer.PROP_SERVER_URL.get());107 85 } 108 86 … … 112 90 */ 113 91 public boolean saveSettings() { 114 OffsetServer.PROP_SERVER_ENABLED.put(useOffsetServer.isSelected());115 OsmosnimkiOffsetServer.PROP_SERVER_URL.put(offsetServerUrl.getText());116 117 92 ImageryLayer.PROP_FADE_AMOUNT.put(this.fadeAmount.getValue()); 118 93 ImageryLayer.PROP_FADE_COLOR.put(this.btnFadeColor.getBackground());
Note:
See TracChangeset
for help on using the changeset viewer.