Changeset 9278 in josm for trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/BoxTextElement.java
- Timestamp:
- 2016-01-03T15:50:53+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/BoxTextElement.java
r9275 r9278 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.mappaint ;2 package org.openstreetmap.josm.gui.mappaint.styleelement; 3 3 4 4 import java.awt.Color; … … 10 10 import org.openstreetmap.josm.data.osm.visitor.paint.PaintColors; 11 11 import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer; 12 import org.openstreetmap.josm.gui.mappaint.Cascade; 13 import org.openstreetmap.josm.gui.mappaint.Environment; 14 import org.openstreetmap.josm.gui.mappaint.Keyword; 15 import org.openstreetmap.josm.gui.mappaint.MultiCascade; 12 16 import org.openstreetmap.josm.tools.CheckParameterUtil; 13 17 … … 15 19 * Text style attached to a style with a bounding box, like an icon or a symbol. 16 20 */ 17 public class BoxTextElem Style extends ElemStyle{21 public class BoxTextElement extends StyleElement { 18 22 19 23 public enum HorizontalTextAlignment { LEFT, CENTER, RIGHT } … … 85 89 public static final Rectangle ZERO_BOX = new Rectangle(0, 0, 0, 0); 86 90 87 public Text Elementtext;91 public TextLabel text; 88 92 // Either boxProvider or box is not null. If boxProvider is different from 89 93 // null, this means, that the box can still change in future, otherwise … … 94 98 public VerticalTextAlignment vAlign; 95 99 96 public BoxTextElem Style(Cascade c, TextElementtext, BoxProvider boxProvider, Rectangle box,100 public BoxTextElement(Cascade c, TextLabel text, BoxProvider boxProvider, Rectangle box, 97 101 HorizontalTextAlignment hAlign, VerticalTextAlignment vAlign) { 98 102 super(c, 5f); … … 107 111 } 108 112 109 public static BoxTextElem Stylecreate(Environment env, BoxProvider boxProvider) {113 public static BoxTextElement create(Environment env, BoxProvider boxProvider) { 110 114 return create(env, boxProvider, null); 111 115 } 112 116 113 public static BoxTextElem Stylecreate(Environment env, Rectangle box) {117 public static BoxTextElement create(Environment env, Rectangle box) { 114 118 return create(env, null, box); 115 119 } 116 120 117 public static BoxTextElem Stylecreate(Environment env, BoxProvider boxProvider, Rectangle box) {121 public static BoxTextElement create(Environment env, BoxProvider boxProvider, Rectangle box) { 118 122 initDefaultParameters(); 119 123 Cascade c = env.mc.getCascade(env.layer); 120 124 121 Text Element text = TextElement.create(env, DEFAULT_TEXT_COLOR, false);125 TextLabel text = TextLabel.create(env, DEFAULT_TEXT_COLOR, false); 122 126 if (text == null) return null; 123 127 // Skip any primitives that don't have text to draw. (Styles are recreated for any tag change.) 124 128 // The concrete text to render is not cached in this object, but computed for each 125 // repaint. This way, one BoxTextElem Styleobject can be used by multiple primitives (to save memory).129 // repaint. This way, one BoxTextElement object can be used by multiple primitives (to save memory). 126 130 if (text.labelCompositionStrategy.compose(env.osm) == null) return null; 127 131 … … 154 158 } 155 159 156 return new BoxTextElem Style(c, text, boxProvider, box, hAlign, vAlign);160 return new BoxTextElement(c, text, boxProvider, box, hAlign, vAlign); 157 161 } 158 162 … … 169 173 } 170 174 171 public static final BoxTextElem StyleSIMPLE_NODE_TEXT_ELEMSTYLE;175 public static final BoxTextElement SIMPLE_NODE_TEXT_ELEMSTYLE; 172 176 static { 173 177 MultiCascade mc = new MultiCascade(); … … 176 180 Node n = new Node(); 177 181 n.put("name", "dummy"); 178 SIMPLE_NODE_TEXT_ELEMSTYLE = create(new Environment(n, mc, "default", null), NodeElem Style.SIMPLE_NODE_ELEMSTYLE.getBoxProvider());182 SIMPLE_NODE_TEXT_ELEMSTYLE = create(new Environment(n, mc, "default", null), NodeElement.SIMPLE_NODE_ELEMSTYLE.getBoxProvider()); 179 183 if (SIMPLE_NODE_TEXT_ELEMSTYLE == null) throw new AssertionError(); 180 184 } … … 207 211 if (obj == null || getClass() != obj.getClass()) 208 212 return false; 209 final BoxTextElem Style other = (BoxTextElemStyle) obj;213 final BoxTextElement other = (BoxTextElement) obj; 210 214 if (!text.equals(other.text)) return false; 211 215 if (boxProvider != null) {
Note:
See TracChangeset
for help on using the changeset viewer.