Changeset 28477 in osm for applications/editors/josm/plugins/OpeningHoursEditor
- Timestamp:
- 2012-07-12T14:42:28+02:00 (12 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/OhePlugin.java
r27852 r28477 40 40 import org.openstreetmap.josm.command.SequenceCommand; 41 41 import org.openstreetmap.josm.data.osm.OsmPrimitive; 42 import org.openstreetmap.josm.gui.MainMenu; 42 43 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 43 44 import org.openstreetmap.josm.plugins.Plugin; … … 72 73 public OhePlugin(PluginInformation info) { 73 74 super(info); 74 Main .main.menu.toolsMenu.add(new OheMenuAction());75 MainMenu.add(Main.main.menu.toolsMenu, new OheMenuAction()); 75 76 } 76 77 … … 88 89 tr("Edit time-tag of selected element in a graphical interface"), Shortcut.registerShortcut( 89 90 "tools:opening_hourseditor", tr("Tool: {0}", tr("Edit opening hours")), KeyEvent.VK_O, 90 Shortcut.ALT_CTRL_SHIFT), false);91 Shortcut.ALT_CTRL_SHIFT), true); 91 92 } 92 93 -
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/OheEditor.java
r26215 r28477 47 47 g.setColor(Color.WHITE); 48 48 g.fillRect(0, 0, getWidth(), getHeight()); 49 50 // draw the time from 12PM to 00AM in a different color 49 51 if (dialog.getHourMode() == ClockSystem.TWELVE_HOURS) { 50 52 g.setColor(new Color(255, 255, 218)); … … 53 55 54 56 // horizontal Lines 55 for (int i = 1; i <24; ++i) {57 for (int i = 0; i <= 24; ++i) { 56 58 if (i % 3 == 0) { 57 59 g.setColor(Color.BLACK); … … 65 67 // vertical Lines 66 68 g.setColor(Color.BLACK); 67 for (int i = 1; i <7; ++i) {69 for (int i = 0; i <= 7; ++i) { 68 70 g.drawLine(getDayPosition(i), 0, getDayPosition(i), getHeight()); 69 71 } … … 113 115 for (int i = 0; i < 7; ++i) { 114 116 if (i > 0) { 115 g.drawLine(getDayPosition(i) + 1, 0, getDayPosition(i) + 1, getHeight());117 g.drawLine(getDayPosition(i), 0, getDayPosition(i), getHeight()); 116 118 } 117 119 … … 134 136 g.setColor(Color.WHITE); 135 137 g.fillRect(0, 0, getWidth(), getHeight()); 138 139 // draw the time from 12PM to 00AM in a different color 136 140 if (dialog.getHourMode() == ClockSystem.TWELVE_HOURS) { 137 141 g.setColor(new Color(255, 255, 218)); … … 139 143 } 140 144 141 for (int i = 1; i <24; ++i) {145 for (int i = 0; i <= 24; ++i) { 142 146 if (i % 3 == 0) { 143 147 g.setColor(Color.BLACK); 144 String text = OpeningTimeUtils.timeString(i * 60, dialog.getHourMode(), false); 145 g.drawString(text, (timeAxisWidth - g.getFontMetrics().stringWidth(text)) / 2, 146 getMinutePosition(i * 60) + (int) (g.getFontMetrics().getHeight() * 0.35)); 148 if (i % 24 != 0) { 149 String text = OpeningTimeUtils.timeString(i * 60, dialog.getHourMode(), false); 150 g.drawString(text, (timeAxisWidth - g.getFontMetrics().stringWidth(text)) / 2, 151 getMinutePosition(i * 60) + (int) (g.getFontMetrics().getHeight() * 0.35)); 152 } 147 153 } else { 148 154 g.setColor(Color.LIGHT_GRAY); … … 216 222 int height = getMinutePosition(minutesEnd) - getMinutePosition(minutesStart); 217 223 218 // work around openjdk bug219 if (Main.isOpenjdk) {220 x++;221 y++;222 }223 224 224 if (minutesStart == minutesEnd) 225 225 return new Rectangle(x, y - 2 - TimeRect.verticalNonDrawedPixels, width, height + 5 + 2 … … 267 267 @Override 268 268 public void mouseEntered(MouseEvent evt) { 269 if (!isEnabled()) { 270 return; // allow no mouse actions when the editor is not enabled 271 } 269 272 mousePositionChanged(0, 0, true); 270 273 } … … 272 275 @Override 273 276 public void mouseExited(MouseEvent evt) { 277 if (!isEnabled()) { 278 return; // allow no mouse actions when the editor is not enabled 279 } 274 280 mousePositionChanged(0, 0, false); 275 281 } … … 277 283 @Override 278 284 public void mousePressed(MouseEvent evt) { 285 if (!isEnabled()) { 286 return; // allow no mouse actions when the editor is not enabled 287 } 279 288 day0 = (int) Math.floor(evt.getX() / getDayWidth()); 280 289 minute0 = (int) Math.floor(evt.getY() / (getMinuteHeight() * TimeRect.minuteResterize)) … … 288 297 @Override 289 298 public void mouseReleased(MouseEvent evt) { 299 if (!isEnabled()) { 300 return; // allow no mouse actions when the editor is not enabled 301 } 290 302 // mouse must be moved 5px before creating a rect 291 303 if (xDragStart == -1 || Math.abs(evt.getX() - xDragStart) + Math.abs(evt.getY() - yDragStart) > 5) { … … 308 320 @Override 309 321 public void mouseDragged(MouseEvent evt) { 322 if (!isEnabled()) { 323 return; // allow no mouse actions when the editor is not enabled 324 } 310 325 // mouse must be moved 5px before drawing a rect 311 326 if (xDragStart == -1 || Math.abs(evt.getX() - xDragStart) + Math.abs(evt.getY() - yDragStart) > 5) { … … 313 328 day1 = (int) Math.floor(evt.getX() / getDayWidth()); 314 329 minute1 = (int) Math.floor(evt.getY() / (getMinuteHeight() * TimeRect.minuteResterize)) 315 * TimeRect.minuteResterize;330 * TimeRect.minuteResterize; 316 331 317 332 // ensure that the new time is in a valid range … … 328 343 @Override 329 344 public void mouseMoved(MouseEvent evt) { 345 if (!isEnabled()) { 346 return; // allow no mouse actions when the editor is not enabled 347 } 330 348 mousePositionChanged(evt.getX(), evt.getY(), true); 331 349 } … … 335 353 int actualDay = (int) Math.floor(x / getDayWidth()); 336 354 int minutes = (int) Math.floor(y / (getMinuteHeight() * TimeRect.minuteResterize)) 337 * TimeRect.minuteResterize;355 * TimeRect.minuteResterize; 338 356 actualDay = Math.max(0, Math.min(6, actualDay)); 339 357 minutes = Math.max(0, Math.min(24 * 60, minutes)); -
applications/editors/josm/plugins/OpeningHoursEditor/src/org/openstreetmap/josm/plugins/ohe/gui/TimeRect.java
r26838 r28477 214 214 @Override 215 215 public void mouseExited(MouseEvent evt) { 216 if (transformType < 0) 216 if (transformType < 0) { 217 217 setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); 218 } 219 editor.mousePositionChanged(0, 0, false); 218 220 } 219 221 … … 293 295 @Override 294 296 public void mouseMoved(MouseEvent evt) { 295 if (transformType < 0) 297 if (transformType < 0) { 296 298 setCursor(new Cursor(transformCursorTypes[getTransformType(evt)])); 299 } 297 300 editor.mousePositionChanged(evt.getX() + getX(), evt.getY() + getY(), true); 298 301 }
Note:
See TracChangeset
for help on using the changeset viewer.