Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoPolygonSeriesProducer.java @ 448:3cb2bea50456
Generate iso line classes according gnv-issues/issue108
gnv-artifacts/trunk@496 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sun, 03 Jan 2010 12:16:55 +0000 |
parents | 92b7ccbf6163 |
children | f7038820df2e |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoPolygonSeriesProducer.java Fri Jan 01 21:52:41 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/raster/IsoPolygonSeriesProducer.java Sun Jan 03 12:16:55 2010 +0000 @@ -27,16 +27,16 @@ public class IsoPolygonSeriesProducer implements RingsHandler { - private static Logger log = Logger.getLogger( - IsoPolygonSeriesProducer.class); + private static Logger log = Logger.getLogger( + IsoPolygonSeriesProducer.class); public static final Float LINE_WIDTH = Float.valueOf(0.1f); - public interface LabelGenerator { + public interface AttributeGenerator { - String generateLabel(int neighbor1, int neighbor2); + Object generateAttribute(int neighbor1, int neighbor2); - } // interface LabelGenerator + } // interface AttributeGenerator protected HashMap<Edge, Integer> open; protected HashMap<IJKey, TIntObjectHashMap> commonOpen; @@ -137,8 +137,9 @@ return getSeries(null); } - public Collection<PolygonSeries> getSeries(LabelGenerator labelGenerator) { - + public Collection<PolygonSeries> getSeries( + AttributeGenerator attributeGenerator + ) { ArrayList<PolygonSeries> series = new ArrayList<PolygonSeries>(); double b1 = minX; @@ -187,17 +188,17 @@ TIntObjectHashMap map = commonOpen.get(key); if (map != null) { - final ArrayList<Edge> headList = new ArrayList<Edge>(); - map.forEachValue(new TObjectProcedure() { - TIntHashSet headSet = new TIntHashSet(); - public boolean execute(Object value) { - Edge head = ((Edge)value).head(); - if (headSet.add(head.a)) { - headList.add(head); - } - return true; - } - }); + final ArrayList<Edge> headList = new ArrayList<Edge>(); + map.forEachValue(new TObjectProcedure() { + TIntHashSet headSet = new TIntHashSet(); + public boolean execute(Object value) { + Edge head = ((Edge)value).head(); + if (headSet.add(head.a)) { + headList.add(head); + } + return true; + } + }); for (Edge head: headList) { @@ -217,14 +218,15 @@ } // for all in common open } // if map defined for key - int itemCount = ps.getItemCount(); - - if (itemCount > 0) { + if (ps.getItemCount() > 0) { series.add(ps); - if (labelGenerator != null) { - ps.setAttribute( - "label", - labelGenerator.generateLabel(key.i, key.j)); + if (attributeGenerator != null) { + Object attribute = attributeGenerator + .generateAttribute(key.i, key.j); + + if (attribute != null) { + ps.setAttribute("label", attribute); + } } ps.setAttribute("line.width", LINE_WIDTH); } @@ -232,5 +234,11 @@ return series; } + + public void clear() { + open.clear(); + complete.clear(); + commonOpen.clear(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: