Changeset 11950 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-04-17T23:55:53+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/layer
- Files:
-
- 10 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r11947 r11950 5 5 6 6 import java.awt.Color; 7 import java.awt.Component;8 7 import java.awt.Dimension; 9 8 import java.awt.Font; … … 50 49 import javax.swing.AbstractAction; 51 50 import javax.swing.Action; 52 import javax.swing.JCheckBoxMenuItem;53 51 import javax.swing.JLabel; 54 52 import javax.swing.JMenuItem; … … 93 91 import org.openstreetmap.josm.gui.MapView; 94 92 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener; 95 import org.openstreetmap.josm.gui.PleaseWaitRunnable;96 93 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 97 94 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 95 import org.openstreetmap.josm.gui.layer.imagery.AutoLoadTilesAction; 96 import org.openstreetmap.josm.gui.layer.imagery.AutoZoomAction; 97 import org.openstreetmap.josm.gui.layer.imagery.DecreaseZoomAction; 98 import org.openstreetmap.josm.gui.layer.imagery.FlushTileCacheAction; 98 99 import org.openstreetmap.josm.gui.layer.imagery.ImageryFilterSettings.FilterChangeListener; 100 import org.openstreetmap.josm.gui.layer.imagery.IncreaseZoomAction; 101 import org.openstreetmap.josm.gui.layer.imagery.LoadAllTilesAction; 102 import org.openstreetmap.josm.gui.layer.imagery.LoadErroneousTilesAction; 99 103 import org.openstreetmap.josm.gui.layer.imagery.ReprojectionTile; 104 import org.openstreetmap.josm.gui.layer.imagery.ShowErrorsAction; 100 105 import org.openstreetmap.josm.gui.layer.imagery.TileAnchor; 101 106 import org.openstreetmap.josm.gui.layer.imagery.TileCoordinateConverter; … … 104 109 import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings.DisplaySettingsChangeEvent; 105 110 import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings.DisplaySettingsChangeListener; 111 import org.openstreetmap.josm.gui.layer.imagery.ZoomToBestAction; 112 import org.openstreetmap.josm.gui.layer.imagery.ZoomToNativeLevelAction; 106 113 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 107 114 import org.openstreetmap.josm.gui.util.GuiHelper; … … 312 319 * @see #invalidate() To trigger a repaint of all places where the layer is displayed. 313 320 */ 314 p rotectedvoid redraw() {321 public void redraw() { 315 322 invalidate(); 316 323 } … … 391 398 * @return average number of screen pixels per tile pixel 392 399 */ 393 p rotecteddouble getScaleFactor(int zoom) {400 public double getScaleFactor(int zoom) { 394 401 if (coordinateConverter != null) { 395 402 return coordinateConverter.getScaleFactor(zoom); … … 399 406 } 400 407 401 p rotectedint getBestZoom() {408 public int getBestZoom() { 402 409 double factor = getScaleFactor(1); // check the ratio between area of tilesize at zoom 1 to current view 403 410 double result = Math.log(factor)/Math.log(2)/2; … … 422 429 } 423 430 424 private static boolean actionSupportLayers(List<Layer> layers) { 431 /** 432 * Default implementation of {@link org.openstreetmap.josm.gui.layer.Layer.LayerAction#supportLayers(List)}. 433 * @param layers layers 434 * @return {@code true} is layers contains only a {@code TMSLayer} 435 */ 436 public static boolean actionSupportLayers(List<Layer> layers) { 425 437 return layers.size() == 1 && layers.get(0) instanceof TMSLayer; 426 438 } … … 512 524 } 513 525 514 private class AutoZoomAction extends AbstractAction implements LayerAction {515 AutoZoomAction() {516 super(tr("Auto zoom"));517 }518 519 @Override520 public void actionPerformed(ActionEvent ae) {521 getDisplaySettings().setAutoZoom(!getDisplaySettings().isAutoZoom());522 }523 524 @Override525 public Component createMenuComponent() {526 JCheckBoxMenuItem item = new JCheckBoxMenuItem(this);527 item.setSelected(getDisplaySettings().isAutoZoom());528 return item;529 }530 531 @Override532 public boolean supportLayers(List<Layer> layers) {533 return actionSupportLayers(layers);534 }535 }536 537 private class AutoLoadTilesAction extends AbstractAction implements LayerAction {538 AutoLoadTilesAction() {539 super(tr("Auto load tiles"));540 }541 542 @Override543 public void actionPerformed(ActionEvent ae) {544 getDisplaySettings().setAutoLoad(!getDisplaySettings().isAutoLoad());545 }546 547 @Override548 public Component createMenuComponent() {549 JCheckBoxMenuItem item = new JCheckBoxMenuItem(this);550 item.setSelected(getDisplaySettings().isAutoLoad());551 return item;552 }553 554 @Override555 public boolean supportLayers(List<Layer> layers) {556 return actionSupportLayers(layers);557 }558 }559 560 private class ShowErrorsAction extends AbstractAction implements LayerAction {561 ShowErrorsAction() {562 super(tr("Show errors"));563 }564 565 @Override566 public void actionPerformed(ActionEvent ae) {567 getDisplaySettings().setShowErrors(!getDisplaySettings().isShowErrors());568 }569 570 @Override571 public Component createMenuComponent() {572 JCheckBoxMenuItem item = new JCheckBoxMenuItem(this);573 item.setSelected(getDisplaySettings().isShowErrors());574 return item;575 }576 577 @Override578 public boolean supportLayers(List<Layer> layers) {579 return actionSupportLayers(layers);580 }581 }582 583 private class LoadAllTilesAction extends AbstractAction {584 LoadAllTilesAction() {585 super(tr("Load all tiles"));586 }587 588 @Override589 public void actionPerformed(ActionEvent ae) {590 loadAllTiles(true);591 }592 }593 594 private class LoadErroneusTilesAction extends AbstractAction {595 LoadErroneusTilesAction() {596 super(tr("Load all error tiles"));597 }598 599 @Override600 public void actionPerformed(ActionEvent ae) {601 loadAllErrorTiles(true);602 }603 }604 605 private class ZoomToNativeLevelAction extends AbstractAction {606 ZoomToNativeLevelAction() {607 super(tr("Zoom to native resolution"));608 }609 610 @Override611 public void actionPerformed(ActionEvent ae) {612 double newFactor = Math.sqrt(getScaleFactor(currentZoomLevel));613 Main.map.mapView.zoomToFactor(newFactor);614 redraw();615 }616 }617 618 private class ZoomToBestAction extends AbstractAction {619 ZoomToBestAction() {620 super(tr("Change resolution"));621 setEnabled(!getDisplaySettings().isAutoZoom() && getBestZoom() != currentZoomLevel);622 }623 624 @Override625 public void actionPerformed(ActionEvent ae) {626 setZoomLevel(getBestZoom());627 }628 }629 630 private class IncreaseZoomAction extends AbstractAction {631 IncreaseZoomAction() {632 super(tr("Increase zoom"));633 setEnabled(!getDisplaySettings().isAutoZoom() && zoomIncreaseAllowed());634 }635 636 @Override637 public void actionPerformed(ActionEvent ae) {638 increaseZoomLevel();639 }640 }641 642 private class DecreaseZoomAction extends AbstractAction {643 DecreaseZoomAction() {644 super(tr("Decrease zoom"));645 setEnabled(!getDisplaySettings().isAutoZoom() && zoomDecreaseAllowed());646 }647 648 @Override649 public void actionPerformed(ActionEvent ae) {650 decreaseZoomLevel();651 }652 }653 654 private class FlushTileCacheAction extends AbstractAction {655 FlushTileCacheAction() {656 super(tr("Flush tile cache"));657 }658 659 @Override660 public void actionPerformed(ActionEvent ae) {661 new PleaseWaitRunnable(tr("Flush tile cache")) {662 @Override663 protected void realRun() {664 clearTileCache();665 }666 667 @Override668 protected void finish() {669 // empty - flush is instaneus670 }671 672 @Override673 protected void cancel() {674 // empty - flush is instaneus675 }676 }.run();677 }678 }679 680 526 /** 681 527 * Simple class to keep clickedTile within hookUpMapView … … 1028 874 } 1029 875 1030 protected void loadAllTiles(boolean force) { 876 /** 877 * Load all visible tiles. 878 * @param force {@code true} to force loading if auto-load is disabled 879 * @since 11950 880 */ 881 public void loadAllTiles(boolean force) { 1031 882 TileSet ts = getVisibleTileSet(); 1032 883 … … 1040 891 } 1041 892 1042 protected void loadAllErrorTiles(boolean force) { 893 /** 894 * Load all visible tiles in error. 895 * @param force {@code true} to force loading if auto-load is disabled 896 * @since 11950 897 */ 898 public void loadAllErrorTiles(boolean force) { 1043 899 TileSet ts = getVisibleTileSet(); 1044 900 ts.loadAllErrorTiles(force); … … 1801 1657 public Action[] getCommonEntries() { 1802 1658 return new Action[] { 1803 new AutoLoadTilesAction( ),1804 new AutoZoomAction( ),1805 new ShowErrorsAction( ),1806 new IncreaseZoomAction( ),1807 new DecreaseZoomAction( ),1808 new ZoomToBestAction( ),1809 new ZoomToNativeLevelAction( ),1810 new FlushTileCacheAction( ),1811 new LoadErrone usTilesAction(),1812 new LoadAllTilesAction( )1659 new AutoLoadTilesAction(this), 1660 new AutoZoomAction(this), 1661 new ShowErrorsAction(this), 1662 new IncreaseZoomAction(this), 1663 new DecreaseZoomAction(this), 1664 new ZoomToBestAction(this), 1665 new ZoomToNativeLevelAction(this), 1666 new FlushTileCacheAction(this), 1667 new LoadErroneousTilesAction(this), 1668 new LoadAllTilesAction(this) 1813 1669 }; 1814 1670 } -
trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java
r11858 r11950 69 69 70 70 @Override 71 p rotectedint getBestZoom() {71 public int getBestZoom() { 72 72 if (!Main.isDisplayingMapView()) 73 73 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.