source: josm/trunk/src/org/openstreetmap/josm/gui/animation/AnimationExtensionManager.java@ 17322

Last change on this file since 17322 was 17322, checked in by Don-vip, 3 years ago

fix #20018 - disable repaint timer when no animation extension is enabled

  • Property svn:eol-style set to native
File size: 1.6 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.animation;
3
4import java.util.Calendar;
5import java.util.Date;
6import java.util.GregorianCalendar;
7
8import org.openstreetmap.josm.data.preferences.BooleanProperty;
9
10/**
11 * Animation extension manager. Copied from Icedtea-Web.
12 * @author Jiri Vanek (Red Hat)
13 * @see <a href="http://icedtea.classpath.org/hg/icedtea-web/rev/87d3081ab573">Initial commit</a>
14 * @since 14578
15 */
16public final class AnimationExtensionManager {
17
18 private static volatile AnimationExtension currentExtension;
19 private static final BooleanProperty PROP_ANIMATION = new BooleanProperty("gui.start.animation", true);
20
21 private AnimationExtensionManager() {
22 // Hide default constructor for utility classes
23 }
24
25 /**
26 * Returns the current animation extension.
27 * @return the current animation extension
28 */
29 public static AnimationExtension getExtension() {
30 if (currentExtension == null) {
31 currentExtension = Boolean.TRUE.equals(PROP_ANIMATION.get()) && isChristmas() ? new ChristmasExtension()
32 : new NoExtension();
33 }
34 return currentExtension;
35 }
36
37 /**
38 * Determines if an extension other than {@link NoExtension} is enabled.
39 * @return {@code true} if an extension other than {@code NoExtension} is enabled.
40 * @since 17322
41 */
42 public static boolean isExtensionEnabled() {
43 return !(getExtension() instanceof NoExtension);
44 }
45
46 private static boolean isChristmas() {
47 Calendar c = new GregorianCalendar();
48 c.setTime(new Date());
49 return c.get(Calendar.DAY_OF_YEAR) > 350;
50 }
51}
Note: See TracBrowser for help on using the repository browser.