CategorizedLine extends AbstractCategorizedLegend<LineParameters> { @Override public LineParameters get(Object o) { if(!(o instanceof Double)){ throw new IllegalArgumentException("Keys are double values in this map"); } Double d = (Double)o; return new LineParameters(color.getFromLower(d),opacity.getFromLower(d),width.getFromLower(d),dash.getFromLower(d)); } CategorizedLine();  CategorizedLine(LineSymbolizer ls); @Override List<CategorizedLegend> getCategorizedLegend(); @Override void setFallbackParameters(LineParameters fallback); @Override LineParameters getFallbackParameters(); @Override Symbolizer getSymbolizer(); @Override String getLegendTypeName(); @Override LineParameters get(Object o); @Override LineParameters put(Double d, LineParameters lp); @Override LineParameters remove(Object o); @Override Uom getStrokeUom(); @Override void setStrokeUom(Uom u); @Override String getLegendTypeId(); static final String NAME; }
@Test public void testImpossibleInstanciation() throws Exception { Style s = getStyle(DASH_RECODE); LineSymbolizer ls = (LineSymbolizer) s.getRules().get(0).getCompositeSymbolizer().getChildren().get(0); try{ CategorizedLine cl = new CategorizedLine(ls); fail(); } catch (IllegalArgumentException uoe){ assertTrue(true); } }
@Test public void testGet() throws Exception { CategorizedLine cl = getCategorizedLine(); assertTrue(cl.get(Double.NEGATIVE_INFINITY).equals(new LineParameters(Color.decode("#113355"),.75,.5,"2 2"))); assertTrue(cl.get(70000.0 ).equals(new LineParameters(Color.decode("#dd66ee"),.75,1.0 ,"2 2"))); assertTrue(cl.get(80000.0 ).equals(new LineParameters(Color.decode("#dd66ee"),.75,1.25,"2 2"))); assertTrue(cl.get(100000.0).equals(new LineParameters(Color.decode("#ffaa99"),.75,1.5 ,"2 2"))); }