/**
 *
 */
package de.rico.editor.gui.filter;

import java.io.File;

import javax.swing.filechooser.FileFilter;

/**
 * A filter that accepts only certain image formats (jpg, png, bmp).
 * @author Frank Bruns
 *
 */
public class FilterImage extends FileFilter
{

	/* (non-Javadoc)
	 * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
	 */
	@Override
	public boolean accept(File file)
	{
		String filename = file.getName();
		return filename.endsWith(".jpg") || filename.endsWith(".JPG")
				|| filename.endsWith(".png") || filename.endsWith(".PNG")
				|| filename.endsWith(".bmp") || filename.endsWith(".BMP")
				|| file.isDirectory();
	}

	/* (non-Javadoc)
	 * @see javax.swing.filechooser.FileFilter#getDescription()
	 */
	@Override
	public String getDescription()
	{
		return "*.jpg, *.png, *.bmp";
	}

}
