Changeset 34558 in osm for applications


Ignore:
Timestamp:
2018-08-18T20:21:43+02:00 (6 years ago)
Author:
donvip
Message:

update to JOSM 14153

Location:
applications/editors/josm/plugins/surveyor
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/surveyor/build.xml

    r34410 r34558  
    77    <property name="commit.message" value="Changed the constructor signature of the plugin main class"/>
    88    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    9     <property name="plugin.main.version" value="12636"/>
     9    <property name="plugin.main.version" value="14153"/>
    1010    <property name="livegpsplugin.jar" value="${plugin.dist.dir}/livegps.jar"/>
    1111
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveEditLayerTimerTask.java

    r33824 r34558  
    1212import javax.swing.JOptionPane;
    1313
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.data.osm.DataSet;
    1615import org.openstreetmap.josm.gui.MainApplication;
     
    5453        } catch (IOException ex) {
    5554            Logging.error(ex);
    56             JOptionPane.showMessageDialog(Main.parent,
     55            JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    5756                tr("Error while exporting {0}: {1}", file.getAbsoluteFile(), ex.getMessage()),
    5857                tr("Error"),
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/AutoSaveGpsLayerTimerTask.java

    r33011 r34558  
    1313import javax.swing.JOptionPane;
    1414
    15 import org.openstreetmap.josm.Main;
     15import org.openstreetmap.josm.gui.MainApplication;
    1616import org.openstreetmap.josm.gui.layer.GpxLayer;
    1717import org.openstreetmap.josm.io.GpxWriter;
     
    7171        } catch (IOException ioExc) {
    7272            ioExc.printStackTrace();
    73             JOptionPane.showMessageDialog(Main.parent,
     73            JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    7474                tr("Error while exporting {0}: {1}", file.getAbsoluteFile(), ioExc.getMessage()),
    7575                tr("Error"),
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/ButtonDescription.java

    r33011 r34558  
    232232            button.addItemListener(this);
    233233        }
    234        
     234
     235        @Override
    235236        public void itemStateChanged(ItemEvent e) {
    236237            boolean value = e.getStateChange() == ItemEvent.SELECTED;
     
    239240        }
    240241
     242        @Override
    241243        public void propertyChange(PropertyChangeEvent evt) {
    242244            if (evt.getPropertyName().equals(ActionConstants.SELECTED_KEY)) {
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/MetaAction.java

    r33011 r34558  
    99import javax.swing.JFrame;
    1010
    11 import org.openstreetmap.josm.Main;
     11import org.openstreetmap.josm.spi.preferences.Config;
    1212
    1313import livegps.LiveGpsData;
     
    8585            System.out.println("Surveyor: no gps data available!");
    8686            // TEST for offline test only:
    87             if (Main.pref.getBoolean("surveyor.debug")) {
     87            if (Config.getPref().getBoolean("surveyor.debug")) {
    8888                for (SurveyorActionDescription action : actions) {
    8989                    action.actionPerformed(new GpsActionEvent(e, 0, 0));
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorActionFactory.java

    r33011 r34558  
    2727            if (action == null) {
    2828                try {
    29                     action = (SurveyorAction) Class.forName(actionClass).newInstance();
     29                    action = (SurveyorAction) Class.forName(actionClass).getDeclaredConstructor().newInstance();
    3030                } catch (ClassNotFoundException e) {
    3131                    actionClass = DEFAULT_PACKAGE + "." + actionClass;
    32                     action = (SurveyorAction) Class.forName(actionClass).newInstance();
     32                    action = (SurveyorAction) Class.forName(actionClass).getDeclaredConstructor().newInstance();
    3333                }
    3434                actionCache.put(actionClass, action);
    3535            }
    3636            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) {
    4238            throw new RuntimeException("Could not create action class '" + actionClass + "'", e);
    4339        }
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorComponent.java

    r33824 r34558  
    2222import javax.swing.JPanel;
    2323
    24 import org.openstreetmap.josm.Main;
     24import org.openstreetmap.josm.gui.MainApplication;
     25import org.openstreetmap.josm.spi.preferences.Config;
     26import org.openstreetmap.josm.tools.Logging;
    2527import org.openstreetmap.josm.tools.XmlObjectParser;
    2628import org.xml.sax.SAXException;
     
    4850        setLayout(new BorderLayout());
    4951        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));
    5254        streetLabel.setFont(streetLabel.getFont().deriveFont(35f));
    5355        add(streetLabel, BorderLayout.NORTH);
     
    103105    public void addButton(ButtonDescription description) {
    104106        if (description.getHotkey() != "" && hotKeys.contains(description.getHotkey())) {
    105             JOptionPane.showMessageDialog(Main.parent,
     107            JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    106108                    tr("Duplicate hotkey for button ''{0}'' - button will be ignored!", description.getLabel()));
    107109        } else {
     
    128130            parser.start(in);
    129131        } catch (SAXException e) {
    130             e.printStackTrace();
     132            Logging.error(e);
    131133        }
    132134        List<SurveyorActionDescription> actions = new ArrayList<>();
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorShowAction.java

    r33824 r34558  
    2020import javax.swing.KeyStroke;
    2121
    22 import org.openstreetmap.josm.Main;
    2322import org.openstreetmap.josm.actions.JosmAction;
    2423import org.openstreetmap.josm.gui.MainApplication;
     24import org.openstreetmap.josm.spi.preferences.Config;
    2525import org.openstreetmap.josm.tools.Logging;
    2626import org.openstreetmap.josm.tools.Shortcut;
     
    107107
    108108    public SurveyorComponent createComponent() {
    109         String source = Main.pref.get("surveyor.source");
     109        String source = Config.getPref().get("surveyor.source");
    110110        if (source == null || source.length() == 0) {
    111111            source = DEFAULT_SOURCE;
    112             Main.pref.put("surveyor.source", DEFAULT_SOURCE);
     112            Config.getPref().put("surveyor.source", DEFAULT_SOURCE);
    113113            // <FIXXME date="04.05.2007" author="cdaller">
    114114            // TODO copy xml file to .josm directory if it does not exist!
     
    119119        } catch (IOException e) {
    120120            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));
    122122        } catch (SAXException e) {
    123123            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()));
    125125        }
    126126        return null;
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/BeepAction.java

    r33824 r34558  
    2121    public void actionPerformed(GpsActionEvent event) {
    2222        // 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);
    3230                }
    3331            }
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/PlayAudioAction.java

    r33824 r34558  
    55import java.io.IOException;
    66import java.io.InputStream;
    7 import java.net.MalformedURLException;
    87
    98import javax.sound.sampled.AudioFormat;
     
    1615
    1716import org.openstreetmap.josm.gui.MainApplication;
     17import org.openstreetmap.josm.tools.Logging;
    1818
    1919import at.dallermassl.josm.plugin.surveyor.GpsActionEvent;
     
    3232    public void actionPerformed(GpsActionEvent event) {
    3333        // 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);
    4241
    43                     // At present, ALAW and ULAW encodings must be converted
    44                     // to PCM_SIGNED before it can be played
    45                     AudioFormat format = stream.getFormat();
    46                     if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
    47                         format = new AudioFormat(
    48                             AudioFormat.Encoding.PCM_SIGNED,
    49                             format.getSampleRate(),
    50                             format.getSampleSizeInBits()*2,
    51                             format.getChannels(),
    52                             format.getFrameSize()*2,
    53                             format.getFrameRate(),
    54                             true);        // big endian
    55                         stream = AudioSystem.getAudioInputStream(format, stream);
    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                }
    5756
    58                     // Create the clip
    59                     DataLine.Info info = new DataLine.Info(
    60                         Clip.class, stream.getFormat(), ((int) stream.getFrameLength()*format.getFrameSize()));
    61                     Clip clip = (Clip) AudioSystem.getLine(info);
     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);
    6261
    63                     // This method does not return until the audio file is completely loaded
    64                     clip.open(stream);
     62                // This method does not return until the audio file is completely loaded
     63                clip.open(stream);
    6564
    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);
    7769            }
    7870        });
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/action/SetWaypointAction.java

    r33824 r34558  
    4545    }
    4646
     47    @Override
    4748    public void actionPerformed(GpsActionEvent event) {
    4849        String markerTitle = getParameters().get(0);
Note: See TracChangeset for help on using the changeset viewer.