Changeset 17842 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2021-05-01T13:11:58+02:00 (4 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r17718 r17842 58 58 import java.util.Arrays; 59 59 import java.util.Collections; 60 import java.util.Date;61 60 import java.util.List; 62 61 import java.util.NoSuchElementException; … … 350 349 * @param showWithoutDate Include tracks that don't have any date set.. 351 350 */ 352 public void filterTracksByDate( Date fromDate, DatetoDate, boolean showWithoutDate) {351 public void filterTracksByDate(Instant fromDate, Instant toDate, boolean showWithoutDate) { 353 352 int i = 0; 354 long from = fromDate. getTime();355 long to = toDate. getTime();353 long from = fromDate.toEpochMilli(); 354 long to = toDate.toEpochMilli(); 356 355 for (IGpxTrack trk : data.getTracks()) { 357 356 Instant[] t = GpxData.getMinMaxTimeForTrack(trk); -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/DateFilterPanel.java
r17715 r17842 10 10 import java.time.ZoneId; 11 11 import java.time.ZonedDateTime; 12 import java.util.Date;13 12 14 13 import javax.swing.JCheckBox; … … 52 51 this.layer = layer; 53 52 54 final DatestartTime, endTime;53 final Instant startTime, endTime; 55 54 Instant[] bounds = layer.data.getMinMaxTimeForAllTracks(); 56 55 if (bounds.length == 0) { 57 startTime = Date.from(ZonedDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault()).toInstant());58 endTime = new Date();56 startTime = ZonedDateTime.of(2000, 1, 1, 0, 0, 0, 0, ZoneId.systemDefault()).toInstant(); 57 endTime = Instant.now(); 59 58 } else { 60 startTime = Date.from(bounds[0]);61 endTime = Date.from(bounds[1]);59 startTime = bounds[0]; 60 endTime = bounds[1]; 62 61 } 63 62 … … 109 108 */ 110 109 public void saveInPrefs() { 111 Config.getPref().putLong(prefDateMin, dateFrom.getDate(). getTime());112 Config.getPref().putLong(prefDateMax, dateTo.getDate(). getTime());110 Config.getPref().putLong(prefDateMin, dateFrom.getDate().toEpochMilli()); 111 Config.getPref().putLong(prefDateMax, dateTo.getDate().toEpochMilli()); 113 112 Config.getPref().putBoolean(prefDate0, noTimestampCb.isSelected()); 114 113 } … … 120 119 public void loadFromPrefs() { 121 120 long t1 = Config.getPref().getLong(prefDateMin, 0); 122 if (t1 != 0) dateFrom.setDate( new Date(t1));121 if (t1 != 0) dateFrom.setDate(Instant.ofEpochMilli(t1)); 123 122 long t2 = Config.getPref().getLong(prefDateMax, 0); 124 if (t2 != 0) dateTo.setDate( new Date(t2));123 if (t2 != 0) dateTo.setDate(Instant.ofEpochMilli(t2)); 125 124 noTimestampCb.setSelected(Config.getPref().getBoolean(prefDate0, false)); 126 125 } … … 135 134 136 135 private void filterTracksByDate() { 137 Datefrom = dateFrom.getDate();138 Dateto = dateTo.getDate();136 Instant from = dateFrom.getDate(); 137 Instant to = dateTo.getDate(); 139 138 layer.filterTracksByDate(from, to, noTimestampCb.isSelected()); 140 139 } -
trunk/src/org/openstreetmap/josm/gui/widgets/DateEditorWithSlider.java
r12304 r17842 7 7 import java.text.DateFormat; 8 8 import java.text.SimpleDateFormat; 9 import java.time.Instant; 9 10 import java.util.ArrayList; 10 11 import java.util.Date; … … 29 30 private final JSpinner spinner; 30 31 private final JSlider slider; 31 private DatedateMin;32 private DatedateMax;32 private Instant dateMin; 33 private Instant dateMax; 33 34 private static final int MAX_SLIDER = 300; 34 35 private boolean watchSlider = true; … … 76 77 add(slider, GBC.eol().insets(10, 0, 0, 0).fill(GBC.HORIZONTAL)); 77 78 78 dateMin = new Date(0);79 dateMax = new Date();79 dateMin = Instant.EPOCH; 80 dateMax = Instant.now(); 80 81 } 81 82 82 83 protected Date dateFromInt(int value) { 83 84 double k = 1.0*value/MAX_SLIDER; 84 return new Date((long) (dateMax. getTime()*k+ dateMin.getTime()*(1-k)));85 return new Date((long) (dateMax.toEpochMilli()*k+ dateMin.toEpochMilli()*(1-k))); 85 86 } 86 87 87 88 protected int intFromDate(Date date) { 88 return (int) (300.0*(date.getTime()-dateMin.get Time()) /89 (dateMax.get Time()-dateMin.getTime()));89 return (int) (300.0*(date.getTime()-dateMin.getEpochSecond()) / 90 (dateMax.getEpochSecond()-dateMin.getEpochSecond())); 90 91 } 91 92 … … 95 96 * @param dateMax The max date 96 97 */ 97 public void setRange( Date dateMin, DatedateMax) {98 this.dateMin = DateUtils.cloneDate(dateMin);99 this.dateMax = DateUtils.cloneDate(dateMax);98 public void setRange(Instant dateMin, Instant dateMax) { 99 this.dateMin = dateMin; 100 this.dateMax = dateMax; 100 101 } 101 102 … … 104 105 * @param date The date 105 106 */ 106 public void setDate( Datedate) {107 spinner.setValue(Date Utils.cloneDate(date));107 public void setDate(Instant date) { 108 spinner.setValue(Date.from(date)); 108 109 } 109 110 … … 112 113 * @return The date 113 114 */ 114 public DategetDate() {115 return DateUtils.cloneDate((Date) spinner.getValue());115 public Instant getDate() { 116 return ((Date) spinner.getValue()).toInstant(); 116 117 } 117 118
Note:
See TracChangeset
for help on using the changeset viewer.