use of lucee.runtime.exp.FunctionException in project Lucee by lucee.
the class ImageCrop method call.
public static String call(PageContext pc, Object name, double x, double y, double width, double height) throws PageException {
// if(name instanceof String) name=pc.getVariable(Caster.toString(name));
Image img = Image.toImage(pc, name);
if (width < 0)
throw new FunctionException(pc, "ImageCrop", 3, "width", "width must contain a none negative value");
if (height < 0)
throw new FunctionException(pc, "ImageCrop", 4, "height", "width must contain a none negative value");
img.crop((float) x, (float) y, (float) width, (float) height);
return null;
}
use of lucee.runtime.exp.FunctionException in project Lucee by lucee.
the class ImageDrawBeveledRect method call.
public static String call(PageContext pc, Object name, double x, double y, double width, double height, boolean raised, boolean filled) throws PageException {
// if(name instanceof String) name=pc.getVariable(Caster.toString(name));
Image img = Image.toImage(pc, name);
if (width < 0)
throw new FunctionException(pc, "ImageDrawBeveledRect", 3, "width", "width must contain a none negative value");
if (height < 0)
throw new FunctionException(pc, "ImageDrawBeveledRect", 4, "height", "width must contain a none negative value");
img.draw3DRect((int) x, (int) y, (int) width, (int) height, raised, filled);
return null;
}
use of lucee.runtime.exp.FunctionException in project Lucee by lucee.
the class ImageDrawRect method call.
public static String call(PageContext pc, Object name, double x, double y, double width, double height, boolean filled) throws PageException {
// if(name instanceof String) name=pc.getVariable(Caster.toString(name));
Image img = Image.toImage(pc, name);
if (width < 0)
throw new FunctionException(pc, "ImageDrawRect", 3, "width", "width must contain a none negative value");
if (height < 0)
throw new FunctionException(pc, "ImageDrawRect", 4, "height", "width must contain a none negative value");
img.drawRect((int) x, (int) y, (int) width, (int) height, filled);
return null;
}
use of lucee.runtime.exp.FunctionException in project Lucee by lucee.
the class ImageDrawRoundRect method call.
public static String call(PageContext pc, Object name, double x, double y, double width, double height, double arcWidth, double arcHeight, boolean filled) throws PageException {
// if(name instanceof String) name=pc.getVariable(Caster.toString(name));
Image img = Image.toImage(pc, name);
if (width < 0)
throw new FunctionException(pc, "ImageDrawRoundRect", 3, "width", "width must contain a none negative value");
if (height < 0)
throw new FunctionException(pc, "ImageDrawRoundRect", 4, "height", "width must contain a none negative value");
if (arcWidth < 0)
throw new FunctionException(pc, "ImageDrawRoundRect", 5, "arcWidth", "arcWidth must contain a none negative value");
if (arcHeight < 0)
throw new FunctionException(pc, "ImageDrawRoundRect", 6, "arcHeight", "arcHeight must contain a none negative value");
img.drawRoundRect((int) x, (int) y, (int) width, (int) height, (int) arcWidth, (int) arcHeight, filled);
return null;
}
use of lucee.runtime.exp.FunctionException in project Lucee by lucee.
the class ImageFilter method call.
public static String call(PageContext pc, Object name, String filterName, Struct parameters) throws PageException {
// if(name instanceof String) name=pc.getVariable(Caster.toString(name));
Image img = Image.toImage(pc, name);
String lcFilterName = filterName.trim().toLowerCase();
// get filter class
Class clazz = filters.get(lcFilterName);
if (clazz == null) {
String[] keys = filters.keySet().toArray(new String[filters.size()]);
Arrays.sort(keys);
String list = ListUtil.arrayToList(keys, ", ");
String soundex = StringUtil.soundex(filterName);
java.util.List<String> similar = new ArrayList<String>();
for (int i = 0; i < keys.length; i++) {
if (StringUtil.soundex(keys[i]).equals(soundex))
similar.add(keys[i]);
}
if (similar.size() > 0) {
list = ListUtil.arrayToList(similar.toArray(new String[similar.size()]), ", ");
throw new FunctionException(pc, "ImageFilter", 2, "filtername", "invalid filter name [" + filterName + "], did you mean [" + list + "]");
}
throw new FunctionException(pc, "ImageFilter", 2, "filtername", "invalid filter name [" + filterName + "], valid filter names are [" + list + "]");
}
// load filter
DynFiltering filter = null;
try {
filter = (DynFiltering) clazz.newInstance();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw Caster.toPageException(t);
}
// execute filter
BufferedImage bi = img.getBufferedImage();
// BufferedImage empty = bi;//ImageUtil.createBufferedImage(bi);
img.image(filter.filter(bi, parameters));
return null;
}
Aggregations