
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.util.HashMap;

/**
 * Created by Nick on 7/26/14.
 */
public class HeatMapPanel extends JPanel {
    HashMap<Integer,Integer> data;
    HeatMapPanel(HashMap<Integer,Integer> data){
        this.data = data;
    }
    //This function will take all the totals, and calculate them out of 255, which will be the Red value in the color code for the heatmap. The RGB values will be R,0,0
    private HashMap<Integer,Integer> calculatePercentages(){
        HashMap<Integer,Integer> tempData = new HashMap<Integer, Integer>();
        int maxValue = getLargestKey();
        for (int keyCode : data.keySet()){
//            Calculate the proportion
//            keyCode     x
//            -------- = ---
//            maxValue   255
//            Which solves to keyCode*255 = maxValue*x
//            Which isolated is equal to (keyCode*255)/maxValue
            int value = keyCode*255/maxValue;
            tempData.put(keyCode,value);
        }
        return tempData;
    }
    //Returns the percentage for the key with the largest value
    private int getLargestKey(){
        int max = 0;
        for (int value : data.values()){
            if (value>max)
                max = value;
        }
        return max;
    }
    @Override
    public void paint(Graphics g){
        data = calculatePercentages();

        //Escape key
//        g.setColor(new Color())
        g.fillRect(0, 0, 30, 30);

        //Leave a 30 pixel space for the space between the escape key and the f row
        //F row and print screen and scrlk and pause/break
        for (int i=0; i<15; i++){
            
        }

    }
    @Override
    public Dimension getPreferredSize(){
        return new Dimension(900,256);
    }
}

@@ -310,24 +310,158 @@
 ata = data;%0A
+        //Debug data%0A        data.put(KeyEvent.VK_F1,50);%0A        data.put(KeyEvent.VK_F2,100);%0A        data.put(KeyEvent.VK_F3,300);%0A
     %7D%0A    //
@@ -797,24 +797,62 @@
 rgestKey();%0A
+        System.out.println(maxValue);%0A
         for 
@@ -882,16 +882,62 @@
 Set())%7B%0A
+            int keyValue = data.get(keyCode);%0A
 //      
@@ -984,19 +984,20 @@
      key
-Cod
+Valu
 e     x%0A
@@ -1196,27 +1196,28 @@
  value = key
-Cod
+Valu
 e*255/maxVal
@@ -1216,24 +1216,63 @@
 5/maxValue;%0A
+            System.out.println(value);%0A
             
@@ -1641,16 +1641,39 @@
 ics g)%7B%0A
+        int colorCode;%0A
         
@@ -1703,17 +1703,16 @@
 ages();%0A
-%0A
         
@@ -1724,18 +1724,199 @@
 ape key%0A
-//
+        if (data.containsKey(KeyEvent.VK_ESCAPE))%0A            colorCode = data.get(KeyEvent.VK_ESCAPE);%0A        else%0A            colorCode = 0;%0A        System.out.println(colorCode);%0A
         
@@ -1936,18 +1936,32 @@
 w Color(
+colorCode,0,0
 ))
+;
 %0A       
@@ -2007,17 +2007,17 @@
 eave a 3
-0
+5
  pixel s
@@ -2108,81 +2108,400 @@
 reen
- and scrlk and pause/break%0A        for (int i=0; i%3C15; i++)%7B%0A            
+%0A        for (int i=0; i%3C=12; i++)%7B%0A            if (data.containsKey(KeyEvent.VK_F1+i))%0A                colorCode = data.get(KeyEvent.VK_F1+i);%0A            else%0A                colorCode = 0;%0A            g.setColor(new Color(colorCode,0,0));%0A            //i+2 so the x value will never be 0, and we actually skip a space. A bit hacky, but it works.%0A            g.fillRect((i+2)*35, 0, 30,30);
 %0A   

Add test values for ehatmap and f row to drawing