Changeset 7950


Ignore:
Timestamp:
04/04/12 16:12:10 (8 years ago)
Author:
aivar
Message:

SLIM Plugin: Trac #695 Problem finding LUT when running from a shortcut.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/projects/slim-plugin/src/main/java/loci/slim/histogram/HistogramTool.java

    r7933 r7950  
    101101    public static IndexColorModel getIndexColorModel() { 
    102102        IndexColorModel colorModel = null; 
    103         // 'getDirectory("luts")' works in IJ but not during NetBeans development 
    104         //TODO On Linux with a link to Fiji on the desktop this startup directory is the desktop! 
    105         String startupPath = IJ.getDirectory("startup"); 
    106         String lutPath = startupPath + "luts" + File.separatorChar + LUT; 
     103  
     104        // 'getDirectory("luts")' works in IJ but not in NetBeans development 
     105        String lutPath = IJ.getDirectory("luts"); 
     106        if (null == lutPath) { 
     107            // when you run from a shortcut in Linux 'getDirectory("startup")' 
     108            //   gives you the directory of the link! 
     109            String startupPath = IJ.getDirectory("startup"); 
     110            lutPath = addSeparator(startupPath) + "luts"; 
     111        } 
     112        lutPath = addSeparator(lutPath) + LUT; 
    107113        try { 
    108114            colorModel = LutLoader.open(lutPath); 
     
    121127        colorModel = PaletteFix.fixIndexColorModel(colorModel, Color.BLACK, Color.WHITE); 
    122128        return colorModel; 
     129    } 
     130     
     131    private static String addSeparator(String path) { 
     132        if (!path.endsWith(File.separator)) { 
     133            path += File.separatorChar; 
     134        } 
     135        return path; 
    123136    } 
    124137 
Note: See TracChangeset for help on using the changeset viewer.