示例#1
0
  @Override
  public Object get(Collection.Key key) throws ExpressionException {
    /*if(NullSupportHelper.full()) {
    	Object o=super.get(key,NullSupportHelper.NULL());
    	if(o!=NullSupportHelper.NULL())return o;

    	o=get(Caster.toIntValue(key.getString(),-1),NullSupportHelper.NULL());
    	if(o!=NullSupportHelper.NULL())return o;
    	throw new ExpressionException("key ["+key.getString()+"] doesn't exist in argument scope. existing keys are ["+
    			lucee.runtime.type.List.arrayToList(CollectionUtil.keys(this),", ")
    			+"]");
    }*/

    // null is supported as returned value with argument scope
    Object o = super.g(key, Null.NULL);
    if (o != Null.NULL) return o;

    o = get(Caster.toIntValue(key.getString(), -1), Null.NULL);
    if (o != Null.NULL) return o;

    throw new ExpressionException(
        "key ["
            + key.getString()
            + "] doesn't exist in argument scope. existing keys are ["
            + lucee.runtime.type.util.ListUtil.arrayToList(CollectionUtil.keys(this), ", ")
            + "]");
  }
示例#2
0
  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);
    BufferedImage dst = null; // ImageUtil.createBufferedImage(src,rect.width,rect.height);

    return filter(src, dst);
  }
示例#3
0
  @Override
  public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Colormap"))) != null)
      setColormap(ImageFilterUtil.toColormap(o, "Colormap"));
    if ((o = parameters.removeEL(KeyImpl.init("Turbulence"))) != null)
      setTurbulence(ImageFilterUtil.toFloatValue(o, "Turbulence"));
    if ((o = parameters.removeEL(KeyImpl.init("Scaling"))) != null)
      setScaling(ImageFilterUtil.toFloatValue(o, "Scaling"));
    if ((o = parameters.removeEL(KeyImpl.init("UseColormap"))) != null)
      setUseColormap(ImageFilterUtil.toBooleanValue(o, "UseColormap"));
    if ((o = parameters.removeEL(KeyImpl.init("UseImageColors"))) != null)
      setUseImageColors(ImageFilterUtil.toBooleanValue(o, "UseImageColors"));
    if ((o = parameters.removeEL(KeyImpl.init("Seed"))) != null)
      setSeed(ImageFilterUtil.toIntValue(o, "Seed"));

    // 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 [Colormap, Turbulence, Scaling, UseColormap, UseImageColors, Seed]");
    }

    return filter(src, dst);
  }
示例#4
0
  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);
  }
示例#5
0
  public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Brightness"))) != null)
      setBrightness(ImageFilterUtil.toFloatValue(o, "Brightness"));
    if ((o = parameters.removeEL(KeyImpl.init("Contrast"))) != null)
      setContrast(ImageFilterUtil.toFloatValue(o, "Contrast"));
    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 [Brightness, Contrast, Dimensions]");
    }

    return filter(src, dst);
  }
示例#6
0
  @Override
  public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Levels"))) != null)
      setLevels(ImageFilterUtil.toIntValue(o, "Levels"));
    if ((o = parameters.removeEL(KeyImpl.init("Matrix"))) != null)
      setMatrix(ImageFilterUtil.toAInt(o, "Matrix"));
    if ((o = parameters.removeEL(KeyImpl.init("ColorDither"))) != null)
      setColorDither(ImageFilterUtil.toBooleanValue(o, "ColorDither"));
    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 [Levels, Matrix, ColorDither, Dimensions]");
    }

    return filter(src, dst);
  }
示例#7
0
  public BIF(PageContext pc, String name) throws ApplicationException {
    super(Component.ACCESS_PUBLIC);
    ci = (ConfigImpl) pc.getConfig();
    FunctionLib fl = ci.getCombinedFLDs(pc.getCurrentTemplateDialect());
    flf = fl.getFunction(name);

    // BIF not found
    if (flf == null) {
      Key[] keys = CollectionUtil.toKeys(fl.getFunctions().keySet());
      throw new ApplicationException(
          ExceptionUtil.similarKeyMessage(
              keys, name, "build in function", "build in functions", null, false));
    }
    try {
      this.id = Hash.md5(name);
    } catch (NoSuchAlgorithmException e) {
      this.id = name;
    }
  }
示例#8
0
  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("Centre")))!=null)setCentre(ImageFilterUtil.toPoint2D(o,"Centre"));
    if ((o = parameters.removeEL(KeyImpl.init("RingWidth"))) != null)
      setRingWidth(ImageFilterUtil.toFloatValue(o, "RingWidth"));
    if ((o = parameters.removeEL(KeyImpl.init("BaseAmount"))) != null)
      setBaseAmount(ImageFilterUtil.toFloatValue(o, "BaseAmount"));
    if ((o = parameters.removeEL(KeyImpl.init("RingAmount"))) != null)
      setRingAmount(ImageFilterUtil.toFloatValue(o, "RingAmount"));
    if ((o = parameters.removeEL(KeyImpl.init("RayAmount"))) != null)
      setRayAmount(ImageFilterUtil.toFloatValue(o, "RayAmount"));
    if ((o = parameters.removeEL(KeyImpl.init("Color"))) != null)
      setColor(ImageFilterUtil.toColorRGB(o, "Color"));
    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 [Radius, Centre, RingWidth, BaseAmount, RingAmount, RayAmount, Color, Dimensions]");
    }

    return filter(src, dst);
  }
示例#9
0
  @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("XAmplitude"))) != null)
      setXAmplitude(ImageFilterUtil.toFloatValue(o, "XAmplitude"));
    if ((o = parameters.removeEL(KeyImpl.init("XWavelength"))) != null)
      setXWavelength(ImageFilterUtil.toFloatValue(o, "XWavelength"));
    if ((o = parameters.removeEL(KeyImpl.init("YAmplitude"))) != null)
      setYAmplitude(ImageFilterUtil.toFloatValue(o, "YAmplitude"));
    if ((o = parameters.removeEL(KeyImpl.init("YWavelength"))) != null)
      setYWavelength(ImageFilterUtil.toFloatValue(o, "YWavelength"));
    if ((o = parameters.removeEL(KeyImpl.init("WaveType"))) != null)
      setWaveType(ImageFilterUtil.toString(o, "WaveType"));
    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 [XAmplitude, XWavelength, YAmplitude, YWavelength, WaveType, EdgeAction, Interpolation]");
    }

    return filter(src, (BufferedImage) null);
  }