Changeset 32583 in osm
- Timestamp:
- 2016-07-05T23:46:31+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/OpeningHoursEditor
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/OpeningHoursEditor/.project
r32286 r32583 21 21 </arguments> 22 22 </buildCommand> 23 <buildCommand> 24 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> 25 <arguments> 26 </arguments> 27 </buildCommand> 23 28 </buildSpec> 24 29 <natures> 25 30 <nature>org.eclipse.jdt.core.javanature</nature> 26 31 <nature>sf.eclipse.javacc.javaccnature</nature> 32 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 27 33 </natures> 28 34 </projectDescription> -
applications/editors/josm/plugins/OpeningHoursEditor/build.xml
r32448 r32583 4 4 <property name="commit.message" value="fixed main version"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="10 353"/>6 <property name="plugin.main.version" value="10420"/> 7 7 8 8 <property name="plugin.author" value="Falko Thomale"/> -
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/ClockSystem.java
r30116 r32583 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.ohe; 2 3 … … 4 5 import java.text.ParseException; 5 6 import java.util.Locale; 7 8 import org.openstreetmap.josm.Main; 6 9 7 10 /** … … 27 30 midnight = localeFormat.format(stdFormat.parse("12:00 AM")); 28 31 } catch (ParseException ignore) { 32 Main.trace(ignore); 29 33 } 30 34 if (midnight.contains("12")) -
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/OhePlugin.java
r32448 r32583 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.ohe; 2 3 … … 59 60 */ 60 61 private final String[][] TAG_EDIT_STRINGS = new String[][] { 61 { "opening_hours", ".*", "opening_hours"},62 { "collection_times", ".*", "collection_times"},63 { "collection_times:local", ".*", "collection_times:local"},64 { "shop", ".*", "opening_hours"},65 { "amenity", "post_box", "collection_times"},66 { "amenity", "recycling", "collection_times"},67 { "amenity", ".*", "opening_hours"},68 { "lit", ".*", "lit"},69 { "highway", ".*", "lit"} };62 {"opening_hours", ".*", "opening_hours"}, 63 {"collection_times", ".*", "collection_times"}, 64 {"collection_times:local", ".*", "collection_times:local"}, 65 {"shop", ".*", "opening_hours"}, 66 {"amenity", "post_box", "collection_times"}, 67 {"amenity", "recycling", "collection_times"}, 68 {"amenity", ".*", "opening_hours"}, 69 {"lit", ".*", "lit"}, 70 {"highway", ".*", "lit"} }; 70 71 71 72 /** … … 86 87 private static final long serialVersionUID = 1456257438391417756L; 87 88 88 publicOheMenuAction() {89 OheMenuAction() { 89 90 super(tr("Edit opening hours"), "opening_hours.png", 90 91 tr("Edit time-tag of selected element in a graphical interface"), Shortcut.registerShortcut( … … 149 150 } 150 151 }; 151 propertyData.setColumnIdentifiers(new String[] { tr("Key"), tr("Value")});152 propertyData.setColumnIdentifiers(new String[] {tr("Key"), tr("Value")}); 152 153 for (Entry<String, Map<String, Integer>> e : valueCount.entrySet()) { 153 154 int count = 0; … … 158 159 e.getValue().put("", selection.size() - count); 159 160 } 160 propertyData.addRow(new Object[] { e.getKey(), e.getValue()});161 propertyData.addRow(new Object[] {e.getKey(), e.getValue()}); 161 162 } 162 163 final JTable propertyTable = new JTable(propertyData); … … 229 230 break searchLoop; 230 231 } else if (value instanceof Map<?, ?>) { 231 for (String v : ((Map<String, Integer>) value).keySet()) 232 for (String v : ((Map<String, Integer>) value).keySet()) { 232 233 if (valuePattern.matcher(v).matches()) { 233 234 preSelectedKey = pattern[2]; 234 235 break searchLoop; 235 236 } 237 } 236 238 } 237 239 } … … 239 241 } 240 242 int preSelectedRow = -1; 241 for (int i = 0; i < propertyData.getRowCount(); ++i) 243 for (int i = 0; i < propertyData.getRowCount(); ++i) { 242 244 if (preSelectedKey.equals(propertyData.getValueAt(i, 0))) { 243 245 preSelectedRow = i; 244 246 } 247 } 245 248 if (preSelectedRow != -1) { 246 249 propertyTable.setEnabled(true); … … 304 307 String[] changedKeyValuePair = null; 305 308 answer = optionPane.getValue(); 306 if (!(answer == null || answer == JOptionPane.UNINITIALIZED_VALUE || (answer instanceof Integer && (Integer) answer != JOptionPane.OK_OPTION))) { 309 if (!(answer == null || answer == JOptionPane.UNINITIALIZED_VALUE 310 || (answer instanceof Integer && (Integer) answer != JOptionPane.OK_OPTION))) { 307 311 changedKeyValuePair = panel.getChangedKeyValuePair(); 308 312 } -
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/OpeningTimeUtils.java
r30737 r32583 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.ohe; 2 3 … … 9 10 * Collection of utility methods. 10 11 */ 11 public class OpeningTimeUtils { 12 public final class OpeningTimeUtils { 13 14 private OpeningTimeUtils() { 15 // Hide default constructors for utilities classes 16 } 12 17 13 18 /** … … 53 58 for (DaytimeSpan timespan : dateTime2.daytimeSpans) { 54 59 if (!timespan.isOff()) { 55 ret.add(new int[] { 60 ret.add(new int[] {dayspan.startDay, dayspan.endDay, timespan.startMinute, 56 61 timespan.endMinute }); 57 62 } … … 245 250 246 251 private static boolean isArrayEmpty(boolean[] bs) { 247 for (int i = 0; i < bs.length; i++) 252 for (int i = 0; i < bs.length; i++) { 248 253 if (bs[i]) 249 254 return false; 255 } 250 256 return true; 251 257 } … … 265 271 * @throws IllegalArgumentException if the day is invalid 266 272 */ 267 public static finalvoid ensureValidDay(int day, String paramName) throws IllegalArgumentException {273 public static void ensureValidDay(int day, String paramName) throws IllegalArgumentException { 268 274 if (day < 0 || day > 6) { 269 275 throw new IllegalArgumentException(paramName + " is not a valid day (0-6). Given value is " + day); … … 277 283 * @throws IllegalArgumentException if the minute is invalid 278 284 */ 279 public static finalvoid ensureValidMinute(int minute, String paramName) throws IllegalArgumentException {285 public static void ensureValidMinute(int minute, String paramName) throws IllegalArgumentException { 280 286 if (minute < 0 || minute > 24*60+1) { 281 287 throw new IllegalArgumentException(paramName + " is not a valid minute (0-1441). Given value is " + minute); -
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/OheDialogPanel.java
r30722 r32583 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.ohe.gui; 2 3 … … 47 48 * The Panel for editing the time-values. 48 49 * 49 * @param plugin50 * @param key51 50 * @param valuesToEdit 52 * can be a String or a Map <String, Integer>which contains51 * can be a String or a Map<String, Integer> which contains 53 52 * multiple values and their number of occurences 54 53 */ … … 70 69 // TODO let the user choose which value he wants to edit (e.g. with a combobox) 71 70 int mostOccurences = 0; 72 for (String v : valuesMap.keySet()) 71 for (String v : valuesMap.keySet()) { 73 72 if (valuesMap.get(v) > mostOccurences) { 74 73 value = v; 75 74 mostOccurences = valuesMap.get(v); 76 75 } 76 } 77 77 } 78 78 } … … 118 118 119 119 public String[] getChangedKeyValuePair() { 120 return new String[] { oldkey, keyField.getText(), valueField.getText()};120 return new String[] {oldkey, keyField.getText(), valueField.getText()}; 121 121 } 122 122 … … 135 135 Main.warn(t); 136 136 137 int tColumns[]= null;137 int[] tColumns = null; 138 138 String info = t.getMessage(); 139 139 140 140 if (t instanceof ParseException) { 141 141 ParseException parserExc = (ParseException) t; 142 tColumns = new int[] { parserExc.currentToken.beginColumn - 1, parserExc.currentToken.endColumn + 1};142 tColumns = new int[] {parserExc.currentToken.beginColumn - 1, parserExc.currentToken.endColumn + 1}; 143 143 } else if (t instanceof SyntaxException) { 144 144 SyntaxException syntaxError = (SyntaxException) t; 145 tColumns = new int[] { syntaxError.getStartColumn(), syntaxError.getEndColumn()};145 tColumns = new int[] {syntaxError.getStartColumn(), syntaxError.getEndColumn()}; 146 146 } else if (t instanceof TokenMgrError) { 147 147 try { … … 150 150 if (idx > -1) { 151 151 int col = Integer.parseInt(info.substring(idx+"column ".length(), info.indexOf('.', idx))); 152 tColumns = new int[] { col - 1, col + 1};152 tColumns = new int[] {col - 1, col + 1}; 153 153 } 154 154 } catch (IndexOutOfBoundsException e) { -
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/OheEditor.java
r30737 r32583 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.ohe.gui; 2 3 … … 20 21 21 22 public class OheEditor extends JPanel implements MouseListener, MouseMotionListener { 23 private final class OhePanel extends JPanel { 24 @Override 25 public void setSize(Dimension d) { 26 super.setSize(d); 27 repositionTimeRects(); 28 } 29 30 @Override 31 public void paintComponent(Graphics g) { 32 if (OheEditor.this.isEnabled()) { 33 g.setColor(Color.WHITE); 34 g.fillRect(0, 0, getWidth(), getHeight()); 35 36 // draw the time from 12PM to 00AM in a different color 37 if (dialog.getHourMode() == ClockSystem.TWELVE_HOURS) { 38 g.setColor(new Color(255, 255, 218)); 39 g.fillRect(0, getMinutePosition(12 * 60), getWidth(), getHeight() - getMinutePosition(12 * 60)); 40 } 41 42 // horizontal Lines 43 for (int i = 0; i <= 24; ++i) { 44 if (i % 3 == 0) { 45 g.setColor(Color.BLACK); 46 } else { 47 g.setColor(Color.LIGHT_GRAY); 48 } 49 g.drawLine(0, getMinutePosition(i * 60), getWidth(), getMinutePosition(i * 60)); 50 } 51 52 // vertical Lines 53 g.setColor(Color.BLACK); 54 for (int i = 0; i <= 7; ++i) { 55 g.drawLine(getDayPosition(i), 0, getDayPosition(i), getHeight()); 56 } 57 58 // if a new Rect is dragged draw it 59 if (day0 >= 0) { 60 Graphics2D g2D = (Graphics2D) g; 61 int day2 = Math.min(day0, day1); 62 int day3 = Math.max(day0, day1); 63 int minute2 = Math.min(minute0, minute1); 64 int minute3 = Math.max(minute0, minute1); 65 Rectangle bounds = getPanelBoundsForTimeinterval(day2, day3 + 1, minute2, minute3); 66 TimeRect.drawTimeRect(g2D, bounds, minute2 == minute3, false); 67 } 68 } else { 69 g.setColor(Color.LIGHT_GRAY); 70 g.fillRect(0, 0, getWidth(), getHeight()); 71 } 72 } 73 } 74 22 75 final OheDialogPanel dialog; 23 76 24 final privateJScrollPane scrollPane;77 private final JScrollPane scrollPane; 25 78 final JPanel contentPanel; 26 79 27 80 ArrayList<TimeRect> timeRects; 28 81 29 final privateint dayAxisHeight = 20;30 final privateint timeAxisWidth = 45;82 private final int dayAxisHeight = 20; 83 private final int timeAxisWidth = 45; 31 84 32 85 public OheEditor(OheDialogPanel oheDialogPanel) { … … 34 87 35 88 // the MainPanel for showing the TimeRects 36 contentPanel = new JPanel() { 37 @Override 38 public void setSize(Dimension d) { 39 super.setSize(d); 40 repositionTimeRects(); 41 } 42 43 @Override 44 public void paintComponent(Graphics g) { 45 if (OheEditor.this.isEnabled()) { 46 g.setColor(Color.WHITE); 47 g.fillRect(0, 0, getWidth(), getHeight()); 48 49 // draw the time from 12PM to 00AM in a different color 50 if (dialog.getHourMode() == ClockSystem.TWELVE_HOURS) { 51 g.setColor(new Color(255, 255, 218)); 52 g.fillRect(0, getMinutePosition(12 * 60), getWidth(), getHeight() - getMinutePosition(12 * 60)); 53 } 54 55 // horizontal Lines 56 for (int i = 0; i <= 24; ++i) { 57 if (i % 3 == 0) { 58 g.setColor(Color.BLACK); 59 } else { 60 g.setColor(Color.LIGHT_GRAY); 61 } 62 63 g.drawLine(0, getMinutePosition(i * 60), getWidth(), getMinutePosition(i * 60)); 64 } 65 66 // vertical Lines 67 g.setColor(Color.BLACK); 68 for (int i = 0; i <= 7; ++i) { 69 g.drawLine(getDayPosition(i), 0, getDayPosition(i), getHeight()); 70 } 71 72 // if a new Rect is dragged draw it 73 if (day0 >= 0) { 74 Graphics2D g2D = (Graphics2D) g; 75 76 int day2 = Math.min(day0, day1); 77 int day3 = Math.max(day0, day1); 78 int minute2 = Math.min(minute0, minute1); 79 int minute3 = Math.max(minute0, minute1); 80 Rectangle bounds = getPanelBoundsForTimeinterval(day2, day3 + 1, minute2, minute3); 81 82 TimeRect.drawTimeRect(g2D, bounds, minute2 == minute3, false); 83 } 84 } else { 85 g.setColor(Color.LIGHT_GRAY); 86 g.fillRect(0, 0, getWidth(), getHeight()); 87 } 88 } 89 }; 89 contentPanel = new OhePanel(); 90 90 contentPanel.addMouseListener(this); 91 91 contentPanel.addMouseMotionListener(this); -
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/TimeRect.java
r30519 r32583 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.ohe.gui; 2 3 … … 34 35 35 36 public static final boolean[][] transformDirections = new boolean[][] { 36 { true, true, true, true}, // Drag37 { true, false, false, false}, // N38 { true, true, false, false}, // NE39 { false, true, false, false}, // E40 { false, true, true, false}, // SE41 { false, false, true, false}, // S42 { false, false, true, true}, // SW43 { false, false, false, true}, // W44 { true, false, false, true}, // NW37 {true, true, true, true}, // Drag 38 {true, false, false, false}, // N 39 {true, true, false, false}, // NE 40 {false, true, false, false}, // E 41 {false, true, true, false}, // SE 42 {false, false, true, false}, // S 43 {false, false, true, true}, // SW 44 {false, false, false, true}, // W 45 {true, false, false, true}, // NW 45 46 }; 46 47
Note:
See TracChangeset
for help on using the changeset viewer.