CategorizedColor extends CategorizedLegend<Color> { public void setParameter(ColorParameter param) { if(param instanceof ColorLiteral){ parameter = param; fireTypeChanged(); } else if(param instanceof Categorize2Color){ RealParameter rp = ((Categorize2Color) param).getLookupValue(); if(rp instanceof RealAttribute){ parameter = param; field = ((RealAttribute) rp).getColumnName(); fireTypeChanged(); } else { throw new IllegalArgumentException("The given ColorParameter instance can't be recognized as a " + "valid CategorizedColor."); } } else { throw new IllegalArgumentException("The given ColorParameter instance can't be recognized as a " + "valid CategorizedColor."); } } 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 testFiredTypeEvent() throws Exception{ RealAttribute vf = new RealAttribute("height"); Categorize2Color c2s = new Categorize2Color(new ColorLiteral("#012345"),new ColorLiteral("#001122"), vf); CategorizedColor cs = new CategorizedColor(c2s); DummyTypeListener tl = new DummyTypeListener(); cs.addListener(tl); cs.setParameter(new ColorLiteral("#AEBECE")); assertTrue(tl.count == 1); cs.setParameter(c2s); assertTrue(tl.count == 2); }