Changeset 30117 in osm
- Timestamp:
- 2013-12-07T22:09:36+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/OpeningTimeUtils.java
r30114 r30117 113 113 */ 114 114 public static String makeStringFromRects(ArrayList<TimeRect> givenTimeRects) { 115 // create an array of booleans representing every minute on all the days 116 // in a week 115 // create an array of booleans representing every minute on all the days in a week 117 116 boolean[][] minuteArray = new boolean[7][24 * 60 + 2]; 118 117 for (int day = 0; day < 7; ++day) { … … 259 258 return ret; 260 259 } 260 261 /** 262 * Ensures the given day is comprised between 0 and 6. 263 * @param day The day to check 264 * @param paramName The parameter name, used in error message 265 * @throws IllegalArgumentException if the day is invalid 266 */ 267 public static final void ensureValidDay(int day, String paramName) throws IllegalArgumentException { 268 if (day < 0 || day > 6) { 269 throw new IllegalArgumentException(paramName + " is not a valid day (0-6). Given value is " + day); 270 } 271 } 272 273 /** 274 * Ensures the given minute is comprised between 0 and 24*60+1. 275 * @param minute The minute to check 276 * @param paramName The parameter name, used in error message 277 * @throws IllegalArgumentException if the minute is invalid 278 */ 279 public static final void ensureValidMinute(int minute, String paramName) throws IllegalArgumentException { 280 if (minute < 0 || minute > 24*60+1) { 281 throw new IllegalArgumentException(paramName + " is not a valid minute (0-1441). Given value is " + minute); 282 } 283 } 261 284 } -
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/OheEditor.java
r30116 r30117 176 176 } 177 177 178 // update all the TimeRects with new Data 178 /** 179 * Updates all the TimeRects with new data. 180 */ 179 181 public void initTimeRects() { 180 182 contentPanel.removeAll(); -
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/TimeRect.java
r30116 r30117 19 19 import javax.swing.JPopupMenu; 20 20 21 import org.openstreetmap.josm.plugins.ohe.OpeningTimeUtils; 22 21 23 public class TimeRect extends JPanel implements MouseListener, MouseMotionListener { 22 24 … … 54 56 55 57 public TimeRect(OheEditor editor, int dayStart, int dayEnd, int minutesStart, int minutesEnd) { 58 OpeningTimeUtils.ensureValidDay(dayStart, "dayStart"); 59 OpeningTimeUtils.ensureValidDay(dayEnd, "dayEnd"); 60 OpeningTimeUtils.ensureValidMinute(minutesStart, "minutesStart"); 61 OpeningTimeUtils.ensureValidMinute(minutesEnd, "minutesEnd"); 62 56 63 this.editor = editor; 57 58 64 this.dayStart = dayStart; 59 65 this.dayEnd = dayEnd; … … 69 75 } 70 76 77 /** 78 * Returns the starting day, as an index between 0 and 6. 79 * @return the starting day index 80 */ 71 81 public int getDayStart() { 72 82 return dayStart; 73 83 } 74 84 85 /** 86 * Returns the ending day, as an index between 0 and 6. 87 * @return the ending day index 88 */ 75 89 public int getDayEnd() { 76 90 return dayEnd; … … 86 100 87 101 public void reposition() { 88 setBounds(editor.getPanelBoundsForTimeinterval(dayStart, dayEnd + 1, 89 minuteStart, minuteEnd)); 102 setBounds(editor.getPanelBoundsForTimeinterval(dayStart, dayEnd + 1, minuteStart, minuteEnd)); 90 103 editor.contentPanel.repaint(); 91 104 } … … 99 112 } 100 113 101 private void updateTimeInterval(int newDayStart, int newDayEnd, 102 int newMinuteStart, int newMinuteEnd) { 114 private void updateTimeInterval(int newDayStart, int newDayEnd, int newMinuteStart, int newMinuteEnd) { 115 OpeningTimeUtils.ensureValidDay(newDayStart, "newDayStart"); 116 OpeningTimeUtils.ensureValidDay(newDayEnd, "newDayEnd"); 117 OpeningTimeUtils.ensureValidMinute(newMinuteStart, "newMinuteStart"); 118 OpeningTimeUtils.ensureValidMinute(newMinuteEnd, "newMinuteEnd"); 119 103 120 dayStart = newDayStart; 104 121 dayEnd = newDayEnd; … … 185 202 public void showMenu(MouseEvent evt) { 186 203 JPopupMenu menu = new JPopupMenu(); 187 final JCheckBoxMenuItem cbMenuItem = new JCheckBoxMenuItem( 188 tr("open end"), isOpenEndInterval()); 204 final JCheckBoxMenuItem cbMenuItem = new JCheckBoxMenuItem(tr("open end"), isOpenEndInterval()); 189 205 menu.add(cbMenuItem); 190 206 cbMenuItem.addActionListener(new ActionListener() { … … 192 208 public void actionPerformed(ActionEvent e) { 193 209 if (cbMenuItem.isSelected()) 194 updateTimeInterval(dayStart, dayEnd, minuteStart, 195 24 * 60 + 1); 210 updateTimeInterval(dayStart, dayEnd, minuteStart, 24 * 60 + 1); 196 211 else 197 212 updateTimeInterval(dayStart, dayEnd, minuteStart, 24 * 60); … … 265 280 } else if (newDayStart >= 0 && newDayEnd <= 6) { 266 281 actualDayDrag += xDiff; 267 updateTimeInterval(newDayStart, newDayEnd, minuteStart, 268 minuteEnd); 282 updateTimeInterval(newDayStart, newDayEnd, minuteStart, minuteEnd); 269 283 } 270 284 } … … 282 296 && (newMinutesEnd <= 24 * 60 || isOpenEndInterval())) { 283 297 actualMinuteDrag += yDiff; 284 updateTimeInterval(dayStart, dayEnd, newMinutesStart, 285 newMinutesEnd); 298 updateTimeInterval(dayStart, dayEnd, newMinutesStart, newMinutesEnd); 286 299 } 287 300 }
Note:
See TracChangeset
for help on using the changeset viewer.