QuasiRandomColors extends IndexedColorMapper { @Override public Paint get(int index) { Integer key = index; if (colorCache.containsKey(key)) { return colorCache.get(key); } float[] colorVariance = getColorVariance(); float hue = colorVariance[0] + colorVariance[1]*seqHue.next().floatValue(); float saturation = colorVariance[2] + colorVariance[3]*seqSat.next().floatValue(); float brightness = colorVariance[4] + colorVariance[5]*seqBrightness.next().floatValue(); Color color = Color.getHSBColor( hue, MathUtils.limit(saturation, 0f, 1f), MathUtils.limit(brightness, 0f, 1f) ); colorCache.put(key, color); return color; } QuasiRandomColors(); @Override Paint get(int index); float[] getColorVariance(); void setColorVariance(float[] colorVariance);  }
@Test public void testGet() { QuasiRandomColors c = new QuasiRandomColors(); final int STEPS = 10; Paint prv = null; for (int i = 0; i < STEPS; i++) { Paint cur = c.get(i); assertNotNull(cur); assertFalse(cur.equals(prv)); prv = cur; } }