Changeset 30737 in osm for applications/editors/josm/plugins/NanoLog
- Timestamp:
- 2014-10-18T23:07:52+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/NanoLog/src/nanolog
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/NanoLog/src/nanolog/Correlator.java
r30701 r30737 1 1 package nanolog; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 3 5 import java.text.ParseException; 4 import java.util.*; 6 import java.util.ArrayList; 7 import java.util.Collections; 8 import java.util.List; 9 5 10 import javax.swing.JOptionPane; 11 6 12 import org.openstreetmap.josm.Main; 7 13 import org.openstreetmap.josm.data.coor.EastNorth; 8 14 import org.openstreetmap.josm.data.coor.LatLon; 9 import org.openstreetmap.josm.data.gpx.*; 15 import org.openstreetmap.josm.data.gpx.GpxData; 16 import org.openstreetmap.josm.data.gpx.GpxTrack; 17 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 18 import org.openstreetmap.josm.data.gpx.WayPoint; 10 19 import org.openstreetmap.josm.tools.Geometry; 11 import static org.openstreetmap.josm.tools.I18n.tr;12 20 import org.openstreetmap.josm.tools.date.PrimaryDateParser; 13 21 … … 24 32 */ 25 33 public static long crudeMatch( List<NanoLogEntry> entries, GpxData data ) { 26 List<NanoLogEntry> sortedEntries = new ArrayList< NanoLogEntry>(entries);34 List<NanoLogEntry> sortedEntries = new ArrayList<>(entries); 27 35 PrimaryDateParser dateParser = new PrimaryDateParser(); 28 36 Collections.sort(sortedEntries); … … 72 80 */ 73 81 public static void correlate( List<NanoLogEntry> entries, GpxData data, long offset ) { 74 List<NanoLogEntry> sortedEntries = new ArrayList< NanoLogEntry>(entries);82 List<NanoLogEntry> sortedEntries = new ArrayList<>(entries); 75 83 //int ret = 0; 76 84 PrimaryDateParser dateParser = new PrimaryDateParser(); -
applications/editors/josm/plugins/NanoLog/src/nanolog/NanoLogLayer.java
r30701 r30737 1 1 package nanolog; 2 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import java.io.*; 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 import java.awt.Color; 6 import java.awt.Graphics2D; 7 import java.awt.Point; 8 import java.awt.event.ActionEvent; 9 import java.awt.event.MouseAdapter; 10 import java.awt.event.MouseEvent; 11 import java.io.BufferedReader; 12 import java.io.File; 13 import java.io.FileInputStream; 14 import java.io.IOException; 15 import java.io.InputStreamReader; 6 16 import java.text.ParseException; 7 17 import java.text.SimpleDateFormat; 8 import java.util.*; 18 import java.util.ArrayList; 19 import java.util.Collections; 20 import java.util.Date; 21 import java.util.HashSet; 9 22 import java.util.List; 10 import java.util.regex.*; 11 import javax.swing.*; 23 import java.util.Set; 24 import java.util.regex.Matcher; 25 import java.util.regex.Pattern; 26 27 import javax.swing.Action; 28 import javax.swing.Icon; 29 import javax.swing.JOptionPane; 30 12 31 import org.openstreetmap.josm.Main; 13 import org.openstreetmap.josm.actions.*; 32 import org.openstreetmap.josm.actions.JosmAction; 33 import org.openstreetmap.josm.actions.RenameLayerAction; 14 34 import org.openstreetmap.josm.data.Bounds; 15 35 import org.openstreetmap.josm.data.coor.EastNorth; … … 18 38 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 19 39 import org.openstreetmap.josm.gui.MapView; 20 import org.openstreetmap.josm.gui.dialogs.*; 21 import org.openstreetmap.josm.gui.layer.*; 22 import static org.openstreetmap.josm.tools.I18n.tr; 40 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 41 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 42 import org.openstreetmap.josm.gui.layer.GpxLayer; 43 import org.openstreetmap.josm.gui.layer.JumpToMarkerActions; 44 import org.openstreetmap.josm.gui.layer.Layer; 23 45 import org.openstreetmap.josm.tools.ImageProvider; 24 46 … … 32 54 private List<NanoLogEntry> log; 33 55 private int selectedEntry; 34 private final Set<NanoLogLayerListener> listeners = new HashSet< NanoLogLayerListener>();56 private final Set<NanoLogLayerListener> listeners = new HashSet<>(); 35 57 private NLLMouseAdapter mouseListener; 36 58 37 59 public NanoLogLayer( List<NanoLogEntry> entries ) { 38 60 super(tr("NanoLog")); 39 log = new ArrayList< NanoLogEntry>(entries);61 log = new ArrayList<>(entries); 40 62 selectedEntry = -1; 41 63 mouseListener = new NLLMouseAdapter(); … … 50 72 super.destroy(); 51 73 } 52 74 53 75 public NanoLogLayer( File file ) throws IOException { 54 76 this(readNanoLog(file)); … … 76 98 return Collections.unmodifiableList(log); 77 99 } 78 100 79 101 public static List<NanoLogEntry> readNanoLog( File file ) throws IOException { 80 102 final Pattern NANOLOG_LINE = Pattern.compile("(.+?)\\t(.+?)(?:\\s*\\{\\{(-?\\d+\\.\\d+),\\s*(-?\\d+\\.\\d+)(?:,\\s*(\\d+))?\\}\\})?"); 81 103 final SimpleDateFormat fmt = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss.SS"); 82 List<NanoLogEntry> result = new ArrayList< NanoLogEntry>();104 List<NanoLogEntry> result = new ArrayList<>(); 83 105 BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF8")); 84 106 while( r.ready() ) { … … 301 323 Main.map.mapView.repaint(); 302 324 } 303 325 304 326 private class CorrelateEntries extends JosmAction { 305 327 private boolean toZero; … … 328 350 } 329 351 } 330 352 331 353 private class SaveLayer extends JosmAction { 332 354 -
applications/editors/josm/plugins/NanoLog/src/nanolog/NanoLogPanel.java
r30701 r30737 20 20 /** 21 21 * NanoLog Panel. Displays the selected log item, along with surrounding 30-50 lines. 22 * 22 * 23 23 * @author zverik 24 24 */ … … 26 26 private JList<String> logPanel; 27 27 private LogListModel listModel; 28 28 29 29 public NanoLogPanel() { 30 30 super(tr("NanoLog"), "nanolog", tr("Open NanoLog panel"), null, 150, false); 31 31 32 32 listModel = new LogListModel(); 33 logPanel = new JList< String>(listModel);33 logPanel = new JList<>(listModel); 34 34 createLayout(logPanel, true, null); 35 35 } 36 36 37 37 public void updateMarkers() { 38 List<NanoLogEntry> entries = new ArrayList< NanoLogEntry>();38 List<NanoLogEntry> entries = new ArrayList<>(); 39 39 for( NanoLogLayer l : Main.map.mapView.getLayersOfType(NanoLogLayer.class) ) { 40 40 entries.addAll(l.getEntries()); … … 74 74 } 75 75 } 76 76 77 77 private class LogListModel extends AbstractListModel<String> { 78 78 private List<NanoLogEntry> entries; 79 79 private final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss"); 80 80 81 public int getSize() { 81 @Override 82 public int getSize() { 82 83 return entries.size(); 83 84 } 84 85 85 public String getElementAt( int index ) { 86 @Override 87 public String getElementAt( int index ) { 86 88 return TIME_FORMAT.format(entries.get(index).getTime()) + " " + entries.get(index).getMessage(); 87 89 }
Note:
See TracChangeset
for help on using the changeset viewer.