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