/usr/share/hyphy/DatapanelAddIns/Character Plot is in hyphy-common 2.2.7+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | RequireVersion ("0.9920060501");
#include "ibfs/char_colors.def";
ExecuteAFile ("`HYPHY_LIB_DIRECTORY`TemplateBatchFiles`DIRECTORY_SEPARATOR`Utility`DIRECTORY_SEPARATOR`GrabBag.bf");
ExecuteAFile ("`HYPHY_LIB_DIRECTORY`TemplateBatchFiles`DIRECTORY_SEPARATOR`Utility`DIRECTORY_SEPARATOR`PostScript.bf");
if (_selFilters == 1)
{
_baseName = _DATAPANEL_SELECTED_FILTERS_[0];
}
else
{
_baseName = _DATAPANEL_DATASET_NAME_;
}
_font_size = 14;
_char_space_mult = 1 + 0.1*((Log (_DATAPANEL_DATAFILTER_.sites)/Log(2) + 1.5)$1);
_char_space = (_font_size*_char_space_mult);
_page_w = 612;
_page_h = 792;
_atom = 5;
DEFAULT_FILE_SAVE_NAME = _baseName + ".ps";
SetDialogPrompt ("Save PostScript graphics to:");
fprintf (PROMPT_FOR_FILE,CLEAR_FILE,_HYPSPageHeader (_page_w,_page_h,"Character Plot for "+_baseName),
_HYPSSetFont ("Courier",_font_size),
"/dmx 6 array currentmatrix def\n",
"/sshift fs 2 idiv fs add def\n",
"/setb {0 0 0 setrgbcolor} def\n",
"/flbx {setrgbcolor newpath 2 copy moveto 4 -1 roll exch 2 copy lineto exch 4 -1 roll 2 copy lineto 4 -1 roll exch lineto pop pop closepath fill setb} def\n",
"/drawletter {translate scale newpath 0 0 moveto false charpath fill dmx setmatrix translate 0.4 0.4 scale newpath sshift 0 moveto false charpath fill dmx setmatrix} def\n"
);
outFile = LAST_FILE_PATH;
_selFilters = Columns(_DATAPANEL_SELECTED_FILTERS_);
if (_selFilters > 1)
{
fprintf (stdout, "ERROR: This plug in-needs zero or one selected data filter\n");
return 0;
}
if (_selFilters == 1)
{
_baseName = _DATAPANEL_SELECTED_FILTERS_[0];
}
else
{
_baseName = _DATAPANEL_DATASET_NAME_;
}
GetDataInfo (_charHandles, _DATAPANEL_DATAFILTER_, "CHARACTERS");
_ccount = Columns (_charHandles);
_unit = {1,_ccount}["1"];
GetDataInfo (_dupInfo, _DATAPANEL_DATAFILTER_);
_result_cache = {};
_maxD = 0;
_char_per_line = _page_w / _char_space $ _atom * _atom;
if (_char_per_line == 0)
{
fprintf (stdout, "\nERROR: At least ",_atom," characters must fit in a line; reduce font size in 'Character Plot' source\n");
}
else
{
fprintf (stdout, "\n", _char_per_line, " characters per line\n");
}
_dbyLine = {};
for (_idx = 0; _idx < _DATAPANEL_DATAFILTER_.sites; _idx = _idx + 1)
{
_siteInfo = {_ccount, 2};
_cCounter = {_ccount, 1};
for (_sidx = 0; _sidx < _DATAPANEL_DATAFILTER_.species; _sidx = _sidx + 1)
{
GetDataInfo (_thisChar, _DATAPANEL_DATAFILTER_, _sidx, _dupInfo[_idx]);
/* don't count gaps */
if (Abs (_thisChar) != Sqrt (_ccount))
{
_cCounter = _cCounter + _thisChar*(1/(_unit*_thisChar)[0]);
}
}
_siteInfo = _siteInfo ["_MATRIX_ELEMENT_ROW_ * _MATRIX_ELEMENT_COLUMN_ + (1-_MATRIX_ELEMENT_COLUMN_)*_cCounter[_MATRIX_ELEMENT_ROW_]"]%0;
for (_sidx = _ccount-1; _sidx >= 0; _sidx = _sidx - 1)
{
if (_siteInfo[_sidx][0] == 0)
{
break;
}
}
_result_cache[_idx] = _siteInfo[{{_sidx+1,0}}][{{_ccount-1,1}}];
_sidx = Rows (_result_cache[_idx]);
if (_sidx > _maxD)
{
_maxD = _sidx;
}
if ((_idx + 1)%_char_per_line==0)
{
_dbyLine [Abs(_dbyLine)] = _maxD;
_maxD = 0;
}
}
_current_x = 0;
_current_y = _page_h-2*_font_size;
_cl = 0;
for (_idx = 0; _idx < _DATAPANEL_DATAFILTER_.sites; _idx = _idx + 1)
{
_cCounter = _result_cache[_idx];
if (Rows(_cCounter))
{
for (_sidx = Rows(_cCounter)-1; _sidx >= 0; _sidx = _sidx - 1)
{
_siteInfo = _current_y-_font_size*(Rows(_cCounter)-1-_sidx);
_my_c = _charHandles[_cCounter[_sidx][1]];
if (Abs(_charColorList[_my_c]))
{
fprintf (outFile, _charColorList[_my_c], " setrgbcolor\n");
}
fprintf (outFile, "(",_cCounter[_sidx][0],") ", _current_x, " ",_siteInfo," (",_my_c,") 1 1 ", _current_x, " ", _siteInfo, " drawletter\n");
if (Abs(_charColorList[_my_c]))
{
fprintf (outFile, "setb\n");
}
}
}
else
{
fprintf (outFile, "( ) ", _current_x, " ",_current_y," (-) 1 1 ", _current_x, " ", _current_y, " drawletter\n");
}
_current_x = _current_x + _char_space;
if ((_idx + 1)%_char_per_line==0 || _idx == _DATAPANEL_DATAFILTER_.sites-1)
{
_current_y = _current_y + _font_size;
if (_idx == _DATAPANEL_DATAFILTER_.sites-1)
{
if (_DATAPANEL_DATAFILTER_.sites % _char_per_line == 0)
{
_startx = _char_per_line;
}
else
{
_startx = _DATAPANEL_DATAFILTER_.sites%_char_per_line$_atom*_atom;
}
_idx2 = _DATAPANEL_DATAFILTER_.sites-_DATAPANEL_DATAFILTER_.sites%_char_per_line;
}
else
{
_idx2 = _idx - _char_per_line + 1;
_startx = _char_per_line;
}
fprintf (outFile, "0 ", _current_y + _font_size * 4$5, " ", (_char_space+1) * _char_per_line , " ", _current_y - _font_size$4, " 0.9 0.9 0.9 flbx\n");
for (_idx3 = _startx; _idx3 > 0; _idx3 = _idx3 - _atom)
{
fprintf (outFile, "( ) 0 0 (",_idx2+_idx3,") 0.9 0.9 ", (_idx3-1) * _char_space, " ", _current_y, " drawletter\n");
}
_current_x = 0;
_current_y = _current_y - (2+_dbyLine[_cl])*_font_size;
_cl = _cl+1;
if (_current_y - (1+_dbyLine[_cl])*_font_size < 0)
{
_current_y = _page_h-2*_font_size;
fprintf (outFile, "showpage\n");
}
}
}
|