Changeset 3523


Ignore:
Timestamp:
12/28/07 17:50:48 (12 years ago)
Author:
curtis
Message:

Stop cache loader thread if CustomWindow is closed.

Location:
trunk/loci/plugins/browser
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/plugins/browser/CacheUpdater.java

    r3521 r3523  
    4545  private boolean quit; 
    4646 
    47   // -- Constructor -- 
     47  // -- Constructors -- 
     48 
     49  public CacheUpdater(Cache cache) { 
     50    this(cache, new CacheIndicator[0], new int[0], new int[0]); 
     51  } 
    4852 
    4953  public CacheUpdater(Cache cache, CacheIndicator[] indicators, int[] lengths, 
  • trunk/loci/plugins/browser/CustomWindow.java

    r3521 r3523  
    4848 */ 
    4949public class CustomWindow extends ImageWindow implements ActionListener, 
    50   AdjustmentListener, ChangeListener, ItemListener, KeyListener 
     50  AdjustmentListener, CacheListener, ChangeListener, ItemListener, KeyListener 
    5151{ 
    5252 
     
    5959  private static final String STOP_STRING = "Stop"; 
    6060 
    61   /**Constant dlu size for indents in GUI*/ 
     61  /** Constant dlu size for indents in GUI. */ 
    6262  private static final String TAB = "5dlu"; 
    6363 
     
    7272  private byte[] lut; 
    7373  private byte[] nullLut; 
     74 
     75  private String patternTitle; 
     76  protected boolean update; 
    7477 
    7578  // -- Fields - widgets -- 
     
    8891  private JPanel channelPanel; 
    8992  private JSpinner fpsSpin; 
    90   private String patternTitle; 
    91   protected boolean update; 
    9293 
    9394  // -- Constructor -- 
     
    610611  } 
    611612 
    612   // -- ItemListener methods -- 
    613  
    614   public synchronized void itemStateChanged(ItemEvent e) { 
    615     if (!update) return; 
    616     JCheckBox channels = (JCheckBox) e.getSource(); 
    617  
    618     z = zSliceSel.getValue(); 
    619     t = tSliceSel.getValue(); 
    620     c = channels.isSelected() ? 1 : 2; 
    621  
    622     showSlice(z, t, c, false); 
     613  // -- CacheListener API methods -- 
     614 
     615  public void cacheUpdated(CacheEvent e) { 
     616    //System.out.println("cacheUpdated: " + e); 
    623617  } 
    624618 
     
    639633  } 
    640634 
     635  // -- ItemListener methods -- 
     636 
     637  public synchronized void itemStateChanged(ItemEvent e) { 
     638    if (!update) return; 
     639    JCheckBox channels = (JCheckBox) e.getSource(); 
     640 
     641    z = zSliceSel.getValue(); 
     642    t = tSliceSel.getValue(); 
     643    c = channels.isSelected() ? 1 : 2; 
     644 
     645    showSlice(z, t, c, false); 
     646  } 
     647 
    641648  // -- KeyListener methods -- 
    642649 
     
    673680  public void windowClosed(WindowEvent e) { 
    674681    if (animationTimer != null) animationTimer.stop(); 
     682    if (db.cacheThread != null) db.cacheThread.quit(); 
    675683    super.windowClosed(e); 
    676684  } 
  • trunk/loci/plugins/browser/LociDataBrowser.java

    r3506 r3523  
    140140    } 
    141141    if (cw != null) { 
     142      cache.removeCacheListener(cw); 
    142143      cw.ow.dispose(); 
    143144      cw.ow = null; 
     
    146147    } 
    147148    cw = new CustomWindow(this, imp, new ImageCanvas(imp)); 
     149    cache.addCacheListener(cw); 
    148150  } 
    149151 
     
    263265          } 
    264266          if (cacheThread != null) cacheThread.quit(); 
    265           cacheThread = new CacheUpdater(cache, 
    266             new CacheIndicator[0], new int[0], new int[0]); 
     267          cacheThread = new CacheUpdater(cache); 
    267268          cacheThread.start(); 
    268269 
Note: See TracChangeset for help on using the changeset viewer.