001/* ----------------------------------------------------------------------------
002   The Kiwi Toolkit - A Java Class Library
003   Copyright (C) 1998-2004 Mark A. Lindner
004
005   This library is free software; you can redistribute it and/or
006   modify it under the terms of the GNU General Public License as
007   published by the Free Software Foundation; either version 2 of the
008   License, or (at your option) any later version.
009
010   This library is distributed in the hope that it will be useful,
011   but WITHOUT ANY WARRANTY; without even the implied warranty of
012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013   General Public License for more details.
014
015   You should have received a copy of the GNU General Public License
016   along with this library; if not, write to the Free Software
017   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
018   02111-1307, USA.
019 
020   The author may be contacted at: mark_a_lindner@yahoo.com
021   ----------------------------------------------------------------------------
022   $Log: TextureViewer.java,v $
023   Revision 1.4  2004/05/12 18:53:25  markl
024   comment block updates
025
026   Revision 1.3  2003/01/19 09:48:48  markl
027   Give the viewer a decent preferred size.
028
029   Revision 1.2  2001/03/12 09:28:00  markl
030   Source code and Javadoc cleanup.
031
032   Revision 1.1  1999/05/10 09:02:10  markl
033   Initial revision
034   ----------------------------------------------------------------------------
035*/
036
037package kiwi.ui;
038
039import java.awt.*;
040import javax.swing.*;
041
042/** An implementation of <code>UIElementViewer</code> for previewing textures.
043 *
044 * @author Mark Lindner
045 */
046
047public class TextureViewer extends KPanel implements UIElementViewer
048  {
049  private static final Dimension preferredSize = new Dimension(150, 150);
050  
051  /** Construct a new <code>TextureViewer</code>.
052   */
053  
054  public TextureViewer()
055    {
056    setOpaque(true);
057    setTexture(null);
058    setPreferredSize(preferredSize);
059    }
060
061  /** Get a reference to the viewer component.
062   *
063   * @return The viewer component.
064   */
065  
066  public JComponent getViewerComponent()
067    {
068    return(this);
069    }
070
071  /** Show the specified element.
072   *
073   * @param element An object, assumed to be an instance of <code>Image</code>,
074   * to display.
075   */
076  
077  public void showElement(UIElement element)
078    {
079    Object obj = element.getObject();
080    
081    if(obj instanceof Image)
082      setTexture((Image)obj);
083    }
084
085  }
086
087/* end of source file */