diff --git a/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java b/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
index c477314de..9482e05d6 100644
|
a
|
b
|
public void drawBoxText(INode n, BoxTextElement bs) {
|
| 660 | 660 | } else throw new AssertionError(); |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | | displayText(n, text, s, bounds, new MapViewPositionAndRotation(mapState.getForView(x, y), 0)); |
| | 663 | displayText(n, text, s, bounds, new MapViewPositionAndRotation(mapState.getForView(x, y), text.rotationAngle.getRotationAngle(n))); |
| 664 | 664 | g.setFont(defaultFont); |
| 665 | 665 | } |
| 666 | 666 | |
diff --git a/src/org/openstreetmap/josm/gui/mappaint/StyleKeys.java b/src/org/openstreetmap/josm/gui/mappaint/StyleKeys.java
index 1b45272cb..53a216257 100644
|
a
|
b
|
|
| 90 | 90 | * MapCSS icon-rotation property key |
| 91 | 91 | */ |
| 92 | 92 | String ICON_ROTATION = "icon-rotation"; |
| | 93 | /** |
| | 94 | * MapCSS text-rotation property key |
| | 95 | */ |
| | 96 | String TEXT_ROTATION = "text-rotation"; |
| 93 | 97 | /** |
| 94 | 98 | * MapCSS icon-width property key |
| 95 | 99 | */ |
diff --git a/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java b/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java
index a0a184537..f89530a00 100644
|
a
|
b
|
static NodeElement create(Environment env, float defaultMajorZindex, boolean all
|
| 86 | 86 | * @since 11670 |
| 87 | 87 | */ |
| 88 | 88 | public static RotationAngle createRotationAngle(Environment env) { |
| | 89 | return createRotationAngle(env, ICON_ROTATION); |
| | 90 | } |
| | 91 | |
| | 92 | public static RotationAngle createTextRotationAngle(Environment env) { |
| | 93 | return createRotationAngle(env, TEXT_ROTATION); |
| | 94 | } |
| | 95 | |
| | 96 | private static RotationAngle createRotationAngle(Environment env, String key) { |
| 89 | 97 | Cascade c = env.mc.getCascade(env.layer); |
| 90 | 98 | |
| 91 | 99 | RotationAngle rotationAngle = RotationAngle.NO_ROTATION; |
| 92 | | final Float angle = c.get(ICON_ROTATION, null, Float.class, true); |
| | 100 | final Float angle = c.get(key, null, Float.class, true); |
| 93 | 101 | if (angle != null) { |
| 94 | 102 | rotationAngle = RotationAngle.buildStaticRotation(angle); |
| 95 | 103 | } else { |
| 96 | | final Keyword rotationKW = c.get(ICON_ROTATION, null, Keyword.class); |
| | 104 | final Keyword rotationKW = c.get(key, null, Keyword.class); |
| 97 | 105 | if (rotationKW != null) { |
| 98 | 106 | if ("way".equals(rotationKW.val)) { |
| 99 | 107 | rotationAngle = RotationAngle.buildWayDirectionRotation(); |
diff --git a/src/org/openstreetmap/josm/gui/mappaint/styleelement/TextLabel.java b/src/org/openstreetmap/josm/gui/mappaint/styleelement/TextLabel.java
index 829385f8a..a45b0b0dc 100644
|
a
|
b
|
|
| 17 | 17 | import org.openstreetmap.josm.gui.mappaint.styleelement.LabelCompositionStrategy.StaticLabelCompositionStrategy; |
| 18 | 18 | import org.openstreetmap.josm.gui.mappaint.styleelement.LabelCompositionStrategy.TagLookupCompositionStrategy; |
| 19 | 19 | import org.openstreetmap.josm.tools.CheckParameterUtil; |
| | 20 | import org.openstreetmap.josm.tools.RotationAngle; |
| 20 | 21 | import org.openstreetmap.josm.tools.Utils; |
| 21 | 22 | |
| 22 | 23 | /** |
| … |
… |
|
| 38 | 39 | * the font to be used when rendering |
| 39 | 40 | */ |
| 40 | 41 | public Font font; |
| | 42 | public RotationAngle rotationAngle; |
| 41 | 43 | /** |
| 42 | 44 | * The color to draw the text in, includes alpha. |
| 43 | 45 | */ |
| … |
… |
|
| 57 | 59 | * @param strategy the strategy indicating how the text is composed for a specific {@link OsmPrimitive} to be rendered. |
| 58 | 60 | * If null, no label is rendered. |
| 59 | 61 | * @param font the font to be used. Must not be null. |
| | 62 | * @param rotationAngle the rotation angle to be used. Must not be null. |
| 60 | 63 | * @param color the color to be used. Must not be null |
| 61 | 64 | * @param haloRadius halo radius |
| 62 | 65 | * @param haloColor halo color |
| 63 | 66 | */ |
| 64 | | protected TextLabel(LabelCompositionStrategy strategy, Font font, Color color, Float haloRadius, |
| 65 | | Color haloColor) { |
| | 67 | protected TextLabel(LabelCompositionStrategy strategy, Font font, RotationAngle rotationAngle, Color color, Float haloRadius, |
| | 68 | Color haloColor) { |
| 66 | 69 | this.labelCompositionStrategy = strategy; |
| 67 | 70 | this.font = Objects.requireNonNull(font, "font"); |
| | 71 | this.rotationAngle = Objects.requireNonNull(rotationAngle, "rotationAngle"); |
| 68 | 72 | this.color = Objects.requireNonNull(color, "color"); |
| 69 | 73 | this.haloRadius = haloRadius; |
| 70 | 74 | this.haloColor = haloColor; |
| … |
… |
protected TextLabel(LabelCompositionStrategy strategy, Font font, Color color, F
|
| 78 | 82 | public TextLabel(TextLabel other) { |
| 79 | 83 | this.labelCompositionStrategy = other.labelCompositionStrategy; |
| 80 | 84 | this.font = other.font; |
| | 85 | this.rotationAngle = other.rotationAngle; |
| 81 | 86 | this.color = other.color; |
| 82 | 87 | this.haloColor = other.haloColor; |
| 83 | 88 | this.haloRadius = other.haloRadius; |
| … |
… |
public static TextLabel create(Environment env, Color defaultTextColor, boolean
|
| 136 | 141 | String s = strategy.compose(env.osm); |
| 137 | 142 | if (s == null) return null; |
| 138 | 143 | Font font = StyleElement.getFont(c, s); |
| | 144 | RotationAngle rotationAngle = NodeElement.createTextRotationAngle(env); |
| 139 | 145 | |
| 140 | 146 | Color color = c.get(TEXT_COLOR, defaultTextColor, Color.class); |
| 141 | 147 | float alpha = c.get(TEXT_OPACITY, 1f, Float.class); |
| … |
… |
public static TextLabel create(Environment env, Color defaultTextColor, boolean
|
| 152 | 158 | haloColor = Utils.alphaMultiply(haloColor, haloAlphaFactor); |
| 153 | 159 | } |
| 154 | 160 | |
| 155 | | return new TextLabel(strategy, font, color, haloRadius, haloColor); |
| | 161 | return new TextLabel(strategy, font, rotationAngle, color, haloRadius, haloColor); |
| 156 | 162 | } |
| 157 | 163 | |
| 158 | 164 | /** |
| … |
… |
protected String toStringImpl() {
|
| 198 | 204 | StringBuilder sb = new StringBuilder(96); |
| 199 | 205 | sb.append("labelCompositionStrategy=").append(labelCompositionStrategy) |
| 200 | 206 | .append(" font=").append(font) |
| 201 | | .append(" color=").append(Utils.toString(color)); |
| | 207 | .append(" color=").append(Utils.toString(color)) |
| | 208 | .append(" rotationAngle=").append(rotationAngle); |
| 202 | 209 | if (haloRadius != null) { |
| 203 | 210 | sb.append(" haloRadius=").append(haloRadius) |
| 204 | 211 | .append(" haloColor=").append(haloColor); |
| … |
… |
protected String toStringImpl() {
|
| 208 | 215 | |
| 209 | 216 | @Override |
| 210 | 217 | public int hashCode() { |
| 211 | | return Objects.hash(labelCompositionStrategy, font, color, haloRadius, haloColor); |
| | 218 | return Objects.hash(labelCompositionStrategy, font, rotationAngle, color, haloRadius, haloColor); |
| 212 | 219 | } |
| 213 | 220 | |
| 214 | 221 | @Override |
| … |
… |
public boolean equals(Object obj) {
|
| 218 | 225 | TextLabel textLabel = (TextLabel) obj; |
| 219 | 226 | return Objects.equals(labelCompositionStrategy, textLabel.labelCompositionStrategy) && |
| 220 | 227 | Objects.equals(font, textLabel.font) && |
| | 228 | Objects.equals(rotationAngle, textLabel.rotationAngle) && |
| 221 | 229 | Objects.equals(color, textLabel.color) && |
| 222 | 230 | Objects.equals(haloRadius, textLabel.haloRadius) && |
| 223 | 231 | Objects.equals(haloColor, textLabel.haloColor); |
diff --git a/styles/standard/elemstyles.mapcss b/styles/standard/elemstyles.mapcss
index 9d7a62948..7b23d5424 100644
|
a
|
b
|
node[amenity=cafe] {
|
| 2585 | 2585 | set icon_z17; |
| 2586 | 2586 | } |
| 2587 | 2587 | node[amenity=restaurant] { |
| | 2588 | text-rotation: 45; |
| 2588 | 2589 | icon-image: "presets/food/restaurant.svg"; |
| 2589 | 2590 | set icon_z17; |
| 2590 | 2591 | } |