[LIB-9] Add functional for transcoding vector images
[chesshog.git] / chesshog-graphics / src / main / java / org / hedgecode / chess / img / ImageFormat.java
index 95380ba..238a7b4 100644 (file)
@@ -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