package org.yggard.brokkgui.style.adapter;

import org.yggard.brokkgui.paint.Texture;

public class TextureStyleAdapter implements IStyleAdapter<Texture>
{
    @Override
    public Texture decode(String style)
    {
        if (!style.startsWith("url("))
            return null;

        String[] splitted = style.replace("url(", "").replace(")", "").split(",");

        switch (splitted.length)
        {
            case 1:
                return new Texture(splitted[0].replace("\"", "").trim());
            case 3:
                return new Texture(splitted[0].replace("\"", "").trim(), Integer.parseInt(splitted[1].trim()),
                        Integer.parseInt(splitted[2].trim()));
            case 5:
                return new Texture(splitted[0].replace("\"", "").trim(), Integer.parseInt(splitted[1].trim()),
                        Integer.parseInt(splitted[2].trim()), Integer.parseInt(splitted[3].trim()),
                        Integer.parseInt(splitted[4].trim()));
            default:
                return null;
        }
    }
}

@@ -584,39 +584,39 @@
 %22%22).trim(), 
-Integer
+Float
 .parse
-In
+Floa
 t(splitted%5B1
@@ -646,39 +646,39 @@
             
-Integer
+Float
 .parse
-In
+Floa
 t(splitted%5B2
@@ -782,31 +782,31 @@
 trim(), 
-Integer
+Float
 .parse
-In
+Floa
 t(splitt
@@ -840,39 +840,39 @@
             
-Integer
+Float
 .parse
-In
+Floa
 t(splitted%5B2
@@ -882,31 +882,31 @@
 rim()), 
-Integer
+Float
 .parse
-In
+Floa
 t(splitt
@@ -948,23 +948,23 @@
     
-Integer
+Float
 .parse
-In
+Floa
 t(sp

Fix texture style adapter float parsing