001         package com.croftsoft.core.animation.painter;
002    
003         import java.awt.Graphics2D;
004         import java.awt.Image;
005         import javax.swing.JComponent;
006    
007         import com.croftsoft.core.lang.NullArgumentException;
008         import com.croftsoft.core.animation.*;
009    
010         /*********************************************************************
011         * Stretches the Image across the entire Component.
012         *
013         * @version
014         *   2002-03-23
015         * @since
016         *   2002-02-17
017         * @author
018         *   <a href="https://www.croftsoft.com/">David Wallace Croft</a>
019         *********************************************************************/
020    
021         public final class  StretchPainter
022           implements ComponentPainter
023         //////////////////////////////////////////////////////////////////////
024         //////////////////////////////////////////////////////////////////////
025         {
026    
027         private final Image  image;
028    
029         //////////////////////////////////////////////////////////////////////
030         //////////////////////////////////////////////////////////////////////
031    
032         public  StretchPainter ( Image  image )
033         //////////////////////////////////////////////////////////////////////
034         {
035           NullArgumentException.check ( this.image = image );
036         }
037    
038         public void  paint (
039           JComponent  component,
040           Graphics2D  graphics )
041         //////////////////////////////////////////////////////////////////////
042         {
043           graphics.drawImage ( image, 0, 0,
044             component.getWidth ( ), component.getHeight ( ), component );
045         }
046    
047         //////////////////////////////////////////////////////////////////////
048         //////////////////////////////////////////////////////////////////////
049         }