CategorizedArea extends AbstractCategorizedLegend<AreaParameters> implements EnablesStroke { @Override public AreaParameters get(Object o) { if(!(o instanceof Double)){ throw new IllegalArgumentException("Keys are double values in this map"); } Double d = (Double)o; double w; Color sc; String da; Double sop; if(strokeEnabled){ w = widthStroke.getFromLower(d); sc = colorStroke.getFromLower(d); da = dashStroke.getFromLower(d); sop = opacityStroke.getFromLower(d); } else { w = .0; sc = Color.WHITE; da = ""; sop = .0; } return new AreaParameters(sc,sop,w,da,colorFill.getFromLower(d),opacityFill.getFromLower(d)); } CategorizedArea();  CategorizedArea(AreaSymbolizer as); @Override List<CategorizedLegend> getCategorizedLegend(); @Override Symbolizer getSymbolizer(); @Override String getLegendTypeName(); @Override AreaParameters get(Object o); @Override AreaParameters put(Double d, AreaParameters ap); @Override AreaParameters remove(Object o); @Override void setFallbackParameters(AreaParameters fallback); @Override AreaParameters getFallbackParameters(); @Override boolean isStrokeEnabled(); @Override void setStrokeEnabled(boolean enable); @Override Uom getStrokeUom(); @Override void setStrokeUom(Uom u); @Override String getLegendTypeId(); static final String NAME; }
@Test public void testBadInstanciation() throws Exception { Style s = getStyle(AREA_RECODE); AreaSymbolizer as = (AreaSymbolizer) s.getRules().get(0).getCompositeSymbolizer().getChildren().get(0); try{ CategorizedArea ca = new CategorizedArea(as); fail(); } catch (IllegalArgumentException iae){ assertTrue(true); } }
@Test public void testGet() throws Exception { CategorizedArea ca = getCategorizedArea(); AreaParameters tester = new AreaParameters(Color.decode("#223344"),.2,2.0,"1 2 1",Color.decode("#113355"),.5); assertTrue(ca.get(Double.NEGATIVE_INFINITY).equals(tester)); tester = new AreaParameters(Color.decode("#dd77ee"),.2,2.0,"1 3 1 2 5",Color.decode("#dd66ee"),.5); assertTrue(ca.get(70000.0).equals(tester)); tester = new AreaParameters(Color.decode("#dd77ee"),.2,7.0,"1 6 8 1",Color.decode("#dd66ee"),.5); assertTrue(ca.get(75000.0).equals(tester)); tester = new AreaParameters(Color.decode("#dd77ee"),.2,10.0,"5 5",Color.decode("#ffaa99"),.5); assertTrue(ca.get(100000.0).equals(tester)); tester = new AreaParameters(Color.decode("#ffaa00"),.2,10.0,"5 5",Color.decode("#ffaa99"),.5); assertTrue(ca.get(110000.0).equals(tester)); }
@Test public void testGetNoStroke() throws Exception { CategorizedArea ca = getNoStroke(); AreaParameters tester = new AreaParameters(Color.WHITE,.0,.0,"",Color.decode("#113355"),.5); assertTrue(ca.get(Double.NEGATIVE_INFINITY).equals(tester)); }