Package de.sciss.eisenkraut.net

Examples of de.sciss.eisenkraut.net.OSCRoot


    final double        prefsVersion;
//    final ObserverPalette    frameObserver;
//    final ControlRoomFrame    paletteCtrlRoom;
    final MainFrame        mainFrame;
//    final CacheManager      cacheManager;
    final OSCRoot        oscServer;
    final SuperColliderClient  superCollider;
    String            lafName;
    List            openDoc      = null;

    // ---- init prefs ----

    oscServer      = new OSCRoot( prefs.node( OSCRoot.DEFAULT_NODE ), 0x4549 );
    prefsVersion = prefs.getDouble( PrefsUtil.KEY_VERSION, 0.0 );
    if( prefsVersion < APP_VERSION ) {
      warnings = PrefsUtil.createDefaults( prefs, prefsVersion );
    } else {
      warnings = null;
    }
   
    // ---- check commandline options ----

        // WebLookAndFeel.install();
        // System.out.println(UIManager.getLookAndFeel().getName());
        UIManager.installLookAndFeel("WebLookAndFeel", "com.alee.laf.WebLookAndFeel");
        WebCheckBoxStyle   .animated            = false;
        WebProgressBarStyle.progressTopColor    = Color.lightGray;
        WebProgressBarStyle.progressBottomColor = Color.gray;
        // XXX TODO: how to really turn of animation?
        WebProgressBarStyle.highlightWhite      = new Color(255, 255, 255, 0); // 48)
        WebProgressBarStyle.highlightDarkWhite  = new Color(255, 255, 255, 0);

    lafName = prefs.get( PrefsUtil.KEY_LOOKANDFEEL, null );
    for( int i = 0; i < args.length; i++ ) {
      if( args[ i ].startsWith( "-" )) {
        if( args[ i ].equals( "-laf" )) {
          if( (i + 2) < args.length ) {
            UIManager.installLookAndFeel( args[ i + 1 ], args[ i + 2 ]);
            if( lafName == null ) lafName = args[ i + 2 ];
            i += 2;
          } else {
            System.err.println( "Option -laf requires two additional arguments (screen-name and class-name)." );
            System.exit( 1 );
          }
        } else {
          System.err.println( "Unknown option " + args[ i ]);
          System.exit( 1 );
        }
      } else {
        if( openDoc == null ) openDoc = new ArrayList();
        openDoc.add( args[ i ]);
      }
    }
       
    // ---- init look-and-feel ----

    System.setProperty( "swing.aatext", "true" );
    lookAndFeelUpdate( lafName );

//    JFrame.setDefaultLookAndFeelDecorated( true );

    // ---- init infrastructure ----
    // warning : reihenfolge is crucial
//    oscServer      = new OSCRoot( prefs.node( OSCRoot.DEFAULT_NODE ), 0x4549 );
    osc          = new OSCRouterWrapper( oscServer, this );
    final CacheManager cache = new PrefCacheManager( prefs.node( PrefCacheManager.DEFAULT_NODE ));
    superCollider    = new SuperColliderClient();

    init();
   
    // ---- listeners ----

    quitAfterSaveListener = new ProcessingThread.Listener() {
      public void processStarted( ProcessingThread.Event e ) { /* empty */ }

      // if the saving was successfull, we will call closeAll again
      public void processStopped( ProcessingThread.Event e )
      {
        if( e.isDone() ) {
          quit();
        }
      }
    };

    try {
      superCollider.init();
    }
    catch( IOException e1 ) {
      BasicWindowHandler.showErrorDialog( null, e1, "SuperColliderClient Initialization" );
      System.exit( 1 );
      return;
    }

//    scPlugInManager    = new SCPlugInManager( this );

    // ---- component views ----

    mainFrame    = new MainFrame();
    ((BasicWindowHandler) getWindowHandler()).setDefaultBorrower( mainFrame );
    final AppWindow ctrlRoom  = new ControlRoomFrame();
    final AppWindow observer  = new ObserverPalette();

    // means no preferences found, so
    // do some more default initializations
    // and display splash screen
    if( prefsVersion == 0.0 ) {
      ctrlRoom.setVisible( true );
      observer.setVisible( true );
      if( cache.getFolder().isDirectory() ) {
        cache.setActive( true );
      }
        new WelcomeScreen( this );
    }

    if( warnings != null ) {
      for( int i = 0; i < warnings.size(); i++ ) {
        System.err.println( warnings.get( i ));
      }
    }

    oscServer.init();
   
    if( prefs.node( PrefsUtil.NODE_AUDIO ).getBoolean( PrefsUtil.KEY_AUTOBOOT, false )) {
      superCollider.boot();
    }
   
View Full Code Here


    setTitle( getResourceString( "framePrefs" ));

    final Container          cp          = getContentPane();
    final Application        app          = AbstractApplication.getApplication();
//    final ActionListener      lafActionListener;
    final OSCRoot          osc;
    final PrefCacheManager      cm;
    final Flag            haveWarned      = new Flag( false );
    final String          txtWarnLookAndFeel  = getResourceString( "warnLookAndFeelUpdate" );

    final TreeExpanderButton    ggTreeAudio;
    final List            collAudioAdvanced;
    SpringPanel            tab;
    PrefParamField          ggParam;
    BasicPathField          ggPath;
    PrefCheckBox          ggCheckBox;
        PrefComboBox          ggChoice;
    JTabbedPane            ggTabPane;
    JLabel              lb;
    JComboBox            ggCombo;
        UIManager.LookAndFeelInfo[]    lafInfos;
    Box                b;

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

    ggTabPane  = new JTabbedPane();

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

    tab    = createTab();

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

    row++;
    cm    = PrefCacheManager.getInstance();
    prefs   = cm.getPreferences();
    key    = PrefCacheManager.KEY_ACTIVE;
    key2  = "prefsCache";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
    tab.gridAdd( lb, 0, row );
    ggCheckBox = new PrefCheckBox( getResourceString( "prefsCacheActive" ));
    ggCheckBox.setPreferences( prefs, key );
//    tab.gridAdd( ggCheckBox, 1, row, -1, 1 );
    b    = Box.createHorizontalBox();
    b.add( ggCheckBox );
//
//    row++;
    key    = PrefCacheManager.KEY_CAPACITY;
    key2  = "prefsCacheCapacity";
    lb    = new JLabel( getResourceString( key2 ) + " [" +
                getResourceString( "labelMegaBytes" ) + "]", TRAILING );
//    tab.gridAdd( lb, 0, row );
    b.add( Box.createHorizontalStrut( 16 ));
    b.add( lb );
    ggParam  = new PrefParamField();
    ggParam.addSpace( spcIntegerFromOne );
    ggParam.setPreferences( prefs, key );
//    tab.gridAdd( ggParam, 1, row, -1, 1 );
    b.add( ggParam );
    tab.gridAdd( b, 1, row, -1, 1 );

    row++;   
    key    = PrefCacheManager.KEY_FOLDER;
    key2  = "prefsCacheFolder";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
    tab.gridAdd( lb, 0, row );
    ggPath  = new BasicPathField( PathField.TYPE_FOLDER, getResourceString( key2 ));
    ggPath.setPreferences( prefs, key );
    tab.gridAdd( ggPath, 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();
//    key2  = "prefsKeyStrokeHelp";
//    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
//    tab.gridAdd( lb, 0, row );
//    ggKeyStroke = new KeyStrokeTextField();
//    ggKeyStroke.setPreferences( prefs, key );
//    tab.gridAdd( ggKeyStroke, 1, row, -1, 1 );

    addTab( ggTabPane, tab, "prefsGeneral");

    // ---------- audio pane ----------

    prefs   = app.getUserPrefs().node( PrefsUtil.NODE_AUDIO );
    audioPrefs  = prefs;
    abPrefs  = audioPrefs.node( PrefsUtil.NODE_AUDIOBOXES );
    tab    = createTab();

    row    = 0;
    key    = PrefsUtil.KEY_SUPERCOLLIDERAPP;
    key2  = "prefsSuperColliderApp";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
    tab.gridAdd( lb, 0, row );
    ggPath = new BasicPathField( PathField.TYPE_INPUTFILE, getResourceString( key2 ));
    ggPath.setPreferences( prefs, key );
//    HelpGlassPane.setHelp( ggPath, key2 );
    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 );
//    tab.gridAdd( ggText, 1, row, -1, 1 );

        row++;
        key    = PrefsUtil.KEY_AUTOBOOT;
        key2  = "prefsAutoBoot";
//    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
//    tab.gridAdd( lb, 0, row );
        ggCheckBox  = new PrefCheckBox( getResourceString( key2 ));
        ggCheckBox.setPreferences( prefs, key );
//    HelpGlassPane.setHelp( ggCheckBox, key2 );
        tab.gridAdd( ggCheckBox, 1, row, -1, 1 );

     row++;
        key    = PrefsUtil.KEY_AUTOPLAYFROMFINDER;
    key2  = "prefsAutoPlayFromFinder";
    lb    = new JLabel( getResourceString( key2 ), JLabel.TRAILING );
    tab.gridAdd( lb, 0, row );
        ggChoice = new PrefComboBox();
        ggChoice.addItem( new StringItem( PrefsUtil.AUTOPLAYFROMFINDER_NONE, getResourceString( key2 + "." + PrefsUtil.AUTOPLAYFROMFINDER_NONE )));
        ggChoice.addItem( new StringItem( PrefsUtil.AUTOPLAYFROMFINDER_PLAY, getResourceString( key2 + "." + PrefsUtil.AUTOPLAYFROMFINDER_PLAY )));
        ggChoice.addItem( new StringItem( PrefsUtil.AUTOPLAYFROMFINDER_LOOP, getResourceString( key2 + "." + PrefsUtil.AUTOPLAYFROMFINDER_LOOP )));
        ggChoice.setPreferences( prefs, key );
        tab.gridAdd( ggChoice, 1, row, -1, 1 );

    row++;
    lb    = new JLabel( getResourceString( "labelAudioIFs" ), TRAILING );
    tab.gridAdd( lb, 0, row );
    tab.gridAdd( createAudioBoxGUI(), 1, row, 1, -1 );

    row++;
    key    = PrefsUtil.KEY_AUDIORATE;
    key2  = "prefsAudioRate";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
    tab.gridAdd( lb, 0, row );
    ggParam  = new PrefParamField();
    ggParam.addSpace( ParamSpace.spcFreqHertz );
    ggCombo = new JComboBox();
    for( int i = 0; i < RATE_ITEMS.length; i++ ) {
      ggCombo.addItem( RATE_ITEMS[ i ]);
    }
    ggParam.setBorder( new ComboBoxEditorBorder() );
    ggCombo.setEditor( ggParam );
    ggCombo.setEditable( true );
    ggParam.setPreferences( prefs, key ); // important to be _afer_ setEditor because otherwise prefs get overwritten!
//    ggCombo.setSelectedIndex( 0 ); // DEFAULT_RATE
//ggParam.setPreferredSize( new Dimension( ggParam.getPreferredSize().width, Math.max( 24, ggParam.getPreferredSize().height )));
//ggCombo.setPreferredSize( new Dimension( ggCombo.getPreferredSize().width, Math.max( 24, ggCombo.getPreferredSize().height )));
    tab.gridAdd( ggCombo, 1, row, -1, 1 );

    row++;
    b  = Box.createHorizontalBox();
    b.add( Box.createHorizontalGlue() );
    ggTreeAudio  = new TreeExpanderButton();
    b.add( ggTreeAudio );
    b.add( new JLabel( getResourceString( "prefsAdvanced" )));
    tab.gridAdd( b, 0, row );

    collAudioAdvanced = new ArrayList();

    row++;
    key2  = "prefsSuperColliderOSC";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
    lb.setVisible( false );
    collAudioAdvanced.add( lb );
    tab.gridAdd( lb, 0, row );
    key    = PrefsUtil.KEY_SCPROTOCOL;
    key2  = "prefsOSCProtocol";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
//    tab.gridAdd( lb, 2, row );
    b    = Box.createHorizontalBox();
    b.add( Box.createHorizontalStrut( 4 ));
    b.add( lb );
    ggChoice = new PrefComboBox();
    ggChoice.addItem( new StringItem( OSCChannel.TCP, "TCP" ));
    ggChoice.addItem( new StringItem( OSCChannel.UDP, "UDP" ));
    ggChoice.setPreferences( prefs, key );
//    tab.gridAdd( ggChoice, 3, row, -1, 1 );
    b.add( ggChoice );

    key    = PrefsUtil.KEY_SCPORT;
    key2  = "prefsOSCPort";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
//    tab.gridAdd( lb, 4, row );
    b.add( Box.createHorizontalStrut( 16 ));
    b.add( lb );
    ggParam  = new PrefParamField();
    ggParam.addSpace( spcIntegerFromZero );
    ggParam.setPreferences( prefs, key );
//    tab.gridAdd( ggParam, 5, row, -1, 1 );
    b.add( ggParam );
    b.setVisible( false );
    collAudioAdvanced.add( b );
    tab.gridAdd( b, 1, row, -1, 1 );

    row++;
    key    = PrefsUtil.KEY_SCBLOCKSIZE;
    key2  = "prefsSCBlockSize";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
    lb.setVisible( false );
    collAudioAdvanced.add( lb );
    tab.gridAdd( lb, 0, row );
    ggParam  = new PrefParamField();
    ggParam.addSpace( spcIntegerFromOne );
    ggParam.setPreferences( prefs, key );
    ggParam.setVisible( false );
    collAudioAdvanced.add( ggParam );
    tab.gridAdd( ggParam, 1, row, -1, 1 );

    row++;
    key    = PrefsUtil.KEY_AUDIOBUSSES;
    key2  = "prefsAudioBusses";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
    lb.setVisible( false );
    collAudioAdvanced.add( lb );
    tab.gridAdd( lb, 0, row );
    ggParam  = new PrefParamField();
    ggParam.addSpace( spcIntegerFromOne );
    ggParam.setPreferences( prefs, key );
    ggParam.setVisible( false );
    collAudioAdvanced.add( ggParam );
    tab.gridAdd( ggParam, 1, row, -1, 1 );
//    pAudio.makeCompactGrid();
//    pAudio.setVisible( false );

    row++;
    key    = PrefsUtil.KEY_SCMEMSIZE;
    key2  = "prefsSCMemSize";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
    lb.setVisible( false );
    collAudioAdvanced.add( lb );
    tab.gridAdd( lb, 0, row );
    ggParam  = new PrefParamField();
    ggParam.addSpace( spcIntegerFromOne );
    ggParam.setPreferences( prefs, key );
    ggParam.setVisible( false );
    collAudioAdvanced.add( ggParam );
    tab.gridAdd( ggParam, 1, row, -1, 1 );

    row++;
    key    = PrefsUtil.KEY_SCRENDEZVOUS;
    key2  = "prefsSCRendezvous";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
    lb.setVisible( false );
    collAudioAdvanced.add( lb );
    tab.gridAdd( lb, 0, row );
    ggCheckBox  = new PrefCheckBox();
    ggCheckBox.setPreferences( prefs, key );
    ggCheckBox.setVisible( false );
    collAudioAdvanced.add( ggCheckBox );
    tab.gridAdd( ggCheckBox, 1, row, -1, 1 );

final SpringPanel tabAudio = tab;
    ggTreeAudio.addActionListener( new ActionListener() {
      public void actionPerformed( ActionEvent e )
      {
        final int    width  = getWindow().getWidth();
        final int    height  = getWindow().getHeight();
        final boolean  visible  = ggTreeAudio.isExpanded();
        int        delta  = 0;
        int        d2;
       
        for( int i = 0; i < collAudioAdvanced.size(); ) {
          d2 = 0;
          for( int j = i + 2; i < j; i++ ) {
            d2 = Math.max( d2, ((JComponent) collAudioAdvanced.get( i )).getPreferredSize().height );
          }
          delta = delta + d2 + 2;
        }

        for( int i = 0; i < collAudioAdvanced.size(); i++ ) {
          ((JComponent) collAudioAdvanced.get( i )).setVisible( visible );
        }
        tabAudio.makeCompactGrid();
        getWindow().setSize( width, height + (visible ? delta : -delta ));
      }
    });

    addTab( ggTabPane, tab, "prefsAudio" );

    // ---------- osc pane ----------

    tab    = createTab();

    row    = 0;
    osc    = OSCRoot.getInstance();
    prefs   = osc.getPreferences();
    key    = OSCRoot.KEY_ACTIVE;
//    key2  = "prefsOSCActive";
    key2  = "prefsOSCServer";
    lb    = new JLabel( getResourceString( key2 ), TRAILING );
    tab.gridAdd( lb, 0, row );
View Full Code Here

TOP

Related Classes of de.sciss.eisenkraut.net.OSCRoot

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.