Changeset 10409 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2016-06-17T02:58:36+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/CopyAction.java
r10382 r10409 13 13 14 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.data.osm.DataSet;16 15 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 16 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; … … 26 25 public final class CopyAction extends JosmAction { 27 26 28 / / regular expression that matches text clipboard contents after copying27 /** regular expression that matches text clipboard contents after copying */ 29 28 public static final String CLIPBOARD_REGEXP = "((node|way|relation)\\s\\d+,)*(node|way|relation)\\s\\d+"; 30 29 … … 57 56 */ 58 57 public static void copy(OsmDataLayer source, Collection<OsmPrimitive> primitives) { 59 / * copy ids to the clipboard */58 // copy ids to the clipboard 60 59 String ids = getCopyString(primitives); 61 60 Utils.copyToClipboard(ids); … … 75 74 @Override 76 75 protected void updateEnabledState() { 77 DataSet ds = getLayerManager().getEditDataSet(); 78 if (ds == null) { 79 setEnabled(false); 80 } else { 81 updateEnabledState(ds.getSelected()); 82 } 76 updateEnabledStateOnCurrentSelection(); 83 77 } 84 78 -
trunk/src/org/openstreetmap/josm/actions/CreateCircleAction.java
r10382 r10409 25 25 import org.openstreetmap.josm.data.coor.EastNorth; 26 26 import org.openstreetmap.josm.data.coor.LatLon; 27 import org.openstreetmap.josm.data.osm.DataSet;28 27 import org.openstreetmap.josm.data.osm.Node; 29 28 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 290 289 @Override 291 290 protected void updateEnabledState() { 292 DataSet ds = getLayerManager().getEditDataSet(); 293 if (ds == null) { 294 setEnabled(false); 295 } else { 296 updateEnabledState(ds.getSelected()); 297 } 291 updateEnabledStateOnCurrentSelection(); 298 292 } 299 293 -
trunk/src/org/openstreetmap/josm/actions/DeleteAction.java
r10382 r10409 10 10 11 11 import org.openstreetmap.josm.Main; 12 import org.openstreetmap.josm.data.osm.DataSet;13 12 import org.openstreetmap.josm.data.osm.OsmPrimitive; 14 13 import org.openstreetmap.josm.tools.Shortcut; … … 38 37 @Override 39 38 protected void updateEnabledState() { 40 DataSet ds = getLayerManager().getEditDataSet(); 41 if (ds == null) { 42 setEnabled(false); 43 } else { 44 updateEnabledState(ds.getSelected()); 45 } 39 updateEnabledStateOnCurrentSelection(); 46 40 } 47 41 -
trunk/src/org/openstreetmap/josm/actions/DistributeAction.java
r10382 r10409 20 20 import org.openstreetmap.josm.command.MoveCommand; 21 21 import org.openstreetmap.josm.command.SequenceCommand; 22 import org.openstreetmap.josm.data.osm.DataSet;23 22 import org.openstreetmap.josm.data.osm.Node; 24 23 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 301 300 @Override 302 301 protected void updateEnabledState() { 303 DataSet ds = getLayerManager().getEditDataSet(); 304 if (ds == null) { 305 setEnabled(false); 306 } else { 307 updateEnabledState(ds.getSelected()); 308 } 302 updateEnabledStateOnCurrentSelection(); 309 303 } 310 304 -
trunk/src/org/openstreetmap/josm/actions/DownloadReferrersAction.java
r10382 r10409 11 11 import org.openstreetmap.josm.Main; 12 12 import org.openstreetmap.josm.actions.downloadtasks.DownloadReferrersTask; 13 import org.openstreetmap.josm.data.osm.DataSet;14 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 14 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 62 61 @Override 63 62 protected void updateEnabledState() { 64 DataSet ds = getLayerManager().getEditDataSet(); 65 if (ds == null) { 66 setEnabled(false); 67 } else { 68 updateEnabledState(ds.getSelected()); 69 } 63 updateEnabledStateOnCurrentSelection(); 70 64 } 71 65 -
trunk/src/org/openstreetmap/josm/actions/DuplicateAction.java
r10382 r10409 11 11 12 12 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.data.osm.DataSet;14 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 14 import org.openstreetmap.josm.data.osm.PrimitiveDeepCopy; … … 36 35 @Override 37 36 protected void updateEnabledState() { 38 DataSet ds = getLayerManager().getEditDataSet(); 39 if (ds == null) { 40 setEnabled(false); 41 } else { 42 updateEnabledState(ds.getSelected()); 43 } 37 updateEnabledStateOnCurrentSelection(); 44 38 } 45 39 -
trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java
r10382 r10409 16 16 import org.openstreetmap.josm.command.SelectCommand; 17 17 import org.openstreetmap.josm.command.SequenceCommand; 18 import org.openstreetmap.josm.data.osm.DataSet;19 18 import org.openstreetmap.josm.data.osm.Node; 20 19 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 36 35 public class FollowLineAction extends JosmAction { 37 36 37 /** 38 * Constructs a new {@code FollowLineAction}. 39 */ 38 40 public FollowLineAction() { 39 41 super( … … 48 50 @Override 49 51 protected void updateEnabledState() { 50 DataSet ds = getLayerManager().getEditDataSet(); 51 if (ds == null) { 52 setEnabled(false); 53 } else { 54 updateEnabledState(ds.getSelected()); 55 } 52 updateEnabledStateOnCurrentSelection(); 56 53 } 57 54 -
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r10382 r10409 1548 1548 @Override 1549 1549 protected void updateEnabledState() { 1550 DataSet ds = getLayerManager().getEditDataSet(); 1551 if (ds == null) { 1552 setEnabled(false); 1553 } else { 1554 updateEnabledState(ds.getSelected()); 1555 } 1550 updateEnabledStateOnCurrentSelection(); 1556 1551 } 1557 1552 -
trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java
r10382 r10409 25 25 import org.openstreetmap.josm.command.SequenceCommand; 26 26 import org.openstreetmap.josm.data.coor.EastNorth; 27 import org.openstreetmap.josm.data.osm.DataSet;28 27 import org.openstreetmap.josm.data.osm.Node; 29 28 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 209 208 @Override 210 209 protected void updateEnabledState() { 211 DataSet ds = getLayerManager().getEditDataSet(); 212 if (ds == null) { 213 setEnabled(false); 214 } else { 215 updateEnabledState(ds.getSelected()); 216 } 210 updateEnabledStateOnCurrentSelection(); 217 211 } 218 212 -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r10369 r10409 171 171 } 172 172 } 173 173 174 174 /** 175 175 * Installs the listeners to this action. … … 351 351 352 352 /** 353 * Updates enabled state according to primitives currently selected in edit data set, if any. 354 * Can be called in {@link #updateEnabledState()} implementations. 355 * @since 10409 356 */ 357 protected final void updateEnabledStateOnCurrentSelection() { 358 DataSet ds = getLayerManager().getEditDataSet(); 359 if (ds == null) { 360 setEnabled(false); 361 } else { 362 updateEnabledState(ds.getSelected()); 363 } 364 } 365 366 /** 353 367 * Adapter for layer change events. Runs updateEnabledState() whenever the active layer changed. 354 368 */ -
trunk/src/org/openstreetmap/josm/actions/MirrorAction.java
r10382 r10409 18 18 import org.openstreetmap.josm.command.MoveCommand; 19 19 import org.openstreetmap.josm.command.SequenceCommand; 20 import org.openstreetmap.josm.data.osm.DataSet;21 20 import org.openstreetmap.josm.data.osm.Node; 22 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 87 86 @Override 88 87 protected void updateEnabledState() { 89 DataSet ds = getLayerManager().getEditDataSet(); 90 if (ds == null) { 91 setEnabled(false); 92 } else { 93 updateEnabledState(ds.getSelected()); 94 } 88 updateEnabledStateOnCurrentSelection(); 95 89 } 96 90 -
trunk/src/org/openstreetmap/josm/actions/MoveAction.java
r10382 r10409 152 152 @Override 153 153 protected void updateEnabledState() { 154 DataSet ds = getLayerManager().getEditDataSet(); 155 if (ds == null) { 156 setEnabled(false); 157 } else { 158 updateEnabledState(ds.getSelected()); 159 } 154 updateEnabledStateOnCurrentSelection(); 160 155 } 161 156 -
trunk/src/org/openstreetmap/josm/actions/SimplifyWayAction.java
r10382 r10409 276 276 @Override 277 277 protected void updateEnabledState() { 278 DataSet ds = getLayerManager().getEditDataSet(); 279 if (ds == null) { 280 setEnabled(false); 281 } else { 282 updateEnabledState(ds.getSelected()); 283 } 278 updateEnabledStateOnCurrentSelection(); 284 279 } 285 280 -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r10382 r10409 32 32 import org.openstreetmap.josm.command.Command; 33 33 import org.openstreetmap.josm.command.SequenceCommand; 34 import org.openstreetmap.josm.data.osm.DataSet;35 34 import org.openstreetmap.josm.data.osm.Node; 36 35 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 658 657 @Override 659 658 protected void updateEnabledState() { 660 DataSet ds = getLayerManager().getEditDataSet(); 661 if (ds == null) { 662 setEnabled(false); 663 } else { 664 updateEnabledState(ds.getSelected()); 665 } 659 updateEnabledStateOnCurrentSelection(); 666 660 } 667 661 -
trunk/src/org/openstreetmap/josm/actions/UnJoinNodeWayAction.java
r10382 r10409 18 18 import org.openstreetmap.josm.Main; 19 19 import org.openstreetmap.josm.command.RemoveNodesCommand; 20 import org.openstreetmap.josm.data.osm.DataSet;21 20 import org.openstreetmap.josm.data.osm.Node; 22 21 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 187 186 @Override 188 187 protected void updateEnabledState() { 189 DataSet ds = getLayerManager().getEditDataSet(); 190 if (ds == null) { 191 setEnabled(false); 192 } else { 193 updateEnabledState(ds.getSelected()); 194 } 188 updateEnabledStateOnCurrentSelection(); 195 189 } 196 190 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTask.java
r10378 r10409 253 253 } 254 254 255 protected OsmDataLayer addNewLayerIfRequired(String newLayerName , Bounds bounds) {255 protected OsmDataLayer addNewLayerIfRequired(String newLayerName) { 256 256 int numDataLayers = getNumDataLayers(); 257 257 if (newLayer || numDataLayers == 0 || (numDataLayers > 1 && getEditLayer() == null)) { … … 268 268 269 269 protected void loadData(String newLayerName, Bounds bounds) { 270 OsmDataLayer layer = addNewLayerIfRequired(newLayerName , bounds);270 OsmDataLayer layer = addNewLayerIfRequired(newLayerName); 271 271 if (layer == null) { 272 272 layer = getEditLayer(); -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r10383 r10409 690 690 if (selectedWay != null) { 691 691 int posn0 = selectedWay.getNodes().indexOf(currentNode); 692 // CHECKSTYLE.OFF: SingleSpaceSeparator 692 693 if (posn0 != -1 && // n0 is part of way 693 // CHECKSTYLE.OFF: SingleSpaceSeparator 694 (posn0 >= 1 && targetNode.equals(selectedWay.getNode(posn0-1))) || // previous node 695 (posn0 < selectedWay.getNodesCount()-1) && targetNode.equals(selectedWay.getNode(posn0+1))) { // next node 696 // CHECKSTYLE.ON: SingleSpaceSeparator 694 (posn0 >= 1 && targetNode.equals(selectedWay.getNode(posn0-1))) || // previous node 695 (posn0 < selectedWay.getNodesCount()-1) && targetNode.equals(selectedWay.getNode(posn0+1))) { // next node 697 696 getLayerManager().getEditDataSet().setSelected(targetNode); 698 697 lastUsedNode = targetNode; 699 698 return true; 700 699 } 700 // CHECKSTYLE.ON: SingleSpaceSeparator 701 701 } 702 702 -
trunk/src/org/openstreetmap/josm/data/validation/tests/Highways.java
r10378 r10409 46 46 * Classified highways in order of importance 47 47 */ 48 // CHECKSTYLE.OFF: SingleSpaceSeparator 48 49 private static final List<String> CLASSIFIED_HIGHWAYS = Arrays.asList( 49 // CHECKSTYLE.OFF: SingleSpaceSeparator50 50 "motorway", "motorway_link", 51 51 "trunk", "trunk_link", … … 56 56 "residential", 57 57 "living_street"); 58 58 // CHECKSTYLE.ON: SingleSpaceSeparator 59 59 60 60 private static final Set<String> KNOWN_SOURCE_MAXSPEED_CONTEXTS = new HashSet<>(Arrays.asList( -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r10405 r10409 141 141 // The only events that may move/resize this map view are window movements or changes to the map view size. 142 142 // We can clean this up more by only recalculating the state on repaint. 143 private final HierarchyListener hierarchyListener = new HierarchyListener() {143 private final transient HierarchyListener hierarchyListener = new HierarchyListener() { 144 144 @Override 145 145 public void hierarchyChanged(HierarchyEvent e) { … … 151 151 }; 152 152 153 private final ComponentAdapter componentListener = new ComponentAdapter() {153 private final transient ComponentAdapter componentListener = new ComponentAdapter() { 154 154 @Override 155 155 public void componentShown(ComponentEvent e) { … … 170 170 * The current state (scale, center, ...) of this map view. 171 171 */ 172 private MapViewState state;172 private transient MapViewState state; 173 173 174 174 /** -
trunk/src/org/openstreetmap/josm/gui/util/GuiSizesHelper.java
r10392 r10409 3 3 4 4 import java.awt.Dimension; 5 import java.awt. HeadlessException;5 import java.awt.GraphicsEnvironment; 6 6 import java.awt.Toolkit; 7 7 … … 20 20 } 21 21 22 23 22 /** cache value for screen resolution */ 24 23 private static float screenDPI = -1; 25 24 26 /** Request the screen resolution (cached) 25 /** 26 * Request the screen resolution (cached) 27 27 * @return screen resolution in DPI 28 28 */ … … 35 35 screenDPI = 96f * scalePref; 36 36 } else { 37 try{37 if (!GraphicsEnvironment.isHeadless()) { 38 38 screenDPI = Toolkit.getDefaultToolkit().getScreenResolution(); 39 } catch (HeadlessException e){39 } else { 40 40 screenDPI = 96; 41 41 } … … 53 53 */ 54 54 public static float getPixelDensity() { 55 float pixelPerInch = getScreenDPI(); 56 return pixelPerInch / 96f; 55 return getScreenDPI() / 96f; 57 56 } 58 57 … … 72 71 public static int getSizeDpiAdjusted(int size) { 73 72 if (size <= 0) return size; 74 float pixelPerInch = getScreenDPI(); 75 return Math.round(size * pixelPerInch / 96); 73 return Math.round(size * getScreenDPI() / 96); 76 74 } 77 75 … … 83 81 public static float getSizeDpiAdjusted(float size) { 84 82 if (size <= 0f) return size; 85 float pixelPerInch = getScreenDPI(); 86 return size * pixelPerInch / 96; 83 return size * getScreenDPI() / 96; 87 84 } 88 85 … … 94 91 public static double getSizeDpiAdjusted(double size) { 95 92 if (size <= 0d) return size; 96 float pixelPerInch = getScreenDPI(); 97 return size * pixelPerInch / 96; 93 return size * getScreenDPI() / 96; 98 94 } 99 95 … … 105 101 public static Dimension getDimensionDpiAdjusted(Dimension dim) { 106 102 float pixelPerInch = getScreenDPI(); 107 int width = dim.width, height = dim.height; 103 int width = dim.width; 104 int height = dim.height; 108 105 if (dim.width > 0) { 109 106 width = Math.round(dim.width * pixelPerInch / 96); -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r10403 r10409 707 707 708 708 /** 709 * Load an image with a given file name. 710 * 711 * @param name The icon name (base name with or without '.png' or '.svg' extension) 712 * @return the requested image or null if the request failed 713 * @see #get(String, String) 714 */ 715 public static ImageIcon get(String name) { 716 return new ImageProvider(name).get(); 717 } 718 719 /** 709 720 * Load an empty image with a given size. 710 721 * … … 717 728 return new ImageIcon(new BufferedImage(iconRealSize.width, iconRealSize.height, 718 729 BufferedImage.TYPE_INT_ARGB)); 719 }720 721 /**722 * Load an image with a given file name.723 *724 * @param name The icon name (base name with or without '.png' or '.svg' extension)725 * @return the requested image or null if the request failed726 * @see #get(String, String)727 */728 public static ImageIcon get(String name) {729 return new ImageProvider(name).get();730 730 } 731 731 -
trunk/src/org/openstreetmap/josm/tools/ImageResource.java
r10370 r10409 13 13 import javax.swing.ImageIcon; 14 14 15 import org.openstreetmap.josm.gui.util.GuiSizesHelper; 16 15 17 import com.kitfox.svg.SVGDiagram; 16 import org.openstreetmap.josm.gui.util.GuiSizesHelper;17 18 18 19 /** … … 50 51 public ImageResource(Image img) { 51 52 CheckParameterUtil.ensureParameterNotNull(img); 52 this.baseImage = img; 53 54 img = scaleBaseImageIfNeeded(img); 55 56 imgCache.put(DEFAULT_DIMENSION, img); 53 baseImage = img; 54 imgCache.put(DEFAULT_DIMENSION, scaleBaseImageIfNeeded(img)); 57 55 } 58 56 … … 71 69 BufferedImage bimg = new BufferedImage(realWidth, realHeight, BufferedImage.TYPE_INT_ARGB); 72 70 bimg.getGraphics().drawImage(realImage, 0, 0, null); 73 img =bimg;71 return bimg; 74 72 } 75 73 return img; … … 98 96 99 97 /** 100 * Returns the image icon at default dimension.101 * @return the image icon at default dimension102 */103 public ImageIcon getImageIcon() {104 return getImageIcon(DEFAULT_DIMENSION);105 }106 107 /**108 98 * Set both icons of an Action 109 99 * @param a The action for the icons … … 135 125 136 126 /** 127 * Returns the image icon at default dimension. 128 * @return the image icon at default dimension 129 */ 130 public ImageIcon getImageIcon() { 131 return getImageIcon(DEFAULT_DIMENSION); 132 } 133 134 /** 137 135 * Get an ImageIcon object for the image of this resource 138 * @param dim The requested dimensions. Use (-1,-1) for the original size 139 * and (width, -1) to set the width, but otherwise scale the image 140 * proportionally. 136 * @param dim The requested dimensions. Use (-1,-1) for the original size and (width, -1) 137 * to set the width, but otherwise scale the image proportionally. 141 138 * @return ImageIcon object for the image of this resource, scaled according to dim 142 139 */
Note:
See TracChangeset
for help on using the changeset viewer.