- Timestamp:
- 2018-04-19T22:34:52+02:00 (7 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AbstractPasteAction.java
r13151 r13649 15 15 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; 16 16 import org.openstreetmap.josm.gui.datatransfer.OsmTransferHandler; 17 import org.openstreetmap.josm.tools.Logging; 17 18 import org.openstreetmap.josm.tools.Shortcut; 18 19 … … 76 77 // Observed behaviour: getActionCommand() returns Action.NAME when triggered via menu, but shortcut text when triggered with it 77 78 if (e != null && !getValue(NAME).equals(e.getActionCommand())) { 78 final PointerInfo pointerInfo = MouseInfo.getPointerInfo(); 79 if (pointerInfo != null) { 80 final Point mp = pointerInfo.getLocation(); 81 final Point tl = mapView.getLocationOnScreen(); 82 final Point pos = new Point(mp.x-tl.x, mp.y-tl.y); 83 if (mapView.contains(pos)) { 84 mPosition = mapView.getEastNorth(pos.x, pos.y); 79 try { 80 final PointerInfo pointerInfo = MouseInfo.getPointerInfo(); 81 if (pointerInfo != null) { 82 final Point mp = pointerInfo.getLocation(); 83 final Point tl = mapView.getLocationOnScreen(); 84 final Point pos = new Point(mp.x-tl.x, mp.y-tl.y); 85 if (mapView.contains(pos)) { 86 mPosition = mapView.getEastNorth(pos.x, pos.y); 87 } 85 88 } 89 } catch (SecurityException ex) { 90 Logging.log(Logging.LEVEL_ERROR, "Unable to get mouse pointer info", ex); 86 91 } 87 92 } -
trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
r13647 r13649 108 108 File cacheDir = new File(Config.getDirs().getCacheDirectory(true), "jcs"); 109 109 110 if (!cacheDir.exists() && !cacheDir.mkdirs()) { 111 Logging.warn("Cache directory " + cacheDir.toString() + " does not exists and could not create it"); 112 } else { 113 File cacheDirLockPath = new File(cacheDir, ".lock"); 114 try { 115 if (!cacheDirLockPath.exists() && !cacheDirLockPath.createNewFile()) { 116 Logging.warn("Cannot create cache dir lock file"); 117 } 118 cacheDirLock = FileChannel.open(cacheDirLockPath.toPath(), StandardOpenOption.WRITE).tryLock(); 119 120 if (cacheDirLock == null) 121 Logging.warn("Cannot lock cache directory. Will not use disk cache"); 122 } catch (IOException e) { 123 Logging.warn("Cannot create cache dir \"" + cacheDirLockPath.toString() + "\" lock file: " + e.toString()); 124 Logging.warn("Will not use disk cache"); 110 try { 111 if (!cacheDir.exists() && !cacheDir.mkdirs()) { 112 Logging.warn("Cache directory " + cacheDir.toString() + " does not exists and could not create it"); 113 } else { 114 File cacheDirLockPath = new File(cacheDir, ".lock"); 115 try { 116 if (!cacheDirLockPath.exists() && !cacheDirLockPath.createNewFile()) { 117 Logging.warn("Cannot create cache dir lock file"); 118 } 119 cacheDirLock = FileChannel.open(cacheDirLockPath.toPath(), StandardOpenOption.WRITE).tryLock(); 120 121 if (cacheDirLock == null) 122 Logging.warn("Cannot lock cache directory. Will not use disk cache"); 123 } catch (IOException e) { 124 Logging.warn("Cannot create cache dir \"" + cacheDirLockPath.toString() + "\" lock file: " + e.toString()); 125 Logging.warn("Will not use disk cache"); 126 } 125 127 } 126 } 128 } catch (SecurityException e) { 129 Logging.log(Logging.LEVEL_WARN, "Unable to configure disk cache. Will not use it", e); 130 } 131 127 132 // this could be moved to external file 128 133 Properties props = new Properties(); … … 140 145 props.setProperty("jcs.default.elementattributes.IsSpool", "true"); 141 146 // CHECKSTYLE.ON: SingleSpaceSeparator 142 CompositeCacheManager cm = CompositeCacheManager.getUnconfiguredInstance(); 143 cm.configure(props); 144 cacheManager = cm; 147 try { 148 CompositeCacheManager cm = CompositeCacheManager.getUnconfiguredInstance(); 149 cm.configure(props); 150 cacheManager = cm; 151 } catch (SecurityException e) { 152 Logging.log(Logging.LEVEL_WARN, "Unable to initialize JCS", e); 153 } 145 154 } 146 155 … … 173 182 if (cacheManager == null) 174 183 initialize(); 175 return getCacheInner(cacheName, maxMemoryObjects, maxDiskObjects, cachePath);184 return cacheManager != null ? getCacheInner(cacheName, maxMemoryObjects, maxDiskObjects, cachePath) : null; 176 185 } 177 186 } -
trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java
r12620 r13649 39 39 public class MultipolygonBuilder { 40 40 41 private static final ForkJoinPool THREAD_POOL = 42 Utils.newForkJoinPool("multipolygon_creation.numberOfThreads", "multipolygon-builder-%d", Thread.NORM_PRIORITY); 41 private static final ForkJoinPool THREAD_POOL = newForkJoinPool(); 42 43 private static ForkJoinPool newForkJoinPool() { 44 try { 45 return Utils.newForkJoinPool( 46 "multipolygon_creation.numberOfThreads", "multipolygon-builder-%d", Thread.NORM_PRIORITY); 47 } catch (SecurityException e) { 48 Logging.log(Logging.LEVEL_ERROR, "Unable to create new ForkJoinPool", e); 49 return null; 50 } 51 } 43 52 44 53 /** … … 385 394 private static List<PolygonLevel> findOuterWaysMultiThread(List<JoinedPolygon> boundaryWays) { 386 395 final IntersectionMatrix cache = new IntersectionMatrix(boundaryWays); 387 return THREAD_POOL.invoke(new Worker(cache, boundaryWays, 0, boundaryWays.size(), new ArrayList<PolygonLevel>(), 388 Math.max(32, boundaryWays.size() / THREAD_POOL.getParallelism() / 3))); 396 if (THREAD_POOL != null) { 397 return THREAD_POOL.invoke(new Worker(cache, boundaryWays, 0, boundaryWays.size(), new ArrayList<PolygonLevel>(), 398 Math.max(32, boundaryWays.size() / THREAD_POOL.getParallelism() / 3))); 399 } else { 400 return new Worker(cache, boundaryWays, 0, boundaryWays.size(), new ArrayList<PolygonLevel>(), 0).computeDirectly(); 401 } 389 402 } 390 403 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r13206 r13649 94 94 public class StyledMapRenderer extends AbstractMapRenderer { 95 95 96 private static final ForkJoinPool THREAD_POOL = 97 Utils.newForkJoinPool("mappaint.StyledMapRenderer.style_creation.numberOfThreads", "styled-map-renderer-%d", Thread.NORM_PRIORITY); 96 private static final ForkJoinPool THREAD_POOL = newForkJoinPool(); 97 98 private static ForkJoinPool newForkJoinPool() { 99 try { 100 return Utils.newForkJoinPool( 101 "mappaint.StyledMapRenderer.style_creation.numberOfThreads", "styled-map-renderer-%d", Thread.NORM_PRIORITY); 102 } catch (SecurityException e) { 103 Logging.log(Logging.LEVEL_ERROR, "Unable to create new ForkJoinPool", e); 104 return null; 105 } 106 } 98 107 99 108 /** … … 1600 1609 // Reason: Make sure, ElemStyles.getStyleCacheWithRange is not called for the same primitive in parallel threads. 1601 1610 // (Could be synchronized, but try to avoid this for performance reasons.) 1602 THREAD_POOL.invoke(new ComputeStyleListWorker(circum, nc, relations, allStyleElems, 1603 Math.max(20, relations.size() / THREAD_POOL.getParallelism() / 3), styles)); 1604 THREAD_POOL.invoke(new ComputeStyleListWorker(circum, nc, new CompositeList<>(nodes, ways), allStyleElems, 1605 Math.max(100, (nodes.size() + ways.size()) / THREAD_POOL.getParallelism() / 3), styles)); 1611 if (THREAD_POOL != null) { 1612 THREAD_POOL.invoke(new ComputeStyleListWorker(circum, nc, relations, allStyleElems, 1613 Math.max(20, relations.size() / THREAD_POOL.getParallelism() / 3), styles)); 1614 THREAD_POOL.invoke(new ComputeStyleListWorker(circum, nc, new CompositeList<>(nodes, ways), allStyleElems, 1615 Math.max(100, (nodes.size() + ways.size()) / THREAD_POOL.getParallelism() / 3), styles)); 1616 } else { 1617 new ComputeStyleListWorker(circum, nc, relations, allStyleElems, 0, styles).computeDirectly(); 1618 new ComputeStyleListWorker(circum, nc, new CompositeList<>(nodes, ways), allStyleElems, 0, styles).computeDirectly(); 1619 } 1606 1620 1607 1621 if (!benchmark.renderSort()) { -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r13434 r13649 1211 1211 public void zoomChanged() { 1212 1212 if (!GraphicsEnvironment.isHeadless()) { 1213 PointerInfo pointerInfo = MouseInfo.getPointerInfo(); 1214 if (pointerInfo != null) { 1215 Point mp = pointerInfo.getLocation(); 1216 updateLatLonText(mp.x, mp.y); 1213 try { 1214 PointerInfo pointerInfo = MouseInfo.getPointerInfo(); 1215 if (pointerInfo != null) { 1216 Point mp = pointerInfo.getLocation(); 1217 updateLatLonText(mp.x, mp.y); 1218 } 1219 } catch (SecurityException ex) { 1220 Logging.log(Logging.LEVEL_ERROR, "Unable to get mouse pointer info", ex); 1217 1221 } 1218 1222 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r13493 r13649 468 468 MainApplication.getMenu().windowMenu.remove(windowMenuItem); 469 469 } 470 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 470 try { 471 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 472 } catch (SecurityException e) { 473 Logging.log(Logging.LEVEL_ERROR, "Unable to remove AWT event listener", e); 474 } 471 475 Config.getPref().removePreferenceChangeListener(this); 472 476 destroyComponents(this, false); … … 977 981 private void dynamicButtonsPropertyChanged() { 978 982 boolean propEnabled = PROP_DYNAMIC_BUTTONS.get(); 979 if (propEnabled) { 980 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_MOTION_EVENT_MASK); 981 } else { 982 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 983 try { 984 if (propEnabled) { 985 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_MOTION_EVENT_MASK); 986 } else { 987 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 988 } 989 } catch (SecurityException e) { 990 Logging.log(Logging.LEVEL_ERROR, "Unable to add/remove AWT event listener", e); 983 991 } 984 992 titleBar.buttonsHide.setVisible(propEnabled); -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetMenu.java
r12646 r13649 24 24 import org.openstreetmap.josm.gui.MainApplication; 25 25 import org.openstreetmap.josm.tools.AlphanumComparator; 26 import org.openstreetmap.josm.tools.Logging; 26 27 27 28 /** … … 100 101 pm.add(copyMenuComponent(c)); 101 102 } 102 PointerInfo pointerInfo = MouseInfo.getPointerInfo(); 103 if (pointerInfo != null) { 104 Point p = pointerInfo.getLocation(); 105 pm.show(Main.parent, p.x-Main.parent.getX(), p.y-Main.parent.getY()); 103 try { 104 PointerInfo pointerInfo = MouseInfo.getPointerInfo(); 105 if (pointerInfo != null) { 106 Point p = pointerInfo.getLocation(); 107 pm.show(Main.parent, p.x-Main.parent.getX(), p.y-Main.parent.getY()); 108 } 109 } catch (SecurityException ex) { 110 Logging.log(Logging.LEVEL_ERROR, "Unable to get mouse pointer info", ex); 106 111 } 107 112 } -
trunk/src/org/openstreetmap/josm/gui/util/AdvancedKeyPressDetector.java
r13270 r13649 82 82 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK); 83 83 } catch (SecurityException ex) { 84 Logging. warn(ex);84 Logging.log(Logging.LEVEL_WARN, "Unable to add AWT event listener", ex); 85 85 } 86 86 timer = new Timer(0, e -> { … … 113 113 Toolkit.getDefaultToolkit().removeAWTEventListener(this); 114 114 } catch (SecurityException ex) { 115 Logging. warn(ex);115 Logging.log(Logging.LEVEL_WARN, "Unable to remove AWT event listener", ex); 116 116 } 117 117 } -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmImageView.java
r12620 r13649 44 44 public JosmImageView(Element elem) throws NoSuchFieldException { 45 45 super(elem); 46 imageField = ImageView.class.getDeclaredField("image");47 stateField = ImageView.class.getDeclaredField("state");48 widthField = ImageView.class.getDeclaredField("width");49 heightField = ImageView.class.getDeclaredField("height");46 imageField = getDeclaredField("image"); 47 stateField = getDeclaredField("state"); 48 widthField = getDeclaredField("width"); 49 heightField = getDeclaredField("height"); 50 50 Utils.setObjectsAccessible(imageField, stateField, widthField, heightField); 51 } 52 53 private static Field getDeclaredField(String name) throws NoSuchFieldException { 54 try { 55 return ImageView.class.getDeclaredField(name); 56 } catch (SecurityException e) { 57 Logging.log(Logging.LEVEL_ERROR, "Unable to access field by reflection", e); 58 return null; 59 } 51 60 } 52 61 -
trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControl.java
r12856 r13649 72 72 try { 73 73 return Class.forName("sun.security.x509.GeneralName") != null; 74 } catch (ClassNotFoundException e) {74 } catch (ClassNotFoundException | SecurityException e) { 75 75 Logging.trace(e); 76 76 return false; -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r13647 r13649 1547 1547 AccessController.doPrivileged((PrivilegedAction<Object>) () -> { 1548 1548 for (AccessibleObject o : objects) { 1549 o.setAccessible(true); 1549 if (o != null) { 1550 o.setAccessible(true); 1551 } 1550 1552 } 1551 1553 return null;
Note:
See TracChangeset
for help on using the changeset viewer.