package flg.rendering;

import java.awt.Color;
import java.awt.Graphics;

import javax.swing.JPanel;


public class HeatMap
extends JPanel {

    private static final long serialVersionUID = 1L;

    public final static int   PIXEL_SIZE       = 5;

    private float[][]         heights;

    public HeatMap(float[][] heights) {
        super();
        this.heights = heights;
    }

    @Override
    public void paint(Graphics g) {

        // draw the grid
        for (int i = 0; i < this.heights[0].length; i++) {
            for (int j = 0; j < this.heights[i].length; j++) {
                float height = this.heights[i][j];

                if (height <= -2) {
                    g.setColor(Color.BLUE);
                } else if (height > -2 && height < 2) {
                    g.setColor(Color.GREEN);
                } else if (height >= 2) {
                    g.setColor(Color.WHITE);
                }


                int x = PIXEL_SIZE * i;
                int y = PIXEL_SIZE * j;

                g.fillRect(x, y, PIXEL_SIZE, PIXEL_SIZE);
            }
        }
    }
}

@@ -242,9 +242,9 @@
   = 
-5
+3
 ;%0A%0A 
@@ -705,14 +705,40 @@
 lor.
-BLUE);
+decode(%22#06109a%22)); // dark blue
 %0A   
@@ -784,18 +784,424 @@
 height %3C
- 2
+= -1.5) %7B%0A                    g.setColor(Color.decode(%22#414df6%22)); // brighter blue%0A                %7D else if (height %3E -1.5 && height %3C= 0.5) %7B%0A                    g.setColor(Color.decode(%22#10b223%22)); // dark green%0A                %7D else if (height %3E 0.5 && height %3C= 1.6) %7B%0A                    g.setColor(Color.decode(%22#2eea1c%22)); // brighter green%0A                %7D else if (height %3E 1.6 && height %3C= 2.75
 ) %7B%0A    
@@ -1239,11 +1239,10 @@
 r.GR
-EEN
+AY
 );%0A 
@@ -1275,19 +1275,21 @@
 height %3E
-=
  2
+.75
 ) %7B%0A    

Extend heat map with better color scale.