code: private String getLinearGradientElement(String id, 
              LinearGradientPaint paint) {
          StringBuilder b = new StringBuilder("<linearGradient id=\"").append(id)
                  .append("\" ");
          Point2D p1 = paint.getStartPoint();
          Point2D p2 = paint.getEndPoint();
          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("\" ");
          if (!paint.getCycleMethod().equals(CycleMethod.NO_CYCLE)) {
              String sm = paint.getCycleMethod().equals(CycleMethod.REFLECT) 
                      ? "reflect" : "repeat";
              b.append("spreadMethod=\"").append(sm).append("\" ");
          }
          b.append("gradientUnits=\"userSpaceOnUse\">");
          for (int i = 0; i < paint.getFractions().length; i++) {
              Color c = paint.getColors()[i];
              float fraction = paint.getFractions()[i];
              b.append("<stop offset=\"").append(geomDP(fraction * 100))
                      .append("%\" stop-color=\"")
                      .append(rgbColorStr(c)).append("\"");
              if (c.getAlpha() < 255) {
                  double alphaPercent = c.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.