Search in sources :

Example 41 with FunctionException

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

the class VariableBlurFilter 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("PremultiplyAlpha"))) != null)
        setPremultiplyAlpha(ImageFilterUtil.toBooleanValue(o, "PremultiplyAlpha"));
    if ((o = parameters.removeEL(KeyImpl.init("Iterations"))) != null)
        setIterations(ImageFilterUtil.toIntValue(o, "Iterations"));
    if ((o = parameters.removeEL(KeyImpl.init("HRadius"))) != null)
        setHRadius(ImageFilterUtil.toIntValue(o, "HRadius"));
    if ((o = parameters.removeEL(KeyImpl.init("VRadius"))) != null)
        setVRadius(ImageFilterUtil.toIntValue(o, "VRadius"));
    if ((o = parameters.removeEL(KeyImpl.init("Radius"))) != null)
        setRadius(ImageFilterUtil.toIntValue(o, "Radius"));
    if ((o = parameters.removeEL(KeyImpl.init("BlurMask"))) != null)
        setBlurMask(ImageFilterUtil.toBufferedImage(o, "BlurMask"));
    // 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 [PremultiplyAlpha, Iterations, HRadius, VRadius, Radius, BlurMask]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 42 with FunctionException

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

the class WarpFilter 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("SourceGrid"))) != null)
        setSourceGrid(ImageFilterUtil.toWarpGrid(o, "SourceGrid"));
    if ((o = parameters.removeEL(KeyImpl.init("DestGrid"))) != null)
        setDestGrid(ImageFilterUtil.toWarpGrid(o, "DestGrid"));
    if ((o = parameters.removeEL(KeyImpl.init("Frames"))) != null)
        setFrames(ImageFilterUtil.toIntValue(o, "Frames"));
    if ((o = parameters.removeEL(KeyImpl.init("MorphImage"))) != null)
        setMorphImage(ImageFilterUtil.toBufferedImage(o, "MorphImage"));
    if ((o = parameters.removeEL(KeyImpl.init("Time"))) != null)
        setTime(ImageFilterUtil.toFloatValue(o, "Time"));
    // 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 [SourceGrid, DestGrid, Frames, MorphImage, Time]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 43 with FunctionException

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

the class WaterFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    // ImageUtil.createBufferedImage(src);
    BufferedImage dst = null;
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Radius"))) != null)
        setRadius(ImageFilterUtil.toFloatValue(o, "Radius"));
    if ((o = parameters.removeEL(KeyImpl.init("CentreX"))) != null)
        setCentreX(ImageFilterUtil.toFloatValue(o, "CentreX"));
    if ((o = parameters.removeEL(KeyImpl.init("CentreY"))) != null)
        setCentreY(ImageFilterUtil.toFloatValue(o, "CentreY"));
    // if((o=parameters.removeEL(KeyImpl.init("Centre")))!=null)setCentre(ImageFilterUtil.toPoint2D(o,"Centre"));
    if ((o = parameters.removeEL(KeyImpl.init("Wavelength"))) != null)
        setWavelength(ImageFilterUtil.toFloatValue(o, "Wavelength"));
    if ((o = parameters.removeEL(KeyImpl.init("Amplitude"))) != null)
        setAmplitude(ImageFilterUtil.toFloatValue(o, "Amplitude"));
    if ((o = parameters.removeEL(KeyImpl.init("Phase"))) != null)
        setPhase(ImageFilterUtil.toFloatValue(o, "Phase"));
    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 [Radius, CentreX, CentreY, Centre, Wavelength, Amplitude, Phase, EdgeAction, Interpolation]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 44 with FunctionException

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

the class WeaveFilter 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("UseImageColors"))) != null)
        setUseImageColors(ImageFilterUtil.toBooleanValue(o, "UseImageColors"));
    if ((o = parameters.removeEL(KeyImpl.init("XGap"))) != null)
        setXGap(ImageFilterUtil.toFloatValue(o, "XGap"));
    if ((o = parameters.removeEL(KeyImpl.init("XWidth"))) != null)
        setXWidth(ImageFilterUtil.toFloatValue(o, "XWidth"));
    if ((o = parameters.removeEL(KeyImpl.init("YWidth"))) != null)
        setYWidth(ImageFilterUtil.toFloatValue(o, "YWidth"));
    if ((o = parameters.removeEL(KeyImpl.init("YGap"))) != null)
        setYGap(ImageFilterUtil.toFloatValue(o, "YGap"));
    if ((o = parameters.removeEL(KeyImpl.init("Crossings"))) != null)
        setCrossings(ImageFilterUtil.toAAInt(o, "Crossings"));
    if ((o = parameters.removeEL(KeyImpl.init("RoundThreads"))) != null)
        setRoundThreads(ImageFilterUtil.toBooleanValue(o, "RoundThreads"));
    if ((o = parameters.removeEL(KeyImpl.init("ShadeCrossings"))) != null)
        setShadeCrossings(ImageFilterUtil.toBooleanValue(o, "ShadeCrossings"));
    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 [UseImageColors, XGap, XWidth, YWidth, YGap, Crossings, RoundThreads, ShadeCrossings, Dimensions]");
    }
    return filter(src, dst);
}
Also used : FunctionException(lucee.runtime.exp.FunctionException) BufferedImage(java.awt.image.BufferedImage)

Example 45 with FunctionException

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

the class BlockFilter method filter.

@Override
public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    // ImageUtil.createBufferedImage(src);
    BufferedImage dst = null;
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("BlockSize"))) != null)
        setBlockSize(ImageFilterUtil.toIntValue(o, "BlockSize"));
    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 [BlockSize, EdgeAction, Interpolation]");
    }
    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