Changeset 6007


Ignore:
Timestamp:
03/09/10 13:15:54 (10 years ago)
Author:
curtis
Message:

Clean up some unchecked operations.

Location:
trunk/components/loci-plugins/src/loci/plugins
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/loci-plugins/src/loci/plugins/LociExporter.java

    r5111 r6007  
    6767  public void run(ImageProcessor ip) { 
    6868    if (!LibraryChecker.checkJava() || !LibraryChecker.checkImageJ()) return; 
    69     HashSet missing = new HashSet(); 
     69    HashSet<String> missing = new HashSet<String>(); 
    7070    LibraryChecker.checkLibrary(LibraryChecker.Library.BIO_FORMATS, missing); 
    7171    LibraryChecker.checkLibrary(LibraryChecker.Library.OME_JAVA_XML, missing); 
  • trunk/components/loci-plugins/src/loci/plugins/LociImporter.java

    r5111 r6007  
    7070    success = false; 
    7171    if (!LibraryChecker.checkJava() || !LibraryChecker.checkImageJ()) return; 
    72     HashSet missing = new HashSet(); 
     72    HashSet<String> missing = new HashSet<String>(); 
    7373    LibraryChecker.checkLibrary(LibraryChecker.Library.BIO_FORMATS, missing); 
    7474    LibraryChecker.checkLibrary(LibraryChecker.Library.OME_JAVA_XML, missing); 
  • trunk/components/loci-plugins/src/loci/plugins/config/ConfigWindow.java

    r5139 r6007  
    298298    FormatEntry[] formats = null; 
    299299    try { 
    300       Class irClass = Class.forName("loci.formats.ImageReader"); 
     300      Class<?> irClass = Class.forName("loci.formats.ImageReader"); 
    301301      Object ir = irClass.newInstance(); 
    302302      Method getClasses = irClass.getMethod("getReaders"); 
     
    330330    String qtVersion = null; 
    331331    try { 
    332       Class qtToolsClass = Class.forName("loci.formats.LegacyQTTools"); 
     332      Class<?> qtToolsClass = Class.forName("loci.formats.LegacyQTTools"); 
    333333      Object qtTools = qtToolsClass.newInstance(); 
    334334      Method getQTVersion = qtToolsClass.getMethod("getQTVersion"); 
     
    342342    String clibIIOVersion = null; 
    343343    try { 
    344       Class jpegSpi = Class.forName( 
     344      Class<?> jpegSpi = Class.forName( 
    345345        "com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReaderSpi"); 
    346346      IIORegistry registry = IIORegistry.getDefaultInstance(); 
     
    360360    String matlabVersion = null; 
    361361    try { 
    362       Class matlabClass = Class.forName("com.mathworks.jmi.Matlab"); 
     362      Class<?> matlabClass = Class.forName("com.mathworks.jmi.Matlab"); 
    363363      Object matlab = matlabClass.newInstance(); 
    364364      Method eval = matlabClass.getMethod("eval", new Class[] {String.class}); 
     
    612612    InvocationTargetException 
    613613  { 
    614     Class utilClass = Class.forName("loci.plugins.util.LociPrefs"); 
     614    Class<?> utilClass = Class.forName("loci.plugins.util.LociPrefs"); 
    615615    Field field = utilClass.getField(fieldName); 
    616616    String key = field.get(null) + "." + entry.readerName; 
    617     Class prefsClass = Class.forName("ij.Prefs"); 
     617    Class<?> prefsClass = Class.forName("ij.Prefs"); 
    618618    Method method = prefsClass.getMethod(methodName, PARAMS); 
    619619    Object[] args = {key, value ? Boolean.TRUE : Boolean.FALSE}; 
  • trunk/components/loci-plugins/src/loci/plugins/config/FormatEntry.java

    r5523 r6007  
    5454  public FormatEntry(PrintWriter log, Object reader) { 
    5555    this.reader = reader; 
    56     Class readerClass = reader.getClass(); 
     56    Class<?> readerClass = reader.getClass(); 
    5757    String n = readerClass.getName(); 
    5858    readerName = n.substring(n.lastIndexOf(".") + 1, n.length() - 6); 
     
    9494  // -- Comparable API methods -- 
    9595 
     96  public int compareTo(Object o) { 
     97    return toString().compareTo(o.toString()); 
     98  } 
     99 
     100  // -- Object API methods -- 
     101 
    96102  public int hashCode() { 
    97103    return toString().hashCode(); 
     
    100106  public boolean equals(Object o) { 
    101107    if (o == null) return false; 
    102     return compareTo(o) == 0; 
     108    if (!(o instanceof FormatEntry)) return false; 
     109    return compareTo((FormatEntry) o) == 0; 
    103110  } 
    104  
    105   public int compareTo(Object o) { 
    106     return toString().compareTo(o.toString()); 
    107   } 
    108  
    109   // -- Object API methods -- 
    110111 
    111112  public String toString() { 
  • trunk/components/loci-plugins/src/loci/plugins/importer/Importer.java

    r5886 r6007  
    4343import java.io.File; 
    4444import java.io.IOException; 
    45 import java.util.Arrays; 
     45import java.util.ArrayList; 
     46import java.util.Collections; 
    4647import java.util.Enumeration; 
    4748import java.util.Hashtable; 
    48 import java.util.Vector; 
    4949 
    5050import loci.common.Location; 
     
    9393  private LociImporter plugin; 
    9494 
    95   private Vector imps = new Vector(); 
     95  private ArrayList<ImagePlus> imps = new ArrayList<ImagePlus>(); 
    9696  private String stackOrder = null; 
    9797 
     
    462462 
    463463      if (options.isConcatenate()) { 
    464         Vector widths = new Vector(); 
    465         Vector heights = new Vector(); 
    466         Vector types = new Vector(); 
    467         Vector newImps = new Vector(); 
     464        ArrayList<Integer> widths = new ArrayList<Integer>(); 
     465        ArrayList<Integer> heights = new ArrayList<Integer>(); 
     466        ArrayList<Integer> types = new ArrayList<Integer>(); 
     467        ArrayList<ImagePlus> newImps = new ArrayList<ImagePlus>(); 
    468468 
    469469        for (int j=0; j<imps.size(); j++) { 
    470           ImagePlus imp = (ImagePlus) imps.get(j); 
     470          ImagePlus imp = imps.get(j); 
    471471          int wj = imp.getWidth(); 
    472472          int hj = imp.getHeight(); 
     
    479479 
    480480            if (wj == wk && hj == hk && tj == tk) { 
    481               ImagePlus oldImp = (ImagePlus) newImps.get(k); 
     481              ImagePlus oldImp = newImps.get(k); 
    482482              ImageStack is = oldImp.getStack(); 
    483483              ImageStack newStack = imp.getStack(); 
     
    487487              } 
    488488              oldImp.setStack(oldImp.getTitle(), is); 
    489               newImps.setElementAt(oldImp, k); 
     489              newImps.set(k, oldImp); 
    490490              append = true; 
    491491              k = widths.size(); 
     
    535535        BF.debug("display ROIs"); 
    536536 
    537         ROIHandler.openROIs(options.getMetadata(), 
    538           (ImagePlus[]) imps.toArray(new ImagePlus[0])); 
     537        ImagePlus[] impsArray = imps.toArray(new ImagePlus[0]); 
     538        ROIHandler.openROIs(options.getMetadata(), impsArray); 
    539539      } 
    540540      else BF.debug("skip ROIs"); 
     
    828828  /** Returns a string with each key/value pair on its own line. */ 
    829829  private String getMetadataString(Hashtable meta, String separator) { 
    830     Enumeration e = meta.keys(); 
    831     Vector v = new Vector(); 
    832     while (e.hasMoreElements()) v.add(e.nextElement()); 
    833     String[] keys = new String[v.size()]; 
    834     v.copyInto(keys); 
    835     Arrays.sort(keys); 
     830    ArrayList<String> keys = new ArrayList<String>(meta.keySet()); 
     831    Collections.sort(keys); 
    836832 
    837833    StringBuffer sb = new StringBuffer(); 
    838     for (int i=0; i<keys.length; i++) { 
    839       sb.append(keys[i]); 
     834    for (String key : keys) { 
     835      sb.append(key); 
    840836      sb.append(separator); 
    841       sb.append(meta.get(keys[i])); 
     837      sb.append(meta.get(key)); 
    842838      sb.append("\n"); 
    843839    } 
  • trunk/components/loci-plugins/src/loci/plugins/importer/ImporterDialog.java

    r5729 r6007  
    3939import java.awt.event.MouseEvent; 
    4040import java.awt.event.MouseListener; 
    41 import java.util.Hashtable; 
     41import java.util.HashMap; 
    4242import java.util.Vector; 
    4343 
     
    9696  protected Checkbox virtualBox; 
    9797 
    98   protected Hashtable infoTable; 
     98  protected HashMap<Component, String> infoTable; 
    9999  protected JEditorPane infoPane; 
    100100 
     
    195195 
    196196    // associate information for each option 
    197     infoTable = new Hashtable(); 
     197    infoTable = new HashMap<Component, String>(); 
    198198    infoTable.put(autoscaleBox, options.getAutoscaleInfo()); 
    199199    infoTable.put(colorizeBox, options.getColorizeInfo()); 
  • trunk/components/loci-plugins/src/loci/plugins/shortcut/ShortcutPanel.java

    r5144 r6007  
    3636import java.io.InputStreamReader; 
    3737import java.net.URL; 
    38 import java.util.Vector; 
     38import java.util.ArrayList; 
    3939 
    4040import javax.swing.BoxLayout; 
     
    9191    // load list of LOCI plugins 
    9292    int index = -1; 
    93     Vector vNames = new Vector(); 
    94     Vector vPlugins = new Vector(); 
    95     Vector vArgs = new Vector(); 
     93    ArrayList<String> vNames = new ArrayList<String>(); 
     94    ArrayList<String> vPlugins = new ArrayList<String>(); 
     95    ArrayList<String> vArgs = new ArrayList<String>(); 
    9696 
    9797    // read from configuration file 
     
    139139 
    140140    openerIndex = index; 
    141     names = new String[vNames.size()]; 
    142     vNames.copyInto(names); 
    143     plugins = new String[vPlugins.size()]; 
    144     vPlugins.copyInto(plugins); 
    145     args = new String[vArgs.size()]; 
    146     vArgs.copyInto(args); 
     141    names = vNames.toArray(new String[0]); 
     142    plugins = vPlugins.toArray(new String[0]); 
     143    args = vArgs.toArray(new String[0]); 
    147144  } 
    148145 
  • trunk/components/loci-plugins/src/loci/plugins/shortcut/ShortcutTransferHandler.java

    r5093 r6007  
    3131import java.io.File; 
    3232import java.io.IOException; 
     33import java.util.Arrays; 
    3334import java.util.List; 
    3435import java.util.StringTokenizer; 
    35 import java.util.Vector; 
    3636 
    3737import javax.swing.JComponent; 
     
    8787      else if (fileIndex >= 0) { 
    8888        File f = (File) t.getTransferData(flavors[fileIndex]); 
    89         list = new Vector(); 
    90         list.add(f); 
     89        list = Arrays.asList(f); 
    9190      } 
    9291      else if (stringIndex >= 0) { 
    9392        String s = (String) t.getTransferData(flavors[stringIndex]); 
    94         list = new Vector(); 
    95         StringTokenizer st = new StringTokenizer(s); 
    96         while (st.hasMoreTokens()) list.add(st.nextToken()); 
     93        list = Arrays.asList(s.split("[ \t\n\r\f]")); 
     94        //StringTokenizer st = new StringTokenizer(s); 
     95        //while (st.hasMoreTokens()) list.add(st.nextToken()); 
    9796      } 
    9897      if (list == null) { 
  • trunk/components/loci-plugins/src/loci/plugins/util/LibraryChecker.java

    r5989 r6007  
    7676 
    7777  /** Checks for a required library. */ 
    78   public static void checkLibrary(Library library, HashSet missing) { 
     78  public static void checkLibrary(Library library, HashSet<String> missing) { 
    7979    switch (library) { 
    8080      case BIO_FORMATS: 
     
    112112   */ 
    113113  public static void checkLibrary(String className, 
    114     String jarFile, HashSet missing) 
     114    String jarFile, HashSet<String> missing) 
    115115  { 
    116116    if (!checkClass(className)) missing.add(jarFile); 
     
    166166   * @return true iff no libraries are missing (the hash set is empty). 
    167167   */ 
    168   public static boolean checkMissing(HashSet missing) { 
     168  public static boolean checkMissing(HashSet<String> missing) { 
    169169    int num = missing.size(); 
    170170    if (num == 0) return true; 
Note: See TracChangeset for help on using the changeset viewer.