ba63ca047c08a7a20146f2c3216aa3330ece39b2
max
  Thu Dec 18 06:26:04 2014 -0800
changes after code review,  refs #14545
diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index fddc25b..5566118 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -1193,55 +1193,56 @@
             maxCount = binCount;
             maxColor = col;
             }
         }
     if (blendCount >= maxCount)
         maxColor = blendColor;
     }
 if (w < 1)
     w = 1;
 hvGfxBox(hvg, x1, y, w, height, maxColor);
 }
 
 void drawScaledBoxSampleLabel(struct hvGfx *hvg,
      int chromStart, int chromEnd, double scale,
      int xOff, int y, int height, Color color, MgFont *font,  char *label)
-/* Draw a box scaled from chromosome to window coordinates and draw a label onto it. */
+/* Draw a box scaled from chromosome to window coordinates and draw a label onto it. 
+ * Lots of code copied from drawScaledBoxSample */
 {
 //int i;
 int x1, x2, w;
 x1 = round((double)(chromStart-winStart)*scale) + xOff;
 x2 = round((double)(chromEnd-winStart)*scale) + xOff;
 
 if (x2 >= MAXPIXELS)
     x2 = MAXPIXELS - 1;
 
 if (x2 < xOff)
     x2 = xOff;
 if (x2 > xOff+insideWidth)
     x2 = xOff+insideWidth;
 if (x1 < xOff)
     x1 = xOff;
 if (x1 > xOff+insideWidth)
     x1 = xOff+insideWidth;
 w = x2-x1;
 if (w < 1)
     w = 1;
 hvGfxBox(hvg, x1, y, w, height, color);
 
 char *shortLabel = cloneString(label);
-/* calculate how many characters we can squeeze into box */
+/* calculate how many characters we can squeeze into the box */
 int charsInBox = w / mgFontCharWidth(font, 'm');
 if (charsInBox > 4)
     {
     if (charsInBox < strlen(label))
         strcpy(shortLabel+charsInBox-3, "...");
     Color labelColor = hvGfxContrastingColor(hvg, color);
     hvGfxTextCentered(hvg, x1, y, w, height, labelColor, font, shortLabel);
     }
 }
 
 void drawScaledBoxSample(struct hvGfx *hvg,
                          int chromStart, int chromEnd, double scale,
                          int xOff, int y, int height, Color color, int score)
 /* Draw a box scaled from chromosome to window coordinates. */
 {
@@ -1335,54 +1336,40 @@
 const struct linkedFeatures *b = *((struct linkedFeatures **)vb);
 return a->start - b->start;
 }
 
 char *linkedFeaturesName(struct track *tg, void *item)
 /* Return name of item. */
 {
 struct linkedFeatures *lf = item;
 return lf->name;
 }
 
 char *linkedFeaturesNameField1(struct track *tg, void *item)
 /* return part before first space in item name */
 {
 struct linkedFeatures *lf = item;
-if (lf->name==NULL)
-    return "";
-char* nonSpc = stringIn(" ", lf->name);
-if (nonSpc==NULL)
-    return lf->name;
-int part1Len = nonSpc - lf->name;
-char *newName = cloneStringZ(lf->name, part1Len);
-return newName;
+return cloneFirstWord(lf->name);
 }
 
-char *linkedFeaturesNameField2(struct track *tg, void *item)
+char *linkedFeaturesNameNotField1(struct track *tg, void *item)
 /* return part after first space in item name */
 {
 struct linkedFeatures *lf = item;
-if (lf->name==NULL)
-    return "";
-
-char* spcPos = stringIn(" ", lf->name);
-if (spcPos==NULL)
-    return lf->name;
-return cloneString(spcPos+1);
+return cloneNotFirstWord(lf->name);
 }
 
-
 void linkedFeaturesFreeList(struct linkedFeatures **pList)
 /* Free up a linked features list. */
 {
 struct linkedFeatures *lf;
 for (lf = *pList; lf != NULL; lf = lf->next)
     {
     slFreeList(&lf->components);
     slFreeList(&lf->codons);
     }
 slFreeList(pList);
 }
 
 void linkedFeaturesFreeItems(struct track *tg)
 /* Free up linkedFeaturesTrack items. */
 {
@@ -3782,31 +3769,31 @@
 tg->drawItemAt = linkedFeaturesDrawAt;
 tg->itemName = linkedFeaturesName;
 tg->mapItemName = linkedFeaturesName;
 tg->mapItem = linkedFeaturesMapItem;
 tg->totalHeight = tgFixedTotalHeightNoOverflow;
 tg->itemHeight = tgFixedItemHeight;
 tg->itemStart = linkedFeaturesItemStart;
 tg->itemEnd = linkedFeaturesItemEnd;
 tg->itemNameColor = linkedFeaturesNameColor;
 tg->nextPrevExon = linkedFeaturesNextPrevItem;
 tg->nextPrevItem = linkedFeaturesLabelNextPrevItem;
 
 if (trackDbSettingClosestToHomeOn(tg->tdb, "linkIdInName"))
     {
     tg->mapItemName = linkedFeaturesNameField1;
-    tg->itemName = linkedFeaturesNameField2;
+    tg->itemName = linkedFeaturesNameNotField1;
     }
 }
 
 int linkedFeaturesSeriesItemStart(struct track *tg, void *item)
 /* Return start chromosome coordinate of item. */
 {
 struct linkedFeaturesSeries *lfs = item;
 return lfs->start;
 }
 
 int linkedFeaturesSeriesItemEnd(struct track *tg, void *item)
 /* Return end chromosome coordinate of item. */
 {
 struct linkedFeaturesSeries *lfs = item;
 return lfs->end;