Changeset 19640 in josm
- Timestamp:
- 2026-10-06T09:35:45+02:00 (10 hours ago)
- Location:
- trunk
- Files:
-
- 18 added
- 5 edited
-
resources/images/grid.svg (added)
-
resources/images/gridorigin.svg (added)
-
resources/images/gridrotate.svg (added)
-
resources/images/preferences/grid.svg (added)
-
src/org/openstreetmap/josm/actions/AlignGridRotationAction.java (added)
-
src/org/openstreetmap/josm/actions/SetGridOriginAction.java (added)
-
src/org/openstreetmap/josm/actions/ShowGridAction.java (added)
-
src/org/openstreetmap/josm/gui/MainMenu.java (modified) (5 diffs)
-
src/org/openstreetmap/josm/gui/MapFrame.java (modified) (4 diffs)
-
src/org/openstreetmap/josm/gui/draw/BlendComposite.java (added)
-
src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java (modified) (7 diffs)
-
src/org/openstreetmap/josm/gui/layer/MapGridPaintable.java (added)
-
src/org/openstreetmap/josm/gui/layer/imagery/ShowTileBordersAction.java (added)
-
src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java (modified) (10 diffs)
-
src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java (modified) (2 diffs)
-
src/org/openstreetmap/josm/gui/preferences/display/GridPreference.java (added)
-
test/unit/org/openstreetmap/josm/actions/GridActionsTest.java (added)
-
test/unit/org/openstreetmap/josm/gui/draw (added)
-
test/unit/org/openstreetmap/josm/gui/draw/BlendCompositeTest.java (added)
-
test/unit/org/openstreetmap/josm/gui/layer/MapGridPaintableTest.java (added)
-
test/unit/org/openstreetmap/josm/gui/layer/imagery/ShowTileBordersActionTest.java (added)
-
test/unit/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettingsTest.java (added)
-
test/unit/org/openstreetmap/josm/gui/preferences/display/GridPreferenceTest.java (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r19547 r19640 31 31 import org.openstreetmap.josm.actions.AboutAction; 32 32 import org.openstreetmap.josm.actions.AddNodeAction; 33 import org.openstreetmap.josm.actions.AlignGridRotationAction; 33 34 import org.openstreetmap.josm.actions.AlignInCircleAction; 34 35 import org.openstreetmap.josm.actions.AlignInLineAction; … … 101 102 import org.openstreetmap.josm.actions.SessionSaveAction; 102 103 import org.openstreetmap.josm.actions.SessionSaveAsAction; 104 import org.openstreetmap.josm.actions.SetGridOriginAction; 105 import org.openstreetmap.josm.actions.ShowGridAction; 103 106 import org.openstreetmap.josm.actions.ShowStatusReportAction; 104 107 import org.openstreetmap.josm.actions.SimplifyWayAction; … … 136 139 import org.openstreetmap.josm.gui.layer.geoimage.WikimediaCommonsLoader.WikimediaCommonsLoadImagesAction; 137 140 import org.openstreetmap.josm.gui.mappaint.MapPaintMenu; 141 import org.openstreetmap.josm.gui.preferences.display.GridPreference; 138 142 import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreference; 139 143 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSearchPrimitiveDialog; … … 257 261 /** View / Hatch area outside download */ 258 262 public final DrawBoundariesOfDownloadedDataAction drawBoundariesOfDownloadedDataAction = new DrawBoundariesOfDownloadedDataAction(); 263 /** View / Grid submenu: the grid drawn over the map and its placement */ 264 public final JMenu gridMenu = new JMenu(tr("Grid")); 265 /** View / Grid / Show */ 266 public final ShowGridAction showGridAction = new ShowGridAction(); 267 /** View / Grid / Set origin to selection */ 268 public final SetGridOriginAction setGridOriginAction = new SetGridOriginAction(); 269 /** View / Grid / Align rotation to selection */ 270 public final AlignGridRotationAction alignGridRotationAction = new AlignGridRotationAction(); 259 271 /** View / Advanced info */ 260 272 public final InfoAction info = new InfoAction(); … … 816 828 viewMenu.add(hatchAreaOutsideDownloadMenuItem); 817 829 ExpertToggleAction.addVisibilitySwitcher(hatchAreaOutsideDownloadMenuItem); 830 // -- Grid submenu 831 gridMenu.setIcon(ImageProvider.get("grid", ImageProvider.ImageSizes.MENU)); 832 gridMenu.add(showGridAction.getCheckbox()); 833 add(gridMenu, setGridOriginAction); 834 add(gridMenu, alignGridRotationAction); 835 gridMenu.addSeparator(); 836 add(gridMenu, PreferencesAction.forPreferenceTab(tr("Grid preferences..."), 837 tr("Click to open the grid tab in the preferences"), GridPreference.class)); 838 viewMenu.add(gridMenu); 818 839 819 840 viewMenu.add(new MapPaintMenu()); -
trunk/src/org/openstreetmap/josm/gui/MapFrame.java
r19384 r19640 74 74 import org.openstreetmap.josm.gui.dialogs.properties.PropertiesDialog; 75 75 import org.openstreetmap.josm.gui.layer.Layer; 76 import org.openstreetmap.josm.gui.layer.MapGridPaintable; 76 77 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 77 78 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; … … 123 124 */ 124 125 public final MapView mapView; 126 /** The grid drawn over the map view, see {@link MapGridPaintable} */ 127 private final MapGridPaintable gridOverlay = new MapGridPaintable(); 125 128 126 129 /** … … 205 208 206 209 mapView = new MapView(MainApplication.getLayerManager(), viewportData); 210 mapView.addTemporaryLayer(gridOverlay); 207 211 208 212 splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true); … … 367 371 368 372 statusLine.destroy(); 373 mapView.removeTemporaryLayer(gridOverlay); 374 gridOverlay.destroy(); 369 375 mapView.destroy(); 370 376 keyDetector.unregister(); -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r19291 r19640 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 7 import java.awt.BasicStroke; 7 8 import java.awt.Color; 8 9 import java.awt.Component; … … 16 17 import java.awt.Shape; 17 18 import java.awt.Toolkit; 19 import java.awt.Stroke; 18 20 import java.awt.event.ActionEvent; 19 21 import java.awt.event.MouseAdapter; … … 94 96 import org.openstreetmap.josm.data.preferences.BooleanProperty; 95 97 import org.openstreetmap.josm.data.preferences.IntegerProperty; 98 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 96 99 import org.openstreetmap.josm.data.projection.Projection; 97 100 import org.openstreetmap.josm.data.projection.ProjectionRegistry; … … 117 120 import org.openstreetmap.josm.gui.layer.imagery.ReprojectionTile; 118 121 import org.openstreetmap.josm.gui.layer.imagery.ShowErrorsAction; 122 import org.openstreetmap.josm.gui.layer.imagery.ShowTileBordersAction; 119 123 import org.openstreetmap.josm.gui.layer.imagery.TileAnchor; 120 124 import org.openstreetmap.josm.gui.layer.imagery.TileCoordinateConverter; … … 182 186 183 187 private static final BooleanProperty POPUP_MENU_ENABLED = new BooleanProperty(PREFERENCE_PREFIX + ".popupmenu", true); 188 /** Color of the border drawn around each tile if enabled, see {@link TileSourceDisplaySettings#isShowTileBorders()} */ 189 private static final NamedColorProperty TILE_BORDER_COLOR = new NamedColorProperty(marktr("imagery tile border"), new Color(0, 0, 0, 96)); 190 private static final Stroke TILE_BORDER_STROKE = new BasicStroke(1f); 184 191 private static final String ERROR_STRING = marktr("Error"); 185 192 … … 1227 1234 } 1228 1235 1229 if (Logging.isDebugEnabled()) { 1236 if (getDisplaySettings().isShowTileBorders()) { 1237 // draw a thin border around the tile 1238 Color oldColor = g.getColor(); 1239 Stroke oldStroke = g.getStroke(); 1240 g.setColor(TILE_BORDER_COLOR.get()); 1241 g.setStroke(TILE_BORDER_STROKE); 1242 g.draw(coordinateConverter.getTileShapeScreen(tile)); 1243 g.setStroke(oldStroke); 1244 g.setColor(oldColor); 1245 } else if (Logging.isDebugEnabled()) { 1230 1246 // draw tile outline in semi-transparent red 1231 1247 g.setColor(new Color(255, 0, 0, 50)); … … 1854 1870 new AutoZoomAction(this), 1855 1871 new ShowErrorsAction(this), 1872 new ShowTileBordersAction(this), 1856 1873 new IncreaseZoomAction(this), 1857 1874 new DecreaseZoomAction(this), -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/TileSourceDisplaySettings.java
r19629 r19640 46 46 private static final String SHOW_ERRORS = "show-errors"; 47 47 48 private static final String SHOW_TILE_BORDERS = "show-tile-borders"; 49 48 50 private static final String DISPLACEMENT = "displacement"; 49 51 … … 59 61 */ 60 62 public static final BooleanProperty PROP_AUTO_ZOOM = new BooleanProperty(PREFERENCE_PREFIX + ".default_autozoom", true); 63 64 /** 65 * The default tile borders property, remembered whenever the user toggles them, so that the choice also 66 * applies to layers created later and after a restart 67 * @since 19640 68 */ 69 public static final BooleanProperty PROP_SHOW_TILE_BORDERS 70 = new BooleanProperty(PREFERENCE_PREFIX + ".default_showtileborders", false); 61 71 62 72 … … 67 77 /** if layer should show errors on tiles */ 68 78 private boolean showErrors; 79 /** if layer should draw a border around each tile */ 80 private boolean showTileBorders; 69 81 70 82 private OffsetBookmark previousOffsetBookmark; … … 97 109 autoLoad = getProperty(prefixes, "default_autoload", PROP_AUTO_LOAD.getDefaultValue()); 98 110 showErrors = getProperty(prefixes, "default_showerrors", Boolean.TRUE); 111 showTileBorders = getProperty(prefixes, "default_showtileborders", PROP_SHOW_TILE_BORDERS.getDefaultValue()); 99 112 } 100 113 101 114 private static boolean getProperty(String[] prefixes, String name, Boolean def) { 102 // iterate through all values to force the preferences to receive the default value. 103 // we only support a default value of true. 104 boolean value = true; 115 // iterate through all values to force the preferences to receive the default value 116 boolean value = def; 105 117 for (String p : prefixes) { 106 118 String key = p + "." + name; 107 boolean currentValue = Config.getPref().getBoolean(key, true);119 boolean currentValue = Config.getPref().getBoolean(key, def); 108 120 if (!Config.getPref().get(key, def.toString()).isEmpty()) { 109 121 value = currentValue; … … 168 180 this.showErrors = showErrors; 169 181 fireSettingsChange(SHOW_ERRORS); 182 } 183 184 /** 185 * If the layer should draw a thin border around each tile. 186 * @return <code>true</code> to draw tile borders. 187 * @since 19640 188 */ 189 public boolean isShowTileBorders() { 190 return showTileBorders; 191 } 192 193 /** 194 * Sets the show tile borders property. Fires a change event. 195 * @param showTileBorders {@code true} if the layer should draw a thin border around each tile 196 * @see #isShowTileBorders() 197 * @since 19640 198 */ 199 public void setShowTileBorders(boolean showTileBorders) { 200 this.showTileBorders = showTileBorders; 201 fireSettingsChange(SHOW_TILE_BORDERS); 170 202 } 171 203 … … 290 322 data.put(AUTO_ZOOM, Boolean.toString(autoZoom)); 291 323 data.put(SHOW_ERRORS, Boolean.toString(showErrors)); 324 data.put(SHOW_TILE_BORDERS, Boolean.toString(showTileBorders)); 292 325 return data; 293 326 } … … 317 350 setShowErrors(Boolean.parseBoolean(doShowErrors)); 318 351 } 352 353 String doShowTileBorders = data.get(SHOW_TILE_BORDERS); 354 if (doShowTileBorders != null) { 355 setShowTileBorders(Boolean.parseBoolean(doShowTileBorders)); 356 } 319 357 } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) { 320 358 throw BugReport.intercept(e).put("data", data); … … 324 362 @Override 325 363 public int hashCode() { 326 return Objects.hash(autoLoad, autoZoom, showErrors); 364 return Objects.hash(autoLoad, autoZoom, showErrors, showTileBorders); 327 365 } 328 366 … … 336 374 return autoLoad == other.autoLoad 337 375 && autoZoom == other.autoZoom 338 && showErrors == other.showErrors; 376 && showErrors == other.showErrors 377 && showTileBorders == other.showTileBorders; 339 378 } 340 379 … … 342 381 public String toString() { 343 382 return "TileSourceDisplaySettings [autoZoom=" + autoZoom + ", autoLoad=" + autoLoad + ", showErrors=" 344 + showErrors + ']'; 383 + showErrors + ", showTileBorders=" + showTileBorders + ']'; 345 384 } 346 385 -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r19535 r19640 52 52 import org.openstreetmap.josm.gui.preferences.display.DrawingPreference; 53 53 import org.openstreetmap.josm.gui.preferences.display.GPXPreference; 54 import org.openstreetmap.josm.gui.preferences.display.GridPreference; 54 55 import org.openstreetmap.josm.gui.preferences.display.LafPreference; 55 56 import org.openstreetmap.josm.gui.preferences.display.LanguagePreference; … … 611 612 SETTINGS_FACTORIES.add(new ProxyPreference.Factory()); 612 613 SETTINGS_FACTORIES.add(new ProjectionPreference.Factory()); 614 SETTINGS_FACTORIES.add(new GridPreference.Factory()); 613 615 SETTINGS_FACTORIES.add(new MapPaintPreference.Factory()); 614 616 SETTINGS_FACTORIES.add(new TaggingPresetPreference.Factory());
Note:
See TracChangeset
for help on using the changeset viewer.
