src/hg/instinct/hgHeatmap2/hgAnnotations.c 1.12
1.12 2009/09/02 17:43:12 jsanborn
added gene labels to geneset view
Index: src/hg/instinct/hgHeatmap2/hgAnnotations.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/hgHeatmap2/hgAnnotations.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -b -B -U 4 -r1.11 -r1.12
--- src/hg/instinct/hgHeatmap2/hgAnnotations.c 19 Aug 2009 23:00:18 -0000 1.11
+++ src/hg/instinct/hgHeatmap2/hgAnnotations.c 2 Sep 2009 17:43:12 -0000 1.12
@@ -617,23 +617,31 @@
int height = hgHeatmapDefaultLabelHeight;
if (!hlList)
return height;
-return height;
-
+boolean drawGeneLabels = TRUE;
+int maxStrWidth = 0;
struct heatmapLay *hl;
for (hl = hlList; hl ; hl = hl->next)
{
- int gsWidth = hl->pixelEnd - hl->pixelStart;
- int strWidth = mgFontStringWidth(hl->font, hl->name);
-
- if (strWidth < gsWidth)
- continue;
+ struct hmElement *hEl;
+ for (hEl = hl->elements; hEl; hEl = hEl->next)
+ {
+ int gWidth = hEl->pixelEnd - hEl->pixelStart;
+ if (gWidth < hlList->fontHeight)
+ {
+ drawGeneLabels = FALSE;
+ break;
+ }
- /* need to go vertical */
- if (height < strWidth + 5)
- height = strWidth + 5;
+ int strWidth = mgFontStringWidth(hl->font, hEl->name);
+ if (strWidth > maxStrWidth)
+ maxStrWidth = strWidth;
}
+ }
+
+if (drawGeneLabels && maxStrWidth > 0)
+ height += maxStrWidth + 5; // 5 pixel buffer between gene labels and geneset label.
return height;
}
@@ -645,8 +653,12 @@
int width = hgHeatmapDefaultPixWidth;
int labelHeight = hlList->height;
+boolean drawGeneLabels = TRUE;
+if (labelHeight == hgHeatmapDefaultLabelHeight)
+ drawGeneLabels = FALSE;
+
vgSetClip(vg, 0, 0, width, labelHeight);
struct heatmapLay *hl;
for (hl = hlList; hl ; hl = hl->next)
@@ -665,15 +677,31 @@
/* Draw geneset label, currently only horizontally, with name cut-off
* if there's not enough room */
vgSetClip(vg, leftX, 0, gsWidth, labelHeight);
+
+ if (drawGeneLabels)
+ {
+ struct hmElement *hEl;
+ for (hEl=hl->elements; hEl; hEl = hEl->next)
+ {
+ int gWidth = hEl->pixelEnd - hEl->pixelStart;
+ if (gWidth < hlList->fontHeight)
+ break; // not enough horizontal space to draw gene name vertically, leave blank.
+
+ verticalTextRight(vg, hEl->pixelStart+1, -5, gWidth-2,
+ labelHeight - hlList->fontHeight, MG_BLACK,
+ hlList->font, hEl->name);
+ }
+ }
+
int strWidth = mgFontStringWidth(hl->font, hl->name);
if (strWidth < gsWidth)
- vgTextCentered(vg, leftX, 0, gsWidth,
- labelHeight, MG_BLACK, hlList->font, hl->name);
+ vgTextCentered(vg, leftX, labelHeight - hlList->fontHeight, gsWidth,
+ hlList->fontHeight, MG_BLACK, hlList->font, hl->name);
else
- vgTextCentered(vg, leftX, 0, strWidth,
- labelHeight, MG_BLACK, hlList->font, hl->name);
+ vgTextCentered(vg, leftX, labelHeight - hlList->fontHeight, strWidth,
+ hlList->fontHeight, MG_BLACK, hlList->font, hl->name);
vgUnclip(vg);
// vgText(vg, hEl->pixelStart + 3, y, MG_BLACK, hl->font, hEl->name);