/* ** j###t ########## #### #### ** j###t ########## #### #### ** j###T "###L J###" ** ######P' ########## ######### ** ######k, ########## T######T ** ####~###L #### ** #### q###L ########## .##### ** #### \###L ########## #####" ** ** $Id$ ** ** Class History ** ** Date Name Description ** ---------|------------|----------------------------------------------- ** 19Aug98 subtle start of recorded history ** */ package key; /** * Is basically an animated atom ;) */ public abstract class AnimatedContainer extends Container implements Animate { transient Thread animated; boolean daemon=false; public AnimatedContainer() { } public AnimatedContainer( boolean isDaemon, boolean isReference ) { super( isReference ); daemon = isDaemon; } public abstract void run(); public void start() { if( animated != null && animated.isAlive() ) { animated.stop(); try { Thread.sleep( 1000 ); } catch( InterruptedException ie ) { } } animated = new Animated( this ); animated.setDaemon( daemon ); animated.setName( getName() ); animated.start(); } public void stop() { if( animated != null ) { animated.stop(); try { animated.join(); } catch( InterruptedException e ) { } animated = null; } } public final boolean isAlive() { if( animated == null ) return( false ); else return( animated.isAlive() ); } boolean canSwap() { return( !isAlive() ); } public final boolean isRunning() { return( Thread.currentThread() == animated ); } public final void yield() { animated.yield(); } public final boolean isDaemon() { return( animated.isDaemon() ); } public final void setPriority( int pri ) { animated.setPriority( pri ); } public final int getPriority() { return( animated.getPriority() ); } void setKey_imp( Object newkey ) { super.setKey_imp( newkey ); if( animated != null && newkey instanceof String ) animated.setName( (String) newkey ); } }