CategorizedString extends CategorizedLegend<String> { public void setParameter(StringParameter param) { if(param instanceof StringLiteral){ parameter = param; fireTypeChanged(); } else if(param instanceof Categorize2String){ RealParameter rp = ((Categorize2String) param).getLookupValue(); if(rp instanceof RealAttribute){ parameter = param; field = ((RealAttribute) rp).getColumnName(); fireTypeChanged(); } else { throw new IllegalArgumentException("The given StringParameter instance can't be recognized as a " + "valid CategorizedString."); } } else { throw new IllegalArgumentException("The given StringParameter instance can't be recognized as a " + "valid CategorizedString."); } } CategorizedString(StringParameter sp); @Override SeParameter getParameter(); void setParameter(StringParameter param); String getFallbackValue(); void setFallbackValue(String value); @Override String get(Double d); @Override void put(Double d, String v); @Override String remove(Double d); @Override String getFromLower(Double d);  }
@Test public void testFiredTypeEvent() throws Exception{ RealAttribute vf = new RealAttribute("height"); Categorize2String c2s = new Categorize2String(new StringLiteral("youhou"),new StringLiteral("fallback"), vf); CategorizedString cs = new CategorizedString(c2s); DummyTypeListener tl = new DummyTypeListener(); cs.addListener(tl); cs.setParameter(new StringLiteral("literal")); assertTrue(tl.count == 1); cs.setParameter(c2s); assertTrue(tl.count == 2); }