001 package com.croftsoft.core.animation.updater;
002
003 import javax.swing.JComponent;
004
005 import com.croftsoft.core.animation.ComponentUpdater;
006 import com.croftsoft.core.lang.NullArgumentException;
007 import com.croftsoft.core.util.ArrayLib;
008
009 /*********************************************************************
010 * Makes a ComponentUpdater array look like a single ComponentUpdater.
011 *
012 * @version
013 * 2003-07-05
014 * @since
015 * 2002-03-06
016 * @author
017 * <a href="http://www.CroftSoft.com/">David Wallace Croft</a>
018 *********************************************************************/
019
020 public final class ArrayComponentUpdater
021 implements ComponentUpdater
022 //////////////////////////////////////////////////////////////////////
023 //////////////////////////////////////////////////////////////////////
024 {
025
026 private ComponentUpdater [ ] componentUpdaters;
027
028 //////////////////////////////////////////////////////////////////////
029 // constructor methods
030 //////////////////////////////////////////////////////////////////////
031
032 public ArrayComponentUpdater (
033 ComponentUpdater [ ] componentUpdaters )
034 //////////////////////////////////////////////////////////////////////
035 {
036 setComponentUpdaters ( componentUpdaters );
037 }
038
039 public ArrayComponentUpdater ( )
040 //////////////////////////////////////////////////////////////////////
041 {
042 this ( new ComponentUpdater [ 0 ] );
043 }
044
045 //////////////////////////////////////////////////////////////////////
046 // accessor/mutator methods
047 //////////////////////////////////////////////////////////////////////
048
049 public ComponentUpdater [ ] getComponentUpdaters ( )
050 //////////////////////////////////////////////////////////////////////
051 {
052 return componentUpdaters;
053 }
054
055 public void add ( ComponentUpdater componentUpdater )
056 //////////////////////////////////////////////////////////////////////
057 {
058 componentUpdaters = ( ComponentUpdater [ ] )
059 ArrayLib.append ( componentUpdaters, componentUpdater );
060 }
061
062 public void setComponentUpdaters (
063 ComponentUpdater [ ] componentUpdaters )
064 //////////////////////////////////////////////////////////////////////
065 {
066 NullArgumentException.check (
067 this.componentUpdaters = componentUpdaters );
068 }
069
070 //////////////////////////////////////////////////////////////////////
071 //////////////////////////////////////////////////////////////////////
072
073 /*********************************************************************
074 * Updates each element in the ComponentUpdater array.
075 *********************************************************************/
076 public void update ( JComponent component )
077 //////////////////////////////////////////////////////////////////////
078 {
079 for ( int i = 0; i < componentUpdaters.length; i++ )
080 {
081 componentUpdaters [ i ].update ( component );
082 }
083 }
084
085 //////////////////////////////////////////////////////////////////////
086 //////////////////////////////////////////////////////////////////////
087 }