Changeset 5739 in josm
- Timestamp:
- 2013-02-21T19:11:14+01:00 (12 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r5555 r5739 69 69 import org.openstreetmap.josm.gui.layer.MapViewPaintable; 70 70 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 71 import org.openstreetmap.josm.gui.util.GuiHelper; 71 72 import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher; 72 73 import org.openstreetmap.josm.tools.Geometry; … … 116 117 private final JCheckBoxMenuItem snapCheckboxMenuItem; 117 118 private boolean useRepeatedShortcut; 118 119 private Stroke rubberLineStroke; 120 private static final BasicStroke BASIC_STROKE = new BasicStroke(1); 121 119 122 public DrawAction(MapFrame mapFrame) { 120 123 super(tr("Draw"), "node/autonode", tr("Draw nodes"), … … 199 202 return; 200 203 super.enterMode(); 201 selectedColor =PaintColors.SELECTED.get(); 204 205 selectedColor = Main.pref.getColor(marktr("helper-line") ,PaintColors.SELECTED.get()); 206 rubberLineStroke = GuiHelper.getCustomizedStroke(Main.pref.get("draw.stroke.helper-line","3")); 202 207 drawHelperLine = Main.pref.getBoolean("draw.helper-line", true); 203 208 drawTargetHighlight = Main.pref.getBoolean("draw.target-highlight", true); … … 1109 1114 if (!snapHelper.isActive()) { // else use color and stoke from snapHelper.draw 1110 1115 g2.setColor(selectedColor); 1111 g2.setStroke( new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));1116 g2.setStroke(rubberLineStroke); 1112 1117 } else if (!snapHelper.drawConstructionGeometry) 1113 1118 return; … … 1127 1132 1128 1133 g2.draw(b); 1129 g2.setStroke( new BasicStroke(1));1134 g2.setStroke(BASIC_STROKE); 1130 1135 } 1131 1136 … … 1310 1315 1311 1316 JCheckBoxMenuItem checkBox; 1312 1317 public final Color ORANGE_TRANSPARENT = new Color(Color.ORANGE.getRed(),Color.ORANGE.getGreen(),Color.ORANGE.getBlue(),128); 1318 1313 1319 public void init() { 1314 1320 snapOn=false; … … 1339 1345 useRepeatedShortcut = Main.pref.getBoolean("draw.anglesnap.toggleOnRepeatedA", true); 1340 1346 1341 normalStroke = new BasicStroke(3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);1347 normalStroke = rubberLineStroke; 1342 1348 snapHelperColor = Main.pref.getColor(marktr("draw angle snap"), Color.ORANGE); 1343 1349 1344 highlightColor = Main.pref.getColor(marktr("draw angle snap highlight"), 1345 new Color(Color.ORANGE.getRed(),Color.ORANGE.getGreen(),Color.ORANGE.getBlue(),128)); 1346 highlightStroke = new BasicStroke(10, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); 1347 1348 float dash1[] = { 4.0f }; 1349 helperStroke = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, 1350 BasicStroke.JOIN_MITER, 10.0f, dash1, 0.0f); 1350 highlightColor = Main.pref.getColor(marktr("draw angle snap highlight"), ORANGE_TRANSPARENT); 1351 highlightStroke = GuiHelper.getCustomizedStroke(Main.pref.get("draw.anglesnap.stroke.highlight","10")); 1352 helperStroke = GuiHelper.getCustomizedStroke(Main.pref.get("draw.anglesnap.stroke.helper","1 4")); 1351 1353 } 1352 1354 -
trunk/src/org/openstreetmap/josm/gui/util/GuiHelper.java
r5735 r5739 2 2 package org.openstreetmap.josm.gui.util; 3 3 4 import java.awt.BasicStroke; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 9 10 import java.awt.Dimension; 10 11 import java.awt.Image; 12 import java.awt.Stroke; 11 13 import java.awt.Toolkit; 12 14 import java.awt.Window; … … 17 19 import java.awt.image.FilteredImageSource; 18 20 import java.lang.reflect.InvocationTargetException; 21 import java.util.Arrays; 19 22 20 23 import javax.swing.GrayFilter; … … 156 159 return timer; 157 160 } 161 162 /** 163 * Return s new BasicStroke object with given thickness and style 164 * @param code = 3.5 -> thickness=3.5px 165 * @param code = 3.5 10 5 -> thickness=3.5px, dashed: 10px filled + 5px empty 166 */ 167 public static Stroke getCustomizedStroke(String code) { 168 String[] s = code.trim().split("[^\\.0-9]+"); 169 170 if (s.length==0) return new BasicStroke(); 171 float w; 172 try { 173 w = Float.parseFloat(s[0]); 174 } catch (NumberFormatException ex) { 175 w = 1.0f; 176 } 177 if (s.length>1) { 178 float dash[]= new float[s.length-1]; 179 try { 180 for (int i=1; i<s.length; i++) { 181 dash[i-1] = Float.parseFloat(s[i]); 182 } 183 } catch (NumberFormatException ex) { 184 System.err.println("Error in stroke preference format: "+code); 185 dash = new float[]{5.0f}; 186 } 187 // dashed stroke 188 return new BasicStroke(w, BasicStroke.CAP_BUTT, 189 BasicStroke.JOIN_MITER, 10.0f, dash, 0.0f); 190 } else { 191 if (w>1) { 192 // thick stroke 193 return new BasicStroke(w, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); 194 } else { 195 // thin stroke 196 return new BasicStroke(w); 197 } 198 } 199 } 200 158 201 }
Note:
See TracChangeset
for help on using the changeset viewer.