Exemplo n.º 1
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);
  }
Exemplo n.º 2
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);
  }
Exemplo n.º 3
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);
  }
Exemplo n.º 4
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);
  }
Exemplo n.º 5
0
  public BufferedImage filter(BufferedImage src, Struct parameters) throws PageException {
    BufferedImage dst = ImageUtil.createBufferedImage(src);
    int width = Caster.toIntValue(parameters.get(KeyImpl.init("Width")));
    int height = Caster.toIntValue(parameters.get(KeyImpl.init("Height")));
    setHeight(height);
    setWidth(width);

    dst = ImageUtil.createBufferedImage(dst, width, height);

    return filter(src, dst);
  }
Exemplo n.º 6
0
  public static Struct getMemoryUsageAsStruct(int type) {
    java.util.List<MemoryPoolMXBean> manager = ManagementFactory.getMemoryPoolMXBeans();
    Iterator<MemoryPoolMXBean> it = manager.iterator();

    MemoryPoolMXBean bean;
    MemoryUsage usage;
    MemoryType _type;
    long used = 0, max = 0, init = 0;
    while (it.hasNext()) {
      bean = it.next();
      usage = bean.getUsage();
      _type = bean.getType();
      if ((type == MEMORY_TYPE_HEAP && _type == MemoryType.HEAP)
          || (type == MEMORY_TYPE_NON_HEAP && _type == MemoryType.NON_HEAP)) {
        used += usage.getUsed();
        max += usage.getMax();
        init += usage.getInit();
      }
    }
    Struct sct = new StructImpl();
    sct.setEL(KeyConstants._used, Caster.toDouble(used));
    sct.setEL(KeyConstants._max, Caster.toDouble(max));
    sct.setEL(KeyConstants._init, Caster.toDouble(init));
    sct.setEL(KeyImpl.init("available"), Caster.toDouble(max - used));
    return sct;
  }
Exemplo n.º 7
0
 public static double call(
     PageContext pc, Query query, String string, Object datatype, Object array)
     throws PageException {
   if (datatype == null) return call(pc, query, string, array);
   query.addColumn(
       KeyImpl.init(string),
       Caster.toArray(array),
       SQLCaster.toSQLType(Caster.toString(datatype)));
   return query.size();
 }
Exemplo n.º 8
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.º 9
0
  public static Struct getMemoryUsageCompact(int type) {
    java.util.List<MemoryPoolMXBean> manager = ManagementFactory.getMemoryPoolMXBeans();
    Iterator<MemoryPoolMXBean> it = manager.iterator();

    MemoryPoolMXBean bean;
    MemoryUsage usage;
    MemoryType _type;
    Struct sct = new StructImpl();
    while (it.hasNext()) {
      bean = it.next();
      usage = bean.getUsage();
      _type = bean.getType();
      if (type == MEMORY_TYPE_HEAP && _type != MemoryType.HEAP) continue;
      if (type == MEMORY_TYPE_NON_HEAP && _type != MemoryType.NON_HEAP) continue;

      double d = ((int) (100D / usage.getMax() * usage.getUsed())) / 100D;
      sct.setEL(KeyImpl.init(bean.getName()), Caster.toDouble(d));
    }
    return sct;
  }
Exemplo n.º 10
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);
  }
Exemplo n.º 11
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);
  }
Exemplo n.º 12
0
 @Override
 public Collection.Key getColumn() {
   return KeyImpl.init(column);
 }
Exemplo n.º 13
0
 public static double call(PageContext pc, Query query, String string, Object array)
     throws PageException {
   query.addColumn(KeyImpl.init(string), Caster.toArray(array));
   return query.size();
 }