Changeset 1899


Ignore:
Timestamp:
12/05/06 14:31:06 (13 years ago)
Author:
chris
Message:

browser:
1) extremely hacky bug fix for dimensional swap when
using cache manager, but, heck six things were wrong
and now they work.
2) essentially when the dimensional swap happens, a
method is called in cachemanager to reinitialize the
cache array entirely now. should work fine.
3) no time to fix other bugs so far

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

Legend:

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

    r1799 r1899  
    7171  private IFormatReader read; 
    7272   
     73  /** The FileStitcher we're using to stitch files.*/ 
     74  private FileStitcher fs; 
     75   
    7376  /** The two axes scrollbars in the CustomWindow.*/ 
    7477  private JScrollBar zSel, tSel; 
     
    142145  */ 
    143146  private boolean loop; 
     147   
     148  /**flag to zap the cache entirely if dimensions are switched*/ 
     149  private boolean zapCache; 
    144150 
    145151  /** A list of indeces to be loaded by the caching thread.*/ 
     
    193199  { 
    194200    //Initialize fields 
     201    zapCache = false; 
    195202    loop = true; 
    196203    curZ = z; 
     
    204211    this.db = db; 
    205212    this.read = db.reader; 
     213    fs = db.fStitch; 
    206214    zInd = null; 
    207215    tInd = null; 
    208216    zSel = null; 
    209217    tSel = null; 
    210     synchronized (read) { 
     218    synchronized (fs) { 
    211219      try { 
    212         sizeZ = read.getSizeZ(fileName); 
    213         sizeT = read.getSizeT(fileName); 
    214         sizeC = read.getSizeC(fileName); 
    215         cache = new ImageProcessor[read.getImageCount(fileName)]; 
     220        sizeZ = fs.getSizeZ(fileName); 
     221        sizeT = fs.getSizeT(fileName); 
     222        sizeC = fs.getSizeC(fileName); 
     223        cache = new ImageProcessor[fs.getImageCount(fileName)]; 
    216224      } 
    217225      catch (Exception exc) { 
     
    17981806    if (DEBUG) System.out.println("CLEARING CACHE"); 
    17991807    quit = true; 
    1800  
    1801     int[] oldIndex = getToCache(true); 
     1808     
     1809    int[] oldIndex = null; 
     1810     
     1811    boolean erase = true; 
     1812    if(!zapCache) { 
     1813      oldIndex = getToCache(true); 
     1814    } 
     1815    else { 
     1816      try { 
     1817        cache = new ImageProcessor[fs.getImageCount(fileName)]; 
     1818      } 
     1819      catch(Exception exc){} 
     1820      erase = false; 
     1821    } 
    18021822     
    18031823    oldZ = curZ; 
     
    18501870    Arrays.sort(newIndex); 
    18511871 
    1852     for (int i = 0; i<oldIndex.length; i++) { 
    1853       if (Arrays.binarySearch(newIndex, oldIndex[i]) < 0) 
    1854         cache[oldIndex[i]] = null; 
     1872    if(erase) { 
     1873      for (int i = 0; i<oldIndex.length; i++) { 
     1874        if (Arrays.binarySearch(newIndex, oldIndex[i]) < 0) 
     1875          cache[oldIndex[i]] = null; 
     1876      } 
    18551877    } 
    18561878 
    18571879    if (DEBUG) System.out.println("Cache Size after clear: " + getSize()); 
     1880  } 
     1881   
     1882  protected void dimChange() { 
     1883    zapCache = true; 
     1884    synchronized (fs) { 
     1885      try { 
     1886        sizeZ = fs.getSizeZ(fileName); 
     1887        sizeT = fs.getSizeT(fileName); 
     1888        sizeC = fs.getSizeC(fileName); 
     1889        cache = new ImageProcessor[fs.getImageCount(fileName)]; 
     1890      } 
     1891      catch (Exception exc) { 
     1892        if (DEBUG) System.out.println("Error reading size of file."); 
     1893      } 
     1894    } 
    18581895  } 
    18591896   
  • trunk/loci/plugins/browser/CustomWindow.java

    r1894 r1899  
    2020You should have received a copy of the GNU Library General Public License 
    2121along with this program; if not, write to the Free Software 
    22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     22Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1G307  USA 
    2323*/ 
    2424 
     
    8181  private JPanel channelPanel; 
    8282  private String patternTitle; 
     83  private boolean update; 
    8384 
    8485  // -- Constructor -- 
     
    8990    this.db = db; 
    9091    ow = null; 
     92    update = true; 
    9193     
    9294    String id = db.id;     
     
    251253 
    252254  public void updateControls() { 
     255    update = false; 
    253256    zSliceSel.setMinimum(1); 
    254257    zSliceSel.setMaximum(db.hasZ ? db.numZ + 1 : 2); 
     
    261264    setC(); 
    262265    repaint(); 
     266    update = true; 
    263267  } 
    264268 
     
    276280      snm.setMaximum((Comparable) new Integer(numThis)); 
    277281      snm.setValue(new Integer(value)); 
    278       if (!hasThis) channelSpin.setEnabled(false); 
    279       if (!hasThis) cLabel.setEnabled(false); 
     282      c = ((Integer) channelSpin.getValue()).intValue(); 
     283      if (!hasThis) { 
     284        channelSpin.setEnabled(false); 
     285        cLabel.setEnabled(false); 
     286        c = 1; 
     287      } 
    280288    } 
    281289    else { 
    282290      // C checkbox 
    283291      switcher.first(channelPanel); 
    284       if (!hasThis) channelBox.setEnabled(false); 
     292      c = channelBox.isSelected() ? 1 : 2; 
     293      if (!hasThis) { 
     294        channelBox.setEnabled(false);     
     295        c = 1; 
     296      } 
    285297    } 
    286298  } 
     
    495507 
    496508  public void adjustmentValueChanged(AdjustmentEvent adjustmentEvent) { 
    497     JScrollBar src = (JScrollBar) adjustmentEvent.getSource(); 
    498  
    499     if (src == zSliceSel) { 
     509    if(update) { 
     510      JScrollBar src = (JScrollBar) adjustmentEvent.getSource(); 
     511   
    500512      z = zSliceSel.getValue(); 
    501     } 
    502     else if (src == tSliceSel) { 
    503513      t = tSliceSel.getValue(); 
    504     } 
    505  
    506     if (!src.getValueIsAdjusting() || db.manager == null) showSlice(z, t, c); 
    507     else showTempSlice(z,t,c); 
     514   
     515      if (!src.getValueIsAdjusting() || db.manager == null) showSlice(z, t, c); 
     516      else showTempSlice(z,t,c); 
     517    } 
    508518  } 
    509519 
     
    511521 
    512522  public synchronized void itemStateChanged(ItemEvent e) { 
    513     JCheckBox channels = (JCheckBox) e.getSource(); 
    514      
    515     c = channels.isSelected() ? 1 : 2; 
    516  
    517     showSlice(z, t, c); 
     523    if(update) { 
     524      JCheckBox channels = (JCheckBox) e.getSource(); 
     525       
     526      z = zSliceSel.getValue(); 
     527      t = tSliceSel.getValue(); 
     528      c = channels.isSelected() ? 1 : 2; 
     529   
     530      showSlice(z, t, c); 
     531    } 
    518532  } 
    519533   
     
    521535   
    522536  public void stateChanged(ChangeEvent e) { 
    523     if( (JSpinner) e.getSource() == channelSpin) { 
    524       c = ((Integer) channelSpin.getValue()).intValue(); 
    525       showSlice(z, t, c); 
     537    if(update) { 
     538      if( (JSpinner) e.getSource() == channelSpin) { 
     539        c = ((Integer) channelSpin.getValue()).intValue(); 
     540        z = zSliceSel.getValue(); 
     541        t = tSliceSel.getValue(); 
     542        showSlice(z, t, c); 
     543      } 
    526544    } 
    527545  } 
  • trunk/loci/plugins/browser/LociDataBrowser.java

    r1860 r1899  
    166166  /** Gets the slice number for the given Z, T and C indices. */ 
    167167  public int getIndex(int z, int t, int c) { 
    168     int result = -1; 
     168    int result = -23; 
    169169    synchronized(reader) { 
    170170      try { 
  • trunk/loci/plugins/browser/OptionsWindow.java

    r1892 r1899  
    700700        update = true; 
    701701        cw.db.setDimensions(); 
     702        if(cw.db.virtual) cw.db.manager.dimChange(); 
    702703        cw.updateControls(); 
    703704      } 
     
    730731        update = true; 
    731732        cw.db.setDimensions(); 
     733        if(cw.db.virtual) cw.db.manager.dimChange(); 
    732734        cw.updateControls(); 
    733735      } 
     
    760762        update = true; 
    761763        cw.db.setDimensions(); 
     764        if(cw.db.virtual) cw.db.manager.dimChange(); 
    762765        cw.updateControls(); 
    763766      } 
     
    770773        catch(Exception exc) {exc.printStackTrace();} 
    771774        cw.db.setDimensions(); 
     775        if(cw.db.virtual) cw.db.manager.dimChange(); 
    772776        cw.updateControls(); 
    773777      } 
Note: See TracChangeset for help on using the changeset viewer.