Пример #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);
  }
Пример #2
0
  public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    if ((o = parameters.removeEL(KeyImpl.init("Amount"))) != null)
      setAmount(ImageFilterUtil.toFloatValue(o, "Amount"));
    if ((o = parameters.removeEL(KeyImpl.init("Exposure"))) != null)
      setExposure(ImageFilterUtil.toFloatValue(o, "Exposure"));
    if ((o = parameters.removeEL(KeyImpl.init("ColorSource"))) != null)
      setColorSource(ImageFilterUtil.toColorRGB(o, "ColorSource"));
    if ((o = parameters.removeEL(KeyImpl.init("Material"))) != null)
      setMaterial(ImageFilterUtil.toLightFilter$Material(o, "Material"));
    if ((o = parameters.removeEL(KeyImpl.init("BumpFunction"))) != null)
      setBumpFunction(ImageFilterUtil.toFunction2D(o, "BumpFunction"));
    if ((o = parameters.removeEL(KeyImpl.init("BumpHeight"))) != null)
      setBumpHeight(ImageFilterUtil.toFloatValue(o, "BumpHeight"));
    if ((o = parameters.removeEL(KeyImpl.init("BumpSoftness"))) != null)
      setBumpSoftness(ImageFilterUtil.toFloatValue(o, "BumpSoftness"));
    if ((o = parameters.removeEL(KeyImpl.init("BumpShape"))) != null)
      setBumpShape(ImageFilterUtil.toIntValue(o, "BumpShape"));
    if ((o = parameters.removeEL(KeyImpl.init("ViewDistance"))) != null)
      setViewDistance(ImageFilterUtil.toFloatValue(o, "ViewDistance"));
    if ((o = parameters.removeEL(KeyImpl.init("EnvironmentMap"))) != null)
      setEnvironmentMap(ImageFilterUtil.toBufferedImage(o, "EnvironmentMap"));
    if ((o = parameters.removeEL(KeyImpl.init("BumpSource"))) != null)
      setBumpSource(ImageFilterUtil.toIntValue(o, "BumpSource"));
    if ((o = parameters.removeEL(KeyImpl.init("DiffuseColor"))) != null)
      setDiffuseColor(ImageFilterUtil.toColorRGB(o, "DiffuseColor"));

    // 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 [Amount, Exposure, ColorSource, Material, BumpFunction, BumpHeight, BumpSoftness, BumpShape, ViewDistance, EnvironmentMap, BumpSource, DiffuseColor]");
    }

    return filter(src, dst);
  }
Пример #3
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);
  }