Changeset 1776


Ignore:
Timestamp:
11/09/06 13:51:49 (13 years ago)
Author:
melissa
Message:

Re-added option to colorize channels.

File:
1 edited

Legend:

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

    r1738 r1776  
    5353  private JCheckBox merge = null; 
    5454  private JCheckBox ignore = null; 
     55  private JCheckBox colorizeChannels = null; 
    5556  private JCheckBox newWindows = null; 
    5657  private JCheckBox showMeta = null; 
     
    6263  private boolean mergeChannels; 
    6364  private boolean ignoreTables; 
     65  private boolean colorize; 
    6466  private boolean splitWindows; 
    6567  private boolean showMetadata; 
     
    8183    mergeChannels = Prefs.get("bioformats.mergeChannels", false); 
    8284    ignoreTables = Prefs.get("bioformats.ignoreTable", false); 
     85    colorize = Prefs.get("bioformats.colorize", false); 
    8386    splitWindows = Prefs.get("bioformats.splitWindows", true); 
    8487    showMetadata = Prefs.get("bioformats.showMetadata", false); 
     
    9497    String mergeString = "Merge channels to RGB"; 
    9598    String ignoreString = "Ignore color lookup table"; 
     99    String colorizeString = "Colorize channels"; 
    96100    String splitString = "Open each channel in its own window"; 
    97101    String metadataString = "Display associated metadata"; 
     
    109113      gd.addCheckbox(mergeString, mergeChannels); 
    110114      gd.addCheckbox(ignoreString, ignoreTables); 
     115      gd.addCheckbox(colorizeString, colorize); 
    111116      gd.addCheckbox(splitString, splitWindows); 
    112117      gd.addCheckbox(metadataString, showMetadata); 
     
    120125      mergeChannels = gd.getNextBoolean(); 
    121126      ignoreTables = gd.getNextBoolean(); 
     127      colorize = gd.getNextBoolean(); 
    122128      splitWindows = gd.getNextBoolean(); 
    123129      showMetadata = gd.getNextBoolean(); 
     
    144150      merge = new JCheckBox(mergeString, mergeChannels); 
    145151      ignore = new JCheckBox(ignoreString, ignoreTables); 
     152      colorizeChannels = new JCheckBox(colorizeString, colorize); 
    146153      newWindows = new JCheckBox(splitString, splitWindows); 
    147154      showMeta = new JCheckBox(metadataString, showMetadata); 
     
    150157      merge.addItemListener(this); 
    151158      ignore.addItemListener(this); 
     159      colorizeChannels.addItemListener(this); 
    152160      newWindows.addItemListener(this); 
    153161      showMeta.addItemListener(this); 
     
    156164      panel.add(merge); 
    157165      panel.add(ignore); 
     166      panel.add(colorizeChannels); 
    158167      panel.add(newWindows); 
    159168      panel.add(showMeta); 
     
    538547      Prefs.set("bioformats.mergeChannels", mergeChannels); 
    539548      Prefs.set("bioformats.ignoreTables", ignoreTables); 
     549      Prefs.set("bioformats.colorize", colorize); 
    540550      Prefs.set("bioformats.splitWindows", splitWindows); 
    541551      Prefs.set("bioformats.showMetadata", showMetadata); 
     
    564574    if (source == merge) mergeChannels = selected; 
    565575    else if (source == ignore) ignoreTables = selected; 
     576    else if (source == colorizeChannels) colorize = selected; 
    566577    else if (source == newWindows) splitWindows = selected; 
    567578    else if (source == showMeta) showMetadata = selected; 
     
    660671 
    661672      // mostly copied from the ImageJ source 
     673  
     674      if (colorize) { 
     675        fi.reds = new byte[256]; 
     676        fi.greens = new byte[256]; 
     677        fi.blues = new byte[256]; 
     678        
     679        for (int j=0; j<256; j++) { 
     680          switch (i) { 
     681            case 0: fi.reds[j] = (byte) j; break; 
     682            case 1: fi.greens[j] = (byte) j; break; 
     683            case 2: fi.blues[j] = (byte) j; break; 
     684          } 
     685        } 
     686 
     687        ImageProcessor ip = imp.getProcessor(); 
     688        ColorModel cm =  
     689          new IndexColorModel(8, 256, fi.reds, fi.greens, fi.blues); 
    662690         
    663       fi.reds = new byte[256]; 
    664       fi.greens = new byte[256]; 
    665       fi.blues = new byte[256]; 
    666         
    667       for (int j=0; j<256; j++) { 
    668         switch (i) { 
    669           case 0: fi.reds[j] = (byte) j; break; 
    670           case 1: fi.greens[j] = (byte) j; break; 
    671           case 2: fi.blues[j] = (byte) j; break; 
    672         } 
    673       } 
    674  
    675       ImageProcessor ip = imp.getProcessor(); 
    676       ColorModel cm =  
    677         new IndexColorModel(8, 256, fi.reds, fi.greens, fi.blues); 
    678          
    679       ip.setColorModel(cm); 
    680       if (imp.getStackSize() > 1) imp.getStack().setColorModel(cm); 
     691        ip.setColorModel(cm); 
     692        if (imp.getStackSize() > 1) imp.getStack().setColorModel(cm); 
     693      } 
    681694 
    682695      imp.setFileInfo(fi); 
Note: See TracChangeset for help on using the changeset viewer.