- Timestamp:
- 2015-04-15T23:51:33+02:00 (10 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r8140 r8199 734 734 } 735 735 736 public void drawNodeIcon(Node n, MapImage img, boolean disabled, boolean selected, boolean member) { 736 public void drawNodeIcon(Node n, MapImage img, boolean disabled, boolean selected, boolean member, double theta) { 737 737 Point p = nc.getPoint(n); 738 738 … … 747 747 g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha)); 748 748 } 749 g.rotate(theta, p.x, p.y); 749 750 g.drawImage(img.getImage(disabled), p.x - w/2 + img.offsetX, p.y - h/2 + img.offsetY, nc); 751 g.rotate(-theta, p.x, p.y); 750 752 g.setPaintMode(); 751 753 if (selected || member) -
trunk/src/org/openstreetmap/josm/gui/mappaint/NodeElemStyle.java
r8133 r8199 19 19 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference; 20 20 import org.openstreetmap.josm.gui.mappaint.StyleCache.StyleList; 21 import org.openstreetmap.josm.gui.util.RotationAngle; 21 22 import org.openstreetmap.josm.tools.Utils; 22 23 … … 26 27 public class NodeElemStyle extends ElemStyle implements StyleKeys { 27 28 public final MapImage mapImage; 29 public final RotationAngle mapImageAngle; 28 30 public final Symbol symbol; 29 31 … … 99 101 public static final StyleList DEFAULT_NODE_STYLELIST_TEXT = new StyleList(NodeElemStyle.SIMPLE_NODE_ELEMSTYLE, BoxTextElemStyle.SIMPLE_NODE_TEXT_ELEMSTYLE); 100 102 101 protected NodeElemStyle(Cascade c, MapImage mapImage, Symbol symbol, float default_major_z_index) { 103 protected NodeElemStyle(Cascade c, MapImage mapImage, Symbol symbol, float default_major_z_index, RotationAngle rotationAngle) { 102 104 super(c, default_major_z_index); 103 105 this.mapImage = mapImage; 104 106 this.symbol = symbol; 107 this.mapImageAngle = rotationAngle; 105 108 } 106 109 … … 117 120 symbol = createSymbol(env); 118 121 } 122 final String rotationString = c.get("icon-rotation", null, String.class); 123 RotationAngle rotationAngle = null; 124 if ("way".equalsIgnoreCase(rotationString)) { 125 rotationAngle = RotationAngle.buildWayDirectionRotation(); 126 } else if (rotationString != null) { 127 try { 128 rotationAngle = RotationAngle.buildStaticRotation(rotationString); 129 } catch (RuntimeException ignore) { 130 } 131 } 119 132 120 133 // optimization: if we neither have a symbol, nor a mapImage … … 123 136 if (!allowDefault && symbol == null && mapImage == null) return null; 124 137 125 return new NodeElemStyle(c, mapImage, symbol, default_major_z_index); 138 return new NodeElemStyle(c, mapImage, symbol, default_major_z_index, rotationAngle); 126 139 } 127 140 … … 257 270 Node n = (Node) primitive; 258 271 if (mapImage != null && painter.isShowIcons()) { 259 painter.drawNodeIcon(n, mapImage, painter.isInactiveMode() || n.isDisabled(), selected, member); 272 painter.drawNodeIcon(n, mapImage, painter.isInactiveMode() || n.isDisabled(), selected, member, 273 mapImageAngle == null ? 0.0 : mapImageAngle.getRotationAngle(primitive)); 260 274 } else if (symbol != null) { 261 275 Color fillColor = symbol.fillColor; -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ExpressionFactory.java
r7937 r8199 30 30 import org.openstreetmap.josm.gui.mappaint.Cascade; 31 31 import org.openstreetmap.josm.gui.mappaint.Environment; 32 import org.openstreetmap.josm.gui.util.RotationAngle; 32 33 import org.openstreetmap.josm.io.XmlWriter; 33 34 import org.openstreetmap.josm.tools.ColorHelper; … … 547 548 548 549 /** 550 * Converts an angle in degrees to radians. 551 * @param degree the angle in degrees 552 * @return the angle in radians 553 * @see Math#toRadians(double) 554 */ 555 public static double degree_to_radians(double degree) { 556 return Math.toRadians(degree); 557 } 558 559 /** 560 * Converts an angle diven in cardinal directions to radians. 561 * The following values are supported: {@code n}, {@code north}, {@code ne}, {@code northeast}, 562 * {@code e}, {@code east}, {@code se}, {@code southeast}, {@code s}, {@code south}, 563 * {@code sw}, {@code southwest}, {@code w}, {@code west}, {@code nw}, {@code northwest}. 564 * @param cardinal the angle in cardinal directions. 565 * @see RotationAngle#parseCardinalRotation(String) 566 * @return the angle in radians 567 */ 568 public static Double cardinal_to_radians(String cardinal) { 569 try { 570 return RotationAngle.parseCardinalRotation(cardinal); 571 } catch (IllegalArgumentException ignore) { 572 return null; 573 } 574 } 575 576 /** 549 577 * Determines if the objects {@code a} and {@code b} are equal. 550 578 * @param a First object
Note:
See TracChangeset
for help on using the changeset viewer.