Changeset 16984 in josm for trunk/src/org/openstreetmap/josm/tools
- Timestamp:
- 2020-08-30T21:27:14+02:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r16946 r16984 48 48 import java.util.concurrent.Executors; 49 49 import java.util.function.Consumer; 50 import java.util.function.UnaryOperator; 50 51 import java.util.regex.Matcher; 51 52 import java.util.regex.Pattern; … … 1331 1332 1332 1333 Point hotSpot = new Point(); 1333 Image image = getCursorImage(name, overlay, hotSpot); 1334 Image image = getCursorImage(name, overlay, dim -> Toolkit.getDefaultToolkit().getBestCursorSize(dim.width, dim.height), hotSpot); 1334 1335 1335 1336 return Toolkit.getDefaultToolkit().createCustomCursor(image, hotSpot, name); … … 1348 1349 * @param name the cursor image filename in "cursor" directory 1349 1350 * @param overlay optional overlay image 1351 * @param bestCursorSizeFunction computes the best cursor size, see {@link Toolkit#getBestCursorSize(int, int)} 1350 1352 * @param hotSpot will be set to the properly scaled hotspot of the cursor 1351 1353 * @return cursor with a given file name, optionally decorated with an overlay image 1352 1354 */ 1353 static Image getCursorImage(String name, String overlay, /* out */ Point hotSpot) { 1355 static Image getCursorImage(String name, String overlay, UnaryOperator<Dimension> bestCursorSizeFunction, /* out */ Point hotSpot) { 1354 1356 ImageProvider imageProvider = new ImageProvider("cursor", name); 1355 1357 if (overlay != null) { … … 1366 1368 // AWT will resize the cursor to bestCursorSize internally anyway, but miss to scale the hotspot as well 1367 1369 // (bug JDK-8238734). So let's do this ourselves, and also scale the hotspot accordingly. 1368 Dimension bestCursorSize = Toolkit.getDefaultToolkit().getBestCursorSize(width, height);1370 Dimension bestCursorSize = bestCursorSizeFunction.apply(new Dimension(width, height)); 1369 1371 if (bestCursorSize.width != 0 && bestCursorSize.height != 0) { 1370 1372 // In principle, we could pass the MultiResolutionImage itself to AWT, but due to bug JDK-8240568,
Note:
See TracChangeset
for help on using the changeset viewer.