Skip to content

Commit eb778a7

Browse files
committed
Add transparent colors3 color heatmap
This relates to issue #66 where we are adding colors to enable the creation of a trace heatmap. The addition of this capability is fairly straightforward: -set the base image to fully transparent (white) -calculate an alpha gradient value for each square in the same way the red, green, and blue gradients are calculated -use this calculated alpha value to set the pixel-wise color -there are two places this is computed in three color heatmap so this will need to be updated in two places.
1 parent c6c9d1e commit eb778a7

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/scripts/Figure_Generation/ThreeColorHeatMap.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public static BufferedImage generateHeatMap(ArrayList<double[]> matrix) throws F
175175
BufferedImage im = new BufferedImage(pixwidth, pixheight, BufferedImage.TYPE_INT_ARGB);
176176
Graphics g = im.getGraphics();
177177
Graphics2D g2 = (Graphics2D) g;
178-
g2.setColor(new Color(255, 255, 255));
178+
g2.setColor(new Color(255, 255, 255, 0));
179179
g2.fillRect(0, 0, pixwidth, pixheight);
180180

181181
int count = 0;
@@ -196,7 +196,8 @@ public static BufferedImage generateHeatMap(ArrayList<double[]> matrix) throws F
196196
int red = (int) (MAXCOLOR.getRed() * sVal + MIDCOLOR.getRed() * (1 - sVal));
197197
int green = (int) (MAXCOLOR.getGreen() * sVal + MIDCOLOR.getGreen() * (1 - sVal));
198198
int blue = (int) (MAXCOLOR.getBlue() * sVal + MIDCOLOR.getBlue() * (1 - sVal));
199-
g.setColor(new Color(red, green, blue));
199+
int alpha = (int) (MAXCOLOR.getAlpha() * sVal + MIDCOLOR.getAlpha() * (1 - sVal));
200+
g.setColor(new Color(red, green, blue, alpha));
200201
} else if (IDj < MIDVAL) {
201202
double v = (MIDVAL - IDj) / LOWER_RATIO;
202203
double sVal = v > 1 ? 1 : v;
@@ -206,7 +207,8 @@ public static BufferedImage generateHeatMap(ArrayList<double[]> matrix) throws F
206207
int red = (int) (MINCOLOR.getRed() * sVal + MIDCOLOR.getRed() * (1 - sVal));
207208
int green = (int) (MINCOLOR.getGreen() * sVal + MIDCOLOR.getGreen() * (1 - sVal));
208209
int blue = (int) (MINCOLOR.getBlue() * sVal + MIDCOLOR.getBlue() * (1 - sVal));
209-
g.setColor(new Color(red, green, blue));
210+
int alpha = (int) (MINCOLOR.getAlpha() * sVal + MIDCOLOR.getAlpha() * (1 - sVal));
211+
g.setColor(new Color(red, green, blue, alpha));
210212
} else {
211213
g.setColor(MIDCOLOR);
212214
}

0 commit comments

Comments
 (0)