001/* 002 * Copyright 2010-2015 Institut Pasteur. 003 * 004 * This file is part of Icy. 005 * 006 * Icy is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * Icy is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with Icy. If not, see <http://www.gnu.org/licenses/>. 018 */ 019package icy.file; 020 021import loci.formats.gui.ExtensionFileFilter; 022 023/** 024 * @deprecated Use {@link ImageFileFormat} instead. 025 */ 026@Deprecated 027public enum FileFormat 028{ 029 TIFF 030 { 031 @Override 032 public String[] getExtensions() 033 { 034 return new String[] {"tif", "tiff"}; 035 } 036 037 @Override 038 public String getDescription() 039 { 040 return "TIFF images"; 041 } 042 }, 043 PNG 044 { 045 @Override 046 public String[] getExtensions() 047 { 048 return new String[] {"png"}; 049 } 050 051 @Override 052 public String getDescription() 053 { 054 return "PNG images"; 055 } 056 }, 057 LSM 058 { 059 @Override 060 public String[] getExtensions() 061 { 062 return new String[] {"lsm"}; 063 } 064 065 @Override 066 public String getDescription() 067 { 068 return "LSM images"; 069 } 070 }, 071 JPG 072 { 073 @Override 074 public String[] getExtensions() 075 { 076 return new String[] {"jpg", "jpeg"}; 077 } 078 079 @Override 080 public String getDescription() 081 { 082 return "JPG images"; 083 } 084 }, 085 AVI 086 { 087 @Override 088 public String[] getExtensions() 089 { 090 return new String[] {"avi"}; 091 } 092 093 @Override 094 public String getDescription() 095 { 096 return "AVI sequences"; 097 } 098 }; 099 100 public ExtensionFileFilter getExtensionFileFilter() 101 { 102 return new ExtensionFileFilter(getExtensions(), getDescription()); 103 } 104 105 /** 106 * Get file format description 107 */ 108 public String getDescription() 109 { 110 return "unknow"; 111 } 112 113 /** 114 * Get file format extensions 115 */ 116 public String[] getExtensions() 117 { 118 return new String[] {""}; 119 } 120 121 /** 122 * Return true if the specified extension matches this format.<br> 123 * <code>defaultValue</code> is returned if no matching format is found (it can be null). 124 */ 125 public boolean matches(String ext) 126 { 127 if (ext == null) 128 return false; 129 130 // always consider lower case extension 131 final String extLC = ext.toLowerCase(); 132 133 for (String e : getExtensions()) 134 if (e.equals(extLC)) 135 return true; 136 137 return false; 138 } 139 140 /** 141 * Return the FileFormat corresponding to specified extension.<br> 142 * <code>defaultValue</code> is returned if no matching format is found. 143 */ 144 public static FileFormat getFileFormat(String ext, FileFormat defaultValue) 145 { 146 for (FileFormat ff : values()) 147 if (ff.matches(ext)) 148 return ff; 149 150 return defaultValue; 151 } 152 153 /** 154 * @deprecated Use {@link #getFileFormat(String, FileFormat)} instead. 155 */ 156 @Deprecated 157 public static FileFormat getFileFormat(String ext) 158 { 159 return getFileFormat(ext, null); 160 } 161}