Changeset 10874 in josm for trunk/src/org/openstreetmap/josm/gui/util
- Timestamp:
- 2016-08-22T20:44:34+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
r10712 r10874 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.BasicStroke;7 6 import java.awt.Color; 8 7 import java.awt.Component; … … 50 49 51 50 import org.openstreetmap.josm.Main; 51 import org.openstreetmap.josm.data.preferences.StrokeProperty; 52 52 import org.openstreetmap.josm.gui.ExtendedDialog; 53 53 import org.openstreetmap.josm.gui.widgets.HtmlPanel; … … 300 300 * @param code = 3.5 -> thickness=3.5px; 3.5 10 5 -> thickness=3.5px, dashed: 10px filled + 5px empty 301 301 * @return stroke for drawing 302 * @see StrokeProperty 302 303 */ 303 304 public static Stroke getCustomizedStroke(String code) { 304 String[] s = code.trim().split("[^\\.0-9]+"); 305 306 if (s.length == 0) return new BasicStroke(); 307 float w; 308 try { 309 w = Float.parseFloat(s[0]); 310 } catch (NumberFormatException ex) { 311 w = 1.0f; 312 } 313 if (s.length > 1) { 314 float[] dash = new float[s.length-1]; 315 float sumAbs = 0; 316 try { 317 for (int i = 0; i < s.length-1; i++) { 318 dash[i] = Float.parseFloat(s[i+1]); 319 sumAbs += Math.abs(dash[i]); 320 } 321 } catch (NumberFormatException ex) { 322 Main.error("Error in stroke preference format: "+code); 323 dash = new float[]{5.0f}; 324 } 325 if (sumAbs < 1e-1) { 326 Main.error("Error in stroke dash format (all zeros): "+code); 327 return new BasicStroke(w); 328 } 329 // dashed stroke 330 return new BasicStroke(w, BasicStroke.CAP_BUTT, 331 BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); 332 } else { 333 if (w > 1) { 334 // thick stroke 335 return new BasicStroke(w, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); 336 } else { 337 // thin stroke 338 return new BasicStroke(w); 339 } 340 } 305 return StrokeProperty.getFromString(code); 341 306 } 342 307
Note:
See TracChangeset
for help on using the changeset viewer.