X-Git-Url: https://git.hedgecode.org/?p=chesshog.git;a=blobdiff_plain;f=chesshog-graphics%2Fsrc%2Fmain%2Fjava%2Forg%2Fhedgecode%2Fchess%2Fimg%2FImageFormat.java;fp=chesshog-graphics%2Fsrc%2Fmain%2Fjava%2Forg%2Fhedgecode%2Fchess%2Fimg%2FImageFormat.java;h=238a7b42d98fe7b62c804989d90d65d5e5d6936b;hp=95380ba8ba7e0df422073192d9fdd10abb56b372;hb=0b24d5b71c19ba38060297084ad39685f76a8539;hpb=cc2bc357ce3c21a0b092af8b2ba3e174d10cac81 diff --git a/chesshog-graphics/src/main/java/org/hedgecode/chess/img/ImageFormat.java b/chesshog-graphics/src/main/java/org/hedgecode/chess/img/ImageFormat.java index 95380ba..238a7b4 100644 --- a/chesshog-graphics/src/main/java/org/hedgecode/chess/img/ImageFormat.java +++ b/chesshog-graphics/src/main/java/org/hedgecode/chess/img/ImageFormat.java @@ -23,41 +23,54 @@ import java.util.List; import javax.imageio.ImageIO; /** - * Supported image formats for reading/writing. + * Supported image formats for reading/writing, indicated by type. * * @author Dmitry Samoshin aka gotty */ public enum ImageFormat { - PNG ( new String[]{"png"} ), - GIF ( new String[]{"gif"} ), - JPG ( new String[]{"jpg", "jpeg"} ), - SVG ( new String[]{"svg"} ), // todo - BMP ( new String[]{"bmp", "wbmp"} ); + PNG ( Type.BITMAP, new String[]{"png"} ), + GIF ( Type.BITMAP, new String[]{"gif"} ), + JPG ( Type.BITMAP, new String[]{"jpg", "jpeg"} ), + BMP ( Type.BITMAP, new String[]{"bmp", "wbmp"} ), + SVG ( Type.VECTOR, new String[]{"svg"} ); - private String[] fortmatExts; + enum Type { + + BITMAP, + VECTOR + + } + + private Type formatType; + private String[] formatExts; private boolean isRead; private boolean isWrite; private static String[] allAvailableExts; - ImageFormat(String[] exts) { - fortmatExts = exts; + ImageFormat(Type type, String[] exts) { + formatType = type; + formatExts = exts; isRead = isExist( - ImageIO.getReaderFormatNames(), fortmatExts + ImageIO.getReaderFormatNames(), formatExts ); isWrite = isExist( - ImageIO.getWriterFormatNames(), fortmatExts + ImageIO.getWriterFormatNames(), formatExts ); } + public Type getType() { + return formatType; + } + public String getExt() { - return fortmatExts[0]; + return formatExts[0]; } public String[] getExts() { - return fortmatExts; + return formatExts; } public boolean isRead() { @@ -99,15 +112,4 @@ public enum ImageFormat { return false; } - -/* - public static void main(String[] args) { - ImageFormat imageFormat = JPG; - System.out.println("Supported format: " + imageFormat); - imageFormat = findFormat("jpeg"); - imageFormat = findFormat("svg"); - imageFormat = findFormat("jpeeg"); - } -*/ - } \ No newline at end of file