Package de.sciss.app

Examples of de.sciss.app.Application


  throws IOException
  {
    final RenderContext        context    = (RenderContext) pt.getClientArg( "context" );
    final RenderPlugIn        plugIn    = (RenderPlugIn) context.getOption( RenderContext.KEY_PLUGIN );
    RenderSource          source;
    final Application        app      = AbstractApplication.getApplication();

    float[][]            inTrnsFrames, outTrnsFrames;
    int                minBlockSize, maxBlockSize, prefBlockSize;
    int                i, numTrns, numRcv, trnsIdx, rcvIdx, readLen, writeLen;
    Transmitter            trns;
    AudioTrail            at;
    boolean[]            trnsRequest;
    Object              val;
    long              readOffset, remainingRead, remainingWrite;
    Set                newOptions;
    String              className;
    boolean              success    = false// pessimist bitchâ„¢
   
    // --- resampling related ---
    int            inOff, inTrnsLen, outTrnsLen;
    int            fltLenI    = 0;
    int            overlapLen  = 0;
    int            overlapOff  = 0;
    int            trnsInside  = 0;
    Resampling        rsmp    = null;
    double          rsmpFactor  = 1.0;
    double          inPhase    = 0.0;
    double          newInPhase  = 0.0;
    double          fltLen    = 0.0;
    float[][][]        trnsOverlaps= null;

    // --- init ---

    readOffset    = context.getTimeSpan().getStart();
    numRcv      = context.getReceivers().size();
    numTrns      = context.getTransmitters().size();
    source      = new RenderSource( numTrns, numRcv );

    try {
      if( !invokeProducerBegin( pt, context, source, plugIn )) return FAILED;
      remainingRead    = context.getTimeSpan().getLength();
      newOptions      = context.getModifiedOptions();
      if( newOptions.contains( RenderContext.KEY_MINBLOCKSIZE )) {
        val        = context.getOption( RenderContext.KEY_MINBLOCKSIZE );
        minBlockSize  = ((Integer) val).intValue();
      } else {
        minBlockSize  = 1;
      }
      if( newOptions.contains( RenderContext.KEY_MAXBLOCKSIZE )) {
        val        = context.getOption( RenderContext.KEY_MAXBLOCKSIZE );
        maxBlockSize  = ((Integer) val).intValue();
      } else {
        maxBlockSize  = 0x7FFFFF;
      }
      if( newOptions.contains( RenderContext.KEY_PREFBLOCKSIZE )) {
        val        = context.getOption( RenderContext.KEY_PREFBLOCKSIZE );
        prefBlockSize  = ((Integer) val).intValue();
      } else {
        prefBlockSize   = Math.max( minBlockSize, Math.min( maxBlockSize, 1024 ));
      }
      assert minBlockSize <= maxBlockSize : "minmaxblocksize";
     
      if( newOptions.contains( RenderContext.KEY_TARGETRATE )) {
      // ---- prepare resampling ----
        val        = context.getOption( RenderContext.KEY_TARGETRATE );
        rsmpFactor    = ((Double) val).doubleValue() / (double) context.getSourceRate();
        className    = classPrefs.get( KEY_RESAMPLING, null );
        if( className == null ) {
          className   = NearestNeighbour.class.getName(); // RSMP_ITEMS[ 0 ].getKey();
          showMessage( JOptionPane.WARNING_MESSAGE, app.getResourceString( "errResamplingClass" ) +
                  " : " + val.toString() );
        }
        try {
          rsmp    = (Resampling) Class.forName( className ).newInstance();
        }
        catch( InstantiationException e1 ) {
          pt.setException( e1 );
          return FAILED;
        }
        catch( IllegalAccessException e2 ) {
          pt.setException( e2 );
          return FAILED;
        }
        catch( ClassNotFoundException e3 ) {
          pt.setException( e3 );
          return FAILED;
        }
        finally {
          if( rsmp == null ) {
            showMessage( JOptionPane.ERROR_MESSAGE,
                   app.getResourceString( "errResamplingClass" ) + " : " + className );
          }
        }
       
        fltLen      = rsmp.getWingSize( rsmpFactor );
        fltLenI      = (int) fltLen + 1;
View Full Code Here


      final File            f    = (File) context.getClientArg( "file" );
      final File            dir    = f.getParentFile();
      File              tempDir  = null;
      boolean              success = false;
      final Map            options  = new HashMap();
      final Application        app    = AbstractApplication.getApplication();
   
      builderFactory    = DocumentBuilderFactory.newInstance();
      builderFactory.setValidating( true );
      transformerFactory  = TransformerFactory.newInstance();

      context.setProgression( -1f );

      try {
        builder    = builderFactory.newDocumentBuilder();
        transformer = transformerFactory.newTransformer();
        builder.setEntityResolver( doc );
        domDoc    = builder.newDocument();
        childNode   = domDoc.createElement( Session.XML_ROOT );
        domDoc.appendChild( childNode );
        options.put( XMLRepresentation.KEY_BASEPATH, dir );
//        doc.getMap().putValue( this, Session.MAP_KEY_PATH, f );
//        doc.setName( f.getName() );
       
        if( dir.exists() ) {
//System.err.println( "dir exists "+dir.getAbsolutePath() );
          tempDir = new File( dir.getAbsolutePath() + ".tmp" );
          if( tempDir.exists() ) {
//System.err.println( "temp dir exists "+tempDir.getAbsolutePath() );
            IOUtil.deleteAll( tempDir );
          }
          if( !dir.renameTo( tempDir )) {
            throw new IOException( tempDir.getAbsolutePath() + " : " +
                         IOUtil.getResourceString( "errMakeDir" ));
          }
        }
        if( !dir.mkdirs() ) {
//System.err.println( "mkdir failed : "+dir.getAbsolutePath() );
          throw new IOException( dir.getAbsolutePath() + " : " +
                       IOUtil.getResourceString( "errMakeDir" ));
        }
       
        doc.toXML( domDoc, childNode, options );
        context.setProgression( -1f );
        transformer.setOutputProperty( OutputKeys.DOCTYPE_SYSTEM, Session.ICHNOGRAM_DTD );
        transformer.transform( new DOMSource( domDoc ), new StreamResult( f ));
        MRJAdapter.setFileCreatorAndType( f, app.getMacOSCreator(), Session.MACOS_FILE_TYPE );
       
        doc.getUndoManager().discardAllEdits();

        if( tempDir != null && tempDir.exists() ) {
          IOUtil.deleteAll( tempDir );
View Full Code Here

    Boolean            b;
    final GridBagLayout      lay        = new GridBagLayout();
    final GridBagConstraints  con        = new GridBagConstraints();
    final Insets        ascetic      = new Insets( 2, 4, 2, 4 );
    final Insets        bourgeois    = new Insets( 2, 24, 14, 4 );
    final Application      app        = AbstractApplication.getApplication();

    this.setLayout( lay );

    ggMode      = new PrefComboBox();
    for( int i = 0; i < modes.length; i++ ) {
      ggMode.addItem( modes[i] );
    }
    ggMode.setSelectedIndex( MODE_CARTESIAN );
    ggMode.setPreferences( classPrefs, KEY_MODE );

    ggApplyX    = new PrefCheckBox(); // Main.getResourceString( "renderVTApplyX" ));
    ggApplyY    = new PrefCheckBox(); // Main.getResourceString( "renderVTApplyY" ));
    ggTransformX  = new PrefComboBox();
    ggTransformY  = new PrefComboBox();
    ggCenterX    = new PrefNumberField();
//    ggCenterX.setSpace( new NumberSpace( 0.0, 1.0, 0.0 ));
    ggCenterX.setSpace( new NumberSpace( -1.0, 1.0, 0.0 ));
//    ggCenterX.setNumber( new Double( 0.5 ));
    ggCenterX.setNumber( new Double( 0.0 ));
    ggCenterY    = new PrefNumberField();
//    ggCenterY.setSpace( new NumberSpace( 0.0, 1.0, 0.0 ));
    ggCenterY.setSpace( new NumberSpace( -1.0, 1.0, 0.0 ));
//    ggCenterY.setNumber( new Double( 0.5 ));
    ggCenterY.setNumber( new Double( 0.0 ));
    funcGUIX    = new JScrollPane( JScrollPane.VERTICAL_SCROLLBAR_NEVER,
                       JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
    funcGUIY    = new JScrollPane( JScrollPane.VERTICAL_SCROLLBAR_NEVER,
                       JScrollPane.HORIZONTAL_SCROLLBAR_NEVER );
    funcGUIX.setViewportBorder( BorderFactory.createEmptyBorder( 2, 2, 2, 2 ));
    funcGUIY.setViewportBorder( BorderFactory.createEmptyBorder( 2, 2, 2, 2 ));
   
    for( int i = 0; i < collAlgorithms.size(); i++ ) {
      map    = (Map) collAlgorithms.get( i );
      b    = (Boolean) map.get( VectorTransformer.KEY_RENDERPLUGIN );
      if( b == null || !b.booleanValue() ) continue;
      item  = new StringItem( map.get( Main.KEY_CLASSNAME ).toString(),
                    map.get( Main.KEY_HUMANREADABLENAME ));
      ggTransformX.addItem( item );
      ggTransformY.addItem( item );
    }

    ggApplyX.setPreferences( classPrefs, KEY_APPLYX );
    ggApplyY.setPreferences( classPrefs, KEY_APPLYY );
    ggTransformX.setPreferences( classPrefs, KEY_TRANSX );
    ggTransformY.setPreferences( classPrefs, KEY_TRANSY );
    ggCenterX.setPreferences( classPrefs, KEY_CENTERX );
    ggCenterY.setPreferences( classPrefs, KEY_CENTERY );

    lb        = new JLabel( app.getResourceString( "renderVTMode" ));
    con.anchor    = GridBagConstraints.WEST;
    con.gridwidth  = 1;
    con.fill    = GridBagConstraints.HORIZONTAL;
    con.insets    = ascetic;
    lay.setConstraints( lb, con );
    this.add( lb );
    con.gridwidth  = GridBagConstraints.REMAINDER;
    con.weightx    = 1.0;
    lay.setConstraints( ggMode, con );
    this.add( ggMode );
//        HelpGlassPane.setHelp( ggMode, "FilterVectorTransformCoord" );  // EEE

    lb        = new JLabel( app.getResourceString( "renderVTCenterX" ));
    con.gridwidth  = 1;
    con.weightx    = 0.0;
    lay.setConstraints( lb, con );
    this.add( lb );
    con.gridwidth  = GridBagConstraints.REMAINDER;
    con.weightx    = 1.0;
    lay.setConstraints( ggCenterX, con );
    this.add( ggCenterX );
//        HelpGlassPane.setHelp( ggCenterX, "FilterVectorTransformCoord" );  // EEE

    lb        = new JLabel( app.getResourceString( "renderVTCenterY" ));
    con.gridwidth  = 1;
    con.weightx    = 0.0;
    lay.setConstraints( lb, con );
    this.add( lb );
    con.gridwidth  = GridBagConstraints.REMAINDER;
View Full Code Here

      final Param          positionSmps;
      final Box          msgPane;
      final DefaultUnitTranslator  timeTrans;
      final ParamField      ggPosition;
//      final JComboBox        ggPosCombo;
      final Application      app  = AbstractApplication.getApplication();
     
      msgPane      = Box.createVerticalBox();
      // XXX sync
      timeTrans    = new DefaultUnitTranslator();
      ggPosition    = new ParamField( timeTrans );
      ggPosition.addSpace( ParamSpace.spcTimeHHMMSS );
      ggPosition.addSpace( ParamSpace.spcTimeSmps );
      ggPosition.addSpace( ParamSpace.spcTimeMillis );
      ggPosition.addSpace( ParamSpace.spcTimePercentF );
      timeTrans.setLengthAndRate( doc.timeline.getLength(), doc.timeline.getRate() )// XXX sync
      if( value != null ) {
        ggPosition.setSpace( space );
        ggPosition.setValue( value );
      }
//      ggPosition.setValue( position );
//      lbCurrentTime  = new TimeLabel( new Color( 0xE0, 0xE0, 0xE0 ));

//      ggPosition.setBorder( new ComboBoxEditorBorder() );
//      ggPosCombo = new JComboBox();
//      ggPosCombo.setEditor( ggPosition );
//      ggPosCombo.setEditable( true );

//      msgPane.gridAdd( ggPosCombo, 0, 1, -1, 1 );
      msgPane.add( Box.createVerticalGlue() );
//      msgPane.add( ggPosCombo );
JButton ggCurrent = new JButton( app.getResourceString( "buttonSetCurrent" ))// "Current"
ggCurrent.setFocusable( false );
//JLabel lbArrow = new JLabel( "\u2193" );  // "\u2939"
//Box b = Box.createHorizontalBox();
//b.add( lbArrow );
//b.add( ggCurrent );
ggCurrent.addActionListener( new ActionListener() {
  public void actionPerformed( ActionEvent ae )
  {
    final long pos = transport.isRunning() ? transport.getCurrentFrame() : doc.timeline.getPosition();
    ggPosition.setValue( new Param( pos, ParamSpace.TIME | ParamSpace.SMPS ))// XXX sync
    ggPosition.requestFocusInWindow();
  }
});
//msgPane.add( b );
msgPane.add( ggCurrent );
      msgPane.add( ggPosition );
      msgPane.add( Box.createVerticalGlue() );
     
      GUIUtil.setInitialDialogFocus( ggPosition );
     
//      ggPosCombo.removeAllItems();
//      // XXX sync
//      ggPosCombo.addItem( new StringItem( new Param( doc.timeline.getPosition() / doc.timeline.getRate(), ParamSpace.TIME | ParamSpace.SECS | ParamSpace.HHMMSS ).toString(), "Current" ));

      final JOptionPane op = new JOptionPane( msgPane, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION );
//      result = JOptionPane.showOptionDialog( BasicWindowHandler.getWindowAncestor( lbTime ), msgPane,
//        app.getResourceString( "inputDlgGoToTime" ),
//        JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null );
      result = BasicWindowHandler.showDialog( op, BasicWindowHandler.getWindowAncestor( lbTime ), app.getResourceString( "inputDlgGoToTime" ));
     
      if( result == JOptionPane.OK_OPTION ) {
        value      = ggPosition.getValue();
        space      = ggPosition.getSpace();
        positionSmps  = timeTrans.translate( value, ParamSpace.spcTimeSmps );
View Full Code Here

    Preferences      childPrefs;
        final boolean    isMacOS    = System.getProperty( "os.name" ).indexOf( "Mac OS" ) >= 0;
        final boolean    isWindows  = System.getProperty( "os.name" ).indexOf( "Windows" ) >= 0;
    final String    fs      = File.separator;
    final List      warnings  = new ArrayList();
    final Application  app      = AbstractApplication.getApplication();

    putDontOverwrite( IOUtil.getUserPrefs(), IOUtil.KEY_TEMPDIR, System.getProperty( "java.io.tmpdir" ));

    // general
    putBooleanDontOverwrite( mainPrefs, KEY_RECALLFRAMES, true );
    putDontOverwrite( mainPrefs, KEY_LOOKANDFEEL, UIManager.getSystemLookAndFeelClassName() );
    putBooleanDontOverwrite( mainPrefs, KEY_INTRUDINGSIZE, isMacOS );
    putBooleanDontOverwrite( mainPrefs, KEY_INSERTIONFOLLOWSPLAY, true );
//    putBooleanDontOverwrite( mainPrefs, KEY_VIEWCHANMETERS , true );
    putBooleanDontOverwrite( mainPrefs, KEY_VIEWMARKERS , true );
    putBooleanDontOverwrite( mainPrefs, KEY_VIEWNULLLINIE , true );
    putBooleanDontOverwrite( mainPrefs, KEY_VIEWVERTICALRULERS, false );
    putBooleanDontOverwrite( mainPrefs, KEY_CATCH, true );
   
    putIntDontOverwrite( mainPrefs, KEY_TIMEUNITS, TIME_MINSECS );
    putIntDontOverwrite( mainPrefs, KEY_VERTSCALE, VSCALE_AMP_LIN );

    putBooleanDontOverwrite( mainPrefs, KEY_BLENDING, false );
    putDoubleDontOverwrite( mainPrefs, KEY_BLENDTIME, 0.250 );
    putBooleanDontOverwrite( mainPrefs, KEY_CATCH, true );

    childPrefs  = mainPrefs.node( NODE_SHARED );
    putBooleanDontOverwrite( childPrefs, KEY_SNAP, true );
    putBooleanDontOverwrite( childPrefs, KEY_VIEWRCVSENSE, true );
    putBooleanDontOverwrite( childPrefs, KEY_VIEWEQPRECEIVER, true );
    putBooleanDontOverwrite( childPrefs, KEY_VIEWTRNSTRAJ, true );
    putBooleanDontOverwrite( childPrefs, KEY_VIEWUSERIMAGES, false );
    putBooleanDontOverwrite( childPrefs, KEY_VIEWRULERS, true );

    // plug-ins
    f      = new File( new File( new File( "" ).getAbsoluteFile(), "plug-ins" ), "lisp" );
    childPrefs  = mainPrefs.node( NODE_PLUGINS );
    putIntDontOverwrite( childPrefs, KEY_AUDIOINPUTS, 8 );
    putIntDontOverwrite( childPrefs, KEY_AUDIOOUTPUTS, 8 );
    putIntDontOverwrite( childPrefs, KEY_AUDIORATE, 44100 );
    putIntDontOverwrite( childPrefs, KEY_RTSENSEBUFSIZE, 512 );
    putIntDontOverwrite( childPrefs, KEY_RTMAXSENSERATE, 690 );
    putIntDontOverwrite( childPrefs, KEY_OLSENSEBUFSIZE, 512 );
    putDontOverwrite( childPrefs, KEY_LISPBOUNCELIST, new File( f, "bouncelist.xml" ).getPath() );
    putDontOverwrite( childPrefs, KEY_LISPFILTERLIST, new File( f, "filterlist.xml" ).getPath() );
    putDontOverwrite( childPrefs, KEY_LISPREALTIMELIST, new File( f, "realtimelist.xml" ).getPath() );
 
    if( childPrefs.get( KEY_SUPERCOLLIDEROSC, null ) == null ) {
//      try {
//        value   = InetAddress.getLocalHost().getHostName() + ":57110";
//      }
//      catch( IOException e1 ) {
//        warnings.add( e1.toString() );
        value   = "127.0.0.1:57110";
//      }
      putDontOverwrite( childPrefs, KEY_SUPERCOLLIDEROSC, value );
    }
   
    // sc app
    if( childPrefs.get( KEY_SUPERCOLLIDERAPP, null ) == null ) {
      f  = findFile( isWindows ? "scsynth.exe" : "scsynth", new String[] {
        fs + "Applications" + fs + "SuperCollider_f",
        fs + "Applications" + fs + "SuperCollider",
        fs + "usr" + fs + "local" + fs + "bin",
        fs + "usr" + fs + "bin",
        "C:\\Program Files\\SuperCollider_f",
        "C:\\Program Files\\PsyCollider"
      });
      if( f == null ) {
        if( isMacOS ) {
          try {
            f = MRJAdapter.findApplication( "SCjm" );
            if( f != null ) f = new File( f.getParentFile(), "scsynth" );
          }
          catch( IOException e1 ) { /* ignore */ }
        }
        if( f == null ) {
          warnings.add( AbstractApplication.getApplication().getResourceString( "errSCSynthAppNotFound" ));
        }
      }
      if( f != null ) putDontOverwrite( childPrefs, KEY_SUPERCOLLIDERAPP, f.getAbsolutePath() );
    }

    // csound app
    if( childPrefs.get( KEY_CSOUNDAPP, null ) == null ) {
      f  = findFile( isWindows ? "consound.exe" : "csound", new String[] {
        fs + "usr" + fs + "local" + fs + "bin",
        fs + "usr" + fs + "bin",
        "C:\\Program Files\\CSound"
      });
      if( f == null ) {
        if( isMacOS ) {
          try {
            f = MRJAdapter.findApplication( "ma++" )// MacCSound is bundles with command line csound
            f = f.getParentFile();
            if( f != null ) {
              f = new File( new File( f, "Commandline Version" ), "csound" );
              if( !f.exists() ) f = null;
            }
          }
          catch( IOException e1 ) {}
        }
        if( f == null ) {
          warnings.add( app.getResourceString( "errCSoundAppNotFound" ));
        }
      }
      if( f != null ) putDontOverwrite( childPrefs, KEY_CSOUNDAPP, f.getAbsolutePath() );
    }
   
View Full Code Here

   *  and transmitters are removed, the timeline
   *  is reset, and session preferences are all cleared!
   */
  public void clear()
  {
    final Application  app = AbstractApplication.getApplication();
 
//    try {
//      bird.waitExclusive( DOOR_ALL );

//      super.clear();
      getMap().clearValues( this );
//      init();
      map.clearValues( this );
      map.putContext( null, MAP_KEY_FLAGS, new MapManager.Context( MapManager.Context.FLAG_LIST_DISPLAY,
                                     MapManager.Context.TYPE_INTEGER, null, null,
                                     null, new Integer( 0 )));
      map.putContext( this, SessionGroup.MAP_KEY_USERIMAGE, new MapManager.Context(
          MapManager.Context.FLAG_OBSERVER_DISPLAY, MapManager.Context.TYPE_FILE,
          new Integer( PathField.TYPE_INPUTFILE ), "labelUserImage", null, new File( "" )));
     
//      final List collTrns = transmitters.getAll();
      selectedReceivers.clear( this );
      selectedTracks.clear( this );
      selectedGroups.clear( this );
      groups.clear( this );
      receivers.clear( this );
      tracks.removeAll( this, transmitters.getAll() ); // not the marker track
      markerTrack.clear( this );
      selectedTracks.addthis, markerTrack );

      setFile( null );
      timeline.clear( this );
//    }
//    finally {
//      bird.releaseExclusive( DOOR_ALL );
//    }
   
    // clear session prefs
    try {
      PrefsUtil.removeAll( app.getUserPrefs().node( PrefsUtil.NODE_SESSION ), true );
    }
    catch( BackingStoreException e1 ) {
      System.err.println( app.getResourceString( "errSavePrefs" ) +
                " - " + e1.getLocalizedMessage() );
    }
  }
View Full Code Here

    String        val, val2;
    SessionObject    so;
    Object        o;
    final List      soList    = new ArrayList();
    final NodeList    rootNL    = node.getChildNodes();
    final Application  app      = AbstractApplication.getApplication();

    options.put( OPTIONS_KEY_SESSION, this );

//    updateFileAttr( domDoc, node );
    try {
//      bird.waitExclusive( DOOR_ALL );
      receivers.pauseDispatcher();
      selectedReceivers.pauseDispatcher();
      tracks.pauseDispatcher();
      selectedTracks.pauseDispatcher();
// EEE
//      transmitters.pauseDispatcher();
//      selectedTransmitters.pauseDispatcher();
      timeline.pauseDispatcher();
      clear();
     
//      super.fromXML( domDoc, node, options );  // parses optional map
     
      // check attributes
      d1 = Double.parseDouble( node.getAttribute( XML_ATTR_COMPATIBLE ));
      if( d1 > FILE_VERSION ) throw new IOException( app.getResourceString( "errIncompatibleFileVersion" ) + " : " + d1 );
      d1 = Double.parseDouble( node.getAttribute( XML_ATTR_VERSION ));
      if( d1 > FILE_VERSION ) options.put( XMLRepresentation.KEY_WARNING,
        app.getResourceString( "warnNewerFileVersion" ) + " : " + d1 );
      val = node.getAttribute( XML_ATTR_PLATFORM );
      if( !val.equals( System.getProperty( "os.name" ))) {
        o   = options.get( XMLRepresentation.KEY_WARNING );
        val2 = (o == null ? "" : o.toString() + "\n") +
             app.getResourceString( "warnDifferentPlatform" ) + " : " + val;
        options.put( XMLRepresentation.KEY_WARNING, val2 );
      }


      for( int k = 0; k < rootNL.getLength(); k++ ) {
        if( !(rootNL.item( k ) instanceof Element) ) continue;
       
        elem  = (Element) rootNL.item( k );
        val    = elem.getTagName();

        // zero or one "map" element
        if( val.equals( XML_ELEM_MAP )) {
          getMap().fromXML( domDoc, elem, options );

        // zero or more "object" elements
        } else if( val.equals( XML_ELEM_OBJECT )) {
          val    = elem.getAttribute( XML_ATTR_NAME );
          if( val.equals( Timeline.XML_OBJECT_NAME )) {
            timeline.fromXML( domDoc, elem, options );
          } else {
            System.err.println( "Warning: unknown session object type: '"+val+"'" );
          }
         
        } else if( val.equals( XML_ELEM_COLL )) {
          val    = elem.getAttribute( XML_ATTR_NAME );
          if( val.equals( XML_VALUE_RECEIVERS )) {
            soList.clear();
            nl = elem.getChildNodes();
            for( int m = 0; m < nl.getLength(); m++ ) {
              elem2  = (Element) nl.item( m );
              val    = elem2.getTagName();
              if( !val.equals( XML_ELEM_OBJECT )) continue;

              if( elem2.hasAttribute( XML_ATTR_CLASS )) {
                val  = elem2.getAttribute( XML_ATTR_CLASS );
              } else // #IMPLIED
                val = "de.sciss.meloncillo.receiver.SigmaReceiver";
              }
              so = (SessionObject) Class.forName( val ).newInstance();
              if( so instanceof XMLRepresentation ) {
                ((XMLRepresentation) so).fromXML( domDoc, elem2, options );
              }
              receivers.getMap().copyContexts( null, MapManager.Context.FLAG_DYNAMIC,
                               MapManager.Context.NONE_EXCLUSIVE, so.getMap() );
              soList.add( so );
            }
            receivers.addAll( this, soList );

          } else if( val.equals( XML_VALUE_TRANSMITTERS )) {
            soList.clear();
            nl = elem.getChildNodes();
            for( int m = 0; m < nl.getLength(); m++ ) {
              elem2  = (Element) nl.item( m );
              val    = elem2.getTagName();
              if( !val.equals( XML_ELEM_OBJECT )) continue;

              if( elem2.hasAttribute( XML_ATTR_CLASS )) {
                val  = elem2.getAttribute( XML_ATTR_CLASS );
              } else // #IMPLIED
                val = "de.sciss.meloncillo.transmitter.SimpleTransmitter";
              }
              so = (SessionObject) Class.forName( val ).newInstance();
              if( so instanceof XMLRepresentation ) {
                ((XMLRepresentation) so).fromXML( domDoc, elem2, options );
              }
              transmitters.getMap().copyContexts( null, MapManager.Context.FLAG_DYNAMIC,
                                MapManager.Context.NONE_EXCLUSIVE, so.getMap() );
              soList.add( so );
            }
            tracks.addAll( this, soList );
//            transmitters.addAll( this, soList );

          } else if( val.equals( XML_VALUE_GROUPS )) {
            soList.clear();
            nl = elem.getChildNodes();
            for( int m = 0; m < nl.getLength(); m++ ) {
              elem2  = (Element) nl.item( m );
              val    = elem2.getTagName();
              if( !val.equals( XML_ELEM_OBJECT )) continue;

              if( elem2.hasAttribute( XML_ATTR_CLASS )) {
                val  = elem2.getAttribute( XML_ATTR_CLASS );
              } else // #IMPLIED
                val = "de.sciss.meloncillo.session.SessionGroup";
              }
              so = (SessionObject) Class.forName( val ).newInstance();
              if( so instanceof XMLRepresentation ) {
                ((XMLRepresentation) so).fromXML( domDoc, elem2, options );
              }
              groups.getMap().copyContexts( null, MapManager.Context.FLAG_DYNAMIC,
                              MapManager.Context.NONE_EXCLUSIVE, so.getMap() );
              soList.add( so );
            }
            groups.addAll( this, soList );

          } else {
            System.err.println( "Warning: unknown session collection type: '"+val+"'" );
          }

        // optional prefs
        } else if( val.equals( "prefs" )) {
          nl    = elem.getChildNodes();
          for( int i = 0; i < nl.getLength(); i++ ) {
            if( !(nl.item( i ) instanceof Element) ) continue;
            elem = (Element) nl.item( i );
            val   = elem.getAttribute( "name" );
            if( val.equals( PrefsUtil.NODE_SESSION )) {
              PrefsUtil.fromXML( app.getUserPrefs().node( PrefsUtil.NODE_SESSION ), domDoc, elem, options );
            } else if( val.equals( PrefsUtil.NODE_SHARED )) {
              if( !app.getUserPrefs().getBoolean( PrefsUtil.KEY_RECALLFRAMES, false )) {  // install filter
                java.util.Set set = new HashSet( 3 );
                set.add( PrefsUtil.KEY_LOCATION );
                set.add( PrefsUtil.KEY_SIZE );
                set.add( PrefsUtil.KEY_VISIBLE );
                options.put( PrefsUtil.OPTIONS_KEY_FILTER, set );
              }
              PrefsUtil.fromXML( app.getUserPrefs().node( PrefsUtil.NODE_SHARED ), domDoc, elem, options );
            } else {
              System.err.println( "Warning: unknown preferences tree '"+val+"'" );
            }
          }
         
View Full Code Here

      super( SUPPORT );

    this.doc  = doc;

    final Container          cp    = getContentPane();
    final Application        app    = AbstractApplication.getApplication();
    final Flag            haveWarned      = new Flag( false );
    final String          txtWarnLookAndFeel  = getResourceString( "warnLookAndFeelUpdate" );

    PrefTextField          ggText;
    KeyStrokeTextField        ggKeyStroke;
    PrefTextArea          ggArea;
    PrefNumberField          ggNumber;
    PrefPathField          ggPath;
    PrefCheckBox          ggCheckBox;
        PrefComboBox          ggChoice;
    JTabbedPane            ggTabPane;
    JLabel              lb;
        UIManager.LookAndFeelInfo[]    lafInfos;
    SpringPanel            tab;

    Preferences            prefs;
    String              key, key2, title;
    int                row;

    ggTabPane      = new JTabbedPane();

      setTitle( getResourceString( "framePrefs" ));

      // ---------- global pane ----------

    tab    = createTab();

    row  = 0;
    prefs   = IOUtil.getUserPrefs();
    key    = IOUtil.KEY_TEMPDIR;
    key2  = "prefsTmpDir";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggPath = new PrefPathField( PathField.TYPE_FOLDER, getResourceString( key2 ));
    ggPath.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggPath, key2 );  // EEE
    tab.gridAdd( ggPath, 1, row );

    row++;
    prefs   = app.getUserPrefs();
    key    = PrefsUtil.KEY_RECALLFRAMES;
    key2  = "prefsRecallFrames";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggCheckBox  = new PrefCheckBox();
    ggCheckBox.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggCheckBox, key2 );  // EEE
    tab.gridAdd( ggCheckBox, 1, row );
   
    row++;
    prefs   = app.getUserPrefs();
        key     = PrefsUtil.KEY_LOOKANDFEEL;
    key2  = "prefsLookAndFeel";
    title  = getResourceString( key2 );
    lb    = new JLabel( title, TRAILING );
    tab.gridAdd( lb, 0, row );
    ggChoice = new PrefComboBox();
    lafInfos = UIManager.getInstalledLookAndFeels();
        for( int i = 0; i < lafInfos.length; i++ ) {
            ggChoice.addItem( new StringItem( lafInfos[i].getClassName(), lafInfos[i].getName() ));
        }
    ggChoice.setPreferences( prefs, key );
    ggChoice.addActionListener( new WarnPrefsChange( ggChoice, ggChoice, haveWarned, txtWarnLookAndFeel, title ));
   
    tab.gridAdd( ggChoice, 1, row, -1, 1 );

    row++;
         key    = BasicWindowHandler.KEY_LAFDECORATION;
    key2  = "prefsLAFDecoration";
    title  = getResourceString( key2 );
    ggCheckBox  = new PrefCheckBox( title );
    ggCheckBox.setPreferences( prefs, key );
    tab.gridAdd( ggCheckBox, 1, row, -1, 1 );
    ggCheckBox.addActionListener( new WarnPrefsChange( ggCheckBox, ggCheckBox, haveWarned, txtWarnLookAndFeel, title ));

    row++;
         key    = BasicWindowHandler.KEY_INTERNALFRAMES;
    key2  = "prefsInternalFrames";
    title  = getResourceString( key2 );
    ggCheckBox  = new PrefCheckBox( title );
    ggCheckBox.setPreferences( prefs, key );
    tab.gridAdd( ggCheckBox, 1, row, -1, 1 );
    ggCheckBox.addActionListener( new WarnPrefsChange( ggCheckBox, ggCheckBox, haveWarned, txtWarnLookAndFeel, title ));

    row++;
         key    = CoverGrowBox.KEY_INTRUDINGSIZE;
    key2  = "prefsIntrudingSize";
    ggCheckBox  = new PrefCheckBox( getResourceString( key2 ));
    ggCheckBox.setPreferences( prefs, key );
    tab.gridAdd( ggCheckBox, 1, row, -1, 1 );

    row++;
         key    = BasicWindowHandler.KEY_FLOATINGPALETTES;
    key2  = "prefsFloatingPalettes";
    ggCheckBox  = new PrefCheckBox( getResourceString( key2 ));
    ggCheckBox.setPreferences( prefs, key );
    tab.gridAdd( ggCheckBox, 1, row, -1, 1 );
    ggCheckBox.addActionListener( new WarnPrefsChange( ggCheckBox, ggCheckBox, haveWarned, txtWarnLookAndFeel, title ));

    row++;
    prefs   = GUIUtil.getUserPrefs();
//       key    = HelpGlassPane.KEY_KEYSTROKE_HELP;  // EEE
    key2  = "prefsKeyStrokeHelp";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggKeyStroke = new KeyStrokeTextField();
    ggKeyStroke.setPreferences( prefs, key );
//      HelpGlassPane.setHelp( ggKeyStroke, key2 );  // EEE
    tab.gridAdd( ggKeyStroke, 1, row );
   
    addTab( ggTabPane, tab, "prefsGeneral" );

    // ---------- plug-ins pane ----------

    prefs   = app.getUserPrefs().node( PrefsUtil.NODE_PLUGINS );
    tab    = createTab();

    row  = 0;
    key    = PrefsUtil.KEY_LISPREALTIMELIST;
    key2  = "prefsLispRealtimeList";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggPath  = new PrefPathField( PathField.TYPE_INPUTFILE, getResourceString( key2 ));
    ggPath.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggPath, key2 );  // EEE
    tab.gridAdd( ggPath, 1, row );

    row++;
    key    = PrefsUtil.KEY_LISPBOUNCELIST;
    key2  = "prefsLispBounceList";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggPath  = new PrefPathField( PathField.TYPE_INPUTFILE, getResourceString( key2 ));
    ggPath.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggPath, key2 );  // EEE
    tab.gridAdd( ggPath, 1, row );

    row++;
    key    = PrefsUtil.KEY_LISPFILTERLIST;
    key2  = "prefsLispFilterList";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggPath = new PrefPathField( PathField.TYPE_INPUTFILE, getResourceString( key2 ));
    ggPath.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggPath, key2 );  // EEE
    tab.gridAdd( ggPath, 1, row );

    row++;
    key    = PrefsUtil.KEY_SUPERCOLLIDEROSC;
    key2  = "prefsSuperColliderOSC";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggText  = new PrefTextField( 32 );
    ggText.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggText, key2 );  // EEE
    tab.gridAdd( ggText, 1, row );

    row++;
    key    = PrefsUtil.KEY_SUPERCOLLIDERAPP;
    key2  = "prefsSuperColliderApp";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggPath = new PrefPathField( PathField.TYPE_INPUTFILE, getResourceString( key2 ));
    ggPath.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggPath, key2 );  // EEE
    tab.gridAdd( ggPath, 1, row );

    row++;
    key    = PrefsUtil.KEY_CSOUNDAPP;
    key2  = "prefsCSoundApp";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggPath = new PrefPathField( PathField.TYPE_INPUTFILE, getResourceString( key2 ));
    ggPath.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggPath, key2 );  // EEE
    tab.gridAdd( ggPath, 1, row );

    row++;
    key    = PrefsUtil.KEY_AUDIOINPUTS;
    key2  = "prefsAudioInputChannels";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggNumber  = new PrefNumberField();
    ggNumber.setSpace( NumberSpace.createIntSpace( 0, 16384 ));
//    ggNumber.setUnit( getResourceString( "labelUnitChannels" ));  // EEE
    ggNumber.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggNumber, key2 );  // EEE
    tab.gridAdd( ggNumber, 1, row );

    row++;
    key    = PrefsUtil.KEY_AUDIOOUTPUTS;
    key2  = "prefsAudioOutputChannels";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggNumber  = new PrefNumberField();
    ggNumber.setSpace( NumberSpace.createIntSpace( 0, 16384 ));
//    ggNumber.setUnit( getResourceString( "labelUnitChannels" ));  // EEE
    ggNumber.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggNumber, key2 );  // EEE
    tab.gridAdd( ggNumber, 1, row );

    row++;
    key    = PrefsUtil.KEY_AUDIORATE;
    key2  = "prefsAudioRate";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggNumber  = new PrefNumberField();
    ggNumber.setSpace( NumberSpace.createIntSpace( 1, 768000 ));
//    ggNumber.setUnit( getResourceString( "labelUnitHertz" ));  // EEE
    ggNumber.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggNumber, key2 );  // EEE
    tab.gridAdd( ggNumber, 1, row );

    row++;
    key    = PrefsUtil.KEY_RTSENSEBUFSIZE;
    key2  = "prefsRTSenseBufSize";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggNumber  = new PrefNumberField();
    ggNumber.setSpace( NumberSpace.createIntSpace( 1, 60000 ));
//    ggNumber.setUnit( getResourceString( "labelUnitMillisec" ));  // EEE
    ggNumber.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggNumber, key2 );  // EEE
    tab.gridAdd( ggNumber, 1, row );

    row++;
    key    = PrefsUtil.KEY_RTMAXSENSERATE;
    key2  = "prefsRTMaxSenseRate";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggNumber  = new PrefNumberField();
    ggNumber.setSpace( NumberSpace.createIntSpace( 1, 768000 ));
//    ggNumber.setUnit( getResourceString( "labelUnitHertz" ));  // EEE
    ggNumber.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggNumber, key2 );  // EEE
    tab.gridAdd( ggNumber, 1, row );

    row++;
    key    = PrefsUtil.KEY_OLSENSEBUFSIZE;
    key2  = "prefsOLSenseBufSize";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggNumber  = new PrefNumberField();
    ggNumber.setSpace( NumberSpace.createIntSpace( 1, 60000 ));
//    ggNumber.setUnit( getResourceString( "labelUnitMillisec" ));  // EEE
    ggNumber.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggNumber, key2 );  // EEE
    tab.gridAdd( ggNumber, 1, row );

    addTab( ggTabPane, tab, "prefsPlugIns" );

    // ---------- session pane ----------

    prefs   = app.getUserPrefs().node( PrefsUtil.NODE_SESSION );
    tab    = createTab();
    row  = 0;

    key    = PrefsUtil.KEY_COMMENT;
    key2  = "prefsComment";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggArea  = new PrefTextArea( 6, 32 );
    ggArea.setPreferences( prefs, key );
//        HelpGlassPane.setHelp( ggArea, key2 );  // EEE
    tab.gridAdd( ggArea, 1, row );

    row++;
    key2  = "prefsSenseRate";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
    ggRate  = new PrefNumberField();
    ggRate.setSpace( NumberSpace.createIntSpace( 1, 768000 ));
//    ggRate.setUnit( getResourceString( "labelUnitHertz" ));  // EEE
//    ggNumber.setPreferences( prefs, key );
    tab.gridAdd( ggRate, 1, row );
    ggRate.addListener( new NumberListener() {
      public void numberChanged( NumberEvent e )
      {
        if( !doc.bird.attemptExclusive( Session.DOOR_TIME, 250 )) {
          ggRate.setNumber( new Double( doc.timeline.getRate() ));   // undo
          return;
        }
        try {
//          root.transport.stopAndWait();
          int newRate = ggRate.getNumber().intValue();
          if( newRate != doc.timeline.getRate() ) {
            doc.timeline.setRate( ggRate, newRate );
          }
        } finally {
          doc.bird.releaseExclusive( Session.DOOR_TIME );
        }
      }
    });
//        HelpGlassPane.setHelp( ggRate, key2 );  // EEE
    tab.gridAdd( ggRate, 1, row );

    addTab( ggTabPane, tab, "prefsSession" );

    // ---------- generic gadgets ----------

    cp.add( ggTabPane, BorderLayout.CENTER );
    AbstractWindowHandler.setDeepFont( cp );

    // ---------- listeners ----------
    addDynamicListening( this );
   
    addListener( new AbstractWindow.Adapter() {
      public void windowClosing( AbstractWindow.Event e )
      {
        setVisible( false );
        dispose();
      }
    });

    setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE );
    init();
    app.addComponent( Main.COMP_PREFS, this );
    }
View Full Code Here

TOP

Related Classes of de.sciss.app.Application

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.