src/main/java/org/jfree/graphics2d/svg/SVGGraphics2D.java
@Override
    public void setPaint(Paint paint) {
        if (paint == null) {
            return;
        }
        this.paint = paint;
        this.gradientPaintRef = null;
        if (paint instanceof Color) {
            setColor((Color) paint);
        } else if (paint instanceof GradientPaint) {
            GradientPaint gp = (GradientPaint) paint;
            GradientPaintKey key = new GradientPaintKey(gp);
            String ref = this.gradientPaints.get(key);
            if (ref == null) {
                int count = this.gradientPaints.keySet().size();
                String id = this.defsKeyPrefix + "gp" + count;
                this.elementIDs.add(id);
                this.gradientPaints.put(key, id);
                this.gradientPaintRef = id;
            } else {
                this.gradientPaintRef = ref;
            }
        } else if (paint instanceof LinearGradientPaint) {
            LinearGradientPaint lgp = (LinearGradientPaint) paint;
            LinearGradientPaintKey key = new LinearGradientPaintKey(lgp);
            String ref = this.linearGradientPaints.get(key);
            if (ref == null) {
                int count = this.linearGradientPaints.keySet().size();
                String id = this.defsKeyPrefix + "lgp" + count;
                this.elementIDs.add(id);
                this.linearGradientPaints.put(key, id);
                this.gradientPaintRef = id;
            }
        } else if (paint instanceof RadialGradientPaint) {
            RadialGradientPaint rgp = (RadialGradientPaint) paint;
            RadialGradientPaintKey key = new RadialGradientPaintKey(rgp);
            String ref = this.radialGradientPaints.get(key);
            if (ref == null) {
                int count = this.radialGradientPaints.keySet().size();
                String id = this.defsKeyPrefix + "rgp" + count;
                this.elementIDs.add(id);
                this.radialGradientPaints.put(key, id);
                this.gradientPaintRef = id;
            }
        }
    }
@Override
    public void setPaint(Paint paint) {
        if (paint == null) {
            return;
        }
        this.paint = paint;
        this.gradientPaintRef = null;
        if (paint instanceof Color) {
            setColor((Color) paint);
        } else if (paint instanceof GradientPaint) {
            GradientPaint gp = (GradientPaint) paint;
            GradientPaintKey key = new GradientPaintKey(gp);
            String ref = this.gradientPaints.get(key);
            if (ref == null) {
                int count = this.gradientPaints.keySet().size();
                String id = this.defsKeyPrefix + "gp" + count;
                this.elementIDs.add(id);
                this.gradientPaints.put(key, id);
                this.gradientPaintRef = id;
            } else {
                this.gradientPaintRef = ref;
            }
        } else if (paint instanceof LinearGradientPaint) {
            LinearGradientPaint lgp = (LinearGradientPaint) paint;
            LinearGradientPaintKey key = new LinearGradientPaintKey(lgp);
            String ref = this.linearGradientPaints.get(key);
            if (ref == null) {
                int count = this.linearGradientPaints.keySet().size();
                String id = this.defsKeyPrefix + "lgp" + count;
                this.elementIDs.add(id);
                this.linearGradientPaints.put(key, id);
                this.gradientPaintRef = id;
            }
        } else if (paint instanceof RadialGradientPaint) {
            RadialGradientPaint rgp = (RadialGradientPaint) paint;
            RadialGradientPaintKey key = new RadialGradientPaintKey(rgp);
            String ref = this.radialGradientPaints.get(key);
            if (ref == null) {
                int count = this.radialGradientPaints.keySet().size();
                String id = this.defsKeyPrefix + "rgp" + count;
                this.elementIDs.add(id);
                this.radialGradientPaints.put(key, id);
                this.gradientPaintRef = id;
            }
        }
    }
@ Override public void setPaint ( Paint paint ) { if ( paint == null ) { return ; } this . paint = paint ; this . gradientPaintRef = null ; if ( paint instanceof Color ) { setColor ( ( Color ) paint ) ; } else if ( paint instanceof GradientPaint ) { GradientPaint gp = ( GradientPaint ) paint ; GradientPaintKey key = new GradientPaintKey ( gp ) ; String ref = this . gradientPaints . get ( key ) ; if ( ref == null ) { int count = this . gradientPaints . keySet ( ) . size ( ) ; String id = this . defsKeyPrefix + "gp" + count ; this . elementIDs . add ( id ) ; this . gradientPaints . put ( key , id ) ; this . gradientPaintRef = id ; } else { this . gradientPaintRef = ref ; } } else if ( paint instanceof LinearGradientPaint ) { LinearGradientPaint lgp = ( LinearGradientPaint ) paint ; LinearGradientPaintKey key = new LinearGradientPaintKey ( lgp ) ; String ref = this . linearGradientPaints . get ( key ) ; if ( ref == null ) { int count = this . linearGradientPaints . keySet ( ) . size ( ) ; String id = this . defsKeyPrefix + "lgp" + count ; this . elementIDs . add ( id ) ; this . linearGradientPaints . put ( key , id ) ; this . gradientPaintRef = id ; } } else if ( paint instanceof RadialGradientPaint ) { RadialGradientPaint rgp = ( RadialGradientPaint ) paint ; RadialGradientPaintKey key = new RadialGradientPaintKey ( rgp ) ; String ref = this . radialGradientPaints . get ( key ) ; if ( ref == null ) { int count = this . radialGradientPaints . keySet ( ) . size ( ) ; String id = this . defsKeyPrefix + "rgp" + count ; this . elementIDs . add ( id ) ; this . radialGradientPaints . put ( key , id ) ; this . gradientPaintRef = id ; } } }
Sets the paint used to draw or fill shapes (or text).  If
{@code paint} is an instance of {@code Color}, this method will
also update the current color attribute (see {@link #getColor()}). If
you pass {@code null} to this method, it does nothing (in
accordance with the JDK specification).

@param paint  the paint ({@code null} is permitted but ignored).

@see #getPaint()
Sets the paint used to draw or fill shapes ( or text ) . If { @code paint } is an instance of { @code Color } this method will also update the current color attribute ( see { @link #getColor () } ) . If you pass { @code null } to this method it does nothing ( in accordance with the JDK specification ) .