示例#1
0
  public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    Object o;
    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" : "")
              + " ["
              + List.arrayToList(parameters.keysAsString(), ", ")
              + "] "
              + (parameters.size() > 1 ? "are" : "is")
              + " not allowed, only the following parameters are supported [Dimensions]");
    }

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