001// License: GPL. For details, see LICENSE file.
002package org.openstreetmap.josm.gui.animation;
003
004import java.util.Calendar;
005import java.util.Date;
006import java.util.GregorianCalendar;
007
008/**
009 * Animation extension manager. Copied from Icedtea-Web.
010 * @author Jiri Vanek (Red Hat)
011 * @see <a href="http://icedtea.classpath.org/hg/icedtea-web/rev/87d3081ab573">Initial commit</a>
012 * @since 14578
013 */
014public final class AnimationExtensionManager {
015
016    private static volatile AnimationExtension currentExtension;
017
018    private AnimationExtensionManager() {
019        // Hide default constructor for utility classes
020    }
021
022    /**
023     * Returns the current animation extension.
024     * @return the current animation extension
025     */
026    public static AnimationExtension getExtension() {
027        if (currentExtension == null) {
028            currentExtension = isChristmas() ? new ChristmasExtension() : new NoExtension();
029        }
030        return currentExtension;
031    }
032
033    private static boolean isChristmas() {
034        Calendar c = new GregorianCalendar();
035        c.setTime(new Date());
036        return c.get(Calendar.DAY_OF_YEAR) > 350;
037    }
038}