Package de.sciss.io

Examples of de.sciss.io.AudioFileFormatPane


      final double        sampleRate;
      final Param          param;
      final Preferences      audioPrefs;

      if( p == null ) {
        affp    = new AudioFileFormatPane( AudioFileFormatPane.NEW_FILE_FLAGS );
        p      = new JPanel( new BorderLayout() );
        p.add( affp, BorderLayout.NORTH );
        AbstractWindowHandler.setDeepFont( affp );
      }
View Full Code Here


    {
      if( protoType.length == 0 ) return null;
   
//      final FileDialog      fDlg;
      final AudioFileDescr[]    afds;
      final AudioFileFormatPane  affp;
//      final JOptionPane      dlg;
      final SpringPanel      msgPane;
      final PathField[]      ggPathFields;
      final int[]          channelsUsed  = new int[ protoType.length ];
      final JCheckBox        ggOpenAfterSave;
      final String        prefsDirKey    = selectionSettings ? PrefsUtil.KEY_FILESAVESELDIR : PrefsUtil.KEY_FILESAVEDIR;
      final JPanel        p;
      int              filesUsed    = 0;
      File            f; // , f2;
      String[]          queryOptions  = { getResourceString( "buttonSave" ),
                                getResourceString( "buttonCancel" )};
      int              i, result;
      String            str;
      JLabel            lb;
      String            fileName, dirName;
      boolean            setFocus    = false;
      int              y        = 0;
     
//System.out.print( "channelMap = [ " );
//for( int kkk = 0; kkk < channelMap.length; kkk++ ) System.out.print( (kkk > 0 ? ", " : "") + channelMap[ kkk ]);
//System.out.println( " ]" );
     
      msgPane      = new SpringPanel( 4, 2, 4, 2 );
      ggPathFields  = new PathField[ protoType.length ];
      affp      = new AudioFileFormatPane( AudioFileFormatPane.FORMAT | AudioFileFormatPane.ENCODING );
      affp.fromDescr( protoType[0] );
      lb        = new JLabel( getResourceString( "labelOutputFile" ), RIGHT );
//      lb.setLabelFor( ggPathField );
      msgPane.gridAdd( lb, 0, y );
      for( int j = 0, chanOff = 0; j < protoType.length; chanOff += protoType[ j ].channels, j++, y++ ) {
        if( channelMap == null ) {
          channelsUsed[ j ] = protoType[ j ].channels;
        } else {
          for( int k = 0; k < channelMap.length; k++ ) {
            if( (channelMap[ k ] >= chanOff) && (channelMap[ k ] < chanOff + protoType[ j ].channels) ) {
              channelsUsed[ j ]++;
            }
          }
        }
//System.out.println( "channelsUsed[ " + j + " ] = " + channelsUsed[ j ]);
        if( channelsUsed[ j ] == 0 ) continue;

        filesUsed++;
        ggPathFields[ j ] = new PathField( PathField.TYPE_OUTPUTFILE, getValue( NAME ).toString() );
        if( protoType[ j ].file == null ) {
          fileName  = getResourceString( "frameUntitled" ) + (ggPathFields.length > 1 ? "-" + (j+1) : "");
        } else if( asCopySettings || selectionSettings ) {
          str  = protoType[ j ].file.getName();
          i  = str.lastIndexOf( '.' );
          if( i == -1 ) i = str.length();
          fileName = str.substring( 0, i ) + (selectionSettings ? getResourceString( "fileDlgCut" ) : " " + getResourceString( "fileDlgCopy" )); // suffix is appended by affp!
        } else {
          fileName = protoType[ j ].file.getName();
        }
        dirName = app.getUserPrefs().get( prefsDirKey, protoType[ j ].file == null ? System.getProperty( "user.home" ) : protoType[ j ].file.getParent() );
        ggPathFields[ j ].setPath( new File( dirName, fileName ));
        affp.automaticFileSuffix( ggPathFields[ j ] );
        if( (protoType[ j ].file == null) || asCopySettings || selectionSettings ) {  // create non-existent file name
          ggPathFields[ j ].setPath( IOUtil.nonExistentFileVariant( ggPathFields[ j ].getPath(), -1,
            selectionSettings ? null : " ", null ));
        }
        ggPathFields[ j ].selectFileName( false );
        msgPane.gridAdd( ggPathFields[ j ], 1, y );
        if( !setFocus ) {
          GUIUtil.setInitialDialogFocus( ggPathFields[ j ]);
          setFocus = true;
        }
      }
      lb = new JLabel( getResourceString( "labelFormat" ), RIGHT );
      msgPane.gridAdd( lb, 0, y );
      msgPane.gridAdd( affp, 1, y, -1, 1 );
      lb.setLabelFor( affp );
      y++;
     
      if( asCopySettings ) {
        ggOpenAfterSave = new JCheckBox( getResourceString( "labelOpenAfterSave" ));
        ggOpenAfterSave.setSelected( openAfterSaveSettings.isSet() );
        msgPane.gridAdd( ggOpenAfterSave, 1, y );
      } else {
        ggOpenAfterSave  = null;
//        msgPane.gridAdd( new JLabel( " " ), 1, y );
      }

      AbstractWindowHandler.setDeepFont( msgPane );
      msgPane.makeCompactGrid();
      p      = new JPanel( new BorderLayout() );
      p.add( msgPane, BorderLayout.NORTH );

      final JOptionPane op = new JOptionPane( p, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, null, queryOptions, queryOptions[ 0 ]);
//      result    = JOptionPane.showOptionDialog( getWindow(), p, getValue( NAME ).toString(),
//                            JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
//                            null, queryOptions, queryOptions[ 0 ]);
      result = BasicWindowHandler.showDialog( op, getWindow(), getValue( NAME ).toString() );

      if( ggOpenAfterSave != null ) {
        openAfterSaveSettings.set( ggOpenAfterSave.isSelected() );
      }

      if( result == 0 ) {
        // save dir prefs
        if( ggPathFields.length > 0 ) {
          app.getUserPrefs().put( prefsDirKey, ggPathFields[ 0 ].getPath().getParent() );
        }
       
        afds = new AudioFileDescr[ filesUsed ];
        for( int j = 0, k = 0; j < ggPathFields.length; j++ ) {
          if( channelsUsed[ j ] == 0 ) continue;
          f = ggPathFields[ j ].getPath();
          if( f.exists() ) {
            queryOptions = new String[] { getResourceString( "buttonOverwrite" ),
                            getResourceString( "buttonCancel" )};
            final JOptionPane op2 = new JOptionPane( getResourceString( "warnFileExists" ) +
                                      ":\n" + f.getAbsolutePath() + "\n" + getResourceString( "warnOverwriteFile" ),
                                      JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_OPTION,
                                      null, queryOptions, queryOptions[1] );
//            result = JOptionPane.showOptionDialog( getWindow(), getResourceString( "warnFileExists" ) +
//              ":\n" + f.getAbsolutePath() + "\n" + getResourceString( "warnOverwriteFile" ),
//              getValue( NAME ).toString(), JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE,
//              null, queryOptions, queryOptions[1] );
            result = BasicWindowHandler.showDialog( op2, getWindow(), getValue( NAME ).toString() );
            if( result != 0 ) return null;
          }
          afds[ k ]    = new AudioFileDescr( protoType[ j ]);
          affp.toDescr( afds[ k ]);
          afds[ k ].file  = f;
          afds[ k ].channels = channelsUsed[ j ];
          k++;
        }
        return afds;
View Full Code Here

TOP

Related Classes of de.sciss.io.AudioFileFormatPane

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.