Hello!

To see the file structure, click on "tree".

Note that updates take place every 10 minutes, commits may not be seen immediately.
Fully operational image generation, independent of JHeatChart libraries.
authormiles <miles@localhost>
Mon, 23 Jul 2012 22:53:04 +0000 (22:53 +0000)
committermiles <miles@localhost>
Mon, 23 Jul 2012 22:53:04 +0000 (22:53 +0000)
svn path=/; revision=368

Personnel/miles/2/src/Heatmap.java

index 2a77845ad6330669269c960c73a4b7fdd8c059b1..2182f40c0a18ea44390802df8a0f562db1cc7d23 100644 (file)
@@ -4,6 +4,7 @@ import java.io.*;
 import java.util.Properties;
 import java.util.Scanner;
 import java.awt.*;
+import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
 import java.awt.image.BufferedImageOp;
 import java.awt.image.ImageProducer;
@@ -39,7 +40,7 @@ public class Heatmap {
        }
        
     private static void generateHeatMapImage(Species[] species) {
-        /*
+        
        File output = new File("heatMap");
        
        int heatMapHeight = 25*allClusterIDs.length;
@@ -63,32 +64,49 @@ public class Heatmap {
             }
         }
        
-        
+        int speciesNameLength = 200;
         int chartWidth = heatMapWidth + 50;
-        int chartHeight = heatMapHeight + 300;
+        int chartHeight = heatMapHeight + speciesNameLength;
                BufferedImage chartImage = new BufferedImage(chartWidth, chartHeight, imageType);
                Graphics2D chartGraphics = chartImage.createGraphics();
         Color background = new Color(255, 255, 255);
                chartGraphics.setColor(background);
                chartGraphics.fillRect(0, 0, chartWidth, chartHeight);
-               chartGraphics.drawImage(heatMapImage, 50, 300, null);
+               chartGraphics.drawImage(heatMapImage, 50, speciesNameLength, null);
                chartGraphics.setColor(Color.black);
                chartGraphics.drawString("Heat Map", 25, 25);
                
                for (int c = 0; c < allClusterIDs.length; c ++) {
                        String clusterID = Integer.toString(allClusterIDs[c]);
-                       chartGraphics.drawString(clusterID, 5, (315 + c*25));
+                       chartGraphics.drawString(clusterID, 5, (speciesNameLength + 15 + c*25));
                }
+               
+               for (int s = 0; s < species.length; s ++) {
+                       int valueXPos = 70 + (s * 25);
+                       int valueYPos = speciesNameLength - 5;
+                       // Create 270 degree rotated transform.
+                       AffineTransform transform = chartGraphics.getTransform();
+                       AffineTransform originalTransform = (AffineTransform) transform.clone();
+                       transform.rotate(Math.toRadians(270), valueXPos, valueYPos);
+                       chartGraphics.setTransform(transform);
+                       
+                       // Draw the string.
+                       chartGraphics.drawString(species[s].name, valueXPos, valueYPos);
+                       
+                       // Revert to original transform before rotation.
+                       chartGraphics.setTransform(originalTransform);
+               }
+               
 
        try {
                        ImageIO.write((RenderedImage) chartImage, "gif", output);
                } catch (IOException e) {
                        System.out.println("Unable to write Heat Map Image");
                }
-               */
                
                
-        
+               
+        /*
        double[][] heatMapVals = new double[allClusterIDs.length][species.length];
         for (int s = 0; s < species.length; s ++) {
                 for (int c = 0; c < allClusterIDs.length; c ++) {
@@ -126,6 +144,7 @@ public class Heatmap {
         } catch (IOException e) {
                 System.out.println("Unable to write image to file");
         }
+        */
         
     }