From 80fdb876d66f561692b9b61ea159dc25bf8c1120 Mon Sep 17 00:00:00 2001
From: Nicolas Dumoulin <nicolas.dumoulin@irstea.fr>
Date: Fri, 4 Sep 2015 16:43:54 +0000
Subject: [PATCH] gradient color dependent to HSI

---
 .../pikelake/environment/Movement2DWithinShapeObserver.java  | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/main/java/pikelake/environment/Movement2DWithinShapeObserver.java b/src/main/java/pikelake/environment/Movement2DWithinShapeObserver.java
index b523f04..ceda3bc 100644
--- a/src/main/java/pikelake/environment/Movement2DWithinShapeObserver.java
+++ b/src/main/java/pikelake/environment/Movement2DWithinShapeObserver.java
@@ -64,6 +64,7 @@ public class Movement2DWithinShapeObserver extends ObserverListener implements C
     private Color shapeColor;
     @Description (name="HSI color",tooltip="HSI color")
     private Color hsiColor;
+    private double hsiMaxValueThreshold=0.5;
     @Description (name="Text color",tooltip="Text color")
     private Color textColor;
     
@@ -94,7 +95,6 @@ public class Movement2DWithinShapeObserver extends ObserverListener implements C
     public Movement2DWithinShapeObserver(int margin,Color bgColor,Color shapeColor) {
         this.margin = margin;
         this.bgColor = bgColor;
-        this.shapeColor = shapeColor;
     }
 
     public String getTitle() {
@@ -257,7 +257,8 @@ public class Movement2DWithinShapeObserver extends ObserverListener implements C
 		            		xHSI2 = (int) (xHSI * (widthMax / grid.getGridWidth()));
 		            		yHSI2 = (int) (yHSI * (heightMax / grid.getGridHeight()));
 		            		
-		                	g2d.fillRect((int) xHSI2, (int) yHSI2, 3, 3);
+		                	g.setColor(new Color(0.43f, (float) (Math.min(1,grid.getCell(cptCell).getHabitatQuality()/hsiMaxValueThreshold)), 0.13f));
+                                        g2d.fillRect((int) xHSI2, (int) yHSI2, 3, 3);
 		                	
 		                	xx[cptCell] = xHSI2;
 		                	yy[cptCell] = yHSI2;
-- 
GitLab