Search in sources :

Example 66 with FunctionException

use of lucee.runtime.exp.FunctionException in project Lucee by lucee.

the class ImageFilterUtil method toLightFilter$Material.

public static LightFilter.Material toLightFilter$Material(Object value, String argName) throws PageException {
    if (value instanceof LightFilter.Material)
        return (LightFilter.Material) value;
    Struct sct = Caster.toStruct(value, null);
    if (sct != null) {
        Material material = new LightFilter.Material();
        material.setDiffuseColor(toColorRGB(sct.get("color"), argName + ".color"));
        material.setOpacity(Caster.toFloatValue(sct.get("opacity")));
        return material;
    }
    String str = Caster.toString(value, null);
    if (str != null) {
        String[] arr = ListUtil.listToStringArray(str, ',');
        if (arr.length == 2) {
            Material material = new LightFilter.Material();
            material.setDiffuseColor(toColorRGB(arr[0], argName + "[1]"));
            material.setOpacity(Caster.toFloatValue(arr[1]));
            return material;
        }
        throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "use the following format [color,opacity]");
    }
    throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "use the following format [\"color,opacity\"] or [{color='#cc0033',opacity=0.5}]");
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) Material(lucee.runtime.img.filter.LightFilter.Material) Struct(lucee.runtime.type.Struct)

Example 67 with FunctionException

use of lucee.runtime.exp.FunctionException in project Lucee by lucee.

the class InterpolateFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Interpolation"))) != null)
        setInterpolation(ImageFilterUtil.toFloatValue(o, "Interpolation"));
    if ((o = parameters.removeEL(KeyImpl.init("destination"))) != null)
        setDestination(ImageFilterUtil.toBufferedImage(o, "destination"));
    // check for arguments not supported
    if (parameters.size() > 0) {
        throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "the parameter" + (parameters.size() > 1 ? "s" : "") + " [" + CollectionUtil.getKeyList(parameters, ", ") + "] " + (parameters.size() > 1 ? "are" : "is") + " not allowed, only the following parameters are supported [Interpolation]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 68 with FunctionException

use of lucee.runtime.exp.FunctionException in project Lucee by lucee.

the class InvertFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Dimensions"))) != null) {
        int[] dim = ImageFilterUtil.toDimensions(o, "Dimensions");
        setDimensions(dim[0], dim[1]);
    }
    // check for arguments not supported
    if (parameters.size() > 0) {
        throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "the parameter" + (parameters.size() > 1 ? "s" : "") + " [" + CollectionUtil.getKeyList(parameters, ", ") + "] " + (parameters.size() > 1 ? "are" : "is") + " not allowed, only the following parameters are supported [Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 69 with FunctionException

use of lucee.runtime.exp.FunctionException in project Lucee by lucee.

the class JavaLnFFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Dimensions"))) != null) {
        int[] dim = ImageFilterUtil.toDimensions(o, "Dimensions");
        setDimensions(dim[0], dim[1]);
    }
    // check for arguments not supported
    if (parameters.size() > 0) {
        throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "the parameter" + (parameters.size() > 1 ? "s" : "") + " [" + CollectionUtil.getKeyList(parameters, ", ") + "] " + (parameters.size() > 1 ? "are" : "is") + " not allowed, only the following parameters are supported [Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 70 with FunctionException

use of lucee.runtime.exp.FunctionException in project Lucee by lucee.

the class LightFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("ColorSource"))) != null)
        setColorSource(ImageFilterUtil.toColorRGB(o, "ColorSource"));
    if ((o = parameters.removeEL(KeyImpl.init("Material"))) != null)
        setMaterial(ImageFilterUtil.toLightFilter$Material(o, "Material"));
    if ((o = parameters.removeEL(KeyImpl.init("BumpFunction"))) != null)
        setBumpFunction(ImageFilterUtil.toFunction2D(o, "BumpFunction"));
    if ((o = parameters.removeEL(KeyImpl.init("BumpHeight"))) != null)
        setBumpHeight(ImageFilterUtil.toFloatValue(o, "BumpHeight"));
    if ((o = parameters.removeEL(KeyImpl.init("BumpSoftness"))) != null)
        setBumpSoftness(ImageFilterUtil.toFloatValue(o, "BumpSoftness"));
    if ((o = parameters.removeEL(KeyImpl.init("BumpShape"))) != null)
        setBumpShape(ImageFilterUtil.toIntValue(o, "BumpShape"));
    if ((o = parameters.removeEL(KeyImpl.init("ViewDistance"))) != null)
        setViewDistance(ImageFilterUtil.toFloatValue(o, "ViewDistance"));
    if ((o = parameters.removeEL(KeyImpl.init("EnvironmentMap"))) != null)
        setEnvironmentMap(ImageFilterUtil.toBufferedImage(o, "EnvironmentMap"));
    if ((o = parameters.removeEL(KeyImpl.init("BumpSource"))) != null)
        setBumpSource(ImageFilterUtil.toIntValue(o, "BumpSource"));
    if ((o = parameters.removeEL(KeyImpl.init("DiffuseColor"))) != null)
        setDiffuseColor(ImageFilterUtil.toColorRGB(o, "DiffuseColor"));
    // check for arguments not supported
    if (parameters.size() > 0) {
        throw new FunctionException(ThreadLocalPageContext.get(), "ImageFilter", 3, "parameters", "the parameter" + (parameters.size() > 1 ? "s" : "") + " [" + CollectionUtil.getKeyList(parameters, ", ") + "] " + (parameters.size() > 1 ? "are" : "is") + " not allowed, only the following parameters are supported [ColorSource, Material, BumpFunction, BumpHeight, BumpSoftness, BumpShape, ViewDistance, EnvironmentMap, BumpSource, DiffuseColor]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Aggregations

FunctionException (lucee.runtime.exp.FunctionException)189 BufferedImage (java.awt.image.BufferedImage)123 Image (lucee.runtime.img.Image)17 Struct (lucee.runtime.type.Struct)13 Array (lucee.runtime.type.Array)12 Resource (lucee.commons.io.res.Resource)10 ArrayList (java.util.ArrayList)7 IOException (java.io.IOException)6 Iterator (java.util.Iterator)6 Query (lucee.runtime.type.Query)6 ForEachQueryIterator (lucee.runtime.type.it.ForEachQueryIterator)6 Enumeration (java.util.Enumeration)5 List (java.util.List)5 ListIterator (java.util.ListIterator)5 ExecutorService (java.util.concurrent.ExecutorService)5 Future (java.util.concurrent.Future)5 Iteratorable (lucee.runtime.type.Iteratorable)5 StringListData (lucee.runtime.type.util.StringListData)5 ArrayImpl (lucee.runtime.type.ArrayImpl)4 StructImpl (lucee.runtime.type.StructImpl)4