Author: echatellier Date: 2011-12-06 18:18:23 +0100 (Tue, 06 Dec 2011) New Revision: 915 Url: http://forge.codelutin.com/repositories/revision/coser/915 Log: Display each haul series in differents colors Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java trunk/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-12-05 10:08:58 UTC (rev 914) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-12-06 17:18:23 UTC (rev 915) @@ -2886,12 +2886,22 @@ public List<Coordinate> getStrataHaulCoordinate(Selection selection, Collection<String> strataCollection) throws CoserBusinessException { List<Coordinate> hauls = new ArrayList<Coordinate>(); + + // serie cache to compute serie index + List<String> serieCache = new ArrayList<String>(); Iterator<String[]> itData = selection.getHaul().iterator(true); while (itData.hasNext()) { String[] tuple = itData.next(); String strata = tuple[Haul.INDEX_STRATUM]; + + // add it to cache (even not selected to stay same color + // in different display) + if (!serieCache.contains(strata)) { + serieCache.add(strata); + } + if (strataCollection.contains(strata)) { String stratum = tuple[Haul.INDEX_STRATUM]; String year = tuple[Haul.INDEX_YEAR]; @@ -2904,7 +2914,8 @@ double dlong = Double.parseDouble(longi); String name = _("coser.business.map.haulname", stratum, year, haul); - Coordinate coordinate = new Coordinate(name, dlat, dlong); + int serieIndex = serieCache.indexOf(strata); + Coordinate coordinate = new Coordinate(serieIndex, name, dlat, dlong); hauls.add(coordinate); } } Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java 2011-12-05 10:08:58 UTC (rev 914) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java 2011-12-06 17:18:23 UTC (rev 915) @@ -41,6 +41,8 @@ /** serialVersionUID. */ private static final long serialVersionUID = -5111417883474394223L; + protected int serie; + protected String name; protected double latitude; @@ -51,13 +53,22 @@ } - public Coordinate(String name, double latitude, double longitude) { + public Coordinate(int serie, String name, double latitude, double longitude) { this(); + this.serie = serie; this.name = name; this.latitude = latitude; this.longitude = longitude; } + public int getSerie() { + return serie; + } + + public void setSerie(int serie) { + this.serie = serie; + } + public String getName() { return name; } Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java 2011-12-05 10:08:58 UTC (rev 914) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java 2011-12-06 17:18:23 UTC (rev 915) @@ -46,11 +46,25 @@ */ public class HaulLocationHandler extends AbstractLocationHandler { + protected static Color[] markerColors = new Color[] { + Color.RED, + Color.BLUE, + Color.CYAN, + Color.GRAY, + Color.BLACK, + Color.GREEN, + Color.GREEN.darker(), + Color.MAGENTA, + Color.PINK, + Color.YELLOW, + new Color(165, 3, 63) // purple + }; + protected List<Coordinate> coordinates; public HaulLocationHandler(List<Coordinate> coordinates) { this.coordinates = coordinates; - setLocationColor(Color.RED); + setLocationColor(Color.GREEN); setShowLocations(true); } @@ -61,14 +75,14 @@ public OMGraphicList get(float nwLat, float nwLon, float seLat, float seLon, OMGraphicList graphicList) { for (Coordinate coordinate : coordinates) { + + // get color index in color array depending on serie + int serie = coordinate.getSerie(); + serie = serie % markerColors.length; + Location location = new BasicLocation(coordinate.getLatitude(), coordinate.getLongitude(), coordinate.getName(), null); location.setLocationHandler(this); - //location.getLabel().setLinePaint(Color.BLACK); - //location.getLabel().setMatted(true); - //location.setLinePaint(Color.BLUE); - location.setShowName(true); - location.setShowLocation(true); - + location.getLocationMarker().setLinePaint(markerColors[serie]); graphicList.add(location); }