Changeset 19254 in josm
- Timestamp:
- 2024-11-06T16:27:33+01:00 (2 weeks ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/GettingStarted.java
r18601 r19254 7 7 import java.awt.EventQueue; 8 8 import java.awt.Graphics; 9 import java.awt.Point; 10 import java.awt.event.MouseMotionListener; 11 import java.awt.event.MouseEvent; 12 import java.awt.event.MouseListener; 9 13 import java.io.IOException; 10 14 import java.nio.charset.StandardCharsets; … … 15 19 import javax.swing.JPanel; 16 20 import javax.swing.JScrollPane; 21 import javax.swing.SwingUtilities; 17 22 import javax.swing.Timer; 18 23 import javax.swing.border.EmptyBorder; 19 24 import javax.swing.event.HyperlinkEvent; 20 25 import javax.swing.event.HyperlinkListener; 26 import javax.swing.event.MouseInputListener; 21 27 22 28 import org.openstreetmap.josm.actions.DownloadAction; … … 24 30 import org.openstreetmap.josm.actions.HistoryInfoAction; 25 31 import org.openstreetmap.josm.data.Version; 32 import org.openstreetmap.josm.gui.animation.AnimationExtension; 26 33 import org.openstreetmap.josm.gui.animation.AnimationExtensionManager; 27 34 import org.openstreetmap.josm.gui.datatransfer.OpenTransferHandler; … … 48 55 * contains news about recent major changes, warning in case of outdated versions, etc. 49 56 */ 50 public final class GettingStarted extends JPanel implements ProxyPreferenceListener {57 public final class GettingStarted extends JPanel implements ProxyPreferenceListener, MouseInputListener { 51 58 52 59 private final LinkGeneral lg; … … 155 162 add(scroller, BorderLayout.CENTER); 156 163 164 scroller.addMouseMotionListener(this); 165 scroller.addMouseListener(this); 166 lg.addMouseMotionListener(this); 167 lg.addMouseListener(this); 168 157 169 getMOTD(); 158 170 … … 177 189 178 190 @Override 191 public void mouseMoved(MouseEvent e) { 192 final AnimationExtension extension = AnimationExtensionManager.getExtension(); 193 if (extension instanceof MouseMotionListener) { 194 ((MouseMotionListener) extension).mouseMoved(e); 195 } 196 } 197 198 @Override 199 public void mouseDragged(MouseEvent e) { 200 // Ignored 201 } 202 203 @Override 204 public void mousePressed(MouseEvent e) { 205 final AnimationExtension extension = AnimationExtensionManager.getExtension(); 206 if (extension instanceof MouseListener) { 207 ((MouseListener) extension).mousePressed(e); 208 } 209 } 210 211 @Override 212 public void mouseEntered(MouseEvent e) { 213 // Ignored 214 } 215 216 @Override 217 public void mouseExited(MouseEvent e) { 218 // Ignored 219 } 220 221 @Override 222 public void mouseReleased(MouseEvent e) { 223 final AnimationExtension extension = AnimationExtensionManager.getExtension(); 224 if (extension instanceof MouseListener) { 225 ((MouseListener) extension).mouseReleased(e); 226 } 227 } 228 229 @Override 230 public void mouseClicked(MouseEvent e) { 231 // Ignored 232 } 233 234 @Override 179 235 public void paint(Graphics g) { 180 236 super.paint(g); 181 237 if (isShowing()) { 182 AnimationExtensionManager.getExtension().adjustForSize(getWidth(), getHeight()); 238 Point p = new Point(0, 0); 239 SwingUtilities.convertPointToScreen(p, this); 240 AnimationExtensionManager.getExtension().adjustForSize(getWidth(), getHeight(), p.x, p.y); 183 241 AnimationExtensionManager.getExtension().animate(); 184 242 AnimationExtensionManager.getExtension().paint(g); -
trunk/src/org/openstreetmap/josm/gui/animation/AnimationExtension.java
r14578 r19254 16 16 * @param w width 17 17 * @param h height 18 * @param x x origin of view area 19 * @param y y origin of view area 18 20 */ 19 void adjustForSize(int w, int h );21 void adjustForSize(int w, int h, int x, int y); 20 22 21 23 /** -
trunk/src/org/openstreetmap/josm/gui/animation/AnimationExtensionManager.java
r17726 r19254 3 3 4 4 import java.time.LocalDate; 5 import java.time.Month; 5 6 import java.time.ZoneId; 6 7 … … 28 29 public static AnimationExtension getExtension() { 29 30 if (currentExtension == null) { 30 currentExtension = Boolean.TRUE.equals(PROP_ANIMATION.get()) && isChristmas() ? new ChristmasExtension() 31 : new NoExtension(); 31 final boolean isAnimated = Boolean.TRUE.equals(PROP_ANIMATION.get()); 32 if (isAnimated && isChristmas()) { 33 currentExtension = new ChristmasExtension(); 34 } else if (isAnimated && isBirthday()) { 35 currentExtension = new BirthdayExtension(); 36 } else { 37 currentExtension = new NoExtension(); 38 } 32 39 } 33 40 return currentExtension; … … 46 53 return LocalDate.now(ZoneId.systemDefault()).getDayOfYear() > 350; 47 54 } 55 56 /** 57 * The first commit of JOSM to svn (r1) was on 2005-09-27 58 * @return {@code true} if today is JOSM's birthday 59 */ 60 private static boolean isBirthday() { 61 LocalDate l = LocalDate.now(ZoneId.systemDefault()); 62 return l.getMonth() == Month.SEPTEMBER && l.getDayOfMonth() == 27; 63 } 48 64 } -
trunk/src/org/openstreetmap/josm/gui/animation/ChristmasExtension.java
r18932 r19254 29 29 30 30 @Override 31 public final void adjustForSize(int w, int h ) {31 public final void adjustForSize(int w, int h, int x, int y) { 32 32 int count = w / (2 * (Star.averageStarWidth + 1)); 33 33 while (objs.size() > count) { -
trunk/src/org/openstreetmap/josm/gui/animation/NoExtension.java
r14581 r19254 16 16 17 17 @Override 18 public void adjustForSize(int w, int h ) {18 public void adjustForSize(int w, int h, int x, int y) { 19 19 // No-op 20 20 }
Note:
See TracChangeset
for help on using the changeset viewer.