Changeset 12778 in osm for applications/editors/josm/plugins/surveyor/src/at
- Timestamp:
- 2009-01-01T18:28:53+01:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/ActionConstants.java
r4277 r12778 14 14 */ 15 15 public final class ActionConstants { 16 17 18 * 19 20 16 17 /** 18 * 19 */ 20 private ActionConstants() { } 21 21 22 22 public static final String SELECTED_KEY = "actionConstants.selected"; -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveAction.java
r12486 r12778 48 48 autoSave = ((AbstractButton)e.getSource()).isSelected(); 49 49 } 50 50 51 51 if(autoSave) { 52 52 if(gpsDataTimer == null) { … … 54 54 } 55 55 TimerTask task; 56 56 57 57 String gpxFilename = MessageFormat.format(GPS_FILE_NAME_PATTERN, new Date()); 58 58 task = new AutoSaveGpsLayerTimerTask(gpxFilename, LiveGpsLayer.LAYER_NAME); 59 59 gpsDataTimer.schedule(task, 1000, AUTO_SAVE_PERIOD_SEC * 1000); 60 60 61 61 String osmFilename = MessageFormat.format(OSM_FILE_NAME_PATTERN, new Date()); 62 62 task = new AutoSaveEditLayerTimerTask(osmFilename); … … 67 67 } 68 68 } 69 70 69 70 71 71 } 72 72 } -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveEditLayerTimerTask.java
r4522 r12778 28 28 public class AutoSaveEditLayerTimerTask extends TimerTask { 29 29 private File file; 30 30 31 31 public AutoSaveEditLayerTimerTask(String filename) { 32 32 file = new File(filename); … … 49 49 // outFile = file; 50 50 // } 51 51 52 52 // write to temporary file, on success, rename tmp file to target file: 53 53 File tmpFile = new File(file.getAbsoluteFile()+".tmp"); … … 60 60 } catch (IOException x) { 61 61 x.printStackTrace(); 62 JOptionPane.showMessageDialog(Main.parent, 63 tr("Error while exporting {0}: {1}", file.getAbsoluteFile(), x.getMessage()), 64 tr("Error"), 62 JOptionPane.showMessageDialog(Main.parent, 63 tr("Error while exporting {0}: {1}", file.getAbsoluteFile(), x.getMessage()), 64 tr("Error"), 65 65 JOptionPane.ERROR_MESSAGE); 66 } 66 } 67 67 } 68 68 -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveGpsLayerTimerTask.java
r6164 r12778 29 29 * if the layer does not exist at the start of the timer task. If the layer does not exist, 30 30 * the file is not written. 31 * 31 * 32 32 * @author cdaller 33 33 * … … 36 36 private String gpsLayerName; 37 37 private File file; 38 38 39 39 /** 40 40 * Constructor using the file to write to and the name of the layer. … … 47 47 this.file = new File(filename); 48 48 } 49 49 50 50 /** 51 51 * @return the gpsLayerName … … 62 62 public void run() { 63 63 64 try { 64 try { 65 65 66 66 GpxLayer gpsLayer = LayerUtil.findGpsLayer(gpsLayerName, GpxLayer.class); … … 78 78 synchronized(LiveGpsLock.class) { 79 79 gpxWriter.write(gpsLayer.data); 80 } 80 } 81 81 tmpFile.renameTo(file); 82 82 } catch (IOException ioExc) { 83 83 ioExc.printStackTrace(); 84 JOptionPane.showMessageDialog(Main.parent, 85 tr("Error while exporting {0}: {1}", file.getAbsoluteFile(), ioExc.getMessage()), 86 tr("Error"), 84 JOptionPane.showMessageDialog(Main.parent, 85 tr("Error while exporting {0}: {1}", file.getAbsoluteFile(), ioExc.getMessage()), 86 tr("Error"), 87 87 JOptionPane.ERROR_MESSAGE); 88 } 88 } 89 89 } 90 90 } -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/ButtonDescription.java
r4499 r12778 44 44 45 45 /** 46 * Default Constructor 46 * Default Constructor 47 47 */ 48 48 public ButtonDescription() { … … 52 52 * @param hotkey 53 53 * @param actions a list of actions to be performed. 54 * @param type if <code>null</code> {@link ButtonType#SINGLE} is used. 54 * @param type if <code>null</code> {@link ButtonType#SINGLE} is used. 55 55 */ 56 56 public ButtonDescription(String label, String hotkey, String iconName, String buttonAction, ButtonType type) { … … 61 61 * @param hotkey 62 62 * @param actions a list of actions to be performed. 63 * @param type if <code>null</code> {@link ButtonType#SINGLE} is used. 63 * @param type if <code>null</code> {@link ButtonType#SINGLE} is used. 64 64 */ 65 65 public ButtonDescription(String label, String hotkey, String iconName, SurveyorActionDescription actionDescription, ButtonType type) { … … 77 77 return list; 78 78 } 79 79 80 80 /** 81 81 * @param hotkey 82 82 * @param actions a list of actions to be performed. 83 * @param type if <code>null</code> {@link ButtonType#SINGLE} is used. 83 * @param type if <code>null</code> {@link ButtonType#SINGLE} is used. 84 84 */ 85 85 public ButtonDescription(String label, String hotkey, String iconName, List<SurveyorActionDescription> actions, ButtonType type) { … … 140 140 return this.type; 141 141 } 142 142 143 143 /** 144 144 * Set the button type as a string. … … 159 159 this.type = type; 160 160 } 161 161 162 162 /** 163 163 * Sets the name of the icon. … … 167 167 this.iconName = icon; 168 168 } 169 169 170 170 /** 171 171 * Creates the button. … … 173 173 */ 174 174 public JComponent createComponent() { 175 175 176 176 String actionName = tr(getLabel()) + " (" + hotkey + ")"; 177 177 178 178 Icon icon = ImageProvider.getIfAvailable("markers",iconName); 179 179 if (icon == null) … … 185 185 action.setActions(actions); 186 186 action.setGpsDataSource(gpsDataSource); 187 187 188 188 AbstractButton button; 189 189 if(type == ButtonType.TOGGLE) { … … 206 206 return button; 207 207 } 208 208 209 209 private static void connectActionAndButton(Action action, AbstractButton button) { 210 210 SelectionStateAdapter adapter = new SelectionStateAdapter(action, button); 211 211 adapter.configure(); 212 212 } 213 214 /** 215 * Class that connects the selection state of the action 213 214 /** 215 * Class that connects the selection state of the action 216 216 * to the selection state of the button. 217 * 217 * 218 218 * @author R.J. Lorimer 219 219 */ … … 223 223 public SelectionStateAdapter(Action theAction, AbstractButton theButton) { 224 224 action = theAction; 225 button = theButton; 225 button = theButton; 226 226 } 227 227 protected void configure() { … … 234 234 action.putValue(ActionConstants.SELECTED_KEY, valueObj); 235 235 } 236 236 237 237 public void propertyChange(PropertyChangeEvent evt) { 238 238 if(evt.getPropertyName().equals(ActionConstants.SELECTED_KEY)) { -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/ButtonType.java
r4277 r12778 9 9 * 10 10 */ 11 public enum ButtonType { 12 SINGLE, 13 TOGGLE 11 public enum ButtonType { 12 SINGLE, 13 TOGGLE 14 14 } -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/GpsActionEvent.java
r4277 r12778 16 16 private static final long serialVersionUID = 2674961758007055637L; 17 17 private LatLon coordinates; 18 18 19 19 20 20 /** … … 36 36 } 37 37 38 38 39 39 40 40 } -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/MetaAction.java
r4277 r12778 18 18 /** 19 19 * Action that fires a {@link SurveyorAction} to the registered actions. 20 * 20 * 21 21 * @author cdaller 22 * 22 * 23 23 */ 24 24 public class MetaAction extends AbstractAction { … … 30 30 31 31 /** 32 * 32 * 33 33 */ 34 34 public MetaAction() { … … 70 70 /* 71 71 * (non-Javadoc) 72 * 72 * 73 73 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) 74 74 */ -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorAction.java
r4277 r12778 18 18 */ 19 19 public void actionPerformed(GpsActionEvent event); 20 20 21 21 /** 22 22 * Sets the parameters for the action execution. -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorActionDescription.java
r4277 r12778 19 19 private List<String> params; 20 20 private SurveyorAction action; 21 22 21 22 23 23 /** 24 * Default Constructor 24 * Default Constructor 25 25 */ 26 26 public SurveyorActionDescription() { … … 80 80 this.params = params; 81 81 } 82 82 83 83 public void actionPerformed(GpsActionEvent e) { 84 84 if(action == null) { … … 88 88 action.actionPerformed(e); 89 89 } 90 90 91 91 /** 92 92 * Sets the classname of the action to use. Callback method of xml parser. … … 96 96 setActionClass(claszName); 97 97 } 98 98 99 99 /** 100 100 * Set the params as a comma separated string. -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorActionFactory.java
r4277 r12778 12 12 * the action instances are used as singletons! 13 13 * A package name of "at.dallermassl.josm.plugin.surveyor.action" is assumed, if the class could 14 * not be found. 15 * 14 * not be found. 15 * 16 16 * @author cdaller 17 17 * -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorComponent.java
r12486 r12778 32 32 /** 33 33 * @author cdaller 34 * 34 * 35 35 */ 36 36 public class SurveyorComponent extends JComponent implements PropertyChangeListener, GpsDataSource { … … 57 57 add(buttonPanel, BorderLayout.CENTER); 58 58 } 59 59 60 60 /** 61 61 * Set the number of rows as a string (callback method from xml parser). … … 66 66 buttonPanel.setLayout(new GridLayout(rows, columns)); 67 67 } 68 68 69 69 /** 70 70 * Set the number of columns as a string (callback method from xml parser). … … 76 76 buttonPanel.setLayout(new GridLayout(rows, columns)); 77 77 } 78 78 79 79 /** 80 80 * Set the width as a string. … … 87 87 } 88 88 } 89 89 90 90 /** 91 91 * Set the width as a string. … … 115 115 } 116 116 } 117 118 117 118 119 119 120 120 public static void main(String[] args) { 121 122 121 122 123 123 // parse xml file and create component from it: 124 124 Reader in = new InputStreamReader(SurveyorComponent.class.getClassLoader().getResourceAsStream("surveyor.xml")); … … 151 151 } catch (SAXException e) { 152 152 e.printStackTrace(); 153 } 154 153 } 154 155 155 // SurveyorComponent surveyorComponent = new SurveyorComponent(); 156 156 // surveyorComponent.setGridSize(3,3); … … 163 163 // surveyorComponent.addButton(new ButtonDescription("Residential", "R", null, "ConsolePrinterAction", null)); 164 164 // surveyorComponent.addButton(new ButtonDescription("Parking", "P", "images/symbols/parking.png", "ConsolePrinterAction", null)); 165 165 166 166 JFrame frame = new JFrame(); 167 167 frame.add(surveyorComponent); … … 179 179 streetLabel.setText(tr("Way: ") + gpsData.getWayInfo()); 180 180 } 181 181 182 182 } 183 183 -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorPlugin.java
r12486 r12778 27 27 * Plugin that uses live gps data and a button panel to add nodes/waypoints etc at the current 28 28 * position. 29 * 29 * 30 30 * TODO: auto save marker layer and data layer? 31 31 * TODO: in action retrieve buttontype state to set on/off values … … 34 34 */ 35 35 public class SurveyorPlugin { 36 36 37 37 private static JFrame surveyorFrame; 38 38 public static final String PREF_KEY_STREET_NAME_FONT_SIZE = "surveyor.way.fontsize"; 39 39 40 40 /** 41 * 41 * 42 42 */ 43 43 public SurveyorPlugin() { 44 44 super(); 45 45 46 46 // try to determine if the livegps plugin was already loaded: 47 47 // PluginInformation pluginInfo = PluginInformation.getLoaded("livegps"); … … 57 57 Class.forName("livegps.LiveGpsPlugin"); 58 58 } catch(ClassNotFoundException cnfe) { 59 String message = 59 String message = 60 60 tr("SurveyorPlugin depends on LiveGpsPlugin!") + "\n" + 61 61 tr("LiveGpsPlugin not found, please install and activate.") + "\n" + 62 tr("SurveyorPlugin is disabled for the moment"); 62 tr("SurveyorPlugin is disabled for the moment"); 63 63 JOptionPane.showMessageDialog(Main.parent, message, tr("SurveyorPlugin"), JOptionPane.ERROR_MESSAGE); 64 64 return; 65 65 } 66 67 66 67 68 68 LiveGpsPlugin gpsPlugin = null; 69 69 Iterator<PluginProxy> proxyIter = Main.plugins.iterator(); … … 101 101 SurveyorPlugin.surveyorFrame = surveyorFrame; 102 102 } 103 103 104 104 } -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorShowAction.java
r12486 r12778 68 68 // comp.addButton(new ButtonDescription("Residential", "R", null, 69 69 // new SurveyorActionDescription("SetWaypointAction", new String[] {"residential", "images/reorder.png"}), null)); 70 // comp.addButton(new ButtonDescription("Parking", "P", "images/symbols/parking.png", 70 // comp.addButton(new ButtonDescription("Parking", "P", "images/symbols/parking.png", 71 71 // new SurveyorActionDescription("SetNodeAction", new String[] {"amenity", "parking", "createdby", "surveyor"}), null)); 72 72 73 73 // add component as gps event listener: 74 74 gpsPlugin.addPropertyChangeListener(comp); 75 75 76 76 // add some hotkeys to the component: 77 77 ActionMap actionMap = comp.getActionMap(); … … 103 103 }); 104 104 inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), "autocenter"); 105 105 106 106 surveyorFrame.add(comp); 107 107 surveyorFrame.pack(); … … 111 111 // <FIXXME date="28.04.2007" author="cdaller"> 112 112 // TODO get old pos of frame from properties 113 // </FIXXME> 113 // </FIXXME> 114 114 SurveyorPlugin.setSurveyorFrame(surveyorFrame); 115 115 } … … 127 127 // <FIXXME date="04.05.2007" author="cdaller"> 128 128 // TODO copy xml file to .josm directory if it does not exist! 129 // </FIXXME> 129 // </FIXXME> 130 130 } 131 131 SurveyorComponent component= null; -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/AbstractSurveyorAction.java
r4277 r12778 15 15 public abstract class AbstractSurveyorAction implements SurveyorAction { 16 16 private List<String> parameters; 17 17 18 18 /** 19 19 * Returns the parameters. … … 23 23 return parameters; 24 24 } 25 25 26 26 /* (non-Javadoc) 27 27 * @see at.dallermassl.josm.plugin.surveyor.SurveyorAction#setParameters(java.util.List) -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/ConsolePrinterAction.java
r4277 r12778 20 20 public void actionPerformed(GpsActionEvent event) { 21 21 LatLon coordinates = event.getCoordinates(); 22 System.out.println(getClass().getSimpleName() + " KOORD: " + coordinates.lat() + ", " 22 System.out.println(getClass().getSimpleName() + " KOORD: " + coordinates.lat() + ", " 23 23 + coordinates.lon() + " params: " + getParameters()); 24 24 } -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/PlayAudioAction.java
r4277 r12778 25 25 /** 26 26 * Action that plays an audio file. 27 * 27 * 28 28 * @author cdaller 29 29 * … … 86 86 } 87 87 } 88 88 89 89 }); 90 90 91 91 } 92 92 } -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetNodeAction.java
r4277 r12778 29 29 public class SetNodeAction implements SurveyorAction { 30 30 private Collection<Tuple<String, String>> keyValues; 31 31 32 32 /** 33 33 * Default Constructor 34 34 */ 35 35 public SetNodeAction() { 36 36 37 37 } 38 38 39 39 /* (non-Javadoc) 40 40 * @see at.dallermassl.josm.plugin.surveyor.SurveyorAction#setParameters(java.util.List) … … 55 55 System.err.println("SetNodeAction: ignoring invalid key value pair: " + keyValuePair); 56 56 } 57 } 57 } 58 58 } 59 59 … … 73 73 Main.ds.setSelected(node); 74 74 } 75 Main.map.repaint(); 75 Main.map.repaint(); 76 76 } 77 77 78 78 79 79 } -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetWaypointAction.java
r9400 r12778 31 31 * Action that sets a marker into a marker layer. The first parameter of the action 32 32 * is used as the text of the marker, the second (if it exists) as an icon. 33 * 33 * 34 34 * @author cdaller 35 35 * … … 40 40 public static final String MARKER_LAYER_NAME = "surveyorwaypointlayer"; 41 41 private WaypointDialog dialog; 42 42 43 43 /** 44 44 * Default Constructor. 45 45 */ 46 46 public SetWaypointAction() { 47 47 48 48 } 49 49 … … 61 61 markerTitle = markerTitle + " " + tr("start"); 62 62 } else { 63 markerTitle = markerTitle + " " + tr("end"); 63 markerTitle = markerTitle + " " + tr("end"); 64 64 } 65 65 } 66 66 67 67 if(dialog == null) { 68 68 dialog = new WaypointDialog(); 69 69 } 70 70 71 71 String markerText = markerTitle; 72 72 String inputText = dialog.openDialog(SurveyorPlugin.getSurveyorFrame(), "Waypoint Description"); … … 75 75 markerText = markerText + " " + inputText; 76 76 } 77 77 78 78 String iconName = getParameters().size() > 1 ? getParameters().get(1) : null; 79 80 // add the waypoint to the marker layer AND to the gpx layer 79 80 // add the waypoint to the marker layer AND to the gpx layer 81 81 // (easy export of data + waypoints): 82 82 MarkerLayer layer = getMarkerLayer(); … … 87 87 synchronized(LiveGpsLock.class) { 88 88 //layer.data.add(new Marker(event.getCoordinates(), markerText, iconName)); 89 89 layer.data.add(new Marker(event.getCoordinates(), markerText, iconName, null, -1.0, 0.0)); 90 90 if(gpsLayer != null) { 91 91 gpsLayer.data.waypoints.add(waypoint); 92 92 } 93 93 } 94 94 95 95 Main.map.repaint(); 96 96 } 97 97 98 98 /** 99 99 * Returns the marker layer with the name {@link #MARKER_LAYER_NAME}. … … 103 103 if(markerLayer == null) { 104 104 markerLayer = LayerUtil.findGpsLayer(MARKER_LAYER_NAME, MarkerLayer.class); 105 105 106 106 if(markerLayer == null) { 107 107 // not found, add a new one 108 108 //markerLayer = new MarkerLayer(new GpxData(), MARKER_LAYER_NAME, null); 109 109 markerLayer = new MarkerLayer(new GpxData(), MARKER_LAYER_NAME, null, null); 110 110 Main.main.addLayer(markerLayer); 111 111 } … … 113 113 return markerLayer; 114 114 } 115 115 116 116 /** 117 117 * Returns the gpx layer that is filled by the live gps data. … … 126 126 break; 127 127 } 128 } 128 } 129 129 } 130 130 return liveGpsLayer; -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/TaggingPresetAction.java
r4277 r12778 23 23 private String presetName; 24 24 private TaggingPreset preset; 25 25 26 26 27 27 /* (non-Javadoc) … … 34 34 } 35 35 LatLon coordinates = event.getCoordinates(); 36 System.out.println(getClass().getSimpleName() + " KOORD: " + coordinates.lat() + ", " 36 System.out.println(getClass().getSimpleName() + " KOORD: " + coordinates.lat() + ", " 37 37 + coordinates.lon() + ", preset=" + presetName); 38 38 // Node node = new Node(coordinates); … … 43 43 // } 44 44 // Main.map.repaint(); 45 45 46 46 // call an annotationpreset to add additional properties... 47 47 preset.actionPerformed(null); … … 63 63 System.err.println("No valid preset '" + parameters.get(0) + "' found - disable action!"); 64 64 return; 65 } 65 } 66 66 } 67 67 -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/gui/DialogClosingThread.java
r4277 r12778 24 24 private long timeout; 25 25 private long loopCount; 26 26 27 27 /** 28 28 * Using the given dialog and the default timeout. … … 31 31 public DialogClosingThread(JDialog dialog) { 32 32 this(dialog, DEFAULT_TIMEOUT); 33 } 34 33 } 34 35 35 /** 36 36 * @param dialog … … 61 61 dialog.dispose(); 62 62 } 63 63 64 64 public void reset() { 65 65 this.loopCount = timeout / 1000; … … 105 105 } 106 106 } 107 107 108 108 public void observe(Component component) { 109 109 component.addKeyListener(this); 110 110 } 111 111 112 112 public void observe(JTextField textfield) { 113 113 textfield.getDocument().addDocumentListener(this); … … 120 120 public void changedUpdate(DocumentEvent e) { 121 121 reset(); 122 System.out.println("changedUpdate: " + e); 122 System.out.println("changedUpdate: " + e); 123 123 } 124 124 … … 138 138 public void removeUpdate(DocumentEvent e) { 139 139 reset(); 140 System.out.println("removeUpdate: " + e); 140 System.out.println("removeUpdate: " + e); 141 141 } 142 142 } -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/gui/WaypointDialog.java
r4277 r12778 21 21 */ 22 22 public class WaypointDialog { 23 23 24 24 public String openDialog(JFrame frame, String message) { 25 25 26 26 JTextField textField = new JTextField(10); 27 27 … … 66 66 dialog.pack(); 67 67 dialog.setVisible(true); 68 68 69 69 70 70 System.out.println("value: " + optionPane.getValue()); -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/util/LayerUtil.java
r6164 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.surveyor.util; -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/util/ResourceLoader.java
r4277 r12778 15 15 */ 16 16 public class ResourceLoader { 17 17 18 18 private ResourceLoader() { 19 19 20 20 } 21 21 22 22 /** 23 23 * Returns an inputstream from urls, files and classloaders, depending on the name.
Note:
See TracChangeset
for help on using the changeset viewer.