CategorizedColor extends CategorizedLegend<Color> { @Override public Color remove(Double d){ if(d==null){ throw new NullPointerException("The input threshold must not be null"); } if(parameter instanceof ColorLiteral){ return null; } else { Categorize2Color c2s = (Categorize2Color) parameter; ColorParameter ret = c2s.remove(new RealLiteral(d)); if(ret == null){ return null; } else if(c2s.getNumClasses()==1 && c2s.getFallbackValue().equals(c2s.get(0))){ parameter = new ColorLiteral(c2s.getFallbackValue().getColor(null)); } if(ret instanceof ColorLiteral){ try{ return ret.getColor(null); } catch (ParameterException pe){ throw new IllegalStateException("We've failed at retrieved the value of a literal. " + "Something is going really wrong here."); } } else { throw new IllegalStateException("We're not supposed to have values that are not ColorLiteral in this categorize."); } } } 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 testRemoveFromLiteral(){ CategorizedColor cs = new CategorizedColor(new ColorLiteral("#EDCBA0")); assertNull(cs.remove(50.0)); assertNull(cs.remove(Double.NEGATIVE_INFINITY)); }
@Test public void testRemoveFromCat(){ CategorizedColor cs = new CategorizedColor(getCategorize2Color()); assertTrue(cs.remove(20.0).equals(Color.decode("#332133"))); assertNull(cs.remove(20.0)); }