Changeset 28624 in osm for applications
- Timestamp:
- 2012-08-24T13:41:33+02:00 (12 years ago)
- Location:
- applications/editors/josm/plugins
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FixAddresses/src/org/openstreetmap/josm/plugins/fixAddresses/FixAddressesPlugin.java
r27338 r28624 27 27 */ 28 28 public class FixAddressesPlugin extends Plugin { 29 private static IncompleteAddressesDialog incompleteAddrDlg;30 29 private static FixAddressesPreferences preferences; 31 30 … … 55 54 @Override 56 55 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 57 // TODO Auto-generated method stub58 super.mapFrameInitialized(oldFrame, newFrame);59 60 56 if (newFrame != null) { 61 incompleteAddrDlg = new IncompleteAddressesDialog();62 57 FixAddressesMapMode faMode = new FixAddressesMapMode(Main.map); 63 58 IconToggleButton faModeButton = new IconToggleButton(faMode); 64 59 faModeButton.setVisible(true); 65 newFrame.addToggleDialog( incompleteAddrDlg);60 newFrame.addToggleDialog(new IncompleteAddressesDialog()); 66 61 } 67 62 } … … 71 66 // TODO Auto-generated method stub 72 67 return getPreferences(); 73 }74 75 /**76 * @return the incompleteAddrDlg77 */78 protected static IncompleteAddressesDialog getIncompleteAddrDlg() {79 return incompleteAddrDlg;80 68 } 81 69 -
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysAction.java
r27852 r28624 58 58 59 59 AlignWaysCmdKeepLength cmdAW; 60 if (AlignWaysPlugin. awDialog.getAwOpt() == AligningModeOption.ALGN_OPT_KEEP_ANGLE) {60 if (AlignWaysPlugin.getAwDialog().getAwOpt() == AligningModeOption.ALGN_OPT_KEEP_ANGLE) { 61 61 cmdAW = new AlignWaysCmdKeepAngles(); 62 62 } else { -
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysDialog.java
r27466 r28624 163 163 164 164 } 165 166 public JCheckBoxMenuItem getWindowMenuItem() {167 return windowMenuItem;168 }169 170 171 165 } -
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysPlugin.java
r27508 r28624 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 import javax.swing.JMenuItem;6 4 7 5 import org.openstreetmap.josm.Main; … … 20 18 public class AlignWaysPlugin extends Plugin { 21 19 22 static AlignWaysMode awMode; 23 private final IconToggleButton btn; 24 static JMenuItem alignWaysMenuItem; 25 static JosmAction awAction; 26 static AlignWaysDialog awDialog; 27 static IconToggleButton optBtn; 20 private static AlignWaysMode awMode; 21 private static IconToggleButton btn; 22 private static JosmAction awAction; 23 private static AlignWaysDialog awDialog; 24 private static IconToggleButton optBtn; 28 25 29 26 // The major version is e.g. used to decide when to trigger What's New windows … … 33 30 super(info); 34 31 35 // Construct the AlignWays mode toggle button36 awMode = new AlignWaysMode(Main.map, "alignways", tr("Align Ways mode"));37 btn = new IconToggleButton(awMode);38 btn.setVisible(true);39 40 32 // Add the action entries to the Tools Menu 41 33 Main.main.menu.toolsMenu.addSeparator(); 42 34 awAction = new AlignWaysAction(); 43 alignWaysMenuItem = MainMenu.add(Main.main.menu.toolsMenu, awAction); 44 45 awDialog = new AlignWaysDialog(awMode); 46 // Prevent user clicking on the Windows menu entry while panel is meaningless 47 awDialog.getWindowMenuItem().setEnabled(false); 35 MainMenu.add(Main.main.menu.toolsMenu, awAction); 48 36 } 49 37 50 38 @Override 51 39 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 52 if(newFrame != null) { 53 optBtn = newFrame.addToggleDialog(AlignWaysPlugin.getAwDialog()); 40 if (newFrame != null) { 41 // Construct the AlignWays mode toggle button 42 awMode = new AlignWaysMode(Main.map, "alignways", tr("Align Ways mode")); 43 btn = new IconToggleButton(awMode); 44 btn.setVisible(true); 45 newFrame.addMapMode(btn); 46 optBtn = newFrame.addToggleDialog(awDialog = new AlignWaysDialog(awMode)); 54 47 } else { 55 // Disable menu item in Windows menu 56 awDialog.getWindowMenuItem().setEnabled(false); 57 } 58 59 if (Main.map != null) { 60 Main.map.addMapMode(btn); 61 // Re-enable menu item in Windows menu 62 awDialog.getWindowMenuItem().setEnabled(true); 48 awDialog = null; 49 optBtn = null; 50 btn = null; 51 awMode = null; 63 52 } 64 53 } … … 91 80 return optBtn; 92 81 } 93 94 82 } -
applications/editors/josm/plugins/alignways/src/com/tilusnet/josm/plugins/alignways/AlignWaysTipsPanel.java
r27348 r28624 101 101 step04.setText(tr("<html>\n<div style=\"font-family:sans-serif\">\n<ul>\n <li><b>Align the segments.</b> Press <b><i><span style=\"color:green\">{0}" 102 102 + "</span></i></b>. Alternatively you''ll find the command in the <b>Tools</b>\n menu or may want to place the action on the <b>toolbar</b>.\n </li>\n</ul>\n</div>\n</html>\n\n", 103 AlignWaysPlugin. awAction.getShortcut().getKeyText()));103 AlignWaysPlugin.getAwAction().getShortcut().getKeyText())); 104 104 step04.setVerticalAlignment(SwingConstants.TOP); 105 105 -
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementDialog.java
r28589 r28624 32 32 * @author ramack 33 33 */ 34 public class MeasurementDialog extends ToggleDialog {34 public class MeasurementDialog extends ToggleDialog implements SelectionChangedListener { 35 35 private static final long serialVersionUID = 4708541586297950021L; 36 36 … … 59 59 */ 60 60 protected JLabel segAngleLabel; 61 61 62 62 /** 63 63 * Constructor … … 112 112 resetButton 113 113 })); 114 115 final MeasurementDialog dlg = this; 116 117 DataSet.addSelectionListener(new SelectionChangedListener() { 118 @Override 119 public void selectionChanged(Collection<? extends OsmPrimitive> arg0) { 120 double length = 0.0; 121 double segAngle = 0.0; 122 double area = 0.0; 123 Node lastNode = null; 124 for(OsmPrimitive p:arg0) { 125 // ignore incomplete nodes 126 if(p instanceof Node && !((Node)p).isIncomplete()) { 127 Node n =(Node)p; 128 if(lastNode == null) { 129 lastNode = n; 130 } else { 131 length += lastNode.getCoor().greatCircleDistance(n.getCoor()); 132 segAngle = MeasurementLayer.angleBetween(lastNode.getCoor(), n.getCoor()); 133 lastNode = n; 134 } 135 } else if (p instanceof Way) { 136 Way w = (Way)p; 137 Node lastN = null; 138 for (Node n: w.getNodes()) { 139 if (lastN != null && lastN.getCoor() != null && n.getCoor() != null) { 140 length += lastN.getCoor().greatCircleDistance(n.getCoor()); 141 //http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/ 142 area += (MeasurementLayer.calcX(n.getCoor()) * MeasurementLayer.calcY(lastN.getCoor())) 143 - (MeasurementLayer.calcY(n.getCoor()) * MeasurementLayer.calcX(lastN.getCoor())); 144 segAngle = MeasurementLayer.angleBetween(lastN.getCoor(), n.getCoor()); 145 } 146 lastN = n; 147 } 148 if (lastN != null && lastN == w.getNodes().iterator().next()) 149 area = Math.abs(area / 2); 150 else 151 area = 0; 152 } 153 } 154 dlg.selectLengthLabel.setText(new DecimalFormat("#0.00").format(length) + " m"); 155 156 dlg.segAngleLabel.setText(new DecimalFormat("#0.0").format(segAngle) + " \u00b0"); 157 dlg.selectAreaLabel.setText(new DecimalFormat("#0.00").format(area) + " m\u00b2"); 158 } 159 }); 114 115 DataSet.addSelectionListener(this); 160 116 } 161 117 … … 166 122 MeasurementPlugin.getCurrentLayer().reset(); 167 123 } 124 125 @Override 126 public void selectionChanged(Collection<? extends OsmPrimitive> newSelection) { 127 double length = 0.0; 128 double segAngle = 0.0; 129 double area = 0.0; 130 Node lastNode = null; 131 for (OsmPrimitive p : newSelection) { 132 // ignore incomplete nodes 133 if (p instanceof Node && !((Node)p).isIncomplete()) { 134 Node n =(Node)p; 135 if (lastNode == null) { 136 lastNode = n; 137 } else { 138 length += lastNode.getCoor().greatCircleDistance(n.getCoor()); 139 segAngle = MeasurementLayer.angleBetween(lastNode.getCoor(), n.getCoor()); 140 lastNode = n; 141 } 142 } else if (p instanceof Way) { 143 Way w = (Way)p; 144 Node lastN = null; 145 for (Node n: w.getNodes()) { 146 if (lastN != null && lastN.getCoor() != null && n.getCoor() != null) { 147 length += lastN.getCoor().greatCircleDistance(n.getCoor()); 148 //http://local.wasp.uwa.edu.au/~pbourke/geometry/polyarea/ 149 area += (MeasurementLayer.calcX(n.getCoor()) * MeasurementLayer.calcY(lastN.getCoor())) 150 - (MeasurementLayer.calcY(n.getCoor()) * MeasurementLayer.calcX(lastN.getCoor())); 151 segAngle = MeasurementLayer.angleBetween(lastN.getCoor(), n.getCoor()); 152 } 153 lastN = n; 154 } 155 if (lastN != null && lastN == w.getNodes().iterator().next()) 156 area = Math.abs(area / 2); 157 else 158 area = 0; 159 } 160 } 161 selectLengthLabel.setText(new DecimalFormat("#0.00").format(length) + " m"); 162 segAngleLabel.setText(new DecimalFormat("#0.0").format(segAngle) + " \u00b0"); 163 selectAreaLabel.setText(new DecimalFormat("#0.00").format(area) + " m\u00b2"); 164 } 165 166 /* (non-Javadoc) 167 * @see org.openstreetmap.josm.gui.dialogs.ToggleDialog#destroy() 168 */ 169 @Override 170 public void destroy() { 171 super.destroy(); 172 DataSet.removeSelectionListener(this); 173 } 168 174 } -
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementLayer.java
r25137 r28624 141 141 DecimalFormat nf = new DecimalFormat("#0.00"); 142 142 DecimalFormat nf2 = new DecimalFormat("#0.0"); 143 MeasurementPlugin.measurementDialog.pathLengthLabel.setText(pathLength < 800?nf2.format(pathLength) + " m":nf.format(pathLength/1000) + " km"); 143 if (MeasurementPlugin.measurementDialog != null) { 144 MeasurementPlugin.measurementDialog.pathLengthLabel.setText(pathLength < 800?nf2.format(pathLength) + " m":nf.format(pathLength/1000) + " km"); 145 } 144 146 } 145 147 -
applications/editors/josm/plugins/measurement/src/org/openstreetmap/josm/plugins/measurement/MeasurementPlugin.java
r23193 r28624 21 21 public MeasurementPlugin(PluginInformation info) { 22 22 super(info); 23 mode = new MeasurementMode(Main.map, "measurement", tr("measurement mode"));24 btn = new IconToggleButton(mode);25 btn.setVisible(true);26 measurementDialog = new MeasurementDialog();27 23 } 28 24 29 25 @Override 30 26 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 31 if(newFrame != null) 32 newFrame.addToggleDialog(measurementDialog); 33 if(Main.map != null) 34 Main.map.addMapMode(btn); 27 if (newFrame != null) { 28 newFrame.addToggleDialog(measurementDialog = new MeasurementDialog()); 29 mode = new MeasurementMode(newFrame, "measurement", tr("measurement mode")); 30 btn = new IconToggleButton(mode); 31 btn.setVisible(true); 32 newFrame.addMapMode(btn); 33 } else { 34 btn = null; 35 mode = null; 36 measurementDialog = null; 37 } 35 38 } 36 39 37 public static MeasurementLayer getCurrentLayer() {38 if (currentLayer == null){40 public static MeasurementLayer getCurrentLayer() { 41 if (currentLayer == null) { 39 42 currentLayer = new MeasurementLayer(tr("Measurements")); 40 43 Main.main.addLayer(currentLayer); -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java
r28568 r28624 79 79 * The side dialog where nodes are listed 80 80 */ 81 private finalRoutingDialog routingDialog;81 private RoutingDialog routingDialog; 82 82 83 83 /** … … 147 147 logger.debug("Loading routing plugin..."); 148 148 preferenceSettings=new RoutingPreferenceDialog(); 149 // Create side dialog150 routingDialog = new RoutingDialog();151 149 // Initialize layers list 152 150 layers = new ArrayList<RoutingLayer>(); … … 188 186 @Override 189 187 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 190 if (newFrame != null) {188 if (newFrame != null) { 191 189 // Create plugin map modes 192 190 addRouteNodeAction = new AddRouteNodeAction(newFrame); … … 205 203 // Enable menu 206 204 menu.enableStartItem(); 207 newFrame.addToggleDialog(routingDialog); 205 newFrame.addToggleDialog(routingDialog = new RoutingDialog()); 206 } else { 207 addRouteNodeAction = null; 208 removeRouteNodeAction = null; 209 moveRouteNodeAction = null; 210 addRouteNodeButton = null; 211 removeRouteNodeButton = null; 212 moveRouteNodeButton = null; 213 routingDialog = null; 208 214 } 209 215 } … … 216 222 if (newLayer instanceof RoutingLayer) { /* show Routing toolbar and dialog window */ 217 223 menu.enableRestOfItems(); 218 routingDialog.showDialog(); 219 routingDialog.refresh(); 224 if (routingDialog != null) { 225 routingDialog.showDialog(); 226 routingDialog.refresh(); 227 } 220 228 }else{ /* hide Routing toolbar and dialog window */ 221 229 menu.disableRestOfItems(); 222 routingDialog.hideDialog(); 230 if (routingDialog != null) { 231 routingDialog.hideDialog(); 232 } 223 233 } 224 234 } … … 267 277 } 268 278 // Reload RoutingDialog table model 269 routingDialog.refresh(); 279 if (routingDialog != null) { 280 routingDialog.refresh(); 281 } 270 282 } 271 283 -
applications/editors/josm/plugins/turnlanes/src/org/openstreetmap/josm/plugins/turnlanes/gui/TurnLanesDialog.java
r28620 r28624 129 129 }; 130 130 131 private final Action editAction = new EditAction();132 private final Action validateAction = new ValidateAction();131 private final JosmAction editAction = new EditAction(); 132 private final JosmAction validateAction = new ValidateAction(); 133 133 134 134 private static final long serialVersionUID = -1998375221636611358L; … … 220 220 MapView.removeEditLayerChangeListener(this); 221 221 DataSet.removeSelectionListener(this); 222 editAction.destroy(); 223 validateAction.destroy(); 222 224 } 223 225 } -
applications/editors/josm/plugins/waypoint_search/src/org/openstreetmap/josm/plugins/waypointSearch/WaypointSearchPlugin.java
r23192 r28624 1 1 package org.openstreetmap.josm.plugins.waypointSearch; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 import org.openstreetmap.josm.gui.MapFrame; 6 import org.openstreetmap.josm.gui.MapView; 7 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 8 import org.openstreetmap.josm.gui.layer.Layer; 3 9 import org.openstreetmap.josm.plugins.Plugin; 4 10 import org.openstreetmap.josm.plugins.PluginInformation; 5 import org.openstreetmap.josm.Main;6 import org.openstreetmap.josm.gui.MapView;7 import org.openstreetmap.josm.gui.layer.Layer;8 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;9 import static org.openstreetmap.josm.tools.I18n.tr;10 11 11 12 public class WaypointSearchPlugin extends Plugin implements LayerChangeListener { … … 15 16 * @param info information about the plugin and its local installation 16 17 */ 17 private Engine engine = new Engine();18 private SelectWaypointDialog waypointDialog = new SelectWaypointDialog(tr("Waypoint search"), "ToolbarIcon", tr("Search after waypoint. Click and move the map view to the waypoint."), null, 100);18 private final Engine engine = new Engine(); 19 private SelectWaypointDialog waypointDialog; 19 20 20 21 public WaypointSearchPlugin(PluginInformation info) { … … 23 24 } 24 25 25 @Override 26 @Override 27 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 28 if (newFrame != null) { 29 newFrame.addToggleDialog(waypointDialog = new SelectWaypointDialog( 30 tr("Waypoint search"), "ToolbarIcon", tr("Search after waypoint. Click and move the map view to the waypoint."), null, 100)); 31 } else { 32 waypointDialog = null; 33 } 34 } 35 36 @Override 26 37 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 27 // TODO Auto-generated method stub28 29 38 } 30 31 39 32 40 @Override 33 41 public void layerAdded(Layer newLayer) { 34 //add dialog 35 if (Main.map.getToggleDialog(SelectWaypointDialog.class)==null) { 36 Main.map.addToggleDialog(waypointDialog); 37 } 38 //update search 39 if (engine.gpxLayersExist()) { 42 // update search 43 if (waypointDialog != null && engine.gpxLayersExist()) { 40 44 waypointDialog.updateSearchResults(); 41 45 } 42 46 } 43 47 44 45 46 48 @Override 47 49 public void layerRemoved(Layer oldLayer) { 48 if ( !engine.gpxLayersExist()) {50 if (waypointDialog != null && !engine.gpxLayersExist()) { 49 51 waypointDialog.updateSearchResults(); 50 52 } 51 53 } 52 53 54 } 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
Note:
See TracChangeset
for help on using the changeset viewer.