/*
 * Copyright
 *   2007 axYus - www.axyus.com
 *   2005 C.Marchand - christophe.marchand@axyus.com
 *
 * This file is part of XEMELIOS.
 *
 * XEMELIOS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * XEMELIOS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with XEMELIOS; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package fr.gouv.finances.cp.utils.ui;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;

import javax.swing.JComponent;
/**
 * This class draws something that seems to be a clock
 * on a translucid background. Use it in a GlassPane to
 * drive users patient ;-))
 * This class is only used to draw the background when necessary ; real job
 * is done by {@link JRotatePanel}
 * @author chm
 *
 */
public class InfiniteGlassPane extends JComponent {
	/**
	 * 
	 */
	private static final long serialVersionUID = 6381799807769407898L;
	protected JRotatePanel rotor=null;
	public InfiniteGlassPane() {
		super();
		initComponents();
	}
	protected void initComponents() {
//		setOpaque(false);
		add(rotor=new JRotatePanel());
		setVisible(false);
		addComponentListener(new ComponentAdapter() {
			@Override
			public void componentResized(ComponentEvent e) {
				rotor.setSize(getSize());
			}
		});
	}
	@Override
	protected void paintComponent(Graphics g) {
//		super.paintComponent(g);
		rotor.paintBackground(g);
		rotor.paintComponent(g);
	}
	@Override
	public void setVisible(boolean aFlag) {
		super.setVisible(aFlag);
		rotor.setSize(getSize());
		rotor.setVisible(aFlag);
	}
	@Override
	public void setSize(Dimension d) {
		super.setSize(d);
		rotor.setSize(d);
	}
	@Override
	public void setSize(int width, int height) {
		super.setSize(width, height);
		rotor.setSize(width,height);
	}
	
}
