Package de.sciss.util

Examples of de.sciss.util.Flag


      if( (insertPos < 0) || (insertPos > timeline.getLength()) ) throw new IllegalArgumentException( String.valueOf( insertPos ));
     
      final ProcessingThread    proc;
      final Span          oldSelSpan, insertSpan, copySpan, cutTimelineSpan;
      final AbstractCompoundEdit  edit;
      final Flag          hasSelectedAudio;
      final List          tis;
      final boolean        expTimeline, cutTimeline;
      final long          docLength, pasteLength, preMaxLen, postMaxLen;
      final BlendContext      bcPre, bcPost;
     
      hasSelectedAudio  = new Flag( false );
      tis          = Track.getInfos( selectedTracks.getAll(), tracks.getAll() );
      if( !checkSyncedAudio( tis, mode == EDIT_INSERT, null, hasSelectedAudio )) return null;

      expTimeline      = (mode == EDIT_INSERT) && hasSelectedAudio.isSet();
      docLength      = timeline.getLength();
      pasteLength      = expTimeline ? tl.getSpan().getLength() :
        Math.min( tl.getSpan().getLength(), docLength - insertPos );
      if( pasteLength == 0 ) return null;
     
      if( mode == EDIT_INSERT ) {
        /*
         *  before paste:
         *
         *   maxRight / post   maxLeft / pre
         *
         *  |                 |              |
         *  |                 |              |
         *  |                 |              |
         *  |        A        |     B        |
         *  +-----------------+--------------+
         *                    |
         *                 insertPos
         *
         *  after paste:
         *
         *  |                 | B #$$$$# A |              |
         *  |                 |  ##$$$$##  |              |
         *  |                 | ###$$$$### |              |
         *  |        A        |####$$$$####|      B       |
         *  +-----------------+------------+--------------+
         *                    |
         *                 insertPos
         */
        // note: now the discrepancy between postMaxLen and preMaxLen is
        // limited to 100%, so pasting at the very end or beginning of
        // a doc will not produce a single sided xfade any more
        // (answering bug 1922862)
        if( insertPos < (docLength - insertPos) ) {
          postMaxLen  = Math.min( insertPos, pasteLength >> 1 );
//          preMaxLen  = Math.min( docLength - insertPos, pasteLength - postMaxLen );
          preMaxLen  = Math.min( postMaxLen << 1, Math.min( docLength - insertPos, pasteLength - postMaxLen ));
//System.out.println( "A" );
        } else {
          preMaxLen  = Math.min( docLength - insertPos, pasteLength >> 1 );
          postMaxLen  = Math.min( preMaxLen << 1, Math.min( insertPos, pasteLength - preMaxLen ));
//System.out.println( "B" );
        }
      } else {
        preMaxLen  = pasteLength >> 1// note: pasteLength already clipped to be <= docLength - insertPos !
        postMaxLen  = pasteLength - preMaxLen;
//System.out.println( "C" );
      }
      bcPre      = createBlendContext( preMaxLen, 0, hasSelectedAudio.isSet() );
      bcPost      = createBlendContext( postMaxLen, 0, hasSelectedAudio.isSet() );
//System.out.println( "D ; preMaxLen = " + preMaxLen + "; postMaxLen = " + postMaxLen + "; bcPre.getLeftLen() = " + (bcPre == null ? null : String.valueOf( bcPre.getLeftLen())) + "; bcPre.getRightLen() = " + (bcPre == null ? null : String.valueOf( bcPre.getRightLen() )) + "; bcPost.getLeftLen() = " + (bcPost == null ? null : String.valueOf( bcPost.getLeftLen() )) + "; bcPost.getRightLen() = " + (bcPost == null ? null : String.valueOf( bcPost.getRightLen() )));

//      if( bcPre != null )  System.out.println( "bcPre  : " + bcPre.getLen() + ", " + bcPre.getLeftLen() + ", "+ bcPre.getRightLen() );
//      if( bcPost != null ) System.out.println( "bcPost : " + bcPost.getLen() + ", " + bcPost.getLeftLen() + ", "+ bcPost.getRightLen() );
     
      insertSpan      = new Span( insertPos, insertPos + pasteLength );
      copySpan      = new Span( tl.getSpan().start, tl.getSpan().start + pasteLength );
      cutTimeline      = (mode == EDIT_INSERT) && !hasSelectedAudio.isSet();
      cutTimelineSpan    = cutTimeline ? new Span( docLength, docLength + pasteLength ) : null;
     
      edit      = new BasicCompoundEdit( name );
      oldSelSpan    = timeline.getSelectionSpan();
      if( !oldSelSpan.isEmpty() ) { // deselect
View Full Code Here


    {
      if( !checkProcess() ) return null;

      final BlendContext      bc;
      final long          cutLength, docLength, newDocLength, maxLen;
      final Flag          hasSelectedAudio;
      final List          tis;
      final AbstractCompoundEdit  edit;
      final boolean         cutTimeline;
      final Span          cutTimelineSpan, selSpan;
      Span            visiSpan;

      hasSelectedAudio  = new Flag( false );
      tis          = Track.getInfos( selectedTracks.getAll(), tracks.getAll() );
      if( !checkSyncedAudio( tis, mode == EDIT_INSERT, null, hasSelectedAudio )) return null;
     
      docLength      = timeline.getLength();
      cutLength      = span.getLength();
      if( mode == EDIT_INSERT ) {
        /*
         *  before delete:
         *
         *  |,,,,,,,,,,,,,,,,,|$$$$$$$#######|............|
         *  |,,,,,,,,,,,,,,,,,|$$$$$$$#######|............|
         *  |,,,,,,,,,,,,,,,,,|$$$$$$$#######|............|
         *  |,,,,,,,,A,,,,,,,,|$$B1$$$###B2##|......C.....|
         *  +-----------------+--------------+------------+
         *                    |     span     |
         *
         *  after delete:
         *                left right
         *  |,,,,,,,,,,,,,    |            |
         *  |,,,,,,,,,,,,,,,  |            |
         *  |,,,,,,,,,,,,,,,,,|            |
         *  |,,,,,,,,,,,,,,,,,|$$          |
         *  |,,,,,,,,,,,,,,,,,|$$$$        |
         *  |,,,,,,,,A,,,,,,,,|$B2$$$      |
         *  +-----------------+------------+
         *                    |
         *      plus
         *  |                 |    ........|
         *  |                 |  ..........|
         *  |                 |............|
         *  |               ##|............|
         *  |             ####|............|
         *  |           ###B2#|......C.....|
         *  +-----------------+------------+
         *                    |
         *                span.start
         */
        maxLen        = Math.min( cutLength, Math.min( span.start, docLength - span.stop ) << 1 );
        bc          = createBlendContext( maxLen >> 1, (maxLen + 1) >> 1, hasSelectedAudio.isSet() );
      } else {
        /*
         *  after delete:
         *                     blend-   blend-
         *                     Len      Len
         *  |,,,,,,,,,,,,,,,,,|$            #|............|
         *  |,,,,,,,,,,,,,,,,,|$$          ##|............|
         *  |,,,,,,,,,,,,,,,,,|$$$        ###|............|
         *  |,,,,,,,,A,,,,,,,,|$B1$      #B2#|......C.....|
         *  +-----------------+--------------+------------+
         *                    |     span     |
         */
        maxLen        = cutLength >> 1;
        bc          = createBlendContext( maxLen, 0, hasSelectedAudio.isSet() );
      }
//      bc          = createBlendContext( Math.min( cutLength, span.start ), Math.min( cutLength, docLength - span.stop ), hasSelectedAudio );
      edit        = new BasicCompoundEdit( name );

//      if( bc != null )  System.out.println( "bc  : " + bc.getLen() + ", " + bc.getLeftLen() + ", "+ bc.getRightLen() );
     
      cutTimeline      = (mode == EDIT_INSERT) && hasSelectedAudio.isSet();
      newDocLength    = cutTimeline ? docLength - cutLength : docLength;
      cutTimelineSpan    = cutTimeline ? new Span( newDocLength, docLength ) : null;
      selSpan        = timeline.getSelectionSpan();
     
      if( (mode == EDIT_INSERT) && !selSpan.isEmpty() ) {
View Full Code Here

      perform();
    }
   
    protected void perform()
    {
      final Flag        confirmed  = new Flag( false );
      final DocumentFrame    frame    = (DocumentFrame) getApplication().getComponent( Main.COMP_MAIN );
      final ProcessingThread  pt      = frame.confirmUnsaved( text, confirmed );
      if( pt == null ) {
        if( !confirmed.isSet() ) return;
        queryAndPerform();
      } else {
        pt.addListener( new ProcessingThread.Listener() {
          public void processStarted( ProcessingThread.Event e ) {}
          public void processStopped( ProcessingThread.Event e ) {
View Full Code Here

  private boolean forcedQuit = false;

  public synchronized void quit()
  {
    final Flag        confirmed  = new Flag( false );
//    final ProcessingThread  pt      = getMenuFactory().closeAll( forcedQuit, confirmed );
    final ProcessingThread  pt      = doc.closeDocument( getResourceString( "menuQuit" ), forcedQuit, confirmed );

    if( pt != null ) {
      pt.addListener( quitAfterSaveListener );
      ((Session) pt.getClientArg( "doc" )).start( pt );
    } else if( confirmed.isSet() ) {
//      OSCRoot.getInstance().quit();
//      SuperColliderClient.getInstance().quit();
      super.quit();
    }
  }
View Full Code Here

      perform();
    }
   
    private void perform()
    {
      final ProcessingThread pt = closeAll( false, new Flag( false ));
      if( pt != null ) {
        pt.addListener( this )// ok, let's save the shit and re-try to close all after that
        ((BasicDocument) pt.getClientArg( "doc" )).start( pt );
      }
    }
View Full Code Here

    final int        choice;
//    final AudioFileDescr  displayAFD  = doc.getDisplayDescr();
    final JOptionPane    op;
    final JDialog       d;
    final JRootPane      rp;
    final Flag        dont    = new Flag( false );
//    AudioFileDescr[]    afds    = doc.getDescr();
    File          f      = doc.getFile();
    String          name    = doc.getName();
   
    if( name == null ) name = getResourceString( "frameUntitled" );
   
//    choice = JOptionPane.showOptionDialog( getWindow(), name + " :\n" + getResourceString( "optionDlgUnsaved" ),
//                         actionName, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.WARNING_MESSAGE, null,
//                         options, options[1] );
    op = new JOptionPane( name + " :\n" + getResourceString( "optionDlgUnsaved" ),
                          JOptionPane.WARNING_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION, null,
                          options, options[ 1 ]);
//    d = op.createDialog( getWindow(), actionName );
    d = op.createDialog( null, actionName );
    rp = d.getRootPane();
    if( rp != null ) {
      rp.getInputMap( JComponent.WHEN_IN_FOCUSED_WINDOW ).put(
        KeyStroke.getKeyStroke( KeyEvent.VK_D, BasicMenuFactory.MENU_SHORTCUT ), "dont" );
      rp.getActionMap().put( "dont", new AbstractAction() {
        public void actionPerformed( ActionEvent e )
        {
          dont.settrue );
          d.dispose();
        }
      });
    }
    BasicWindowHandler.showDialog( d );
//    d.setVisible( true );
    if( dont.isSet() ) {
      choice = 2;
    } else {
      final Object value = op.getValue();
      if( (value == null) || (value == options[ 1 ])) {
        choice = 1;
View Full Code Here

      perform();
    }
   
    private void perform()
    {
      final Flag        confirmed  = new Flag( false );
      final ProcessingThread  pt      = confirmUnsaved( getValue( NAME ).toString(), confirmed );
     
      if( pt == null ) {
        if( !confirmed.isSet() ) return;
        clear();
      } else {
        pt.addListener( new ProcessingThread.Listener() {
          public void processStarted( ProcessingThread.Event e ) {}
          public void processStopped( ProcessingThread.Event e ) {
View Full Code Here

    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;
View Full Code Here

TOP

Related Classes of de.sciss.util.Flag

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.