001/**
002 * Copyright (C) 2014  Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/
003 *
004 * This file is part of Dicoogle/dicoogle.
005 *
006 * Dicoogle/dicoogle is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * Dicoogle/dicoogle is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with Dicoogle.  If not, see <http://www.gnu.org/licenses/>.
018 */
019package pt.ua.dicoogle.rGUI.client.UIHelper;
020
021import org.slf4j.LoggerFactory;
022import pt.ua.dicoogle.rGUI.client.windows.MainWindow;
023
024import java.awt.*;
025import java.net.URL;
026import java.util.concurrent.Semaphore;
027
028/**
029 * @author Samuel Campos <samuelcampos@ua.pt>
030 */
031@Deprecated
032public class TrayIconCreator {
033
034    private static TrayIconCreator instance = null;
035    private static Semaphore sem = new Semaphore(1, true);
036
037    private TrayIcon trayIcon;
038
039    public static synchronized TrayIconCreator getInstance() {
040        try {
041            sem.acquire();
042            if (instance == null) {
043                instance = new TrayIconCreator();
044            }
045            sem.release();
046        } catch (InterruptedException ex) {
047            LoggerFactory.getLogger(MainWindow.class).error(ex.getMessage(), ex);
048        }
049        return instance;
050    }
051
052    public static Image getImage(final String pathAndFileName) {
053        final URL url = Thread.currentThread().getContextClassLoader().getResource(pathAndFileName);
054        return Toolkit.getDefaultToolkit().getImage(url);
055    }
056
057}