void drawXScaleHydro(struct pbStamp *pbStampPtr, struct pbStampPict *stampPictPtr, double increment) /* mark the X axis scale */ { int i; double txmin, tymin, txmax, tymax; double xValue; int xx, yy; char labelStr[20]; int i0, i9; txmin = pbStampPtr->xmin; txmax = pbStampPtr->xmax; tymin = pbStampPtr->ymin; tymax = pbStampPtr->ymax; i0 =0; i9 =(int)((txmax - txmin)/increment); for (i=0; i<=i9; i++) { vLineM((double)i*increment+txmin, 0.0, (tymax-tymin)*0.05, 1, boundaryColor); xValue = txmin + increment*(double)i; calStampXY(stampPictPtr, xValue, 0, &xx, &yy); safef(labelStr, sizeof(labelStr), "%.1f", xValue); vgTextCentered(g_vg, xx-5, yy+5, 10, 10, MG_BLACK, g_font, labelStr); } }
void markStamp(struct pbStamp *pbStampPtr, struct pbStampPict *stampPictPtr, double xValue, char *valStr, double tx[], double ty[]) /* mark the the stamp with a vertical line */ { int ix, iy; double txmin, tymin, txmax, tymax; double ytop=0.0; int len; int xx, yy; int i, iTarget; len = pbStampPtr->len; txmin = pbStampPtr->xmin; txmax = pbStampPtr->xmax; tymin = pbStampPtr->ymin; tymax = pbStampPtr->ymax; calStampXY(stampPictPtr, txmin+(txmax-txmin)/2.0, tymax, &xx, &yy); vgTextCentered(g_vg, xx-5, yy+3, 10, 10, pbBlue, g_font, valStr); ix = stampPictPtr->xOrig; iy = stampPictPtr->yOrig; calStampXY(stampPictPtr, (txmax-txmin)/2.0, tymax, &xx, &yy); iTarget = -1; for (i=0; i<(len-1); i++) { if ((xValue >= tx[i]) && (xValue <= tx[i+1])) { iTarget = i; } } if (iTarget != -1) { if (ty[iTarget] > 0.1 * (tymax - tymin)) { ytop = ty[iTarget]; } else { ytop = 0.1 * (tymax - tymin) + tymin; } } vLineM(tx[iTarget]+(tx[iTarget+1]-tx[iTarget])/2.0, 0, ytop, 2, pbBlue); }
void markStamp0(struct pbStamp *pbStampPtr, struct pbStampPict *stampPictPtr, double xValue, char *valStr, double tx[], double ty[]) /* mark the the stamp with valStr only, used for 'N/A' case only */ { double txmin, tymin, txmax, tymax; int len; int xx, yy; len = pbStampPtr->len; txmin = pbStampPtr->xmin; txmax = pbStampPtr->xmax; tymin = pbStampPtr->ymin; tymax = pbStampPtr->ymax; calStampXY(stampPictPtr, txmin+(txmax-txmin)/2.0, tymax, &xx, &yy); vgTextCentered(g_vg, xx-5, yy+3, 10, 10, pbBlue, g_font, valStr); }
void vgDrawRulerBumpText(struct vGfx *vg, int xOff, int yOff, int height, int width, Color color, MgFont *font, int startNum, int range, int bumpX, int bumpY) /* Draw a ruler inside the indicated part of mg with numbers that start at * startNum and span range. Bump text positions slightly. */ { int tickSpan; int tickPos; double scale; int firstTick; int remainder; int end = startNum + range; int x; char tbuf[14]; int numWid; int goodNumTicks; int niceNumTicks = width/35; numLabelString(startNum+range, tbuf); numWid = mgFontStringWidth(font, tbuf)+4+bumpX; goodNumTicks = width/numWid; if (goodNumTicks < 1) goodNumTicks = 1; if (goodNumTicks > niceNumTicks) goodNumTicks = niceNumTicks; tickSpan = figureTickSpan(range, goodNumTicks); scale = (double)width / range; firstTick = startNum + tickSpan; remainder = firstTick % tickSpan; firstTick -= remainder; for (tickPos=firstTick; tickPos<end; tickPos += tickSpan) { numLabelString(tickPos, tbuf); numWid = mgFontStringWidth(font, tbuf)+4; x = (int)((tickPos-startNum) * scale) + xOff; vgBox(vg, x, yOff, 1, height, color); if (x - numWid >= xOff) { vgTextCentered(vg, x-numWid + bumpX, yOff + bumpY, numWid, height, color, font, tbuf); } } }
void drawXScaleMW(struct pbStamp *pbStampPtr, struct pbStampPict *stampPictPtr, int increment) /* mark the X axis scale */ { int i; double txmin, tymin, txmax, tymax; int xx, yy; char labelStr[20]; txmin = pbStampPtr->xmin; txmax = pbStampPtr->xmax; tymin = pbStampPtr->ymin; tymax = pbStampPtr->ymax; for (i=(int)txmin; i<=(int)txmax; i=i+increment) { vLineM((double)i+0.5, 0.0, (tymax-tymin)*0.05, 1, boundaryColor); calStampXY(stampPictPtr, (double)i+0.5, 0, &xx, &yy); safef(labelStr, sizeof(labelStr), "%dK", i/1000); vgTextCentered(g_vg, xx-5, yy+5, 10, 10, MG_BLACK, g_font, labelStr); } }
void drawPbStampB(struct pbStamp *pbStampPtr, struct pbStampPict *stampPictPtr) /* draw the stamp, especially for the AA Anomaly */ { int ix, iy, iw, ih; char *stampTable, *stampTitle, *stampDesc; double txmin, tymin, txmax, tymax; int i, n, index; int xx, yy; char charStr[2]; int titleLen; stampTable = cloneString(pbStampPtr->stampTable); stampTitle = cloneString(pbStampPtr->stampTitle); n = pbStampPtr->len; txmin = pbStampPtr->xmin; txmax = pbStampPtr->xmax; tymin = pbStampPtr->ymin; tymax = pbStampPtr->ymax; stampDesc = cloneString(pbStampPtr->stampDesc); ix = stampPictPtr->xOrig; iy = stampPictPtr->yOrig; iw = stampPictPtr->width; ih = stampPictPtr->height; xScale = (double)(iw)/(txmax - txmin); yScale = (double)(ih)/(tymax - tymin); calStampXY(stampPictPtr, txmin, tymax, &xx, &yy); mapBoxStamp(xx, yy, iw, ih, "Amino Acid Anomalies", "pepAnomalies"); calStampXY(stampPictPtr, txmin+(txmax-txmin)/2.0, tymax, &xx, &yy); vgTextCentered(g_vg, xx-5, yy-12, 10, 10, MG_BLACK, g_font, "Amino Acid Anomalies"); titleLen = strlen("Amino Acid Anomoly"); mapBoxStampTitle(xx-5-titleLen*6/2-6, yy-14, titleLen*6+12, 14, "Amino Acid Anomolies", "pepAnomalies"); /* calStampXY(stampPictPtr, txmax-(txmax-txmin)*.25, tymin+(tymax-tymin)/4.0*3.0, &xx, &yy); vgTextCentered(g_vg, xx, yy-10, 10, 10, MG_BLACK, g_font, "+2 stddev"); calStampXY(stampPictPtr, txmax-(txmax-txmin)*.25, tymin+(tymax-tymin)/4.0, &xx, &yy); vgTextCentered(g_vg, xx, yy-10, 10, 10, MG_BLACK, g_font, "-2 stddev"); */ index = 0; hLine(tx[index], (tymax-tymin)/8.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY); hLine(tx[index], (tymax-tymin)/4.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY); hLine(tx[index], (tymax-tymin)/8.0*3.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY); hLine(tx[index], (tymax-tymin)/4.0*3.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY); hLine(tx[index], (tymax-tymin)/8.0*4.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY); hLine(tx[index], (tymax-tymin)/8.0*5.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY); hLine(tx[index], (tymax-tymin)/8.0*7.0, (tx[index+1]-tx[index])/2.0, 1, MG_GRAY); for (index=0; index < (n-1); index++) { hLine(tx[index], (tymax-tymin)/2.0, tx[index+1]-tx[index], 1, MG_BLACK); } vLine(tx[0], 0, ty[0], 1, pbBlue); hLine(txmin, tymin, txmax-txmin, 2, boundaryColor); /* this line needs to call hLine2 for fine tuning at the right hand side ending */ hLine2(txmin, tymax, txmax-txmin, 2, boundaryColor); vLine(txmin, tymin, tymax-tymin, 2, boundaryColor); vLine(txmax, tymin, tymax-tymin, 2, boundaryColor); if (strcmp(pbStampPtr->stampName, "pepRes") == 0) { for (i=0; i<20; i++) { calStampXY(stampPictPtr, tx[i], tymin, &xx, &yy); safef(charStr, sizeof(charStr), "%c", aaAlphabet[i]); vgTextCentered(g_vg, xx+1, yy+5, 10, 10, MG_BLACK, g_font, charStr); } } }
void drawPbStamp(struct pbStamp *pbStampPtr, struct pbStampPict *stampPictPtr) /* draw the stamp */ { int ix, iy, iw, ih; char *stampName, *stampTable, *stampTitle, *stampDesc; double txmin, tymin, txmax, tymax; int i, n, index; int xx, yy; char charStr[2]; Color edgeColor; Color stampColor; int titleLen; stampName = cloneString(pbStampPtr->stampName); stampTable = cloneString(pbStampPtr->stampTable); stampTitle = cloneString(pbStampPtr->stampTitle); n = pbStampPtr->len; txmin = pbStampPtr->xmin; txmax = pbStampPtr->xmax; tymin = pbStampPtr->ymin; tymax = pbStampPtr->ymax; stampDesc = cloneString(pbStampPtr->stampDesc); ix = stampPictPtr->xOrig; iy = stampPictPtr->yOrig; iw = stampPictPtr->width; ih = stampPictPtr->height; xScale = (double)(iw)/(txmax - txmin); yScale = (double)(ih)/(tymax - tymin); calStampXY(stampPictPtr, txmin, tymax, &xx, &yy); mapBoxStamp(xx, yy, iw, ih, stampTitle, stampName); calStampXY(stampPictPtr, txmin+(txmax-txmin)/2.0, tymax, &xx, &yy); vgTextCentered(g_vg, xx-5, yy-12, 10, 10, MG_BLACK, g_font, stampTitle); titleLen = strlen(stampTitle); mapBoxStampTitle(xx-5-titleLen*6/2-6, yy-14, titleLen*6+12, 14, stampTitle, stampName); edgeColor = boundaryColor; stampColor = vgFindColorIx(g_vg, 220, 220, 220); for (index=0; index < (n-1); index++) { pbBox(tx[index], tymin, tx[index+1]-tx[index], ty[index], stampColor); hLine(tx[index], ty[index], tx[index+1]-tx[index], 1, edgeColor); } vLine(tx[0], 0, ty[0], 1, edgeColor); for (index=0; index < (n-1); index++) { if (ty[index+1] > ty[index]) { vLine(tx[index+1], ty[index], ty[index+1]-ty[index], 1, edgeColor); } else { vLine(tx[index+1], ty[index+1], ty[index]-ty[index+1], 1, edgeColor); } } hLine(txmin, tymin, txmax-txmin, 2, boundaryColor); /* this line needs to call hLine2 for fine tuning at the right hand side ending */ hLine2(txmin, tymax, txmax-txmin, 2, boundaryColor); vLine(txmin, tymin, tymax-tymin, 2, boundaryColor); vLine(txmax, tymin, tymax-tymin, 2, boundaryColor); if (strcmp(pbStampPtr->stampName, "pepRes") == 0) { for (i=0; i<20; i++) { calStampXY(stampPictPtr, tx[i], tymin, &xx, &yy); safef(charStr, sizeof(charStr), "%c", aaAlphabet[i]); vgTextCentered(g_vg, xx+1, yy+5, 10, 10, MG_BLACK, g_font, charStr); } } }