- Timestamp:
- 2016-07-22T22:30:54+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapView.java
r10496 r10586 920 920 synchronized (temporaryLayers) { 921 921 for (MapViewPaintable mvp : temporaryLayers) { 922 mvp.paint(tempG, this, box); 922 try { 923 mvp.paint(tempG, this, box); 924 } catch (RuntimeException e) { 925 throw BugReport.intercept(e).put("mvp", mvp); 926 } 923 927 } 924 928 } 925 929 926 930 // draw world borders 927 tempG.setColor(Color.WHITE); 928 Bounds b = getProjection().getWorldBoundsLatLon(); 929 double lat = b.getMinLat(); 930 double lon = b.getMinLon(); 931 932 Point p = getPoint(b.getMin()); 933 934 GeneralPath path = new GeneralPath(); 935 936 double d = 1.0; 937 path.moveTo(p.x, p.y); 938 double max = b.getMax().lat(); 939 for (; lat <= max; lat += d) { 940 p = getPoint(new LatLon(lat >= max ? max : lat, lon)); 941 path.lineTo(p.x, p.y); 942 } 943 lat = max; max = b.getMax().lon(); 944 for (; lon <= max; lon += d) { 945 p = getPoint(new LatLon(lat, lon >= max ? max : lon)); 946 path.lineTo(p.x, p.y); 947 } 948 lon = max; max = b.getMinLat(); 949 for (; lat >= max; lat -= d) { 950 p = getPoint(new LatLon(lat <= max ? max : lat, lon)); 951 path.lineTo(p.x, p.y); 952 } 953 lat = max; max = b.getMinLon(); 954 for (; lon >= max; lon -= d) { 955 p = getPoint(new LatLon(lat, lon <= max ? max : lon)); 956 path.lineTo(p.x, p.y); 957 } 958 959 int w = getWidth(); 960 int h = getHeight(); 961 962 // Work around OpenJDK having problems when drawing out of bounds 963 final Area border = new Area(path); 964 // Make the viewport 1px larger in every direction to prevent an 965 // additional 1px border when zooming in 966 final Area viewport = new Area(new Rectangle(-1, -1, w + 2, h + 2)); 967 border.intersect(viewport); 968 tempG.draw(border); 931 try { 932 drawWorldBorders(tempG); 933 } catch (RuntimeException e) { 934 throw BugReport.intercept(e).put("bounds", () -> getProjection().getWorldBoundsLatLon()); 935 } 969 936 970 937 if (Main.isDisplayingMapView() && Main.map.filterDialog != null) { … … 1007 974 } 1008 975 976 private void drawWorldBorders(Graphics2D tempG) { 977 tempG.setColor(Color.WHITE); 978 Bounds b = getProjection().getWorldBoundsLatLon(); 979 double lat = b.getMinLat(); 980 double lon = b.getMinLon(); 981 982 Point p = getPoint(b.getMin()); 983 984 GeneralPath path = new GeneralPath(); 985 986 double d = 1.0; 987 path.moveTo(p.x, p.y); 988 double max = b.getMax().lat(); 989 for (; lat <= max; lat += d) { 990 p = getPoint(new LatLon(lat >= max ? max : lat, lon)); 991 path.lineTo(p.x, p.y); 992 } 993 lat = max; max = b.getMax().lon(); 994 for (; lon <= max; lon += d) { 995 p = getPoint(new LatLon(lat, lon >= max ? max : lon)); 996 path.lineTo(p.x, p.y); 997 } 998 lon = max; max = b.getMinLat(); 999 for (; lat >= max; lat -= d) { 1000 p = getPoint(new LatLon(lat <= max ? max : lat, lon)); 1001 path.lineTo(p.x, p.y); 1002 } 1003 lat = max; max = b.getMinLon(); 1004 for (; lon >= max; lon -= d) { 1005 p = getPoint(new LatLon(lat, lon <= max ? max : lon)); 1006 path.lineTo(p.x, p.y); 1007 } 1008 1009 int w = getWidth(); 1010 int h = getHeight(); 1011 1012 // Work around OpenJDK having problems when drawing out of bounds 1013 final Area border = new Area(path); 1014 // Make the viewport 1px larger in every direction to prevent an 1015 // additional 1px border when zooming in 1016 final Area viewport = new Area(new Rectangle(-1, -1, w + 2, h + 2)); 1017 border.intersect(viewport); 1018 tempG.draw(border); 1019 } 1020 1009 1021 /** 1010 1022 * Sets up the viewport to prepare for drawing the view. -
trunk/src/org/openstreetmap/josm/gui/MapViewState.java
r10486 r10586 18 18 import org.openstreetmap.josm.data.projection.Projection; 19 19 import org.openstreetmap.josm.gui.download.DownloadDialog; 20 import org.openstreetmap.josm.tools.bugreport.BugReport; 20 21 21 22 /** … … 97 98 component = component.getParent(); 98 99 } 99 topLeftOnScreen = position.getLocationOnScreen(); 100 try { 101 topLeftOnScreen = position.getLocationOnScreen(); 102 } catch (RuntimeException e) { 103 throw BugReport.intercept(e).put("position", position).put("parent", () -> position.getParent()); 104 } 100 105 } 101 106 -
trunk/src/org/openstreetmap/josm/tools/bugreport/BugReport.java
r10585 r10586 20 20 * You should then add some debug information there. This can be the OSM ids that caused the error, information on the data you were working on 21 21 * or other local variables. Make sure that no excpetions may occur while computing the values. It is best to send plain local variables to 22 * put(...). Then simply throw the throwable you got from the bug report. The global exception handler will do the rest. 22 * put(...). If you need to do computations, put them into a lambda expression. Then simply throw the throwable you got from the bug report. 23 * The global exception handler will do the rest. 23 24 * <pre> 24 25 * int id = ...; … … 27 28 * ... your code ... 28 29 * } catch (RuntimeException t) { 29 * throw BugReport.intercept(t).put("id", id).put("tag", tag);30 * throw BugReport.intercept(t).put("id", id).put("tag", () -> x.getTag()); 30 31 * } 31 32 * </pre> 32 33 * 33 34 * Instead of re-throwing, you can call {@link ReportedException#warn()}. This will display a warning to the user and allow it to either report 34 * the ex ecption or ignore it.35 * the exception or ignore it. 35 36 * 36 37 * @author Michael Zangl -
trunk/src/org/openstreetmap/josm/tools/bugreport/ReportedException.java
r10585 r10586 17 17 import java.util.NoSuchElementException; 18 18 import java.util.Set; 19 import java.util.function.Supplier; 19 20 20 21 import org.openstreetmap.josm.Main; … … 180 181 181 182 /** 182 * Adds some debug values to this exception. 183 * Adds some debug values to this exception. The value is converted to a string. Errors during conversion are handled. 183 184 * 184 185 * @param key … … 189 190 */ 190 191 public ReportedException put(String key, Object value) { 192 return put(key, () -> value); 193 } 194 195 /** 196 * Adds some debug values to this exception. This method automatically catches errors that occur during the production of the value. 197 * 198 * @param key 199 * The key to add this for. Does not need to be unique but it would be nice. 200 * @param valueSupplier 201 * A supplier that is called once to get the value. 202 * @return This exception for easy chaining. 203 * @since 10586 204 */ 205 public ReportedException put(String key, Supplier<Object> valueSupplier) { 191 206 String string; 192 207 try { 208 Object value = valueSupplier.get(); 193 209 if (value == null) { 194 210 string = "null";
Note:
See TracChangeset
for help on using the changeset viewer.