Exemple #1
0
  public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Threshold"))) != null)
      setThreshold(ImageFilterUtil.toIntValue(o, "Threshold"));
    if ((o = parameters.removeEL(KeyImpl.init("Iterations"))) != null)
      setIterations(ImageFilterUtil.toIntValue(o, "Iterations"));
    if ((o = parameters.removeEL(KeyImpl.init("Colormap"))) != null)
      setColormap(ImageFilterUtil.toColormap(o, "Colormap"));
    if ((o = parameters.removeEL(KeyImpl.init("NewColor"))) != null)
      setNewColor(ImageFilterUtil.toColorRGB(o, "NewColor"));

    // 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 [Threshold, Iterations, Colormap, NewColor, BlackFunction]");
    }

    return filter(src, dst);
  }
Exemple #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("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);
  }