Class ScaleFilter

  • All Implemented Interfaces:
    java.io.Serializable, javax.servlet.Filter, javax.servlet.FilterConfig
    Direct Known Subclasses:
    CropFilter

    @Deprecated
    public class ScaleFilter
    extends ImageFilter
    Deprecated.
    This filter renders a scaled version of an image read from a given URL. The image can be output as a GIF, JPEG or PNG image or similar.

    Parameters:

    scaleX
    integer, the new width of the image.
    scaleY
    integer, the new height of the image.
    scaleUniform
    boolean, wether or not uniform scalnig should be used. Default is true.
    scaleUnits
    string, one of PIXELS, PERCENT. PIXELS is default.
    scaleQuality
    string, one of SCALE_SMOOTH, SCALE_FAST, SCALE_REPLICATE, SCALE_AREA_AVERAGING. SCALE_DEFAULT is default (see Image.getScaledInstance(int,int,int), Image for more details).

    Examples:

     <IMG src="/scale/test.jpg?scaleX=500&scaleUniform=false">
     <IMG src="/scale/test.png?scaleY=50&scaleUnits=PERCENT">
     
    Version:
    $Id: ScaleFilter.java#1 $
    Author:
    Harald Kuhr, last modified by $Author: haku $
    See Also:
    Serialized Form
    • Field Detail

      • UNITS_PIXELS

        public static final int UNITS_PIXELS
        Deprecated.
        Width and height are absolute pixels. The default.
        See Also:
        Constant Field Values
      • UNITS_PERCENT

        public static final int UNITS_PERCENT
        Deprecated.
        Width and height are percentage of original width and height.
        See Also:
        Constant Field Values
      • UNITS_UNKNOWN

        public static final int UNITS_UNKNOWN
        Deprecated.
        Unknown units.
        See Also:
        Constant Field Values
      • PARAM_SCALE_QUALITY

        protected static final java.lang.String PARAM_SCALE_QUALITY
        Deprecated.
        scaleQuality
        See Also:
        Constant Field Values
      • PARAM_SCALE_UNITS

        protected static final java.lang.String PARAM_SCALE_UNITS
        Deprecated.
        scaleUnits
        See Also:
        Constant Field Values
      • PARAM_SCALE_UNIFORM

        protected static final java.lang.String PARAM_SCALE_UNIFORM
        Deprecated.
        scaleUniform
        See Also:
        Constant Field Values
      • PARAM_SCALE_X

        protected static final java.lang.String PARAM_SCALE_X
        Deprecated.
        scaleX
        See Also:
        Constant Field Values
      • PARAM_SCALE_Y

        protected static final java.lang.String PARAM_SCALE_Y
        Deprecated.
        scaleY
        See Also:
        Constant Field Values
      • PARAM_IMAGE

        protected static final java.lang.String PARAM_IMAGE
        Deprecated.
        image
        See Also:
        Constant Field Values
      • defaultScaleQuality

        protected int defaultScaleQuality
        Deprecated.
    • Constructor Detail

      • ScaleFilter

        public ScaleFilter()
        Deprecated.
    • Method Detail

      • doFilter

        protected java.awt.image.RenderedImage doFilter​(java.awt.image.BufferedImage pImage,
                                                        javax.servlet.ServletRequest pRequest,
                                                        ImageServletResponse pResponse)
        Deprecated.
        Reads the image from the requested URL, scales it, and returns it in the Servlet stream. See above for details on parameters.
        Specified by:
        doFilter in class ImageFilter
        Parameters:
        pImage - the image to filter
        pRequest - the servlet request
        pResponse - the servlet response
        Returns:
        the filtered image
      • getQuality

        protected int getQuality​(java.lang.String pQualityStr)
        Deprecated.
        Gets the quality constant for the scaling, from the string argument.
        Parameters:
        pQualityStr - The string representation of the scale quality constant.
        Returns:
        The matching quality constant, or the default quality if none was found.
        See Also:
        Image, Image.getScaledInstance(int,int,int)
      • setDefaultScaleQuality

        public void setDefaultScaleQuality​(java.lang.String pDefaultScaleQuality)
        Deprecated.
      • getUnits

        protected int getUnits​(java.lang.String pUnitStr)
        Deprecated.
        Gets the units constant for the width and height arguments, from the given string argument.
        Parameters:
        pUnitStr - The string representation of the units constant, can be one of "PIXELS" or "PERCENT".
        Returns:
        The mathcing units constant, or UNITS_UNKNOWN if none was found.
      • getDimensions

        protected java.awt.Dimension getDimensions​(java.awt.Image pImage,
                                                   int pWidth,
                                                   int pHeight,
                                                   int pUnits,
                                                   boolean pUniformScale)
        Deprecated.
        Gets the dimensions (height and width) of the scaled image. The dimensions are computed based on the old image's dimensions, the units used for specifying new dimensions and whether or not uniform scaling should be used (se algorithm below).
        Parameters:
        pImage - the image to be scaled
        pWidth - the new width of the image, or -1 if unknown
        pHeight - the new height of the image, or -1 if unknown
        pUnits - the constant specifying units for width and height parameter (UNITS_PIXELS or UNITS_PERCENT)
        pUniformScale - boolean specifying uniform scale or not
        Returns:
        a Dimension object, with the correct width and heigth in pixels, for the scaled version of the image.