001/*
002 * Copyright 2010-2015 Institut Pasteur.
003 * 
004 * This file is part of Icy.
005 * 
006 * Icy 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 * Icy 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 Icy. If not, see <http://www.gnu.org/licenses/>.
018 */
019package icy.gui.component;
020
021import icy.gui.util.ComponentUtil;
022import icy.util.GraphicsUtil;
023
024import java.awt.Color;
025import java.awt.Dimension;
026import java.awt.Font;
027import java.awt.Graphics;
028import java.awt.Graphics2D;
029import java.awt.RenderingHints;
030
031/**
032 * @deprecated Don't use this anymore...
033 * 
034 * @author Fabrice de Chaumont
035 */
036@Deprecated
037public class IcyLogo extends IcyPanel // implements ComponentListener
038{
039    private static final long serialVersionUID = 3914710344010035775L;
040
041    final String title;
042    final Font titleFont;
043
044    public IcyLogo(String title)
045    {
046        this(title, null);
047    }
048
049    public IcyLogo(String title, Dimension dim)
050    {
051        super();
052
053        this.title = title;
054
055        if (dim != null)
056            setPreferredSize(dim);
057        else
058            ComponentUtil.setPreferredHeight(this, 60);
059
060        titleFont = new Font("Arial", Font.BOLD, 26);
061    }
062
063    @Override
064    protected void paintComponent(Graphics g)
065    {
066        super.paintComponent(g);
067
068        Graphics2D g2 = (Graphics2D) g.create();
069
070        final int w = getWidth();
071        final int h = getHeight();
072
073        g2.setColor(Color.white);
074        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
075
076        g2.setFont(titleFont);
077        GraphicsUtil.drawCenteredString(g2, title, w / 2, h / 2, false);
078
079        g2.dispose();
080    }
081}