51 NCBI_ASSERT(
false,
"Unknown tooltip formatter type!");
57 const string pmURL(
"/pubmed/");
60 vector<string> tokens;
63 ITERATE(vector<string>, pmidIter, tokens) {
64 string pmid = *pmidIter;
78 if(!pmlinks.empty()) {
80 if(isBulletColPresent) {
96 if(isBulletColPresent)
101 isGoToPresent =
true;
124 if (!sBulletSrc.empty())
125 m_sTooltipText +=
"<img class=\"sv-bintrack\" src=\"" + sBulletSrc +
"\"/>";
133 if (!sBulletSrc.empty())
134 m_sTooltipText +=
"<img class=\"sv-bintrack\" src=\"" + sBulletSrc +
"\"/> ";
142 if (isNoWrap || width) {
143 styleAttr =
" style=\"";
144 styleAttr += isNoWrap ?
"white-space:nowrap;" :
"";
171 m_sTooltipText +=
"<tr class=\"sv-bintrack\"><td class=\"sv-bintrack-tag\">";
181 m_sLinksText +=
"<tr class=\"sv-bintrack\"><td class=\"sv-bintrack-tag\">";
191 m_sLinksText +=
"<tr class=\"sv-bintrack\"><td class=\"sv-bintrack-tag\">";
203 m_sLinksText +=
"<tr class=\"sv-bintrack\"><td class=\"sv-bintrack-tag\" align=\"right\" valign=\"top\" style=\"white-space: nowrap\">[<i>" + sTitle +
"</i>]</td><td class=\"sv-bintrack\" colspan=\"0\"/></tr>";
208 m_sTooltipText +=
"<tr class=\"sv-bintrack\"><td class=\"sv-bintrack-value\" align=\"right\" valign=\"top\" style=\"white-space: nowrap\">[<i>" + sContents +
"</i>]</td><td class=\"sv-bintrack\" colspan=\"0\"/></tr>";
215 string sWholeTooltip;
217 sWholeTooltip +=
"<table class=\"sv-bintrack\" style=\"border-spacing:2px\">" +
m_sTooltipText +
"</table>";
221 sWholeTooltip +=
"<br/> ";
222 sWholeTooltip +=
"<table class=\"sv-bintrack\" style=\"border-spacing:2px\">" +
m_sLinksText +
"</table>";
226 return sWholeTooltip;
257 if (!pCSSTableFormatter)
282 if(!sBulletSrc.empty()) {
292 if (!sBulletSrc.empty())
304 string(isNoWrap ?
" nowrap" :
"") +
328 string spacedValue(sValue);
332 m_sTooltipText +=
"<tr><td align=\"right\" valign=\"top\" nowrap><span style=\"font-weight:bold\">";
345 m_sLinksText +=
"<tr><td align=\"right\" valign=\"top\" nowrap><span style=\"font-weight:bold\">";
358 m_sLinksText +=
"<tr><td align=\"right\" valign=\"top\" nowrap><span style=\"font-weight:bold\">";
373 m_sLinksText +=
"<tr><td align=\"right\" valign=\"top\" nowrap>[<i>" + sTitle +
"</i>]</td><td colspan=\"0\"/></tr>";
378 m_sTooltipText +=
"<tr><td align=\"right\" valign=\"top\" nowrap>[<i>" + sContents +
"</i>]</td><td colspan=\"0\"/></tr>";
385 string sWholeTooltip;
387 sWholeTooltip +=
"<table margin=\"0\" padding=\"0\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">" +
m_sTooltipText +
"</table>";
391 sWholeTooltip +=
"<br/> ";
392 sWholeTooltip +=
"<table margin=\"0\" padding=\"0\" border=\"0\" cellpadding=\"0\" cellspacing=\"2\">" +
m_sLinksText +
"</table>";
396 return sWholeTooltip;
416 string sSpacedText(sText);
429 string sUpdateURL =
NStr::Replace(sUrl,
"/projects/sviewer/",
"");
430 return CreateLink(sText,
string(
"$GENOMIC_LINK$") + sUpdateURL);
445 size_t pos =
input.find(search);
446 while (string::npos != pos) {
447 occurences.push_back(pos);
448 pos =
input.find(search, pos + 1);
454 size_t length = (end <
input.length() ? end :
input.length() - 1) - start + 1;
455 unsigned fragments = (unsigned)
round(length / (
double)fragment_length);
456 unsigned insertions(0);
457 for (
unsigned i = 1;
i <= fragments; ++
i) {
458 size_t pos = start +
i*fragment_length + insertions;
459 if (pos >
input.length())
462 input.insert(pos, 1,
' ');
470 if (
input.length() <= fragment_length)
473 vector<size_t> spaces;
478 if (spaces.empty()) {
483 spaces.push_back(
input.length() - 1);
487 unsigned insertions = 0;
489 start = end + insertions;
490 end = spaces[
i++] + insertions;
491 if ((end - start + 1) > fragment_length)
492 insertions +=
x_InsertSpaces(
input, start + insertions, end + insertions, fragment_length);
494 while (
i < spaces.size());
521 if (!sBulletSrc.empty())
581 sWholeTooltip +=
"\n";
586 return sWholeTooltip;
tooltips using plain text formatting
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NCBI_ASSERT(expr, mess)
static string GetNcbiBaseUrl()
CCSSTableTooltipFormatter()
virtual void FinishRow()=0
finish the row (i.e. no other contents will be added to it)
virtual void AddValueCol(const string &sContents="", unsigned width=200, bool isNoWrap=false)
adds a value column to the row
virtual void AddDividerRow(unsigned colspan=2)
add a horizontal divider between sections of the table
virtual void Append(const ITooltipFormatter &tooltip)
appends another formatter to this one
virtual string CreateNcbiLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied NCBI URL path
virtual string Render()
returns the formatted tooltip text and resets the formatter for reuse
static CIRef< ITooltipFormatter > CreateTooltipFormatter()
ETooltipFormatters
supported types of formatters
virtual string Render()
returns the formatted tooltip text and resets the formatter for reuse
virtual void AddTagCol(const string &sContents="", const string &sBulletSrc="")
adds a tag column to the row
virtual void AddPubmedLinksRow(const string &pmids, bool &isGoToPresent, bool isBulletColPresent)
add a row containing all links to specified Pubmed IDs
virtual void AddRow(const string &sContents="", unsigned colspan=2)
add a row with a cell, spanning across all columns
virtual void AddLinkRow(const string &sTag, const string &sValue, unsigned valueColWidth=200)
add a row with two columns
void x_FindAllOccurences(const string &input, char search, vector< size_t > &occurences) const
virtual void AddDividerRow(unsigned colspan=2)
add a horizontal divider between sections of the table
virtual void Append(const ITooltipFormatter &tooltip)
appends another formatter to this one
virtual void AddValueCol(const string &sContents="", unsigned width=200, bool isNoWrap=false)=0
adds a value column to the row
virtual string CreateNcbiLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied NCBI URL path
virtual void AddBulletCol(const string &sBulletSrc="")
add a cell with an image
virtual void MaybeAddGoToRow(bool &isGoToPresent, bool isBulletColPresent)
conditionally add a Go To row
static CIRef< ITooltipFormatter > CreateTooltipFormatter(ETooltipFormatters)
factory for requested tooltip formatter creation
virtual void AddLinkRow(const string &sTag, const string &sValue, unsigned valueColWidth=200)
add a row with two columns
virtual void MaybeAddGoToRow(bool &isGoToPresent, bool isBulletColPresent)
conditionally add a Go To row
virtual void AddTagCol(const string &sContents="", const string &sBulletSrc="")=0
adds a tag column to the row
unsigned x_InsertSpaces(string &input, size_t start, size_t end, size_t fragment_length=65) const
virtual void AddLinksTitle(const string &sTitle)
add a row with the links title
virtual void AddSectionRow(const string &sContents)
add a section row
virtual string CreateNcbiLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied NCBI URL path
virtual string CreateGenomicLink(const string &sText, const string &sUrl) const
virtual string Render()
returns the formatted tooltip text and resets the formatter for reuse
virtual void FinishRow()
finish the row (i.e. no other contents will be added to it)
virtual void FinishRow()
finish the row (i.e. no other contents will be added to it)
virtual void AddTagCol(const string &sContents="", const string &sBulletSrc="")
adds a tag column to the row
virtual void AddBulletCol(const string &sBulletSrc="")=0
add a cell with an image
virtual void AddTagCol(const string &sContents="", const string &sBulletSrc="")
adds a tag column to the row
static CIRef< ITooltipFormatter > CreateTooltipFormatter()
virtual void FinishRow()
finish the row (i.e. no other contents will be added to it)
virtual CIRef< ITooltipFormatter > CreateInstance()
creates another instance of the same tooltip formatter
virtual bool IsEmpty() const
Indicates if the tooltip is empty.
virtual void AddPubmedLinksRow(const string &pmids, bool &isGoToPresent, bool isBulletColPresent)
add a row containing all links to specified Pubmed IDs
virtual void StartRow()
start a new table row
virtual void StartRow()
start a new table row
virtual void AddLinkRow(const string &sTag, const string &sValue, unsigned valueColWidth=200)
add a row with two columns
virtual bool IsEmpty() const
Indicates if the tooltip is empty.
virtual CIRef< ITooltipFormatter > CreateInstance()
creates another instance of the same tooltip formatter
virtual void AddRow(const string &sContents="", unsigned colspan=2)
add a row with a cell, spanning across all columns
virtual void AddRow(const string &sContents="", unsigned colspan=2)
add a row with a cell, spanning across all columns
virtual CIRef< ITooltipFormatter > CreateInstance()
creates another instance of the same tooltip formatter
virtual void AddSectionRow(const string &sContents)
add a section row
virtual void AddValueCol(const string &sContents="", unsigned width=200, bool isNoWrap=false)
adds a value column to the row
virtual string CreateLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied URL
virtual void AddSectionRow(const string &sContents)
add a section row
virtual void StartRow()=0
start a new table row
virtual void MaybeAddGoToRow(bool &isGoToPresent, bool isBulletColPresent)
conditionally add a Go To row
virtual void Append(const ITooltipFormatter &tooltip)
appends another formatter to this one
virtual void AddLinksTitle(const string &sTitle)
add a row with the links title
virtual string CreateLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied URL
virtual void AddPubmedLinksRow(const string &pmids, bool &isGoToPresent, bool isBulletColPresent)
add a row containing all links to specified Pubmed IDs
static CIRef< ITooltipFormatter > CreateTooltipFormatter()
virtual string CreateLink(const string &sText, const string &sUrl) const
construct the HTML code for a link from the displayed text label and supplied URL
virtual string CreateNcbiLink(const string &sText, const string &sUrl) const =0
construct the HTML code for a link from the displayed text label and supplied NCBI URL path
virtual void AddValueCol(const string &sContents="", unsigned width=200, bool isNoWrap=false)
adds a value column to the row
virtual void StartRow()
start a new table row
virtual void AddBulletCol(const string &sBulletSrc="")
add a cell with an image
virtual bool IsEmpty() const
Indicates if the tooltip is empty.
virtual void AddDividerRow(unsigned colspan=2)
add a horizontal divider between sections of the table
virtual void AddLinksTitle(const string &sTitle)
add a row with the links title
virtual void AddBulletCol(const string &sBulletSrc="")
add a cell with an image
@ eTooltipFormatter_CSSTable
generated table is CSS based, generated NCBI URLs are paths (recommended for SViewer)
@ eTooltipFormatter_Html
generated table is HTML attributes (no CSS) based, generate NCBI URLs are absolute (recommended for G...
@ eTooltipFormatter_Text
plain text formatted
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static string HtmlEncode(const CTempString str, THtmlEncode flags=fHtmlEnc_EncodeAll)
Encode a string for HTML.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
@ fConvErr_NoThrow
Do not throw an exception on error.
constexpr auto sort(_Init &&init)