/*****************************************************************************
 * Copyright (C) The Apache Software Foundation. All rights reserved.        *
 * ------------------------------------------------------------------------- *
 * This software is published under the terms of the Apache Software License *
 * version 1.1, a copy of which has been included with this distribution in  *
 * the LICENSE file.                                                         *
 *****************************************************************************/

package org.apache.batik.svggen;

import java.util.*;

import org.w3c.dom.Document;

/**
 * Abstract class with common utility methods used by subclasses
 * for specific convertion operations. It holds a reference to a
 * domFactory Document, which many implementations use, and provides
 * a convenience method, to offers a convertion of double values
 * to String that remove the trailing '.' character on integral
 * values.
 *
 * @author <a href="mailto:vincent.hardy@eng.sun.com">Vincent Hardy</a>
 * @version $Id$
 */
public abstract class AbstractSVGFilterConverter
    implements SVGFilterConverter, ErrorConstants {
    /**
     * Used by converters to create Elements and other DOM objects
     */
    protected SVGGeneratorContext generatorContext;

    /**
     * Map of descriptions already processed by this converter. The
     * key type is left to the implementations
     */
    protected Map descMap = new HashMap();

    /**
     * Set of definitions to interpret the values of the attributes
     * generated by this converter since its creation
     */
    protected List defSet = new LinkedList();

    /**
     * @param generatorContext an be used by the SVGConverter extentions
     *        to create Elements and other types of DOM objects.
     */
    public AbstractSVGFilterConverter(SVGGeneratorContext generatorContext) {
        if (generatorContext == null)
            throw new SVGGraphics2DRuntimeException(ERR_CONTEXT_NULL);
        this.generatorContext = generatorContext;
    }

    /**
     * @return set of definitions referenced by the attribute
     *         values created by the implementation since its
     *         creation. The return value should never be null.
     *         If no definition is needed, an empty set should be
     *         returned.
     */
    public List getDefinitionSet(){
        return defSet;
    }

    /**
     * Utility method for subclasses.
     * @return the double value formated as an int if there
     *         is no fractional part. This avoids the extra
     *         ".0" that a standard convertion gives.
     */
    public static String doubleString(double value){
        if(((int)value) == value)
            return Integer.toString((int)value);
        else
            return Double.toString(value);
    }

    /**
     * Utility method for subclasses.
     * @return the double value formated as an int if there
     *         is no fractional part. This avoids the extra
     *         ".0" that a standard convertion gives.
     */
    public static String doubleString(double value, int precision){
        value = Math.round(value*precision)/(double)precision;
        if(((int)value) == value)
            return Integer.toString((int)value);
        else
            return Double.toString(value);
    }
}

@@ -2859,510 +2859,6 @@
  %7D%0A%0A
-    /**%0A     * Utility method for subclasses.%0A     * @return the double value formated as an int if there%0A     *         is no fractional part. This avoids the extra%0A     *         %22.0%22 that a standard convertion gives.%0A     */%0A    public static String doubleString(double value, int precision)%7B%0A        value = Math.round(value*precision)/(double)precision;%0A        if(((int)value) == value)%0A            return Integer.toString((int)value);%0A        else%0A            return Double.toString(value);%0A    %7D%0A
 %7D%0A

Remove un-used/un-necessary code. PR: Obtained from: Submitted by: Reviewed by: