230b2b23ed69e202ac634bb16c62a833354f2fcd max Tue Dec 9 13:18:48 2014 -0800 new tdb statement "labelOnFeature", refs #14512 diff --git src/hg/hgTracks/bedTrack.c src/hg/hgTracks/bedTrack.c index dc7f6c6..c092189 100644 --- src/hg/hgTracks/bedTrack.c +++ src/hg/hgTracks/bedTrack.c @@ -514,66 +514,74 @@ else if (tg->colorShades) { adjustBedScoreGrayLevel(tdb, bed, scoreMin, scoreMax); color = tg->colorShades[grayInRange(bed->score, scoreMin, scoreMax)]; } /* Keep the item at least 4 pixels wide at all viewpoints */ if (thickDrawItem && (w < 4)) { x1 -= ((5-w) >> 1); w = 4; x2 = x1 + w; } if (color) { hvGfxBox(hvg, x1, y, w, heightPer, color); - if (tg->drawName && vis != tvSquish) + if (tg->drawLabelInBox) + { + char *label = tg->itemName(tg, bed); + drawScaledBoxSampleLabel(hvg, s, e, scale, xOff, y, heightPer, color, font, label); + } + else if (tg->drawName && vis != tvSquish) { /* Clip here so that text will tend to be more visible... */ char *s = tg->itemName(tg, bed); w = x2-x1; if (w > mgFontStringWidth(font, s)) { Color textColor = hvGfxContrastingColor(hvg, color); hvGfxTextCentered(hvg, x1, y, w, heightPer, textColor, font, s); } mapBoxHgcOrHgGene(hvg, bed->chromStart, bed->chromEnd, x1, y, x2 - x1, heightPer, tg->track, tg->mapItemName(tg, bed), NULL, directUrl, withHgsid, NULL); } } -if (tg->subType == lfWithBarbs || tg->exonArrows) +if ((tg->subType == lfWithBarbs || tg->exonArrows) && !tg->drawLabelInBox) { int dir = 0; if (bed->strand[0] == '+') dir = 1; else if(bed->strand[0] == '-') dir = -1; if (dir != 0 && w > 2) { int midY = y + (heightPer>>1); Color textColor = hvGfxContrastingColor(hvg, color); clippedBarbs(hvg, x1, midY, w, tl.barbHeight, tl.barbSpacing, dir, textColor, TRUE); } } } void bedDrawSimple(struct track *tg, int seqStart, int seqEnd, struct hvGfx *hvg, int xOff, int yOff, int width, MgFont *font, Color color, enum trackVisibility vis) /* Draw simple Bed items. */ { +// optional setting to draw labels onto the feature boxes, not next to them +tg->drawLabelInBox = cartOrTdbBoolean(cart, tg->tdb, "labelOnFeature" , FALSE); + if (!tg->drawItemAt) errAbort("missing drawItemAt in track %s", tg->track); if (tg->items == NULL && vis == tvDense && canDrawBigBedDense(tg)) { bigBedDrawDense(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color); } else genericDrawItems(tg, seqStart, seqEnd, hvg, xOff, yOff, width, font, color, vis); } char *bedName(struct track *tg, void *item) /* Return name of bed track item. */ {