Exemplo n.º 1
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);
  }
Exemplo n.º 2
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);
  }