⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spatialfilefilter.java

📁 Java source code for the Ant Colony Optimization Problem.
💻 JAVA
字号:
package jwo.jpss.spatial.gui;

import javax.swing.filechooser.*;
import java.io.File;
			
//  **************************************************************
/** Provides a file filter to allow only spatial files to be 
  * to be displayed in a JFileChooser.
  * @author  Jo Wood.
  * @version 1.3, 11th October, 2001.
  */
//  **************************************************************

public class SpatialFileFilter extends FileFilter
{       
    // ---------------------- Class variables -------------------

    private static final String[] extensions = {"gis","grd","txt","xml"};

    // ------------------- Implemented Methods ------------------
    
    /** Filters only file extensions of known spatial file formats.
      * @param file File to consider displaying.
      * @return true if file has a recognised spatial filename extension.
      */
    public boolean accept(File file) 
    {
        if (file.isDirectory()) 
            return true;
        
        // Find file name extension.
        String fileName = file.getName();
        int i = fileName.lastIndexOf('.');

        if ((i > 0) && (i < fileName.length()-1))
        {
            String ext = fileName.substring(i+1);
            for (int extNum=0; extNum<extensions.length; extNum++)
            {
                if (ext.equalsIgnoreCase(extensions[extNum]))
                    return true;
             }
        }
        return false;
    }
    
    /** Reports the description of this filter for the file chooser.
      * @return Description of this filter.
      */
    public String getDescription() 
    {
        return new String("Spatial files");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -