001 package com.croftsoft.apps.chat.view; 002 003 import java.awt.*; 004 import javax.swing.JComponent; 005 006 import com.croftsoft.core.animation.ComponentAnimator; 007 import com.croftsoft.core.animation.ComponentPainter; 008 import com.croftsoft.core.animation.painter.ColorPainter; 009 import com.croftsoft.core.awt.image.ImageCache; 010 import com.croftsoft.core.lang.NullArgumentException; 011 012 import com.croftsoft.apps.chat.model.ChatGameAccessor; 013 014 /********************************************************************* 015 * ChatGame ComponentAnimator. 016 * 017 * @version 018 * 2003-06-11 019 * @since 020 * 2003-06-06 021 * @author 022 * <a href="https://www.croftsoft.com/">David Wallace Croft</a> 023 *********************************************************************/ 024 025 public final class ChatGameAnimator 026 implements ComponentAnimator 027 ////////////////////////////////////////////////////////////////////// 028 ////////////////////////////////////////////////////////////////////// 029 { 030 031 private static final Color BACKGROUND_COLOR = Color.BLACK; 032 033 // 034 035 private final ChatGameAccessor chatGameAccessor; 036 037 private final ComponentPainter backgroundColorPainter; 038 039 private final ChatWorldAnimator chatWorldAnimator; 040 041 ////////////////////////////////////////////////////////////////////// 042 ////////////////////////////////////////////////////////////////////// 043 044 public ChatGameAnimator ( 045 ChatGameAccessor chatGameAccessor, 046 JComponent component, 047 ClassLoader classLoader, 048 String mediaDir ) 049 ////////////////////////////////////////////////////////////////////// 050 { 051 NullArgumentException.check ( 052 this.chatGameAccessor = chatGameAccessor ); 053 054 backgroundColorPainter = new ColorPainter ( BACKGROUND_COLOR ); 055 056 chatWorldAnimator = new ChatWorldAnimator ( 057 chatGameAccessor.getChatWorldAccessor ( ), 058 new ImageCache ( 059 Transparency.BITMASK, 060 component, 061 classLoader, 062 mediaDir ) ); 063 } 064 065 ////////////////////////////////////////////////////////////////////// 066 // interface ComponentAnimator methods 067 ////////////////////////////////////////////////////////////////////// 068 069 public void update ( JComponent component ) 070 ////////////////////////////////////////////////////////////////////// 071 { 072 chatWorldAnimator.update ( component ); 073 } 074 075 public void paint ( 076 JComponent component, 077 Graphics2D graphics ) 078 ////////////////////////////////////////////////////////////////////// 079 { 080 backgroundColorPainter.paint ( component, graphics ); 081 082 chatWorldAnimator.paint ( component, graphics ); 083 } 084 085 ////////////////////////////////////////////////////////////////////// 086 ////////////////////////////////////////////////////////////////////// 087 }