CategorizedColor extends CategorizedLegend<Color> { @Override public Color get(Double d){ if(parameter instanceof ColorLiteral){ return Double.isInfinite(d) && d < 0 ? ((ColorLiteral) parameter).getColor(null) : null; } else { try{ ColorParameter sp = ((Categorize2Color)parameter).get(new RealLiteral(d)); return sp == null ? null : sp.getColor(null); } catch (ParameterException pe){ throw new IllegalArgumentException("Can't process the input value: "+d, pe); } } } CategorizedColor(ColorParameter sp); @Override SeParameter getParameter(); void setParameter(ColorParameter param); Color getFallbackValue(); void setFallbackValue(Color value); @Override Color get(Double d); @Override void put(Double d, Color v); @Override Color remove(Double d); @Override Color getFromLower(Double d);  }
@Test public void testGetFromCategorize(){ CategorizedColor cs = new CategorizedColor(getCategorize2Color()); assertTrue(cs.get(20.0).equals(Color.decode("#332133"))); assertTrue(cs.get(Double.NEGATIVE_INFINITY).equals(Color.decode("#012345"))); assertNull(cs.get(25.0)); assertTrue(cs.get(30.0).equals(Color.decode("#A8B9C0"))); cs = new CategorizedColor(new ColorLiteral("#EDCBA0")); assertNull(cs.get(25.0)); assertTrue(cs.get(Double.NEGATIVE_INFINITY).equals(Color.decode("#EDCBA0"))); }