Changeset 11758 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-03-21T13:39:51+01:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r11755 r11758 61 61 import org.openstreetmap.josm.data.osm.visitor.paint.relations.Multipolygon.PolyData; 62 62 import org.openstreetmap.josm.data.osm.visitor.paint.relations.MultipolygonCache; 63 import org.openstreetmap.josm.data.preferences.AbstractProperty; 64 import org.openstreetmap.josm.data.preferences.BooleanProperty; 65 import org.openstreetmap.josm.data.preferences.IntegerProperty; 66 import org.openstreetmap.josm.data.preferences.StringProperty; 63 67 import org.openstreetmap.josm.gui.MapViewState.MapViewPoint; 64 68 import org.openstreetmap.josm.gui.NavigatableComponent; … … 263 267 private static final double cosPHI = Math.cos(PHI); 264 268 private static final double sinPHI = Math.sin(PHI); 269 /** 270 * If we should use left hand traffic. 271 */ 272 private static final AbstractProperty<Boolean> PREFERENCE_LEFT_HAND_TRAFFIC 273 = new BooleanProperty("mappaint.lefthandtraffic", false).cached(); 274 /** 275 * Indicates that the renderer should enable anti-aliasing 276 * @since 11758 277 */ 278 public static final AbstractProperty<Boolean> PREFERENCE_ANTIALIASING_USE 279 = new BooleanProperty("mappaint.use-antialiasing", true).cached(); 280 /** 281 * The mode that is used for anti-aliasing 282 * @since 11758 283 */ 284 public static final AbstractProperty<String> PREFERENCE_TEXT_ANTIALIASING 285 = new StringProperty("mappaint.text-antialiasing", "default").cached(); 286 287 /** 288 * The line with to use for highlighting 289 */ 290 private static final AbstractProperty<Integer> HIGHLIGHT_LINE_WIDTH = new IntegerProperty("mappaint.highlight.width", 4).cached(); 291 private static final AbstractProperty<Integer> HIGHLIGHT_POINT_RADIUS = new IntegerProperty("mappaint.highlight.radius", 7).cached(); 292 private static final AbstractProperty<Integer> WIDER_HIGHLIGHT = new IntegerProperty("mappaint.highlight.bigger-increment", 5).cached(); 293 private static final AbstractProperty<Integer> HIGHLIGHT_STEP = new IntegerProperty("mappaint.highlight.step", 4).cached(); 265 294 266 295 private Collection<WaySegment> highlightWaySegments; 267 268 // highlight customization fields269 private int highlightLineWidth;270 private int highlightPointRadius;271 private int widerHighlight;272 private int highlightStep;273 296 274 297 //flag that activate wider highlight mode … … 783 806 /** 784 807 * highlights a given GeneralPath using the settings from BasicStroke to match the line's 785 * style. Width of the highlight is hard coded.808 * style. Width of the highlight can be changed by user preferences 786 809 * @param path path to draw 787 810 * @param line line style … … 791 814 return; 792 815 g.setColor(highlightColorTransparent); 793 float w = line.getLineWidth() + highlightLineWidth; 794 if (useWiderHighlight) w += widerHighlight; 816 float w = line.getLineWidth() + HIGHLIGHT_LINE_WIDTH.get(); 817 if (useWiderHighlight) { 818 w += WIDER_HIGHLIGHT.get(); 819 } 820 int step = Math.max(HIGHLIGHT_STEP.get(), 1); 795 821 while (w >= line.getLineWidth()) { 796 822 g.setStroke(new BasicStroke(w, line.getEndCap(), line.getLineJoin(), line.getMiterLimit())); 797 823 g.draw(path); 798 w -= highlightStep;824 w -= step; 799 825 } 800 826 } … … 808 834 private void drawPointHighlight(Point2D p, int size) { 809 835 g.setColor(highlightColorTransparent); 810 int s = size + highlightPointRadius; 811 if (useWiderHighlight) s += widerHighlight; 836 int s = size + HIGHLIGHT_POINT_RADIUS.get(); 837 if (useWiderHighlight) { 838 s += WIDER_HIGHLIGHT.get(); 839 } 840 int step = Math.max(HIGHLIGHT_STEP.get(), 1); 812 841 while (s >= size) { 813 842 int r = (int) Math.floor(s/2d); 814 843 g.fill(new RoundRectangle2D.Double(p.getX()-r, p.getY()-r, s, s, r, r)); 815 s -= highlightStep;844 s -= step; 816 845 } 817 846 } … … 1041 1070 private void displayText(OsmPrimitive osm, TextLabel text, String name, Rectangle2D nb, 1042 1071 MapViewPositionAndRotation center) { 1043 AffineTransform at = AffineTransform.getTranslateInstance(center.getPoint().getInViewX(), center.getPoint().getInViewY()); 1044 at.rotate(center.getRotation()); 1045 at.translate(-nb.getCenterX(), -nb.getCenterY()); 1072 AffineTransform at = new AffineTransform(); 1073 if (Math.abs(center.getRotation()) < .01) { 1074 // Explicitly no rotation: move to full pixels. 1075 at.setToTranslation(Math.round(center.getPoint().getInViewX() - nb.getCenterX()), 1076 Math.round(center.getPoint().getInViewY() - nb.getCenterY())); 1077 } else { 1078 at.setToTranslation(center.getPoint().getInViewX(), center.getPoint().getInViewY()); 1079 at.rotate(center.getRotation()); 1080 at.translate(-nb.getCenterX(), -nb.getCenterY()); 1081 } 1046 1082 displayText(() -> { 1047 1083 AffineTransform defaultTransform = g.getTransform(); … … 1261 1297 scale = nc.getScale(); 1262 1298 1263 leftHandTraffic = Main.pref.getBoolean("mappaint.lefthandtraffic", false);1299 leftHandTraffic = PREFERENCE_LEFT_HAND_TRAFFIC.get(); 1264 1300 1265 1301 useStrokes = paintSettings.getUseStrokesDistance() > circum; … … 1268 1304 isOutlineOnly = paintSettings.isOutlineOnly(); 1269 1305 1270 antialiasing = Main.pref.getBoolean("mappaint.use-antialiasing", true) ?1306 antialiasing = PREFERENCE_ANTIALIASING_USE.get() ? 1271 1307 RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF; 1272 1308 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antialiasing); 1273 1309 1274 1310 Object textAntialiasing; 1275 switch ( Main.pref.get("mappaint.text-antialiasing", "default")) {1311 switch (PREFERENCE_TEXT_ANTIALIASING.get()) { 1276 1312 case "on": 1277 1313 textAntialiasing = RenderingHints.VALUE_TEXT_ANTIALIAS_ON; … … 1299 1335 } 1300 1336 g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, textAntialiasing); 1301 1302 highlightLineWidth = Main.pref.getInteger("mappaint.highlight.width", 4);1303 highlightPointRadius = Main.pref.getInteger("mappaint.highlight.radius", 7);1304 widerHighlight = Main.pref.getInteger("mappaint.highlight.bigger-increment", 5);1305 highlightStep = Main.pref.getInteger("mappaint.highlight.step", 4);1306 1337 } 1307 1338
Note:
See TracChangeset
for help on using the changeset viewer.