package com.example;

import javax.swing.*;

/**
 * TODO fix image sizes
 * @author innokenty
 */
public enum Icon {
    OOPS("img/oops.png"),
    SORRY_BRO("img/sorry-bro.jpg"),
    UP("img/up.png"),
    GHOST("img/ghost.png"),
    PLUS("img/plus.png"),
    ZOOM_IN("img/zoom_in.png"),
    ZOOM_OUT("img/zoom_out.png"),
    ZOOM_EXPAND("img/zoom_expand.png"),
    ZOOM_SHRINK("img/zoom_shrink.png"),
    ;

    private final String resourceName;

    Icon(String resourceName) {
        this.resourceName = resourceName;
    }

    public ImageIcon build() {
        return new ImageIcon(this
                .getClass()
                .getClassLoader()
                .getResource(resourceName));
    }
}

@@ -32,45 +32,156 @@
 vax.
-swing.*;%0A%0A/**%0A * TODO fix image sizes
+imageio.ImageIO;%0Aimport javax.swing.*;%0Aimport java.awt.*;%0Aimport java.awt.image.BufferedImage;%0Aimport java.io.IOException;%0Aimport java.net.URL;%0A%0A/**
 %0A * 
@@ -504,21 +504,81 @@
 k.png%22),
+;%0A
 %0A    
+private static final int SCALE_METHOD = Image.SCALE_SMOOTH
 ;%0A%0A    p
@@ -693,16 +693,130 @@
 %0A    %7D%0A%0A
+    private URL getResource() %7B%0A        return this.getClass().getClassLoader().getResource(resourceName);%0A    %7D%0A%0A
     publ
@@ -871,40 +871,120 @@
 con(
-this
+getResource());
 %0A    
+%7D%0A%0A
     
-        .getClass
+public ImageIcon build(int width, int height) %7B%0A        URL resource = getResource
 ()
+;
 %0A   
@@ -992,78 +992,299 @@
     
- 
+try %7B%0A
        
-.getClassLoader()%0A                .getResource(resourceName));
+     BufferedImage image = ImageIO.read(resource);%0A            Image scaled = image.getScaledInstance(width, height, SCALE_METHOD);%0A            return new ImageIcon(scaled);%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A            return build();%0A        %7D
 %0A   

add - add method to get scaled image to Icon enum