public MultipleGradientPaint calculateGradient() { List<Thumb<Color>> stops = getStops(); int len = stops.size(); // set up the data for the gradient float[] fractions = new float[len]; Color[] colors = new Color[len]; int i = 0; for (Thumb<Color> thumb : stops) { colors[i] = (Color) thumb.getObject(); fractions[i] = thumb.getPosition(); i++; } // get the final gradient this.setGradient(calculateGradient(fractions, colors)); return getGradient(); }