Changeset 11797 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-03-31T22:11:31+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/BoxTextElement.java
r11452 r11797 108 108 109 109 /** 110 * A rectangle with size 0x0111 */112 public static final Rectangle ZERO_BOX = new Rectangle(0, 0, 0, 0);113 114 /**115 110 * The default style a simple node should use for it's text 116 111 */ … … 138 133 */ 139 134 public TextLabel text; 140 // Either boxProvider or box is not null. If boxProvider is different from 141 // null, this means, that the box can still change in future, otherwise 142 // it is fixed. 135 /** 136 * The {@link HorizontalTextAlignment} for this text. 137 */ 138 public HorizontalTextAlignment hAlign; 139 /** 140 * The {@link VerticalTextAlignment} for this text. 141 */ 142 public VerticalTextAlignment vAlign; 143 143 protected BoxProvider boxProvider; 144 protected Rectangle box;145 /**146 * The {@link HorizontalTextAlignment} for this text.147 */148 public HorizontalTextAlignment hAlign;149 /**150 * The {@link VerticalTextAlignment} for this text.151 */152 public VerticalTextAlignment vAlign;153 144 154 145 /** … … 157 148 * @param text The text to display 158 149 * @param boxProvider The box provider to use 159 * @param box The initial box to use.160 150 * @param hAlign The {@link HorizontalTextAlignment} 161 151 * @param vAlign The {@link VerticalTextAlignment} 162 152 */ 163 public BoxTextElement(Cascade c, TextLabel text, BoxProvider boxProvider, Rectangle box,153 public BoxTextElement(Cascade c, TextLabel text, BoxProvider boxProvider, 164 154 HorizontalTextAlignment hAlign, VerticalTextAlignment vAlign) { 165 155 super(c, 5f); … … 169 159 this.text = text; 170 160 this.boxProvider = boxProvider; 171 this.box = box == null ? ZERO_BOX : box;172 161 this.hAlign = hAlign; 173 162 this.vAlign = vAlign; 174 }175 176 /**177 * Create a new {@link BoxTextElement} with a dynamic box178 * @param env The MapCSS environment179 * @param boxProvider The box provider that computes the box.180 * @return A new {@link BoxTextElement} or <code>null</code> if the creation failed.181 */182 public static BoxTextElement create(Environment env, BoxProvider boxProvider) {183 return create(env, boxProvider, null);184 }185 186 /**187 * Create a new {@link BoxTextElement} with a fixed box188 * @param env The MapCSS environment189 * @param box The box190 * @return A new {@link BoxTextElement} or <code>null</code> if the creation failed.191 */192 public static BoxTextElement create(Environment env, Rectangle box) {193 return create(env, null, box);194 163 } 195 164 … … 198 167 * @param env The MapCSS environment 199 168 * @param boxProvider The box provider. 200 * @param box The box. Only considered if boxProvider is null.201 169 * @return A new {@link BoxTextElement} or <code>null</code> if the creation failed. 202 170 */ 203 public static BoxTextElement create(Environment env, BoxProvider boxProvider , Rectangle box) {171 public static BoxTextElement create(Environment env, BoxProvider boxProvider) { 204 172 initDefaultParameters(); 205 173 … … 244 212 } 245 213 246 return new BoxTextElement(c, text, boxProvider, box,hAlign, vAlign);214 return new BoxTextElement(c, text, boxProvider, hAlign, vAlign); 247 215 } 248 216 … … 252 220 */ 253 221 public Rectangle getBox() { 254 if (boxProvider != null) { 255 BoxProviderResult result = boxProvider.get(); 256 if (!result.isTemporary()) { 257 box = result.getBox(); 258 boxProvider = null; 259 } 260 return result.getBox(); 261 } 262 return box; 222 return boxProvider.get().getBox(); 263 223 } 264 224 … … 285 245 vAlign == that.vAlign && 286 246 Objects.equals(text, that.text) && 287 Objects.equals(boxProvider, that.boxProvider) && 288 Objects.equals(box, that.box); 247 Objects.equals(boxProvider, that.boxProvider); 289 248 } 290 249 291 250 @Override 292 251 public int hashCode() { 293 return Objects.hash(super.hashCode(), text, boxProvider, box,hAlign, vAlign);252 return Objects.hash(super.hashCode(), text, boxProvider, hAlign, vAlign); 294 253 } 295 254 296 255 @Override 297 256 public String toString() { 298 return "BoxTextElem Style{" + super.toString() + ' ' + text.toStringImpl()299 + " box=" + box+ " hAlign=" + hAlign + " vAlign=" + vAlign + '}';257 return "BoxTextElement{" + super.toString() + ' ' + text.toStringImpl() 258 + " box=" + getBox() + " hAlign=" + hAlign + " vAlign=" + vAlign + '}'; 300 259 } 301 260 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/NodeElement.java
r11763 r11797 376 376 @Override 377 377 public String toString() { 378 StringBuilder s = new StringBuilder(64).append("NodeElem Style{").append(super.toString());378 StringBuilder s = new StringBuilder(64).append("NodeElement{").append(super.toString()); 379 379 if (mapImage != null) { 380 380 s.append(" icon=[" + mapImage + ']');
Note:
See TracChangeset
for help on using the changeset viewer.