public void loadSystem ( ) { chooser . setDialogTitle ( "Open" ) ; int resp = chooser . showOpenDialog ( this ) ; if ( resp == JFileChooser . APPROVE_OPTION ) { File file = chooser . getSelectedFile ( ) ; File path = file . getParentFile ( ) ; try { ParticleSystem system = ParticleIO . loadConfiguredSystem ( file ) ; game . setSystem ( system ) ; emitters . clear ( ) ; for ( int i = 0 ; i < system . getEmitterCount ( ) ; i ++ ) { final ConfigurableEmitter emitter = ( ConfigurableEmitter ) system . getEmitter ( i ) ; if ( emitter . getImageName ( ) != null ) { File possible = new File ( path , emitter . getImageName ( ) ) ; if ( possible . exists ( ) ) { emitter . setImageName ( possible . getAbsolutePath ( ) ) ; } else { chooser . setDialogTitle ( "Locate the image: " + emitter . getImageName ( ) ) ; FileFilter filter = new FileFilter ( ) { public boolean accept ( File f ) { if ( f . isDirectory ( ) ) { return true ; } return ( f . getName ( ) . equals ( emitter . getImageName ( ) ) ) ; } public String getDescription ( ) { return emitter . getImageName ( ) ; } } ; chooser . addChoosableFileFilter ( filter ) ; resp = chooser . showOpenDialog ( this ) ; if ( resp == JFileChooser . APPROVE_OPTION ) { File image = chooser . getSelectedFile ( ) ; emitter . setImageName ( image . getAbsolutePath ( ) ) ; path = image . getParentFile ( ) ; } chooser . setDialogTitle ( "Open" ) ; chooser . resetChoosableFileFilters ( ) ; chooser . addChoosableFileFilter ( xmlFileFilter ) ; } } emitters . add ( emitter ) ; } additive . setSelected ( system . getBlendingMode ( ) == ParticleSystem . BLEND_ADDITIVE ) ; pointsEnabled . setSelected ( system . usePoints ( ) ) ; emitters . setSelected ( 0 ) ; } catch ( IOException e ) { Log . error ( e ) ; JOptionPane . showMessageDialog ( this , e . getMessage ( ) ) ; } } }
Load a complete particle system XML description