code: private String getLinearGradientElement(String id, GradientPaint paint) {
          StringBuilder b = new StringBuilder("<linearGradient id=\"").append(id)
                  .append("\" ");
          Point2D p1 = paint.getPoint1();
          Point2D p2 = paint.getPoint2();
          b.append("x1=\"").append(geomDP(p1.getX())).append("\" ");
          b.append("y1=\"").append(geomDP(p1.getY())).append("\" ");
          b.append("x2=\"").append(geomDP(p2.getX())).append("\" ");
          b.append("y2=\"").append(geomDP(p2.getY())).append("\" ");
          b.append("gradientUnits=\"userSpaceOnUse\">");
          Color c1 = paint.getColor1();
          b.append("<stop offset=\"0%\" stop-color=\"").append(rgbColorStr(c1))
                  .append("\"");
          if (c1.getAlpha() < 255) {
              double alphaPercent = c1.getAlpha() / 255.0;
              b.append(" stop-opacity=\"").append(transformDP(alphaPercent))
                      .append("\"");
          }
          b.append("/>");
          Color c2 = paint.getColor2();
          b.append("<stop offset=\"100%\" stop-color=\"").append(rgbColorStr(c2))
                  .append("\"");
          if (c2.getAlpha() < 255) {
              double alphaPercent = c2.getAlpha() / 255.0;
              b.append(" stop-opacity=\"").append(transformDP(alphaPercent))
                      .append("\"");
          }
          b.append("/>");
          return b.append("</linearGradient>").toString();
      }
docs: Returns an element to represent a linear gradient.  All the linear
  gradients that are used get written to the DEFS element in the SVG.
  
  @param id  the reference id.
  @param paint  the gradient.
  
  @return The SVG element.