001         package com.croftsoft.apps.slideshow;
002         
003         import java.awt.*;
004         import java.util.logging.*;
005         import javax.swing.*;
006    
007         import com.croftsoft.core.animation.ComponentAnimator;
008         import com.croftsoft.core.animation.animator.NullComponentAnimator;
009         import com.croftsoft.core.lang.NullArgumentException;
010         import com.croftsoft.core.lang.lifecycle.Initializable;
011         import com.croftsoft.core.lang.lifecycle.Updatable;
012    
013         /*********************************************************************
014         * View.
015         *  
016         * @version
017         *   $Id: SlideshowView.java,v 1.1 2006/12/16 09:26:39 croft Exp $
018         * @since
019         *   2006-12-15
020         * @author
021         *   <a href="https://www.croftsoft.com/">David Wallace Croft</a>
022         *********************************************************************/
023    
024         public final class  SlideshowView
025           implements Initializable, Updatable
026         //////////////////////////////////////////////////////////////////////
027         //////////////////////////////////////////////////////////////////////
028         {
029           
030         private static final String  CLASS_NAME
031           = SlideshowView.class.getName ( );
032         
033         //
034         
035         private final SlideshowConfig  slideshowConfig;
036         
037         private final Logger           logger;
038         
039         private final JComponent       jComponent;
040         
041         //
042         
043         private ComponentAnimator  componentAnimator;
044         
045         //////////////////////////////////////////////////////////////////////
046         // constructor methods
047         //////////////////////////////////////////////////////////////////////
048         
049         public  SlideshowView ( final SlideshowConfig  slideshowConfig )
050         //////////////////////////////////////////////////////////////////////
051         {
052           NullArgumentException.check (
053             this.slideshowConfig = slideshowConfig );
054           
055           logger = Logger.getLogger ( CLASS_NAME );
056           
057           componentAnimator = NullComponentAnimator.INSTANCE;
058           
059           jComponent = new JComponent ( )
060             {
061               private static final long  serialVersionUID = 0L;
062             
063               @Override
064               public void  paintComponent ( final Graphics  graphics )
065               {
066                 componentAnimator.paint ( this, ( Graphics2D ) graphics );
067               }
068             };
069         }
070         
071         //////////////////////////////////////////////////////////////////////
072         // mutator methods
073         //////////////////////////////////////////////////////////////////////
074         
075         public void  setContentPane ( final Container  contentPane )
076         //////////////////////////////////////////////////////////////////////
077         {
078           contentPane.setLayout ( new BorderLayout ( ) );
079           
080           contentPane.add ( jComponent, BorderLayout.CENTER );
081         }
082         
083         //////////////////////////////////////////////////////////////////////
084         // lifecycle methods
085         //////////////////////////////////////////////////////////////////////
086         
087         public void  init ( )
088         //////////////////////////////////////////////////////////////////////
089         {
090           componentAnimator
091             = new SlideshowAnimator ( slideshowConfig, jComponent );
092         }
093         
094         public void  update ( )
095         //////////////////////////////////////////////////////////////////////
096         {
097           componentAnimator.update ( jComponent );
098         }       
099    
100         //////////////////////////////////////////////////////////////////////
101         //////////////////////////////////////////////////////////////////////
102         }