Changeset 6155


Ignore:
Timestamp:
04/20/10 16:37:25 (10 years ago)
Author:
curtis
Message:

Various cleanup and refactoring progress.

  • Progress on Bio-Formats Importer refactoring, specifically Colorizer. The current state is untested, and probably broken.
  • Fix various warnings throughout Common, Bio-Formats and Plugins.
  • Ignore more warnings within the forked components (since we are trying to maintain the minimum possible changes from the forked code).
Location:
trunk/components
Files:
2 added
44 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/ChannelFiller.java

    r5590 r6155  
    141141        return buf; 
    142142      } 
    143       else { 
    144         short[][] s = ImageTools.indexedToRGB(reader.get16BitLookupTable(), 
    145           pix, isLittleEndian()); 
     143      short[][] s = ImageTools.indexedToRGB(reader.get16BitLookupTable(), 
     144        pix, isLittleEndian()); 
    146145 
    147         if (isInterleaved()) { 
    148           int pt = 0; 
    149           for (int i=0; i<s[0].length; i++) { 
    150             for (int j=0; j<s.length; j++) { 
    151               buf[pt++] = (byte) (isLittleEndian() ? 
    152                 (s[j][i] & 0xff) : (s[j][i] >> 8)); 
    153               buf[pt++] = (byte) (isLittleEndian() ? 
    154                 (s[j][i] >> 8) : (s[j][i] & 0xff)); 
    155             } 
     146      if (isInterleaved()) { 
     147        int pt = 0; 
     148        for (int i=0; i<s[0].length; i++) { 
     149          for (int j=0; j<s.length; j++) { 
     150            buf[pt++] = (byte) (isLittleEndian() ? 
     151              (s[j][i] & 0xff) : (s[j][i] >> 8)); 
     152            buf[pt++] = (byte) (isLittleEndian() ? 
     153              (s[j][i] >> 8) : (s[j][i] & 0xff)); 
    156154          } 
    157155        } 
    158         else { 
    159           int pt = 0; 
    160           for (int i=0; i<s.length; i++) { 
    161             for (int j=0; j<s[i].length; j++) { 
    162               buf[pt++] = (byte) (isLittleEndian() ? 
    163                 (s[i][j] & 0xff) : (s[i][j] >> 8)); 
    164               buf[pt++] = (byte) (isLittleEndian() ? 
    165                 (s[i][j] >> 8) : (s[i][j] & 0xff)); 
    166             } 
     156      } 
     157      else { 
     158        int pt = 0; 
     159        for (int i=0; i<s.length; i++) { 
     160          for (int j=0; j<s[i].length; j++) { 
     161            buf[pt++] = (byte) (isLittleEndian() ? 
     162              (s[i][j] & 0xff) : (s[i][j] >> 8)); 
     163            buf[pt++] = (byte) (isLittleEndian() ? 
     164              (s[i][j] >> 8) : (s[i][j] & 0xff)); 
    167165          } 
    168166        } 
    169         return buf; 
    170167      } 
     168      return buf; 
    171169    } 
    172170    return reader.openBytes(no, buf, x, y, w, h); 
  • trunk/components/bio-formats/src/loci/formats/ImageReader.java

    r6141 r6155  
    6464  private static ClassList<IFormatReader> defaultClasses; 
    6565 
    66   // -- Static helper methods -- 
    67  
    68   private static ClassList<IFormatReader> getDefaultReaderClasses() { 
     66  // -- Static utility methods -- 
     67 
     68  public static ClassList<IFormatReader> getDefaultReaderClasses() { 
    6969    if (defaultClasses == null) { 
    7070      // load built-in reader classes from readers.txt file 
  • trunk/components/bio-formats/src/loci/formats/ImageWriter.java

    r6141 r6155  
    5959  private static ClassList<IFormatWriter> defaultClasses; 
    6060 
    61   // -- Static helper methods -- 
    62  
    63   private static ClassList<IFormatWriter> getDefaultWriterClasses() { 
     61  // -- Static utility methods -- 
     62 
     63  public static ClassList<IFormatWriter> getDefaultWriterClasses() { 
    6464    if (defaultClasses == null) { 
    6565      // load built-in writer classes from writers.txt file 
  • trunk/components/bio-formats/src/loci/formats/services/JAIIIOServiceImpl.java

    r6128 r6155  
    3232import javax.imageio.IIOImage; 
    3333import javax.imageio.ImageIO; 
     34import javax.imageio.ImageWriteParam; 
    3435import javax.imageio.spi.IIORegistry; 
    35 import javax.imageio.spi.ImageReaderSpi; 
    3636import javax.imageio.spi.ServiceRegistry; 
    3737import javax.imageio.stream.ImageOutputStream; 
     
    9696    J2KImageWriteParam param = 
    9797      (J2KImageWriteParam) writer.getDefaultWriteParam(); 
    98     param.setCompressionMode(J2KImageWriteParam.MODE_EXPLICIT); 
     98    param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); 
    9999    param.setCompressionType("JPEG2000"); 
    100100    param.setLossless(lossless); 
     
    117117    J2KImageReaderSpi spi =  
    118118      registry.getServiceProviderByClass(J2KImageReaderSpi.class); 
    119     J2KImageReader reader = new J2KImageReader((ImageReaderSpi) spi); 
     119    J2KImageReader reader = new J2KImageReader(spi); 
    120120    reader.setInput(mciis); 
    121121    return reader.read(0); 
  • trunk/components/bio-formats/src/loci/formats/services/NetCDFServiceImpl.java

    r6128 r6155  
    3434import loci.common.services.AbstractService; 
    3535import loci.common.services.ServiceException; 
    36  
    37 import org.slf4j.Logger; 
    38 import org.slf4j.LoggerFactory; 
    39  
    4036import ucar.ma2.Array; 
    4137import ucar.ma2.InvalidRangeException; 
     
    6359    "Required JAR files are netcdf-4.0.jar and slf4j-jdk14.jar."; 
    6460 
    65   private static final Logger LOGGER = 
    66     LoggerFactory.getLogger(NetCDFServiceImpl.class); 
    67  
    6861  // -- Fields -- 
    6962 
     
    164157        return variable.read(origin, shape).reduce().copyToNDJavaArray(); 
    165158      } 
    166       else { 
    167         return variable.read().copyToNDJavaArray(); 
    168       } 
     159            return variable.read().copyToNDJavaArray(); 
    169160    } 
    170161    catch (InvalidRangeException e) { 
  • trunk/components/common/src/loci/common/AbstractNIOHandle.java

    r6050 r6155  
    4141 
    4242  /** Error message to be used when instantiating an EOFException. */ 
    43   protected static final String EOF_ERROR_MSG =  
     43  protected static final String EOF_ERROR_MSG = 
    4444    "Attempting to read beyond end of file."; 
    4545 
     
    4949 
    5050  // -- Constructors -- 
    51    
     51 
    5252  // -- AbstractNIOHandle methods -- 
    5353 
     
    7979    return true; 
    8080  } 
    81    
     81 
    8282  /** 
    8383   * Sets the new length of the handle. 
  • trunk/components/common/src/loci/common/CBZip2InputStream.java

    r6050 r6155  
    145145    LoggerFactory.getLogger(CBZip2InputStream.class); 
    146146 
    147   private static void reportCRCError() throws IOException { 
     147  private static void reportCRCError() { 
    148148    // The clean way would be to throw an exception. 
    149149    //throw new IOException("crc error"); 
     
    250250  public int read() throws IOException { 
    251251    if (this.in != null) return read0(); 
    252     else throw new IOException("stream closed"); 
     252    throw new IOException("stream closed"); 
    253253  } 
    254254 
     
    380380  } 
    381381 
    382   private void endBlock() throws IOException { 
     382  private void endBlock() { 
    383383    this.computedBlockCRC = this.crc.getFinalCRC(); 
    384384 
     
    661661              continue; 
    662662            } 
    663             else throw new IOException("unexpected end of stream"); 
     663            throw new IOException("unexpected end of stream"); 
    664664          } 
    665665          int zvec = (bsBuffShadow >> (bsLiveShadow - zn)) & ((1 << zn) - 1); 
     
    675675                continue; 
    676676              } 
    677               else throw new IOException("unexpected end of stream"); 
     677              throw new IOException("unexpected end of stream"); 
    678678            } 
    679679            bsLiveShadow--; 
     
    732732            continue; 
    733733          } 
    734           else throw new IOException("unexpected end of stream"); 
     734          throw new IOException("unexpected end of stream"); 
    735735        } 
    736736        int zvec = (bsBuffShadow >> (bsLiveShadow - zn)) & ((1 << zn) - 1); 
     
    746746              continue; 
    747747            } 
    748             else throw new IOException("unexpected end of stream"); 
     748            throw new IOException("unexpected end of stream"); 
    749749          } 
    750750          bsLiveShadow--; 
     
    782782          continue; 
    783783        } 
    784         else throw new IOException("unexpected end of stream"); 
     784        throw new IOException("unexpected end of stream"); 
    785785      } 
    786786      bsLiveShadow--; 
  • trunk/components/common/src/loci/common/DataTools.java

    r6124 r6155  
    112112    short total = 0; 
    113113    for (int i=0, ndx=off; i<len; i++, ndx++) { 
    114       total |= ((int) bytes[ndx]) << ((little ? i : len - i - 1) * 8); 
     114      total |= bytes[ndx] << ((little ? i : len - i - 1) * 8); 
    115115    } 
    116116    return total; 
     
    181181    int total = 0; 
    182182    for (int i=0, ndx=off; i<len; i++, ndx++) { 
    183       total |= ((int) bytes[ndx]) << ((little ? i : len - i - 1) * 8); 
     183      total |= bytes[ndx] << ((little ? i : len - i - 1) * 8); 
    184184    } 
    185185    return total; 
     
    572572 
    573573  /** 
     574   * @param signed The signed parameter is ignored. 
    574575   * @deprecated Use {@link #makeDataArray(byte[], int, boolean, boolean)} 
    575576   *   regardless of signedness. 
     
    592593 
    593594  public static int swap(int x) { 
    594     return (int) ((swap((short) x) << 16) | (swap((short) (x >> 16)) & 0xFFFF)); 
     595    return (swap((short) x) << 16) | (swap((short) (x >> 16)) & 0xFFFF); 
    595596  } 
    596597 
    597598  public static long swap(long x) { 
    598     return (long) (((long) swap((int) x) << 32) | 
    599       ((long) swap((int) (x >> 32)) & 0xFFFFFFFFL)); 
     599    return ((long) swap((int) x) << 32) | (swap((int) (x >> 32)) & 0xFFFFFFFFL); 
    600600  } 
    601601 
  • trunk/components/common/src/loci/common/FileHandle.java

    r6050 r6155  
    284284  public void setOrder(ByteOrder order) { 
    285285    // TODO Auto-generated method stub 
    286      
    287286  } 
    288287 
  • trunk/components/common/src/loci/common/IRandomAccess.java

    r6050 r6155  
    5252  /** Returns the length of this stream. */ 
    5353  long length() throws IOException; 
    54    
     54 
    5555  /** 
    5656   * Returns the current order of the stream. 
     
    5858   */ 
    5959  ByteOrder getOrder(); 
    60    
     60 
    6161  /** 
    6262   * Sets the byte order of the stream. 
  • trunk/components/common/src/loci/common/IniParser.java

    r6098 r6155  
    127127 
    128128  /** Opens a buffered reader for the given resource. */ 
    129   public static BufferedReader openTextResource(String path) 
    130     throws IOException 
    131   { 
     129  public static BufferedReader openTextResource(String path) { 
    132130    return openTextResource(path, IniParser.class); 
    133131  } 
    134132 
    135133  /** Opens a buffered reader for the given resource. */ 
    136   public static BufferedReader openTextResource(String path, Class<?> c) 
    137     throws IOException 
    138   { 
     134  public static BufferedReader openTextResource(String path, Class<?> c) { 
    139135    return new BufferedReader(new InputStreamReader( 
    140136      c.getResourceAsStream(path))); 
  • trunk/components/common/src/loci/common/NIOByteBufferProvider.java

    r6100 r6155  
    4141 *   <li>http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6417205</li> 
    4242 * </ul> 
    43  *  
     43 * 
    4444 * @author Chris Allan <callan at blackcat dot ca> 
    4545 * 
     
    5656 
    5757  /** Logger for this class. */ 
    58   private static final Logger LOGGER =  
     58  private static final Logger LOGGER = 
    5959    LoggerFactory.getLogger(NIOByteBufferProvider.class); 
    6060 
     
    9191        // Ensure we have an integer here at least 
    9292        Integer.parseInt(tokenizer.nextToken()); 
    93         // This is the actual "major" version number we want to check  
     93        // This is the actual "major" version number we want to check 
    9494        int y = Integer.parseInt(tokenizer.nextToken()); 
    9595        if (y >= MINIMUM_JAVA_VERSION) { 
     
    148148  protected ByteBuffer allocateDirect(long bufferStartPosition, int newSize) 
    149149    throws IOException { 
    150     ByteBuffer buffer = ByteBuffer.allocate((int) newSize); 
     150    ByteBuffer buffer = ByteBuffer.allocate(newSize); 
    151151    channel.read(buffer, bufferStartPosition); 
    152152    return buffer; 
     
    164164  protected ByteBuffer allocateMappedByteBuffer( 
    165165      long bufferStartPosition, int newSize) throws IOException { 
    166     return channel.map(mapMode, bufferStartPosition, newSize);  
     166    return channel.map(mapMode, bufferStartPosition, newSize); 
    167167  } 
    168168} 
  • trunk/components/common/src/loci/common/NIOFileHandle.java

    r6094 r6155  
    321321  /* @see java.io.DataInput.readUnsignedByte() */ 
    322322  public int readUnsignedByte() throws IOException { 
    323     return (int) (readByte() & 0xFF); 
     323    return readByte() & 0xFF; 
    324324  } 
    325325 
    326326  /* @see java.io.DataInput.readUnsignedShort() */ 
    327327  public int readUnsignedShort() throws IOException { 
    328     return (int) readShort() & 0xFFFF; 
     328    return readShort() & 0xFFFF; 
    329329  } 
    330330 
  • trunk/components/common/src/loci/common/NIOInputStream.java

    r6050 r6155  
    7272  // -- Constructors -- 
    7373 
    74   /** 
    75    * Constructs an NIOInputStream around the given file. 
    76    */ 
     74  /** Constructs an NIOInputStream around the given file. */ 
    7775  public NIOInputStream(String filename) throws IOException { 
    7876    this.filename = filename; 
     
    8280 
    8381  /** Constructs a random access stream around the given handle. */ 
    84   public NIOInputStream(IRandomAccess handle) throws IOException { 
     82  public NIOInputStream(IRandomAccess handle) { 
    8583    raf = handle; 
    8684  } 
    8785 
    8886  /** Constructs a random access stream around the given byte array. */ 
    89   public NIOInputStream(byte[] array) throws IOException { 
     87  public NIOInputStream(byte[] array) { 
    9088    this(new ByteArrayHandle(array)); 
    9189  } 
     
    9694  public DataInputStream getInputStream() { 
    9795    // FIXME: To be implemented. 
    98           return null; 
     96    return null; 
    9997  } 
    10098 
     
    154152  public String readString(String lastChars) throws IOException { 
    155153    if (lastChars.length() == 1) return findString(lastChars); 
    156     else { 
    157       String[] terminators = new String[lastChars.length()]; 
    158       for (int i=0; i<terminators.length; i++) { 
    159         terminators[i] = lastChars.substring(i, i + 1); 
    160       } 
    161       return findString(terminators); 
     154 
     155    String[] terminators = new String[lastChars.length()]; 
     156    for (int i=0; i<terminators.length; i++) { 
     157      terminators[i] = lastChars.substring(i, i + 1); 
    162158    } 
     159    return findString(terminators); 
    163160  } 
    164161 
     
    252249    while (loc < maxLen) { 
    253250      long pos = startPos + loc; 
    254       int num = blockSize; 
    255       if (pos + blockSize > inputLen) num = (int) (inputLen - pos); 
    256251 
    257252      // if we're not saving the string, drop any old, unnecessary output 
     
    268263 
    269264      // read block from stream 
    270       int r = in.read(buf, 0, blockSize); 
     265      int num = blockSize; 
     266      if (pos + blockSize > inputLen) num = (int) (inputLen - pos); 
     267      int r = in.read(buf, 0, num); 
    271268      if (r <= 0) throw new IOException("Cannot read from stream: " + r); 
    272269 
     
    296293          return out.toString(); 
    297294        } 
    298         else return null; 
     295        return null; 
    299296      } 
    300297 
  • trunk/components/common/src/loci/common/RandomAccessInputStream.java

    r6121 r6155  
    128128  public String readString(String lastChars) throws IOException { 
    129129    if (lastChars.length() == 1) return findString(lastChars); 
    130     else { 
    131       String[] terminators = new String[lastChars.length()]; 
    132       for (int i=0; i<terminators.length; i++) { 
    133         terminators[i] = lastChars.substring(i, i + 1); 
    134       } 
    135       return findString(terminators); 
     130    String[] terminators = new String[lastChars.length()]; 
     131    for (int i=0; i<terminators.length; i++) { 
     132      terminators[i] = lastChars.substring(i, i + 1); 
    136133    } 
     134    return findString(terminators); 
    137135  } 
    138136 
     
    271269          return out.toString(); 
    272270        } 
    273         else return null; 
     271        return null; 
    274272      } 
    275273 
     
    400398 
    401399  public int read() throws IOException { 
    402     int b = (int) readByte(); 
     400    int b = readByte(); 
    403401    if (b == -1 && (getFilePointer() >= length())) return 0; 
    404402    return b; 
  • trunk/components/common/src/loci/common/ReflectedUniverse.java

    r6050 r6155  
    427427      return fieldVal; 
    428428    } 
    429     else { 
    430       // get variable 
    431       Object var = variables.get(varName); 
    432       return var; 
    433     } 
     429    // get variable 
     430    Object var = variables.get(varName); 
     431    return var; 
    434432  } 
    435433 
  • trunk/components/common/src/loci/common/Region.java

    r6050 r6155  
    7979   */ 
    8080  public Region intersection(Region r) { 
    81     int x = (int) Math.max(this.x, r.x); 
    82     int y = (int) Math.max(this.y, r.y); 
    83     int w = (int) Math.min(this.x + this.width, r.x + r.width) - x; 
    84     int h = (int) Math.min(this.y + this.height, r.y + r.height) - y; 
     81    int x = Math.max(this.x, r.x); 
     82    int y = Math.max(this.y, r.y); 
     83    int w = Math.min(this.x + this.width, r.x + r.width) - x; 
     84    int h = Math.min(this.y + this.height, r.y + r.height) - y; 
    8585 
    8686    if (w < 0) w = 0; 
  • trunk/components/common/src/loci/common/StreamHandle.java

    r6128 r6155  
    7575   * will be big-endian. 
    7676   */ 
    77   public StreamHandle() throws IOException { 
     77  public StreamHandle() { 
    7878    fp = 0; 
    7979    order = ByteOrder.BIG_ENDIAN; 
     
    418418 
    419419  /** Reset the marked position, if necessary. */ 
    420   private void markManager() throws IOException { 
     420  private void markManager() { 
    421421    if (fp >= mark + RandomAccessInputStream.MAX_OVERHEAD - 1) { 
    422422      mark = fp; 
  • trunk/components/common/src/loci/common/services/DependencyException.java

    • Property svn:executable deleted
  • trunk/components/common/src/loci/common/services/ServiceFactory.java

    r6152 r6155  
    126126   */ 
    127127  public <T extends Service> T getInstance(Class<T> type) 
    128     throws DependencyException { 
     128    throws DependencyException 
     129  { 
    129130    Class<T> impl = (Class<T>) services.get(type); 
    130131    if (impl == null && services.containsKey(type)) { 
  • trunk/components/common/src/loci/common/xml/XMLTools.java

    r6128 r6155  
    410410      return false; 
    411411    } 
    412     else LOGGER.info(schemaPath); 
     412    LOGGER.info(schemaPath); 
    413413 
    414414    LOGGER.info("Validating {}", label); 
  • trunk/components/forks/jai/.settings/org.eclipse.jdt.core.prefs

    r5093 r6155  
    1 #Fri May 08 07:09:16 CDT 2009 
     1#Mon Apr 19 18:13:41 CDT 2010 
    22eclipse.preferences.version=1 
    33org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 
     
    1111org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 
    1212org.eclipse.jdt.core.compiler.problem.autoboxing=ignore 
    13 org.eclipse.jdt.core.compiler.problem.deprecation=warning 
     13org.eclipse.jdt.core.compiler.problem.comparingIdentical=ignore 
     14org.eclipse.jdt.core.compiler.problem.deadCode=ignore 
     15org.eclipse.jdt.core.compiler.problem.deprecation=ignore 
    1416org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled 
    1517org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled 
     
    3032org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=ignore 
    3133org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore 
     34org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore 
    3235org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore 
    3336org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore 
     37org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore 
    3438org.eclipse.jdt.core.compiler.problem.noEffectAssignment=ignore 
    3539org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=ignore 
  • trunk/components/forks/mdbtools/.settings/org.eclipse.jdt.core.prefs

    r5093 r6155  
    1 #Fri May 08 07:10:50 CDT 2009 
     1#Mon Apr 19 18:10:12 CDT 2010 
    22eclipse.preferences.version=1 
    33org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 
     
    1111org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning 
    1212org.eclipse.jdt.core.compiler.problem.autoboxing=ignore 
    13 org.eclipse.jdt.core.compiler.problem.deprecation=warning 
     13org.eclipse.jdt.core.compiler.problem.comparingIdentical=ignore 
     14org.eclipse.jdt.core.compiler.problem.deadCode=ignore 
     15org.eclipse.jdt.core.compiler.problem.deprecation=ignore 
    1416org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled 
    1517org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled 
     
    3032org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=ignore 
    3133org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore 
     34org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore 
    3235org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore 
    3336org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore 
     37org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore 
    3438org.eclipse.jdt.core.compiler.problem.noEffectAssignment=ignore 
    3539org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=ignore 
     
    5963org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled 
    6064org.eclipse.jdt.core.compiler.problem.unusedImport=ignore 
    61 org.eclipse.jdt.core.compiler.problem.unusedLabel=warning 
     65org.eclipse.jdt.core.compiler.problem.unusedLabel=ignore 
    6266org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore 
    6367org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore 
  • trunk/components/forks/poi/.settings/org.eclipse.jdt.core.prefs

    r5093 r6155  
    1 #Fri May 08 07:12:07 CDT 2009 
     1#Mon Apr 19 18:12:46 CDT 2010 
    22eclipse.preferences.version=1 
    33org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 
     
    1111org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning 
    1212org.eclipse.jdt.core.compiler.problem.autoboxing=ignore 
    13 org.eclipse.jdt.core.compiler.problem.deprecation=warning 
     13org.eclipse.jdt.core.compiler.problem.comparingIdentical=ignore 
     14org.eclipse.jdt.core.compiler.problem.deadCode=ignore 
     15org.eclipse.jdt.core.compiler.problem.deprecation=ignore 
    1416org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled 
    1517org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled 
     
    3032org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=ignore 
    3133org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore 
     34org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore 
    3235org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore 
    3336org.eclipse.jdt.core.compiler.problem.missingSerialVersion=ignore 
     37org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore 
    3438org.eclipse.jdt.core.compiler.problem.noEffectAssignment=ignore 
    3539org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=ignore 
  • trunk/components/loci-plugins/src/loci/plugins/Colorizer.java

    r5555 r6155  
    3636import ij.process.ImageProcessor; 
    3737import ij.process.LUT; 
    38 import ij.util.Tools; 
    3938 
    4039import java.awt.Color; 
    41 import java.awt.Dimension; 
    42 import java.awt.Graphics; 
    43 import java.awt.GridBagConstraints; 
    44 import java.awt.Insets; 
    45 import java.awt.Panel; 
    46 import java.awt.TextField; 
    47 import java.awt.event.TextEvent; 
    48 import java.awt.event.TextListener; 
    4940import java.awt.image.IndexColorModel; 
    5041import java.io.IOException; 
    5142import java.util.Arrays; 
    52 import java.util.Vector; 
    5343 
    5444import loci.formats.FormatTools; 
     
    8272  private ImagePlus imp; 
    8373 
    84   private String stackOrder; 
    85   private boolean color; 
    86   private boolean hyperstack; 
    87   private byte[][][] lut; 
    88   private String mergeOption; 
    89  
    90   private int series = 0; 
    91  
    9274  // -- PlugInFilter API methods -- 
    9375 
     
    10183    if (!LibraryChecker.checkJava() || !LibraryChecker.checkImageJ()) return; 
    10284 
    103     stackOrder = "XYCZT"; 
    104  
    105     boolean doPrompt = false; 
     85    String stackOrder = "XYCZT"; 
     86    boolean color = false; 
     87    boolean hyperstack = false; 
     88    byte[][][] lut = null; 
     89    String mergeOption = null; 
     90    int series = 0; 
    10691 
    10792    if (arg == null || arg.trim().equals("")) { 
     
    124109      stackOrder = gd.getNextChoice(); 
    125110      hyperstack = gd.getNextBoolean(); 
    126  
    127       if (color && lut == null) doPrompt = true; 
    128111    } 
    129112    else { 
     
    133116        Macro.getValue(arg, "colorize", "false")).booleanValue(); 
    134117      int colorNdx = Integer.parseInt(Macro.getValue(arg, "ndx", "-1")); 
    135       if (color) { 
    136         if (colorNdx >= 0 && colorNdx < 3) { 
    137           lut = new byte[imp.getNChannels()][3][256]; 
    138           for (int channel=0; channel<lut.length; channel++) { 
    139             if (colorNdx + channel >= lut[channel].length) break; 
    140             for (int q=0; q<lut[channel][colorNdx + channel].length; q++) { 
    141               lut[channel][colorNdx + channel][q] = (byte) q; 
    142             } 
    143           } 
    144         } 
    145         else if (lut == null) doPrompt = true; 
    146       } 
     118      if (color) lut = makeDefaultLut(imp.getNChannels(), colorNdx); 
    147119      mergeOption = Macro.getValue(arg, "merge_option", null); 
    148120      hyperstack = Boolean.valueOf( 
     
    157129      return; 
    158130    } 
     131     
     132    ImagePlus newImp = Colorizer.colorize(imp, color, stackOrder, lut, series, mergeOption, hyperstack); 
     133 
     134    if (newImp != null) { 
     135      imp.close(); // close original 
     136      newImp.show(); 
     137    } 
     138 
     139    lut = null; 
     140  } 
     141 
     142  // -- Colorizer API methods -- 
     143 
     144  public static ImagePlus colorize(ImagePlus imp, boolean color, 
     145    String stackOrder, byte[][][] lut, int series, 
     146    String mergeOption, boolean hyperstack) 
     147  { 
     148    ImageStack stack = imp.getImageStack(); 
     149 
     150    if (stack.isVirtual()) { 
     151      throw new IllegalArgumentException("Cannot colorize virtual stack"); 
     152    } 
    159153 
    160154    Calibration calibration = imp.getCalibration(); 
     
    167161 
    168162    if (imp.isComposite() || stack.isRGB() || (nChannels == 1 && !color)) { 
    169       return; 
     163      return null; 
    170164    } 
    171165 
    172166    ImagePlus newImp = new ImagePlus(); 
    173     boolean closeOriginal = true; 
    174167 
    175168    if (color) { 
     169      if (lut == null) lut = promptForColors(nChannels, series); 
     170 
    176171      if (nChannels > 1) { 
    177172        imp = ImagePlusTools.reorder(imp, stackOrder, "XYCZT"); 
     
    179174        CompositeImage composite = 
    180175          new CompositeImage(imp, CompositeImage.COLOR); 
     176 
    181177        for (int i=0; i<nChannels; i++) { 
    182178          composite.setPosition(i + 1, 1, 1); 
    183           if (doPrompt) promptForColor(i); 
    184179          if (lut != null) { 
    185180            LUT channelLut = new LUT(lut[i][0], lut[i][1], lut[i][2]); 
     
    191186      } 
    192187      else { 
     188        if (lut == null) return null; 
     189 
    193190        ImageStack newStack = 
    194191          new ImageStack(stack.getWidth(), stack.getHeight()); 
     
    196193          newStack.addSlice(stack.getSliceLabel(i), stack.getProcessor(i)); 
    197194        } 
    198  
    199         if (doPrompt) { 
    200           promptForColor(0); 
    201         } 
    202         if (lut == null) return; 
    203  
    204         IndexColorModel model = new IndexColorModel(8, 256, lut[0][0], 
    205           lut[0][1], lut[0][2]); 
     195        IndexColorModel model = new IndexColorModel(8, 256, 
     196          lut[0][0], lut[0][1], lut[0][2]); 
    206197        newStack.setColorModel(model); 
    207198        newImp.setStack(imp.getTitle(), newStack); 
     
    212203 
    213204      if (nChannels < 4 && type == ImagePlus.GRAY8) { 
    214         newImp = makeRGB(newImp, stack, nChannels); 
     205        newImp = makeRGB(imp, stackOrder, newImp, stack, nChannels); 
    215206      } 
    216207      else if (nChannels <= 7 && type != ImagePlus.COLOR_256) { 
     
    264255 
    265256            if (imp.getType() == ImagePlus.GRAY8 && n < 4) { 
    266               newImp = makeRGB(newImp, stack, n); 
     257              newImp = makeRGB(imp, stackOrder, newImp, stack, n); 
    267258            } 
    268259            imp.setDimensions(n, imp.getNSlices()*num[n - 2], 
     
    285276      newImp.setFileInfo(imp.getOriginalFileInfo()); 
    286277      if (!newImp.isComposite()) newImp.setOpenAsHyperStack(hyperstack); 
    287       newImp.show(); 
    288     } 
    289     if (closeOriginal) imp.close(); 
    290     lut = null; 
    291   } 
    292  
    293   // -- Colorizer API methods -- 
    294  
    295   public void setLookupTable(byte[][] lut, int channel) { 
    296     if (this.lut == null) { 
    297       this.lut = new byte[imp.getNChannels()][][]; 
    298     } 
    299     if (channel < this.lut.length) this.lut[channel] = lut; 
    300   } 
    301  
     278    } 
     279 
     280    return newImp; 
     281  } 
     282 
     283  public static byte[][][] makeDefaultLut(int nChannels, int index) { 
     284    if (index < 0 || index >= 3) return null; 
     285 
     286    byte[][][] lut = new byte[nChannels][3][256]; 
     287    for (int channel = 0; channel < nChannels; channel++) { 
     288      if (index + channel >= lut[channel].length) break; 
     289      for (int q = 0; q < lut[channel][index + channel].length; q++) { 
     290        lut[channel][index + channel][q] = (byte) q; 
     291      } 
     292    } 
     293    return lut; 
     294  } 
     295   
    302296  // -- Helper methods -- 
    303297 
    304   private ImagePlus makeRGB(ImagePlus ip, ImageStack s, int c) { 
     298  private static ImagePlus makeRGB(ImagePlus imp, String stackOrder, ImagePlus ip, ImageStack s, int c) { 
    305299    ImageStack newStack = new ImageStack(s.getWidth(), s.getHeight()); 
    306300 
     
    331325  } 
    332326 
    333   private void promptForColor(int channel) { 
     327  private static byte[][] promptForColor(int channel, int series) { 
    334328    CustomColorChooser chooser = new CustomColorChooser( 
    335329      "Color Chooser - Channel " + channel, null, series, channel); 
    336330 
    337331    Color color = chooser.getColor(); 
    338     if (color == null) return; 
     332    if (color == null) return null; 
    339333    double redIncrement = ((double) color.getRed()) / 255; 
    340334    double greenIncrement = ((double) color.getGreen()) / 255; 
    341335    double blueIncrement = ((double) color.getBlue()) / 255; 
    342336 
    343     if (lut == null) lut = new byte[imp.getNChannels()][3][256]; 
     337    byte[][] channelLut = new byte[3][256]; 
    344338    for (int i=0; i<256; i++) { 
    345       lut[channel][0][i] = (byte) (i * redIncrement); 
    346       lut[channel][1][i] = (byte) (i * greenIncrement); 
    347       lut[channel][2][i] = (byte) (i * blueIncrement); 
    348     } 
    349   } 
    350  
    351   // -- Helper class -- 
    352  
    353   /** 
    354    * Adapted from ij.gui.ColorChooser.  ColorChooser is not used because 
    355    * there is no way to change the slider labels - this means that we can't 
    356    * record macros in which custom colors are chosen for multiple channels. 
    357    */ 
    358   class CustomColorChooser implements TextListener { 
    359     Vector colors; 
    360     ColorPanel panel; 
    361     Color initialColor; 
    362     int red, green, blue; 
    363     String title; 
    364  
    365     private int series, channel; 
    366  
    367     public CustomColorChooser(String title, Color initialColor, int series, 
    368       int channel) 
    369     { 
    370         this.title = title; 
    371         if (initialColor == null) initialColor = Color.BLACK; 
    372         this.initialColor = initialColor; 
    373         red = initialColor.getRed(); 
    374         green = initialColor.getGreen(); 
    375         blue = initialColor.getBlue(); 
    376         this.series = series; 
    377         this.channel = channel; 
    378     } 
    379  
    380     // -- ColorChooser API methods -- 
    381  
    382     /** 
    383      * Displays a color selection dialog and returns the color 
    384      *  selected by the user. 
    385      */ 
    386     public Color getColor() { 
    387       GenericDialog gd = new GenericDialog(title); 
    388       gd.addSlider(makeLabel("Red:"), 0, 255, red); 
    389       gd.addSlider(makeLabel("Green:"), 0, 255, green); 
    390       gd.addSlider(makeLabel("Blue:"), 0, 255, blue); 
    391       panel = new ColorPanel(initialColor); 
    392       gd.addPanel(panel, GridBagConstraints.CENTER, new Insets(10, 0, 0, 0)); 
    393       colors = gd.getNumericFields(); 
    394       for (int i=0; i<colors.size(); i++) { 
    395         ((TextField) colors.elementAt(i)).addTextListener(this); 
    396       } 
    397       gd.showDialog(); 
    398       if (gd.wasCanceled()) return null; 
    399       int red = (int) gd.getNextNumber(); 
    400       int green = (int) gd.getNextNumber(); 
    401       int blue = (int) gd.getNextNumber(); 
    402       return new Color(red, green, blue); 
    403     } 
    404  
    405     public void textValueChanged(TextEvent e) { 
    406       int red = getColorValue(0); 
    407       int green = getColorValue(1); 
    408       int blue = getColorValue(2); 
    409       panel.setColor(new Color(red, green, blue)); 
    410       panel.repaint(); 
    411     } 
    412  
    413     // -- Helper methods -- 
    414  
    415     private int getColorValue(int index) { 
    416       int color = 
    417         (int) Tools.parseDouble(((TextField) colors.get(index)).getText()); 
    418       if (color < 0) color = 0; 
    419       if (color > 255) color = 255; 
    420       return color; 
    421     } 
    422  
    423     private String makeLabel(String baseLabel) { 
    424       return "Series_" + series + "_Channel_" + channel + "_" + baseLabel; 
    425     } 
    426   } 
    427  
    428   static class ColorPanel extends Panel { 
    429     private static final int WIDTH = 100, HEIGHT = 50; 
    430     private Color c; 
    431  
    432     public ColorPanel(Color c) { 
    433       this.c = c; 
    434     } 
    435  
    436     public Dimension getPreferredSize() { 
    437       return new Dimension(WIDTH, HEIGHT); 
    438     } 
    439  
    440     void setColor(Color c) { this.c = c; } 
    441  
    442     public Dimension getMinimumSize() { 
    443       return new Dimension(WIDTH, HEIGHT); 
    444     } 
    445  
    446     public void paint(Graphics g) { 
    447       g.setColor(c); 
    448       g.fillRect(0, 0, WIDTH, HEIGHT); 
    449       g.setColor(Color.black); 
    450       g.drawRect(0, 0, WIDTH-1, HEIGHT-1); 
    451     } 
    452  
     339      channelLut[0][i] = (byte) (i * redIncrement); 
     340      channelLut[1][i] = (byte) (i * greenIncrement); 
     341      channelLut[2][i] = (byte) (i * blueIncrement); 
     342    } 
     343    return channelLut; 
     344  } 
     345   
     346  private static byte[][][] promptForColors(int nChannels, int series) { 
     347    byte[][][] lut = new byte[nChannels][][]; 
     348    for (int i=0; i<nChannels; i++) { 
     349      lut[i] = promptForColor(i, series); 
     350      if (lut[i] == null) return null; 
     351    } 
     352    return lut; 
    453353  } 
    454354 
  • trunk/components/loci-plugins/src/loci/plugins/importer/Concatenator.java

    r6132 r6155  
    2626package loci.plugins.importer; 
    2727 
    28 import ij.IJ; 
    2928import ij.ImagePlus; 
    3029import ij.ImageStack; 
     
    3433 
    3534import loci.formats.IFormatReader; 
     35import loci.plugins.Colorizer; 
    3636import loci.plugins.Slicer; 
    3737 
     
    7171      boolean append = false; 
    7272      for (int k=0; k<widths.size(); k++) { 
    73         int wk = ((Integer) widths.get(k)).intValue(); 
    74         int hk = ((Integer) heights.get(k)).intValue(); 
    75         int tk = ((Integer) types.get(k)).intValue(); 
     73        int wk = widths.get(k); 
     74        int hk = heights.get(k); 
     75        int tk = types.get(k); 
    7676 
    7777        if (wj == wk && hj == hk && tj == tk) { 
     
    102102 
    103103    for (int j=0; j<newImps.size(); j++) { 
    104       ImagePlus imp = (ImagePlus) newImps.get(j); 
     104      ImagePlus imp = newImps.get(j); 
    105105      if (splitC || splitZ || splitT) { 
    106         boolean hyper = options.isViewHyperstack(); 
    107         imp = Slicer.reslice(imp, splitC, splitZ, splitT, hyper, stackOrder); 
     106        imp = Slicer.reslice(imp, splitC, splitZ, splitT, 
     107          options.isViewHyperstack(), stackOrder); 
    108108      } 
    109       // TODO: Change IJ.runPlugIn to direct API calls in relevant plugins. 
    110       // Should not be calling show() here just to make other plugins happy! :-( 
    111109      if (options.isMergeChannels() && options.isWindowless()) { 
    112         imp.show(); 
    113         IJ.runPlugIn("loci.plugins.Colorizer", "stack_order=" + stackOrder + 
    114           " merge=true merge_option=[" + options.getMergeOption() + "] " + 
    115           "series=" + r.getSeries() + " hyper_stack=" + 
    116           options.isViewHyperstack() + " "); 
    117         imp.close(); 
     110        imp = Colorizer.colorize(imp, true, stackOrder, null, 
     111          r.getSeries(), options.getMergeOption(), options.isViewHyperstack()); 
    118112      } 
    119113      else if (options.isMergeChannels()) { 
    120         imp.show(); 
    121         IJ.runPlugIn("loci.plugins.Colorizer", "stack_order=" + stackOrder + 
    122           " merge=true series=" + r.getSeries() + " hyper_stack=" + 
    123           options.isViewHyperstack() + " "); 
    124         imp.close(); 
     114        imp = Colorizer.colorize(imp, true, stackOrder, null, 
     115          r.getSeries(), null, options.isViewHyperstack()); 
    125116      } 
     117      newImps.set(j, imp); 
    126118    } 
    127119 
  • trunk/components/loci-plugins/src/loci/plugins/importer/DisplayHandler.java

    r6132 r6155  
    2929import ij.ImagePlus; 
    3030import ij.WindowManager; 
    31 import ij.plugin.filter.PlugInFilterRunner; 
    3231 
    3332import java.awt.image.IndexColorModel; 
     
    8180 
    8281  /** Displays standard metadata in a table in its own window. */ 
    83   public SearchableWindow displayOriginalMetadata() throws IOException { 
     82  public SearchableWindow displayOriginalMetadata() { 
    8483    if (!options.isShowMetadata()) return null; 
    8584     
     
    149148 
    150149    if (imp.isVisible() && !options.isVirtual()) { 
    151       String arg = "stack_order=" + stackOrder + " merge=true series=" + 
    152         r.getSeries() + " hyper_stack=" + options.isViewHyperstack(); 
    153       if (windowless) arg += " merge_option=[" + options.getMergeOption() + "]"; 
    154       arg += " "; 
    155       IJ.runPlugIn("loci.plugins.Colorizer", arg); 
     150      String mergeOptions = windowless ? options.getMergeOption() : null; 
     151      imp = Colorizer.colorize(imp, true, stackOrder, null, r.getSeries(), mergeOptions, options.isViewHyperstack()); 
     152      // CTR TODO finish this 
    156153      if (WindowManager.getCurrentImage().getID() != imp.getID()) imp.close(); 
    157154    } 
     
    166163      boolean splitT = options.isSplitTimepoints(); 
    167164 
    168       if (!imp.isVisible()) imp.show(); 
    169  
    170165      boolean customColorize = options.isCustomColorize(); 
    171166      boolean browser = options.isViewBrowser(); 
     
    173168 
    174169      if (options.isColorize() || customColorize) { 
    175         IJ.runPlugIn("loci.plugins.Colorizer", "stack_order=" + stackOrder + 
    176           " merge=false colorize=true ndx=" + (customColorize ? "-1" : "0") + 
    177           " series=" + r.getSeries() + " hyper_stack=" + 
    178           options.isViewHyperstack() + " "); 
    179         imp.close(); 
     170        byte[][][] lut = 
     171          Colorizer.makeDefaultLut(imp.getNChannels(), customColorize ? -1 : 0); 
     172        imp = Colorizer.colorize(imp, true, stackOrder, lut, r.getSeries(), null, options.isViewHyperstack()); 
    180173      } 
    181174      else if (colorModels != null && !browser && !virtual) { 
    182         Colorizer colorizer = new Colorizer(); 
    183         String arg = "stack_order=" + stackOrder + " merge=false " + 
    184           "colorize=true series=" + r.getSeries() + " hyper_stack=" + 
    185           hyper + " "; 
    186         colorizer.setup(arg, imp); 
    187         for (int channel=0; channel<colorModels.length; channel++) { 
    188           byte[][] lut = new byte[3][256]; 
    189           colorModels[channel].getReds(lut[0]); 
    190           colorModels[channel].getGreens(lut[1]); 
    191           colorModels[channel].getBlues(lut[2]); 
    192           colorizer.setLookupTable(lut, channel); 
     175        byte[][][] lut = new byte[colorModels.length][][]; 
     176        for (int channel=0; channel<lut.length; channel++) { 
     177          lut[channel] = new byte[3][256]; 
     178          colorModels[channel].getReds(lut[channel][0]); 
     179          colorModels[channel].getGreens(lut[channel][1]); 
     180          colorModels[channel].getBlues(lut[channel][2]); 
    193181        } 
    194         new PlugInFilterRunner(colorizer, "", arg); 
    195         imp.close(); 
     182        imp = Colorizer.colorize(imp, true, 
     183          stackOrder, lut, r.getSeries(), null, hyper); 
    196184      } 
    197185 
    198186      if (splitC || splitZ || splitT) { 
    199187        imp = Slicer.reslice(imp, splitC, splitZ, splitT, hyper, stackOrder); 
    200         imp.close(); 
    201188      } 
    202189    } 
     190 
     191    imp.show(); 
    203192  } 
    204193   
     
    259248      //ru.setVar("pattern", pattern); 
    260249      ru.exec("dataset = new Dataset(name, pattern)"); 
     250      ru.setVar("imp", imp); 
    261251      // TODO: finish VisBio logic 
    262252    } 
  • trunk/components/loci-plugins/src/loci/plugins/importer/IdDialog.java

    r5307 r6155  
    9393 
    9494    // verify that id is valid 
    95     Location idLoc = id == null ? null : new Location(id); 
    96     if (idLoc == null) { 
    97       if (!options.isQuiet()) IJ.error("Bio-Formats", "No file was specified."); 
    98       return STATUS_FINISHED; 
    99     } 
    100     else if (!idLoc.exists() && !id.toLowerCase().endsWith(".fake")) { 
     95    Location idLoc = new Location(id); 
     96    if (!idLoc.exists() && !id.toLowerCase().endsWith(".fake")) { 
    10197      if (!options.isQuiet()) { 
    10298        IJ.error("Bio-Formats", 
  • trunk/components/loci-plugins/src/loci/plugins/importer/ImagePlusReader.java

    r6132 r6155  
    340340  private ImagePlus createImage(ImageStack stack, 
    341341    int series, FileInfo fi, String stackOrder, IndexColorModel[] colorModels) 
    342     throws FormatException, IOException 
    343342  { 
    344343    if (stack == null) return null; 
     
    398397    if (used.length > 1 && groupFiles) { 
    399398      FilePattern fp = new FilePattern(new Location(file)); 
    400       if (fp != null) { 
    401         title = fp.getPattern(); 
    402         if (title == null) { 
    403           title = file; 
    404           if (title.indexOf(".") != -1) { 
    405             title = title.substring(0, title.lastIndexOf(".")); 
    406           } 
    407         } 
    408         title = title.substring(title.lastIndexOf(File.separator) + 1); 
    409       } 
     399            title = fp.getPattern(); 
     400            if (title == null) { 
     401              title = file; 
     402              if (title.indexOf(".") != -1) { 
     403                title = title.substring(0, title.lastIndexOf(".")); 
     404              } 
     405            } 
     406            title = title.substring(title.lastIndexOf(File.separator) + 1); 
    410407    } 
    411408    if (seriesName != null && !file.endsWith(seriesName) && 
  • trunk/components/loci-plugins/src/loci/plugins/importer/Importer.java

    r6132 r6155  
    7070    try { 
    7171      BF.debug("parse core options"); 
    72       options = parseOptions(arg, false); 
     72      options = parseOptions(arg); 
    7373      if (plugin.canceled) return; 
    7474 
     
    104104 
    105105  /** Parses core options. */ 
    106   public ImporterOptions parseOptions(String arg, boolean quiet) 
    107     throws IOException 
    108   { 
     106  public ImporterOptions parseOptions(String arg) throws IOException { 
    109107    ImporterOptions options = new ImporterOptions(); 
    110108    options.loadOptions(); 
     
    121119 
    122120  /** Displays standard metadata in a table in its own window. */ 
    123   public void displayOriginalMetadata(ImporterOptions options) 
    124     throws IOException 
    125   { 
     121  public void displayOriginalMetadata(ImporterOptions options) { 
    126122    DisplayHandler displayHandler = new DisplayHandler(options); 
    127123    displayHandler.displayOriginalMetadata(); 
  • trunk/components/loci-plugins/src/loci/plugins/importer/ImporterDialog.java

    r6039 r6155  
    363363  public void focusGained(FocusEvent e) { 
    364364    Object src = e.getSource(); 
    365     String text = (String) infoTable.get(src); 
     365    String text = infoTable.get(src); 
    366366    infoPane.setText("<html>" + text); 
    367367    infoPane.setCaretPosition(0); 
  • trunk/components/loci-plugins/src/loci/plugins/importer/ImporterMetadata.java

    r6131 r6155  
    7979 
    8080      // merge series metadata 
    81       Hashtable seriesMeta = r.getSeriesMetadata(); 
     81      Hashtable<String, Object> seriesMeta = r.getSeriesMetadata(); 
    8282      MetadataTools.merge(seriesMeta, this, s); 
    8383 
  • trunk/components/loci-plugins/src/loci/plugins/importer/ImporterOptions.java

    r6130 r6155  
    467467 
    468468  /** Prompts for the file pattern, if necessary. May override id value. */ 
    469   private boolean promptFilePattern() throws FormatException, IOException { 
     469  private boolean promptFilePattern() { 
    470470    if (!isGroupFiles()) { 
    471471      BF.debug("no need to prompt for file pattern"); 
     
    497497 
    498498  /** Prompts for which series to import, if necessary. */ 
    499   private boolean promptSeries() throws FormatException, IOException { 
     499  private boolean promptSeries() { 
    500500    // initialize series-related derived values 
    501501    series = new boolean[reader.r.getSeriesCount()]; 
  • trunk/components/loci-plugins/src/loci/plugins/importer/ImporterReader.java

    r6130 r6155  
    8181  // -- Constructors -- 
    8282 
    83   public ImporterReader() throws FormatException, IOException { 
     83  public ImporterReader() throws IOException { 
    8484    this(new ImporterOptions()); 
    8585  } 
    8686 
    87   public ImporterReader(ImporterOptions options) 
    88     throws FormatException, IOException 
    89   { 
     87  public ImporterReader(ImporterOptions options) { 
    9088    this.options = options; 
    9189    computeNameAndLocation(); 
     
    161159    if (options.isLocal() || options.isHTTP()) { 
    162160      if (!options.isQuiet()) IJ.showStatus("Identifying " + idName); 
    163       ImageReader reader = ImageProcessorReader.makeImageReader(); 
     161      ImageReader reader = LociPrefs.makeImageReader(); 
    164162      try { baseReader = reader.getReader(options.getId()); } 
    165163      catch (FormatException exc) { 
  • trunk/components/loci-plugins/src/loci/plugins/importer/SeriesDialog.java

    r6132 r6155  
    185185    } 
    186186 
    187     boxes = (Checkbox[]) gd.getCheckboxes().toArray(new Checkbox[0]); 
     187    boxes = WindowTools.getCheckboxes(gd).toArray(new Checkbox[0]); 
    188188 
    189189    // remove components and re-add everything so that the thumbnails and 
     
    194194    Panel masterPanel = new Panel() { 
    195195      // ClassCastException is thrown if dispatchEventImpl is not overridden 
     196      // CTR TODO - there must be a better way 
    196197      protected void dispatchEventImpl(AWTEvent e) { } 
    197198    }; 
  • trunk/components/loci-plugins/src/loci/plugins/macro/LociFunctions.java

    r6130 r6155  
    4545import loci.plugins.util.ImageProcessorReader; 
    4646import loci.plugins.util.ImagePlusTools; 
     47import loci.plugins.util.LociPrefs; 
    4748 
    4849/** 
     
    7475  public LociFunctions() { 
    7576    r = new ImageProcessorReader(new ChannelSeparator( 
    76       new FileStitcher(ImageProcessorReader.makeImageReader(), true))); 
     77      new FileStitcher(LociPrefs.makeImageReader(), true))); 
    7778    try { 
    7879      ServiceFactory factory = new ServiceFactory(); 
  • trunk/components/loci-plugins/src/loci/plugins/prefs/OptionsList.java

    r5418 r6155  
    6161  // -- Constructor -- 
    6262 
    63   public OptionsList(String path, Class c) throws IOException { 
     63  public OptionsList(String path, Class<?> c) throws IOException { 
    6464    this(new IniParser().parseINI(path, c)); 
    6565  } 
  • trunk/components/loci-plugins/src/loci/plugins/util/BF.java

    r5857 r6155  
    4646    if (IJ.debugMode) IJ.log("LOCI: " + msg); 
    4747  } 
    48  
     48   
    4949} 
  • trunk/components/loci-plugins/src/loci/plugins/util/ImageProcessorReader.java

    r6141 r6155  
    3636 
    3737import loci.common.DataTools; 
    38 import loci.formats.ClassList; 
    3938import loci.formats.FormatException; 
    4039import loci.formats.FormatTools; 
    4140import loci.formats.IFormatReader; 
    42 import loci.formats.ImageReader; 
    4341import loci.formats.ImageTools; 
    4442import loci.formats.MinMaxCalculator; 
    45 import loci.formats.in.ND2Reader; 
    46 import loci.formats.in.PictReader; 
    47 import loci.formats.in.QTReader; 
    48 import loci.formats.in.SDTReader; 
    49 import loci.formats.in.TiffDelegateReader; 
    5043 
    5144/** 
     
    6255  // -- Utility methods -- 
    6356 
    64   /** Converts the given reader into a ImageProcessorReader, wrapping if needed. */ 
     57  /** 
     58   * Converts the given reader into a ImageProcessorReader, wrapping if needed. 
     59   */ 
    6560  public static ImageProcessorReader makeImageProcessorReader(IFormatReader r) { 
    6661    if (r instanceof ImageProcessorReader) return (ImageProcessorReader) r; 
     
    6863  } 
    6964 
    70   /** 
    71    * Creates an image reader according to the current configuration settings, 
    72    * including which format readers are currently enabled, as well as 
    73    * format-specific configuration settings. 
    74    */ 
    75   public static ImageReader makeImageReader() { 
    76     // include only enabled classes 
    77     Class<? extends IFormatReader>[] c = null; 
    78     try { 
    79       ClassList<IFormatReader> defaultClasses = 
    80         new ClassList<IFormatReader>("readers.txt", IFormatReader.class); 
    81       c = defaultClasses.getClasses(); 
    82     } 
    83     catch (IOException exc) { 
    84       return new ImageReader(); 
    85     } 
    86     ClassList<IFormatReader> enabledClasses = 
    87       new ClassList<IFormatReader>(IFormatReader.class); 
    88     for (int i=0; i<c.length; i++) { 
    89       boolean on = LociPrefs.isReaderEnabled(c[i]); 
    90       if (on) enabledClasses.addClass(c[i]); 
    91     } 
    92     ImageReader reader = new ImageReader(enabledClasses); 
    93  
    94     // toggle reader-specific options 
    95     boolean nd2Nikon = LociPrefs.isND2Nikon(); 
    96     boolean pictQTJava = LociPrefs.isPictQTJava(); 
    97     boolean qtQTJava = LociPrefs.isQTQTJava(); 
    98     boolean sdtIntensity = LociPrefs.isSDTIntensity(); 
    99     boolean tiffImageIO = LociPrefs.isTiffImageIO(); 
    100     IFormatReader[] r = reader.getReaders(); 
    101     for (int i=0; i<r.length; i++) { 
    102       if (r[i] instanceof ND2Reader) { 
    103         ND2Reader nd2 = (ND2Reader) r[i]; 
    104         nd2.setLegacy(nd2Nikon); 
    105       } 
    106       else if (r[i] instanceof PictReader) { 
    107         PictReader pict = (PictReader) r[i]; 
    108         pict.setLegacy(pictQTJava); 
    109       } 
    110       else if (r[i] instanceof QTReader) { 
    111         QTReader qt = (QTReader) r[i]; 
    112         qt.setLegacy(qtQTJava); 
    113       } 
    114       else if (r[i] instanceof SDTReader) { 
    115         SDTReader sdt = (SDTReader) r[i]; 
    116         sdt.setIntensity(sdtIntensity); 
    117       } 
    118       else if (r[i] instanceof TiffDelegateReader) { 
    119         TiffDelegateReader tiff = (TiffDelegateReader) r[i]; 
    120         tiff.setLegacy(tiffImageIO); 
    121       } 
    122     } 
    123  
    124     return reader; 
    125   } 
    126  
    12765  // -- Constructors -- 
    12866 
    12967  /** Constructs an ImageProcessorReader around a new image reader. */ 
    130   public ImageProcessorReader() { super(makeImageReader()); } 
     68  public ImageProcessorReader() { super(LociPrefs.makeImageReader()); } 
    13169 
    13270  /** Constructs an ImageProcessorReader with the given reader. */ 
     
    15391   * 
    15492   * @param no Position of image plane. 
    155    * @param crop Image cropping specifications, or null if no cropping 
    156    *   is to be done. 
     93   * @param crop Image cropping specifications, 
     94   *   or null if no cropping is to be done. 
    15795   */ 
    15896  public ImageProcessor[] openProcessors(int no, Rectangle crop) 
     
    231169          byte[] tmp = q; 
    232170          q = new byte[w * h]; 
    233           System.arraycopy(tmp, 0, q, 0, (int) Math.min(q.length, tmp.length)); 
     171          System.arraycopy(tmp, 0, q, 0, Math.min(q.length, tmp.length)); 
    234172        } 
    235173        if (isSigned) q = DataTools.makeSigned(q); 
     
    243181          short[] tmp = q; 
    244182          q = new short[w * h]; 
    245           System.arraycopy(tmp, 0, q, 0, (int) Math.min(q.length, tmp.length)); 
     183          System.arraycopy(tmp, 0, q, 0, Math.min(q.length, tmp.length)); 
    246184        } 
    247185        if (isSigned) q = DataTools.makeSigned(q); 
     
    254192          int[] tmp = q; 
    255193          q = new int[w * h]; 
    256           System.arraycopy(tmp, 0, q, 0, (int) Math.min(q.length, tmp.length)); 
     194          System.arraycopy(tmp, 0, q, 0, Math.min(q.length, tmp.length)); 
    257195        } 
    258196 
     
    264202          float[] tmp = q; 
    265203          q = new float[w * h]; 
    266           System.arraycopy(tmp, 0, q, 0, (int) Math.min(q.length, tmp.length)); 
     204          System.arraycopy(tmp, 0, q, 0, Math.min(q.length, tmp.length)); 
    267205        } 
    268206        ip[i] = new FloatProcessor(w, h, q, null); 
     
    273211          double[] tmp = q; 
    274212          q = new double[w * h]; 
    275           System.arraycopy(tmp, 0, q, 0, (int) Math.min(q.length, tmp.length)); 
     213          System.arraycopy(tmp, 0, q, 0, Math.min(q.length, tmp.length)); 
    276214        } 
    277215        ip[i] = new FloatProcessor(w, h, q); 
     
    281219    return ip; 
    282220  } 
     221   
     222  // -- IFormatReader methods -- 
     223   
     224  /** @Override */ 
     225  public Class<?> getNativeDataType() { 
     226    return ImageProcessor[].class; 
     227  } 
     228   
     229  /** @Override */ 
     230  public Object openPlane(int no, int x, int y, int w, int h) 
     231    throws FormatException, IOException  
     232  { 
     233    return openProcessors(no, new Rectangle(x, y, w, h)); 
     234  } 
    283235 
    284236} 
  • trunk/components/loci-plugins/src/loci/plugins/util/ImageProcessorSource.java

    r6130 r6155  
    5151  // -- Constructors -- 
    5252 
    53   public ImageProcessorSource(IFormatReader reader) throws CacheException { 
     53  public ImageProcessorSource(IFormatReader reader) { 
    5454    if (reader instanceof ImageProcessorReader) { 
    5555      this.reader = (ImageProcessorReader) reader; 
  • trunk/components/loci-plugins/src/loci/plugins/util/LociPrefs.java

    r5880 r6155  
    2727 
    2828import ij.Prefs; 
     29 
     30import loci.formats.ClassList; 
    2931import loci.formats.IFormatReader; 
     32import loci.formats.ImageReader; 
     33import loci.formats.in.ND2Reader; 
     34import loci.formats.in.PictReader; 
     35import loci.formats.in.QTReader; 
     36import loci.formats.in.SDTReader; 
     37import loci.formats.in.TiffDelegateReader; 
    3038 
    3139/** 
     
    5664 
    5765  /** 
     66   * Creates an image reader according to the current configuration settings, 
     67   * including which format readers are currently enabled, as well as 
     68   * format-specific configuration settings. 
     69   */ 
     70  public static ImageReader makeImageReader() { 
     71    ClassList<IFormatReader> defaultClasses = 
     72      ImageReader.getDefaultReaderClasses(); 
     73    Class<? extends IFormatReader>[] c = defaultClasses.getClasses(); 
     74 
     75    // include only enabled classes 
     76    ClassList<IFormatReader> enabledClasses = 
     77      new ClassList<IFormatReader>(IFormatReader.class); 
     78    for (int i=0; i<c.length; i++) { 
     79      boolean on = LociPrefs.isReaderEnabled(c[i]); 
     80      if (on) enabledClasses.addClass(c[i]); 
     81    } 
     82    ImageReader reader = new ImageReader(enabledClasses); 
     83 
     84    // toggle reader-specific options 
     85    boolean nd2Nikon = LociPrefs.isND2Nikon(); 
     86    boolean pictQTJava = LociPrefs.isPictQTJava(); 
     87    boolean qtQTJava = LociPrefs.isQTQTJava(); 
     88    boolean sdtIntensity = LociPrefs.isSDTIntensity(); 
     89    boolean tiffImageIO = LociPrefs.isTiffImageIO(); 
     90    IFormatReader[] r = reader.getReaders(); 
     91    for (int i=0; i<r.length; i++) { 
     92      if (r[i] instanceof ND2Reader) { 
     93        ND2Reader nd2 = (ND2Reader) r[i]; 
     94        nd2.setLegacy(nd2Nikon); 
     95      } 
     96      else if (r[i] instanceof PictReader) { 
     97        PictReader pict = (PictReader) r[i]; 
     98        pict.setLegacy(pictQTJava); 
     99      } 
     100      else if (r[i] instanceof QTReader) { 
     101        QTReader qt = (QTReader) r[i]; 
     102        qt.setLegacy(qtQTJava); 
     103      } 
     104      else if (r[i] instanceof SDTReader) { 
     105        SDTReader sdt = (SDTReader) r[i]; 
     106        sdt.setIntensity(sdtIntensity); 
     107      } 
     108      else if (r[i] instanceof TiffDelegateReader) { 
     109        TiffDelegateReader tiff = (TiffDelegateReader) r[i]; 
     110        tiff.setLegacy(tiffImageIO); 
     111      } 
     112    } 
     113 
     114    return reader; 
     115  } 
     116 
     117  /** 
    58118   * Gets whether windowless mode should be used when 
    59119   * opening this reader's currently initialized dataset. 
     
    63123  } 
    64124 
    65   public static boolean isReaderEnabled(Class c) { 
     125  public static boolean isReaderEnabled(Class<? extends IFormatReader> c) { 
    66126    return getPref(PREF_READER_ENABLED, c, true); 
    67127  } 
     
    89149  // -- Helper methods -- 
    90150 
    91   private static boolean getPref(String pref, Class c, boolean defaultValue) { 
     151  private static boolean getPref(String pref, 
     152    Class<? extends IFormatReader> c, boolean defaultValue) 
     153  { 
    92154    String n = c.getName(); 
    93155    String readerName = n.substring(n.lastIndexOf(".") + 1, n.length() - 6); 
  • trunk/components/loci-plugins/src/loci/plugins/util/WindowTools.java

    r6039 r6155  
    2828import ij.IJ; 
    2929import ij.ImageJ; 
     30import ij.gui.GenericDialog; 
    3031 
    3132import java.awt.BorderLayout; 
     33import java.awt.Checkbox; 
    3234import java.awt.Component; 
    3335import java.awt.Container; 
     
    4042import java.awt.Rectangle; 
    4143import java.awt.ScrollPane; 
     44import java.awt.TextField; 
    4245import java.awt.Toolkit; 
    4346import java.awt.Window; 
     
    4548import java.io.PrintStream; 
    4649import java.util.StringTokenizer; 
     50import java.util.Vector; 
    4751 
    4852/** 
     
    190194  } 
    191195 
     196  @SuppressWarnings("unchecked") 
     197  public static Vector<TextField> getNumericFields(GenericDialog gd) { 
     198    return gd.getNumericFields(); 
     199  } 
     200   
     201  @SuppressWarnings("unchecked") 
     202  public static Vector<Checkbox> getCheckboxes(GenericDialog gd) { 
     203    return gd.getCheckboxes(); 
     204  } 
     205   
    192206} 
  • trunk/components/loci-plugins/utils/Read_Image.java

    r6130 r6155  
    1616import loci.formats.IFormatReader; 
    1717import loci.plugins.util.ImageProcessorReader; 
     18import loci.plugins.util.LociPrefs; 
    1819 
    1920/** A very simple example of using Bio-Formats in an ImageJ plugin. */ 
     
    2526    String id = dir + name; 
    2627    ImageProcessorReader r = new ImageProcessorReader( 
    27       new ChannelSeparator(ImageProcessorReader.makeImageReader())); 
     28      new ChannelSeparator(LociPrefs.makeImageReader())); 
    2829    try { 
    2930      IJ.showStatus("Examining file " + name); 
  • trunk/components/stubs/lwf-stubs/src/com/luratech/lwf/lwfDecoder.java

    r6050 r6155  
    4646public class lwfDecoder { 
    4747 
     48  /** 
     49         * @param stream 
     50   * @param password 
     51   * @param licenseCode 
     52   * @throws IOException 
     53         */ 
    4854  public lwfDecoder(InputStream stream, String password, String licenseCode) 
    4955    throws IOException, SecurityException 
     
    5965  } 
    6066 
     67  /** 
     68         * @param image 
     69   * @param limit 
     70   * @param quality 
     71   * @param scale 
     72         */ 
    6173  public void decodeToMemoryGray8(byte[] image, int limit, 
    6274    int quality, int scale) throws SecurityException 
     
    6476  } 
    6577 
     78  /** 
     79   * @param image 
     80   * @param imageoffset 
     81   * @param limit 
     82   * @param quality 
     83   * @param scale 
     84   * @param pdx 
     85   * @param pdy 
     86   * @param clip_x 
     87   * @param clip_y 
     88   * @param clip_w 
     89   * @param clip_h 
     90   * @throws SecurityException 
     91   */ 
    6692  public void decodeToMemoryGray16(short[] image, int imageoffset, int limit, 
    6793    int quality, int scale, int pdx, int pdy, int clip_x, int clip_y, 
Note: See TracChangeset for help on using the changeset viewer.