home *** CD-ROM | disk | FTP | other *** search
/ Sony Community Place / circus2e.exe / DATA.Z / chgclr.java < prev    next >
Text File  |  1996-09-25  |  1KB  |  54 lines

  1. //
  2. // chgclr.java
  3. //    change current color of color panel
  4. //
  5. // (c) Copyright 1996 Sony Corporation. All rights reserved.
  6.  
  7. import vrml.*;
  8. import vrml.field.*;
  9. import vrml.node.*;
  10. import java.util.*;
  11.  
  12. public class chgclr extends Script {
  13.     SFColor diffuse;
  14.     SFInt32 no;
  15.     float f[] = new float[3];
  16.     final int COLOR_MAX = 18;
  17.     
  18.     public void processEvent(Event e){
  19.     if( ((ConstSFBool)e.getValue()).getValue() == true ){
  20.         String str = e.getName();
  21.  
  22. //        System.out.println( "chgclr: " + str ); 
  23.  
  24.         try{
  25.         if( str.startsWith( "clicked" )){
  26.             Integer ii = new Integer (str.substring( 7 ));
  27.             int i = ii.intValue();
  28.             if ( i >= 0 && i < COLOR_MAX ){
  29.                 diffuse.setValue( GenerateColor.getSFColor( i ));
  30.                 no.setValue( i );
  31.             }
  32.         }
  33.         else{
  34.             getBrowser().setDescription ( "invalid header:" + str );
  35.         }
  36.         } catch ( Exception ex ){
  37.             getBrowser().setDescription ( "error: wrl file is not correct." );
  38.         }
  39.  
  40.     }
  41.     }
  42.     public void initialize (){
  43.         diffuse = ( SFColor ) getEventOut("diffuse") ;
  44.         no = ( SFInt32 ) getEventOut("no") ;
  45.     }
  46. }
  47.  
  48.  
  49.      
  50.  
  51.  
  52.  
  53.  
  54.