Search in sources :

Example 26 with FunctionException

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

the class RotateFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    // BufferedImage dst=ImageUtil.createBufferedImage(src,src.getWidth()+400,src.getHeight()+400);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Angle"))) != null)
        setAngle(ImageFilterUtil.toFloatValue(o, "Angle"));
    if ((o = parameters.removeEL(KeyImpl.init("EdgeAction"))) != null)
        setEdgeAction(ImageFilterUtil.toString(o, "EdgeAction"));
    if ((o = parameters.removeEL(KeyImpl.init("Interpolation"))) != null)
        setInterpolation(ImageFilterUtil.toString(o, "Interpolation"));
    // 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 [Angle, EdgeAction, Interpolation]");
    }
    // Rectangle rect = new Rectangle(0, 0, src.getWidth(), src.getHeight());
    // transformSpace(rect);
    // ImageUtil.createBufferedImage(src,rect.width,rect.height);
    BufferedImage dst = null;
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 27 with FunctionException

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

the class SaturationFilter 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("Amount"))) != null)
        setAmount(ImageFilterUtil.toFloatValue(o, "Amount"));
    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 [Amount, Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 28 with FunctionException

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

the class ScratchFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    // ImageUtil.createBufferedImage(src);
    BufferedImage dst = src;
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Angle"))) != null)
        setAngle(ImageFilterUtil.toFloatValue(o, "Angle"));
    if ((o = parameters.removeEL(KeyImpl.init("Density"))) != null)
        setDensity(ImageFilterUtil.toFloatValue(o, "Density"));
    if ((o = parameters.removeEL(KeyImpl.init("AngleVariation"))) != null)
        setAngleVariation(ImageFilterUtil.toFloatValue(o, "AngleVariation"));
    if ((o = parameters.removeEL(KeyImpl.init("Length"))) != null)
        setLength(ImageFilterUtil.toFloatValue(o, "Length"));
    if ((o = parameters.removeEL(KeyImpl.init("Seed"))) != null)
        setSeed(ImageFilterUtil.toIntValue(o, "Seed"));
    if ((o = parameters.removeEL(KeyImpl.init("Color"))) != null)
        setColor(ImageFilterUtil.toColorRGB(o, "Color"));
    if ((o = parameters.removeEL(KeyImpl.init("Width"))) != null)
        setWidth(ImageFilterUtil.toFloatValue(o, "Width"));
    // 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 [Angle, Density, AngleVariation, Length, Seed, Color, Width]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 29 with FunctionException

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

the class ShadeFilter 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("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("EnvironmentMap"))) != null)
        setEnvironmentMap(ImageFilterUtil.toBufferedImage(o, "EnvironmentMap"));
    if ((o = parameters.removeEL(KeyImpl.init("BumpSource"))) != null)
        setBumpSource(ImageFilterUtil.toIntValue(o, "BumpSource"));
    // 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 [BumpFunction, BumpHeight, BumpSoftness, EnvironmentMap, BumpSource]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 30 with FunctionException

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

the class ShadowFilter 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("Radius"))) != null)
        setRadius(ImageFilterUtil.toFloatValue(o, "Radius"));
    if ((o = parameters.removeEL(KeyImpl.init("Angle"))) != null)
        setAngle(ImageFilterUtil.toFloatValue(o, "Angle"));
    if ((o = parameters.removeEL(KeyImpl.init("Distance"))) != null)
        setDistance(ImageFilterUtil.toFloatValue(o, "Distance"));
    if ((o = parameters.removeEL(KeyImpl.init("Opacity"))) != null)
        setOpacity(ImageFilterUtil.toFloatValue(o, "Opacity"));
    if ((o = parameters.removeEL(KeyImpl.init("ShadowColor"))) != null)
        setShadowColor(ImageFilterUtil.toColorRGB(o, "ShadowColor"));
    if ((o = parameters.removeEL(KeyImpl.init("AddMargins"))) != null)
        setAddMargins(ImageFilterUtil.toBooleanValue(o, "AddMargins"));
    if ((o = parameters.removeEL(KeyImpl.init("ShadowOnly"))) != null)
        setShadowOnly(ImageFilterUtil.toBooleanValue(o, "ShadowOnly"));
    // 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 [Radius, Angle, Distance, Opacity, ShadowColor, AddMargins, ShadowOnly]");
    }
    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