Changeset 21236 in osm for applications/editors
- Timestamp:
- 2010-05-12T11:15:45+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/buildings_tools
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/buildings_tools/.settings/org.eclipse.jdt.ui.prefs
r20245 r21236 1 # Sat Jun 06 18:09:10 MSD 20091 #Wed May 12 12:21:49 MSD 2010 2 2 eclipse.preferences.version=1 3 formatter_profile=_BTProf 4 formatter_settings_version=11 3 5 org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/> -
applications/editors/josm/plugins/buildings_tools/src/buildings_tools/AddressDialog.java
r20269 r21236 56 56 } 57 57 58 private static String nextHouseNum() 59 { 58 private static String nextHouseNum() { 60 59 if (lhousenum==null) return ""; 61 try 62 { 63 Integer num = NumberFormat.getInstance().parse(lhousenum).intValue(); 64 if (inc) num=num+2; else num = num-2; 65 return num.toString(); 66 } catch (ParseException e) 67 { 68 return lhousenum; 60 try { 61 Integer num = NumberFormat.getInstance().parse(lhousenum).intValue(); 62 if (inc) num=num+2; else num = num-2; 63 return num.toString(); 64 } catch (ParseException e) { 65 return lhousenum; 69 66 } 70 67 } 71 public void saveValues() 72 { 68 public void saveValues() { 73 69 lhousenum = housenum.getText(); 74 70 lstreetname = streetname.getText(); 75 71 inc = cincdec.getSelectedIndex() == 0; 76 72 } 77 public String getHouseNum() 78 { 73 public String getHouseNum() { 79 74 return housenum.getText(); 80 75 } 81 public String getStreetName() 82 { 76 public String getStreetName() { 83 77 return streetname.getText(); 84 78 } -
applications/editors/josm/plugins/buildings_tools/src/buildings_tools/Building.java
r20245 r21236 47 47 while (angconstraint>(Math.PI/4)) angconstraint-=Math.PI/4; 48 48 } 49 public double getLength() 50 { 49 public double getLength() { 51 50 return len; 52 51 } 53 52 54 public void reset() 55 { 53 public void reset() { 56 54 len = 0; 57 55 en1=null; … … 64 62 public EastNorth Point3() { return en3; } 65 63 public EastNorth Point4() { return en4; } 66 private void updMetrics() 67 { 64 private void updMetrics() { 68 65 meter = 2*Math.PI/(Math.cos(Math.toRadians(eastNorth2latlon(p1).lat())) * eqlen); 69 66 reset(); 70 67 } 71 public void setBase(EastNorth base) 72 { 68 public void setBase(EastNorth base) { 73 69 node = null; 74 70 p1 = base; 75 71 updMetrics(); 76 72 } 77 public void setBase(Node base) 78 { 73 public void setBase(Node base) { 79 74 node = base; 80 75 p1 = latlon2eastNorth(base.getCoor()); 81 76 updMetrics(); 82 77 } 83 public void setPlace(EastNorth p2,double width,double lenstep) 84 { 78 public void setPlace(EastNorth p2,double width,double lenstep) { 85 79 double heading = p1.heading(p2); 86 80 double hdang = 0; 87 if (angconstrainted) 88 { 81 if (angconstrainted) { 89 82 hdang = Math.round((heading-angconstraint)/Math.PI*4); 90 83 if (hdang>=8)hdang-=8; … … 103 96 lwidth = width; 104 97 Main.map.statusLine.setHeading(Math.toDegrees(heading)); 105 if (angconstrainted) 106 { 98 if (angconstrainted) { 107 99 Main.map.statusLine.setAngle(hdang*45); 108 100 } 109 101 } 110 public void paint(Graphics2D g, MapView mv) 111 { 102 public void paint(Graphics2D g, MapView mv) { 112 103 if (len == 0) return; 113 104 GeneralPath b = new GeneralPath(); … … 122 113 g.draw(b); 123 114 } 124 public Way create() 125 { 115 public Way create() { 126 116 if (len == 0) return null; 127 117 Node n1; … … 134 124 Node n4 = new Node(eastNorth2latlon(en4)); 135 125 if (n1.getCoor().isOutSideWorld()||n2.getCoor().isOutSideWorld()|| 136 n3.getCoor().isOutSideWorld()||n4.getCoor().isOutSideWorld()) 137 { 126 n3.getCoor().isOutSideWorld()||n4.getCoor().isOutSideWorld()) { 138 127 JOptionPane.showMessageDialog(Main.parent, 139 128 tr("Cannot place building outside of the world.")); … … 142 131 Way w = new Way(); 143 132 w.addNode(n1); 144 if (lwidth>=0) 145 { 133 if (lwidth>=0) { 146 134 w.addNode(n2); 147 135 w.addNode(n3); 148 136 w.addNode(n4); 149 } else 150 { 137 } else { 151 138 w.addNode(n4); 152 139 w.addNode(n3); -
applications/editors/josm/plugins/buildings_tools/src/buildings_tools/BuildingSizeAction.java
r20245 r21236 12 12 public class BuildingSizeAction extends JosmAction { 13 13 14 public BuildingSizeAction() 15 { 14 public BuildingSizeAction() { 16 15 super(tr("Set buildings size"),"mapmode/building",tr("Set buildings size"), 17 16 Shortcut.registerShortcut("edit:buildingsdialog", -
applications/editors/josm/plugins/buildings_tools/src/buildings_tools/BuildingSizeDialog.java
r20245 r21236 45 45 setVisible(true); 46 46 } 47 public double width() 48 { 49 try 50 { 51 return NumberFormat.getInstance().parse(twidth.getText()).doubleValue(); 52 } catch (ParseException e) 53 { 47 public double width() { 48 try { 49 return NumberFormat.getInstance().parse(twidth.getText()).doubleValue(); 50 } catch (ParseException e) { 51 return 0; 52 } 53 } 54 public double lenstep() { 55 try { 56 return NumberFormat.getInstance().parse(tlenstep.getText()).doubleValue(); 57 } catch (ParseException e) { 54 58 return 0; 55 59 } 56 60 } 57 public double lenstep() 58 { 59 try 60 { 61 return NumberFormat.getInstance().parse(tlenstep.getText()).doubleValue(); 62 } catch (ParseException e) 63 { 64 return 0; 65 } 66 } 67 public boolean useAddr() 68 { 61 public boolean useAddr() { 69 62 return caddr.isSelected(); 70 63 } -
applications/editors/josm/plugins/buildings_tools/src/buildings_tools/BuildingsToolsPlugin.java
r20245 r21236 21 21 } 22 22 23 public BuildingsToolsPlugin(PluginInformation info) 24 { 23 public BuildingsToolsPlugin(PluginInformation info) { 25 24 super(info); 26 25 Main.main.menu.editMenu.addSeparator(); 27 MainMenu.add(Main.main.menu.editMenu, new BuildingSizeAction()); 26 MainMenu.add(Main.main.menu.editMenu, new BuildingSizeAction()); 28 27 } 29 28 @Override public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { -
applications/editors/josm/plugins/buildings_tools/src/buildings_tools/DrawBuildingAction.java
r20250 r21236 58 58 Building building = new Building(); 59 59 60 public static void SetAddrDialog(boolean _useAddr) 61 { 60 public static void SetAddrDialog(boolean _useAddr) { 62 61 useAddr = _useAddr; 63 62 } 64 public static void SetSizes(double newwidth,double newlenstep) 65 { 63 public static void SetSizes(double newwidth,double newlenstep) { 66 64 width = newwidth; 67 65 lenstep = newlenstep; 68 66 } 69 public static double getWidth() 70 { 67 public static double getWidth() { 71 68 return width; 72 69 } 73 70 74 public static double getLenStep() 75 { 71 public static double getLenStep() { 76 72 return lenstep; 77 73 } 78 public DrawBuildingAction(MapFrame mapFrame) 79 { 74 public DrawBuildingAction(MapFrame mapFrame) { 80 75 super(tr("Draw buildings"),"building",tr("Draw buildings"), 81 76 Shortcut.registerShortcut("mapmode:buildings", … … 117 112 } catch(Exception e) {} 118 113 } 119 private static void showAddrDialog(Way w) 120 { 114 private static void showAddrDialog(Way w) { 121 115 AddressDialog dlg = new AddressDialog(); 122 116 int answer = dlg.getValue(); … … 133 127 @Override public void enterMode() { 134 128 super.enterMode(); 129 if (getCurrentDataSet() == null) { 130 Main.map.selectSelectTool(false); 131 return; 132 } 135 133 currCursor = cursorCrosshair; 136 134 Main.map.mapView.addMouseListener(this); … … 157 155 } 158 156 159 public void cancelDrawing() 160 { 157 public void cancelDrawing() { 161 158 mode = Mode.None; 162 159 if(Main.map == null || Main.map.mapView == null) … … 172 169 } 173 170 174 private void ProcessMouseEvent(MouseEvent e) 175 { 171 private void ProcessMouseEvent(MouseEvent e) { 176 172 mousePos = e.getPoint(); 177 173 if (mode == Mode.None) return; 178 174 Node n; 179 if (mode == Mode.Drawing) 180 { 181 if (e.isControlDown()) n = null; else n = Main.map.mapView.getNearestNode(mousePos); 182 if (n == null) 175 if (mode == Mode.Drawing) { 176 if (e.isControlDown()) { 177 n = null; 178 } else { 179 n = Main.map.mapView.getNearestNode(mousePos); 180 } 181 if (n == null) { 183 182 p2 = latlon2eastNorth(Main.map.mapView.getLatLon(mousePos.x, mousePos.y)); 184 else183 } else { 185 184 p2 = latlon2eastNorth(n.getCoor()); 185 } 186 186 building.setPlace(p2, width, e.isControlDown()?0:lenstep); 187 187 Main.map.statusLine.setDist(building.getLength()); 188 188 return; 189 189 } 190 if (mode == Mode.DrawingWidth) 191 { 192 if (e.isControlDown()) n = null; else n = Main.map.mapView.getNearestNode(mousePos); 193 if (n == null) 190 if (mode == Mode.DrawingWidth) { 191 if (e.isControlDown()) { 192 n = null; 193 } else { 194 n = Main.map.mapView.getNearestNode(mousePos); 195 } 196 if (n == null) { 194 197 p3 = latlon2eastNorth(Main.map.mapView.getLatLon(mousePos.x, mousePos.y)); 195 else198 } else { 196 199 p3 = latlon2eastNorth(n.getCoor()); 197 200 } 198 201 double mwidth = 199 202 ((p3.east()-p2.east())*(p2.north()-p1.north())+ … … 209 212 { 210 213 if (mode == Mode.None) return; 211 if (building.getLength() ==0)return;214 if (building.getLength() == 0) return; 212 215 213 216 g.setColor(selectedColor); … … 226 229 227 230 Node n = Main.map.mapView.getNearestNode(mousePos); 228 if (n == null) 229 { 231 if (n == null) { 230 232 p1 = latlon2eastNorth(Main.map.mapView.getLatLon(mousePos.x, mousePos.y)); 231 233 building.setBase(p1); 232 } else 233 { 234 } else { 234 235 p1 = latlon2eastNorth(n.getCoor()); 235 236 building.setBase(n); … … 239 240 } 240 241 241 private void drawingAdvance(MouseEvent e) 242 { 242 private void drawingAdvance(MouseEvent e) { 243 243 ProcessMouseEvent(e); 244 if (building.getLength() > 0) 245 { 246 if (width == 0 && mode == Mode.Drawing) 247 { 244 if (building.getLength() > 0) { 245 if (width == 0 && mode == Mode.Drawing) { 248 246 p2 = building.Point2(); 249 247 mode = Mode.DrawingWidth; … … 263 261 } 264 262 265 @Override public void mousePressed(MouseEvent e) 266 { 263 @Override public void mousePressed(MouseEvent e) { 267 264 if (e.getButton() != MouseEvent.BUTTON1) return; 268 265 if(!Main.map.mapView.isActiveLayerDrawable()) return; … … 272 269 } 273 270 274 @Override public void mouseDragged(MouseEvent e) 275 { 271 @Override public void mouseDragged(MouseEvent e) { 276 272 ProcessMouseEvent(e); 277 273 updCursor(); … … 279 275 } 280 276 281 @Override public void mouseReleased(MouseEvent e) 282 { 277 @Override public void mouseReleased(MouseEvent e) { 283 278 if (e.getButton() != MouseEvent.BUTTON1) return; 284 279 if(!Main.map.mapView.isActiveLayerDrawable()) return; 285 286 280 boolean dragged = true; 287 281 if (drawStartPos != null) … … 293 287 } 294 288 295 private void updCursor() 296 { 289 private void updCursor() { 297 290 if (mousePos==null) return; 298 291 Node n = Main.map.mapView.getNearestNode(mousePos); … … 300 293 301 294 } 302 @Override public void mouseMoved(MouseEvent e) 303 { 295 @Override public void mouseMoved(MouseEvent e) { 304 296 if(!Main.map.mapView.isActiveLayerDrawable()) return; 305 297 ProcessMouseEvent(e); … … 319 311 } 320 312 321 public void UpdateConstraint(Collection<? extends OsmPrimitive> newSelection) 322 { 313 public void UpdateConstraint(Collection<? extends OsmPrimitive> newSelection) { 323 314 building.disableAngConstraint(); 324 315 if (newSelection.size()!=2)return;
Note:
See TracChangeset
for help on using the changeset viewer.