public synchronized void init() {

        if (inited) {
            return;
        }

        // shading dictionary
        if (shading == null) {
            shading = library.getDictionary(entries, "Shading");
        }

        shadingType = library.getInt(shading, "ShadingType");
        bBox = library.getRectangle(shading, "BBox");
        colorSpace = PColorSpace.getColorSpace(library,
                library.getObject(shading, "ColorSpace"));
        if (library.getObject(shading, "Background") != null &&
                library.getObject(shading, "Background") instanceof Vector) {
            background = (Vector) library.getObject(shading, "Background");
        }
        antiAlias = library.getBoolean(shading, "AntiAlias");

        // get type 2 specific data.
        if (library.getObject(shading, "Domain") instanceof Vector) {
            domain = (Vector<Float>) library.getObject(shading, "Domain");
        } else {
            domain = new Vector<Float>(2);
            domain.add(new Float(0.0));
            domain.add(new Float(1.0));
        }

        if (library.getObject(shading, "Coords") instanceof Vector) {
            coords = (Vector) library.getObject(shading, "Coords");
        }
        if (library.getObject(shading, "Extend") instanceof Vector) {
            extend = (Vector<Boolean>) library.getObject(shading, "Extend");
        } else {
            extend = new Vector<Boolean>(2);
            extend.add(false);
            extend.add(false);
        }
        Object tmp = library.getObject(shading, "Function");
        if (tmp != null) {
            function = Function.getFunction(library,
                    tmp);
        }

        // calculate the t's
        float t0 = ((Number) domain.get(0)).floatValue();
        float t1 = ((Number) domain.get(1)).floatValue();

        // first off, create the two needed start and end points of the line
        Point2D.Float startPoint = new Point2D.Float(
                ((Number) coords.get(0)).floatValue(),
                ((Number) coords.get(1)).floatValue());

        Point2D.Float endPoint = new Point2D.Float(
                ((Number) coords.get(2)).floatValue(),
                ((Number) coords.get(3)).floatValue());

        // corner case where a pdf engine give zero zero coords which batik
        // can't handle so we pad it slightly.
        if (startPoint.equals(endPoint)) {
            endPoint.x++;
        }

        // calculate colour based on points that make up the line, 10 is a good
        // number for speed and gradient quality. 
        int numberOfPoints = 10;
        Color[] colors = calculateColorPoints(numberOfPoints, startPoint, endPoint, t0, t1);
        float[] dist = calculateDomainEntries(numberOfPoints, t0, t1);

        linearGradientPaint = new LinearGradientPaint(
                startPoint, endPoint, dist, colors,
                MultipleGradientPaint.NO_CYCLE,
                MultipleGradientPaint.LINEAR_RGB,
                matrix);
        inited = true;
    }