Changeset 34558 in osm
- Timestamp:
- 2018-08-18T20:21:43+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/surveyor
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/surveyor/build.xml
r34410 r34558 7 7 <property name="commit.message" value="Changed the constructor signature of the plugin main class"/> 8 8 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 9 <property name="plugin.main.version" value="1 2636"/>9 <property name="plugin.main.version" value="14153"/> 10 10 <property name="livegpsplugin.jar" value="${plugin.dist.dir}/livegps.jar"/> 11 11 -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveEditLayerTimerTask.java
r33824 r34558 12 12 import javax.swing.JOptionPane; 13 13 14 import org.openstreetmap.josm.Main;15 14 import org.openstreetmap.josm.data.osm.DataSet; 16 15 import org.openstreetmap.josm.gui.MainApplication; … … 54 53 } catch (IOException ex) { 55 54 Logging.error(ex); 56 JOptionPane.showMessageDialog(Main .parent,55 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 57 56 tr("Error while exporting {0}: {1}", file.getAbsoluteFile(), ex.getMessage()), 58 57 tr("Error"), -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveGpsLayerTimerTask.java
r33011 r34558 13 13 import javax.swing.JOptionPane; 14 14 15 import org.openstreetmap.josm. Main;15 import org.openstreetmap.josm.gui.MainApplication; 16 16 import org.openstreetmap.josm.gui.layer.GpxLayer; 17 17 import org.openstreetmap.josm.io.GpxWriter; … … 71 71 } catch (IOException ioExc) { 72 72 ioExc.printStackTrace(); 73 JOptionPane.showMessageDialog(Main .parent,73 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 74 74 tr("Error while exporting {0}: {1}", file.getAbsoluteFile(), ioExc.getMessage()), 75 75 tr("Error"), -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/ButtonDescription.java
r33011 r34558 232 232 button.addItemListener(this); 233 233 } 234 234 235 @Override 235 236 public void itemStateChanged(ItemEvent e) { 236 237 boolean value = e.getStateChange() == ItemEvent.SELECTED; … … 239 240 } 240 241 242 @Override 241 243 public void propertyChange(PropertyChangeEvent evt) { 242 244 if (evt.getPropertyName().equals(ActionConstants.SELECTED_KEY)) { -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/MetaAction.java
r33011 r34558 9 9 import javax.swing.JFrame; 10 10 11 import org.openstreetmap.josm. Main;11 import org.openstreetmap.josm.spi.preferences.Config; 12 12 13 13 import livegps.LiveGpsData; … … 85 85 System.out.println("Surveyor: no gps data available!"); 86 86 // TEST for offline test only: 87 if ( Main.pref.getBoolean("surveyor.debug")) {87 if (Config.getPref().getBoolean("surveyor.debug")) { 88 88 for (SurveyorActionDescription action : actions) { 89 89 action.actionPerformed(new GpsActionEvent(e, 0, 0)); -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorActionFactory.java
r33011 r34558 27 27 if (action == null) { 28 28 try { 29 action = (SurveyorAction) Class.forName(actionClass). newInstance();29 action = (SurveyorAction) Class.forName(actionClass).getDeclaredConstructor().newInstance(); 30 30 } catch (ClassNotFoundException e) { 31 31 actionClass = DEFAULT_PACKAGE + "." + actionClass; 32 action = (SurveyorAction) Class.forName(actionClass). newInstance();32 action = (SurveyorAction) Class.forName(actionClass).getDeclaredConstructor().newInstance(); 33 33 } 34 34 actionCache.put(actionClass, action); 35 35 } 36 36 return action; 37 } catch (InstantiationException e) { 38 throw new RuntimeException("Could not create action class '" + actionClass + "'", e); 39 } catch (IllegalAccessException e) { 40 throw new RuntimeException("Could not create action class '" + actionClass + "'", e); 41 } catch (ClassNotFoundException e) { 37 } catch (ReflectiveOperationException e) { 42 38 throw new RuntimeException("Could not create action class '" + actionClass + "'", e); 43 39 } -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorComponent.java
r33824 r34558 22 22 import javax.swing.JPanel; 23 23 24 import org.openstreetmap.josm.Main; 24 import org.openstreetmap.josm.gui.MainApplication; 25 import org.openstreetmap.josm.spi.preferences.Config; 26 import org.openstreetmap.josm.tools.Logging; 25 27 import org.openstreetmap.josm.tools.XmlObjectParser; 26 28 import org.xml.sax.SAXException; … … 48 50 setLayout(new BorderLayout()); 49 51 streetLabel = new JLabel(tr("Way: ")); 50 float fontSize = Float.parseFloat( Main.pref.get(SurveyorPlugin.PREF_KEY_STREET_NAME_FONT_SIZE, "35"));51 Main.pref.put(SurveyorPlugin.PREF_KEY_STREET_NAME_FONT_SIZE, String.valueOf(fontSize));52 float fontSize = Float.parseFloat(Config.getPref().get(SurveyorPlugin.PREF_KEY_STREET_NAME_FONT_SIZE, "35")); 53 Config.getPref().put(SurveyorPlugin.PREF_KEY_STREET_NAME_FONT_SIZE, String.valueOf(fontSize)); 52 54 streetLabel.setFont(streetLabel.getFont().deriveFont(35f)); 53 55 add(streetLabel, BorderLayout.NORTH); … … 103 105 public void addButton(ButtonDescription description) { 104 106 if (description.getHotkey() != "" && hotKeys.contains(description.getHotkey())) { 105 JOptionPane.showMessageDialog(Main .parent,107 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 106 108 tr("Duplicate hotkey for button ''{0}'' - button will be ignored!", description.getLabel())); 107 109 } else { … … 128 130 parser.start(in); 129 131 } catch (SAXException e) { 130 e.printStackTrace();132 Logging.error(e); 131 133 } 132 134 List<SurveyorActionDescription> actions = new ArrayList<>(); -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorShowAction.java
r33824 r34558 20 20 import javax.swing.KeyStroke; 21 21 22 import org.openstreetmap.josm.Main;23 22 import org.openstreetmap.josm.actions.JosmAction; 24 23 import org.openstreetmap.josm.gui.MainApplication; 24 import org.openstreetmap.josm.spi.preferences.Config; 25 25 import org.openstreetmap.josm.tools.Logging; 26 26 import org.openstreetmap.josm.tools.Shortcut; … … 107 107 108 108 public SurveyorComponent createComponent() { 109 String source = Main.pref.get("surveyor.source");109 String source = Config.getPref().get("surveyor.source"); 110 110 if (source == null || source.length() == 0) { 111 111 source = DEFAULT_SOURCE; 112 Main.pref.put("surveyor.source", DEFAULT_SOURCE);112 Config.getPref().put("surveyor.source", DEFAULT_SOURCE); 113 113 // <FIXXME date="04.05.2007" author="cdaller"> 114 114 // TODO copy xml file to .josm directory if it does not exist! … … 119 119 } catch (IOException e) { 120 120 Logging.error(e); 121 JOptionPane.showMessageDialog(Main .parent, tr("Could not read surveyor definition: {0}", source));121 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Could not read surveyor definition: {0}", source)); 122 122 } catch (SAXException e) { 123 123 Logging.error(e); 124 JOptionPane.showMessageDialog(Main .parent, tr("Error parsing {0}: {1}", source, e.getMessage()));124 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Error parsing {0}: {1}", source, e.getMessage())); 125 125 } 126 126 return null; -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/BeepAction.java
r33824 r34558 21 21 public void actionPerformed(GpsActionEvent event) { 22 22 // run as a separate thread 23 MainApplication.worker.execute(new Runnable() { 24 public void run() { 25 for (int index = 0; index < beepNumber; ++index) { 26 Toolkit.getDefaultToolkit().beep(); 27 try { 28 Thread.sleep(200); 29 } catch (InterruptedException ignore) { 30 Logging.debug(ignore); 31 } 23 MainApplication.worker.execute(() -> { 24 for (int index = 0; index < beepNumber; ++index) { 25 Toolkit.getDefaultToolkit().beep(); 26 try { 27 Thread.sleep(200); 28 } catch (InterruptedException ignore) { 29 Logging.debug(ignore); 32 30 } 33 31 } -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/PlayAudioAction.java
r33824 r34558 5 5 import java.io.IOException; 6 6 import java.io.InputStream; 7 import java.net.MalformedURLException;8 7 9 8 import javax.sound.sampled.AudioFormat; … … 16 15 17 16 import org.openstreetmap.josm.gui.MainApplication; 17 import org.openstreetmap.josm.tools.Logging; 18 18 19 19 import at.dallermassl.josm.plugin.surveyor.GpsActionEvent; … … 32 32 public void actionPerformed(GpsActionEvent event) { 33 33 // run as a separate thread 34 MainApplication.worker.execute(new Runnable() { 35 public void run() { 36 try { 37 if (audioSource == null) { 38 audioSource = getParameters().get(0); 39 } 40 InputStream in = new BufferedInputStream(ResourceLoader.getInputStream(audioSource)); 41 AudioInputStream stream = AudioSystem.getAudioInputStream(in); 34 MainApplication.worker.execute(() -> { 35 try { 36 if (audioSource == null) { 37 audioSource = getParameters().get(0); 38 } 39 InputStream in = new BufferedInputStream(ResourceLoader.getInputStream(audioSource)); 40 AudioInputStream stream = AudioSystem.getAudioInputStream(in); 42 41 43 44 45 46 47 48 49 50 51 52 53 54 55 56 42 // At present, ALAW and ULAW encodings must be converted 43 // to PCM_SIGNED before it can be played 44 AudioFormat format = stream.getFormat(); 45 if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) { 46 format = new AudioFormat( 47 AudioFormat.Encoding.PCM_SIGNED, 48 format.getSampleRate(), 49 format.getSampleSizeInBits()*2, 50 format.getChannels(), 51 format.getFrameSize()*2, 52 format.getFrameRate(), 53 true); // big endian 54 stream = AudioSystem.getAudioInputStream(format, stream); 55 } 57 56 58 59 60 61 57 // Create the clip 58 DataLine.Info info = new DataLine.Info( 59 Clip.class, stream.getFormat(), ((int) stream.getFrameLength()*format.getFrameSize())); 60 Clip clip = (Clip) AudioSystem.getLine(info); 62 61 63 64 62 // This method does not return until the audio file is completely loaded 63 clip.open(stream); 65 64 66 // Start playing 67 clip.start(); 68 } catch (MalformedURLException e) { 69 e.printStackTrace(); 70 } catch (IOException e) { 71 e.printStackTrace(); 72 } catch (LineUnavailableException e) { 73 e.printStackTrace(); 74 } catch (UnsupportedAudioFileException e) { 75 e.printStackTrace(); 76 } 65 // Start playing 66 clip.start(); 67 } catch (IOException | LineUnavailableException | UnsupportedAudioFileException e1) { 68 Logging.error(e1); 77 69 } 78 70 }); -
applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetWaypointAction.java
r33824 r34558 45 45 } 46 46 47 @Override 47 48 public void actionPerformed(GpsActionEvent event) { 48 49 String markerTitle = getParameters().get(0);
Note:
See TracChangeset
for help on using the changeset viewer.