Changeset 4311


Ignore:
Timestamp:
08/15/08 14:02:49 (12 years ago)
Author:
melissa
Message:

First cut at applying macros to virtual stacks. Has not been thoroughly tested with more complex macros, but it works for basic stuff (rotating, drawing, etc.).

Location:
trunk/loci/plugins
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/plugins/BFVirtualStack.java

    r4304 r4311  
    2929import ij.process.ImageProcessor; 
    3030import java.io.IOException; 
     31import java.util.Vector; 
    3132import loci.formats.*; 
    3233import loci.formats.cache.*; 
     
    5051//  protected String stackOrder; 
    5152//  protected int merge; 
     53 
     54  private Vector[] methodStacks; 
     55  private int currentSlice = -1; 
     56  private RecordedImageProcessor currentProcessor; 
    5257 
    5358  // -- Static utility methods -- 
     
    8489    cache = new Cache(new CrosshairStrategy(len), 
    8590      new ImageProcessorSource(this), false); 
     91    methodStacks = new Vector[r.getImageCount()]; 
     92    for (int i=0; i<methodStacks.length; i++) { 
     93      methodStacks[i] = new Vector(); 
     94    } 
    8695  } 
    8796 
     
    94103  public Cache getCache() { return cache; } 
    95104 
     105  public RecordedImageProcessor getRecordedProcessor() { 
     106    return currentProcessor; 
     107  } 
     108 
     109  public Vector getMethodStack() { 
     110    if (currentSlice >= 0) return methodStacks[currentSlice]; 
     111    return null; 
     112  } 
     113 
    96114  // -- VirtualStack API methods -- 
    97115 
    98116  public synchronized ImageProcessor getProcessor(int n) { 
    99117    // check cache first 
     118    if (currentSlice >= 0 && currentProcessor != null) { 
     119      Vector currentStack = currentProcessor.getMethodStack(); 
     120      if (currentStack.size() > 1) { 
     121        methodStacks[currentSlice].addAll(currentStack); 
     122      } 
     123    } 
    100124    int[] pos = reader.getZCTCoords(n - 1); 
     125    ImageProcessor ip = null; 
     126 
    101127    try { 
    102       ImageProcessor ip = (ImageProcessor) cache.getObject(pos); 
    103       if (ip != null) return ip; 
     128      ip = (ImageProcessor) cache.getObject(pos); 
    104129    } 
    105130    catch (CacheException exc) { 
     
    110135    try { 
    111136      // CTR TODO - fix this 
    112       return Util.openProcessors(reader, n - 1)[0]; 
     137      if (ip == null) { 
     138        ip = Util.openProcessors(reader, n - 1)[0]; 
     139      } 
    113140//      int index = FormatTools.getReorderedIndex(reader, stackOrder, n - 1); 
    114141//      if (merge <= 1) return Util.openProcessor(reader, index); 
     
    129156      exc.printStackTrace(); 
    130157    } 
     158 
     159    if (ip != null) { 
     160      currentSlice = n - 1; 
     161      currentProcessor = new RecordedImageProcessor(ip, currentSlice); 
     162      return currentProcessor; 
     163    } 
     164 
    131165    return null; 
    132166  } 
  • trunk/loci/plugins/Importer.java

    r4308 r4311  
    655655    if (stack == null) return; 
    656656    String title = getTitle(r, file, series, options.isGroupFiles()); 
    657     ImagePlus imp = new ImagePlus(title, stack) { 
    658       public void close() { 
    659         super.close(); 
    660         if (options.isVirtual()) { 
    661           try { 
    662             r.close(); 
    663           } 
    664           catch (IOException e) { } 
    665         } 
    666       } 
    667     }; 
     657    ImagePlus imp = null; 
     658    if (options.isVirtual()) { 
     659      imp = new VirtualImagePlus(title, stack); 
     660      ((VirtualImagePlus) imp).setReader(r); 
     661    } 
     662    else imp = new ImagePlus(title, stack); 
     663 
    668664    imp.setProperty("Info", metadata); 
    669665 
Note: See TracChangeset for help on using the changeset viewer.