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 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401
|
%--------------------------------------------
%
% Package pgfplots, library for dynamic content in PDF files
% (clickable plots)
%
% Copyright 2007/2008 by Christian Feuersänger.
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with this program. If not, see <http://www.gnu.org/licenses/>.
%
%--------------------------------------------
\pgfutil@ifundefined{pgfplotsset}{%
\PackageError{pgfplots}{Sorry, \string\usetikzlibrary{pgfplots.clickable} needs to hook into PGFPlots routines, disabling it -- please provide the command AFTER \string\usepackage{pgfplots}}{}%
\endinput
}{%
}%
\edef\pgfplotscatcodeDQ{\the\catcode`\"}%
\catcode`\"=12
\newif\ifpgfplots@clickable
\newif\ifpgfplots@annot@printable
\pgfqkeys{/pgfplots}{
@backgroundpath@hook/.add code={}{\pgfplots@create@clickable@plotarea@hook},
clickable/.is if=pgfplots@clickable,
clickable/.default=true,
clickable=true,
/pgfplots/execute at begin axis/.add={}{%
\pgfplots@clickable@beginaxis
},%
clickable coords code/.code={%
\def\pgfplots@clickable@init@@{%
\pgfplots@clickable@startcoordcollect
\pgfplotsset{%
/pgfplots/execute at end plot@@/.add={}{%
\pgfplots@clickable@endcoordcollect
},
/pgfplots/execute for finished point/.add={}{%
\pgfplots@clickable@coordcollect{#1}%
},%
}%
\let\pgfplots@clickable@init@@=\relax
}%
\pgfkeysalso{%
/pgfplots/execute at begin plot@@/.add={}{%
\pgfplots@clickable@init@@
},
}%
},
clickable coords/.style={
clickable coords code={\def\pgfplotsretval{#1}},
},
clickable coords/.default={(xy)},
annot/js fillColor/.initial={["RGB",1,1,.855]},
annot/point format/.initial={(\%.1f, \%.1f)},
annot/point format 3d/.initial={(\%.1f, \%.1f, \%.1f)},
annot/slope format/.initial={\%.1f*x \%+.1f},
annot/printable/.is if=pgfplots@annot@printable,
annot/printable/.default=true,
% Available are:
% Times-Roman font.Times
% Times-Bold font.TimesB
% Times-Italic font.TimesI
% Times-BoldItalic font.TimesBI
% Helvetica font.Helv
% Helvetica-Bold font.HelvB
% Helvetica-Oblique font.HelvI
% Helvetica-BoldOblique font.HelvBI
% Courier font.Cour
% Courier-Bold font.CourB
% Courier-Oblique font.CourI
% Courier-BoldOblique font.CourBI
% Symbol font.Symbol
% ZapfDingbats font.ZapfD
annot/font/.initial={font.Times},
% annot/font={"CMR10"},
annot/textSize/.initial=11,
annot/richtext/.initial=true,
annot/richtext/.default=true,
annot/popup size generic/.initial=auto,
annot/popup size snap/.initial=auto,
clickable coords size/.style={
/pgfplots/annot/popup size snap={#1},
},
annot/popup size/.style={
/pgfplots/annot/popup size generic={#1},
/pgfplots/annot/popup size snap={#1},
},
annot/width/.initial=,
annot/height/.initial=,
annot/jsname/.initial=,
annot/dim/.initial=2,
annot/xmin/.initial=,
annot/xmax/.initial=,
annot/ymin/.initial=,
annot/ymax/.initial=,
annot/zmin/.initial=,
annot/zmax/.initial=,
annot/xscale/.initial=, % "log" or "linear" or "log:<basis>"
annot/yscale/.initial=,
annot/zscale/.initial=,
annot/minminmin/.initial=,
annot/xaxis/.initial=,
annot/yaxis/.initial=,
annot/zaxis/.initial=,
% format:
% [<plot1coords>, <plot2coords>,...,<plotncoords>]
% with <ploticoords> = [<coord>,<coord>,....,<coord>]
% and <coord> = [ <x>, <y>, "text" ]
% for example:
% [[[0.0e0,-4.0849609e-1,": (0,0)"],[1.25e-1,-3.7412109e-1,": (3,1)"],[2.5e-1,-3.0849609e-1,": (2,1)"],[3.75e-1,-2.1162109e-1,": (3,3)"],[5.0e-1,-8.3496094e-2,": (1,1)"],[6.25e-1,7.5878906e-2,": (3,5)"],[7.5e-1,2.6650391e-1,": (2,3)"],[8.75e-1,4.8837891e-1,": (3,7)"],[1.0e0,7.4150391e-1,": (0,1)"]]]
annot/collected plots/.initial=,
annot/snap dist/.initial=4,
every semilogy axis/.append style={/pgfplots/annot/point format={(\%.1f, \%.1e)}},
every semilogx axis/.append style={/pgfplots/annot/point format={(\%.1e, \%.1f)}},
every loglog axis/.append style={/pgfplots/annot/point format={(\%.1e, \%.1e)}},
}
\pgfkeysifdefined{/pgfplots/annot/xy pattern}{%
}{%
\pgfkeyssetvalue{/pgfplots/annot/xy pattern}{(xy)}%
}%
\pgfkeysifdefined{/pgfplots/annot/no such coord}{%
}{%
\pgfkeyssetvalue{/pgfplots/annot/no such coord}{--}%
}%
% ATTENTION:
% The eforms package creates \begin{Form} and \end{Form} in \AtBeginDocument and \AtEndDocument!
\def\pgfplots@glob@TMPa{pgfsys-pdftex.def}
\ifx\pgfplots@glob@TMPa\pgfsysdriver
\RequirePackage[pdftex]{insdljs}
\RequirePackage[pdftex]{eforms}
\else
\def\pgfplots@glob@TMPa{pgfsys-dvipdfm.def}
\ifx\pgfplots@glob@TMPa\pgfsysdriver
\RequirePackage[dvipdfm]{insdljs}
\RequirePackage[dvipdfm]{eforms}
\else
\def\pgfplots@glob@TMPa{pgfsys-dvips.def}
\ifx\pgfplots@glob@TMPa\pgfsysdriver
\RequirePackage[dvips]{insdljs}
\RequirePackage[dvips]{eforms}
\else
\def\pgfplots@glob@TMPa{pgfsys-textures.def}
\ifx\pgfplots@glob@TMPa\pgfsysdriver
\RequirePackage[textures]{insdljs}
\RequirePackage[textures]{eforms}
\else
\RequirePackage{insdljs}
\RequirePackage{eforms}
\fi\fi\fi\fi
% Work-around for a bug in \begindljs of acrotex:
% if " is active, \begindljs will be wrong.
%--------------------------------------------------
% HAS BEEN FIXED IN THE MEANTIME
% \def\begindljs
% {%
% \iwvo{\string\begingroup}
% {\uccode`c=`\%\uppercase{\iwvo{\string\obeyspaces\string\obeylines\string\global\string\let\string^\string^M=\string\jsR c}}}
% {\escapechar=-1 \lccode`C=`\%\lowercase{\iwvo{\string\\catcode`\string\\"=12C}}}
% }
%--------------------------------------------------
% Bugfix to fix incompatibility when '<' and '>' are active (as for
% \usepackage[spanish]{babel}:
\def\write@objs@BUGGY
{%
\iwvo{\begingroup}
{\lccode`C=`\%\lowercase{\iwvo{\string\ccpdftex C}}}
{\lccode`C=`\%\lowercase{\iwvo{\string\input{dljscc.def}C\the\dljsobjtoks}}}
\iwvo{\endgroup}
\iwvo{\string\endinput}%
}
\def\write@objs@CORRECT
{%
\iwvo{\begingroup}
\iwvo{\string\catcode`\string\<=12 }
\iwvo{\string\catcode`\string\>=12 }
{\lccode`C=`\%\lowercase{\iwvo{\string\ccpdftex C}}}
{\lccode`C=`\%\lowercase{\iwvo{\string\input{dljscc.def}C\the\dljsobjtoks}}}
\iwvo{\endgroup}
\iwvo{\string\endinput}%
}
\pgfutil@ifundefined{write@objs}{}{%
\ifx\write@objs\write@objs@BUGGY
\let\write@objs=\write@objs@CORRECT
\fi
}%
\def\pgfplots@clickable@no{0}
% This catcode-hackery is too much for me, I don't get '|' to work in
% conjunction with ltxdoc document style.
% So, I simply use \pgfplotsVERTBAR instead... *sigh*.
{
\catcode`\"=12
\gdef\pgfplotsDQ{"}%
\catcode`\|=12
\gdef\pgfplotsVERTBAR{|}%
\catcode`\#=12
\gdef\pgfplotsHASH{#}%
\catcode`\%=12 \gdef\pgfplotsPERCENT{%}}
% this here is a bugfix to resolve an incompatibility between insdljs
% an \usepackage[spanish]{babel}:
\def\@roman#1{\romannumeral #1}%
% FIXME : write this stuff DIRECTLY into a pdf using \pdfobj! I don't
% need ANY TeX code inside of the methods. Maybe I can even use some
% sort of "include external .js file" command instead of /S /Javascript /JS
%
% FIXME : collect this stuff using \beginpgfplotsverbatim ...
% \endpgfplotsverbatim to avoid the \catcode problems! Who knows
% whether there are more of them...
%
% FIXME : using '\jobname' here produces a bug in insdljs :-(
% The problem: insdljs creates a macro named 'dlsj\jobname' or
% something like that, but if fails to use '\csname' properly. So:
% only normal letters are allowed inside of the argument here.
\begin{insDLJS}[processAnnotatedPlot]{pgfplotsJS}{pgfplots Clickable Plot Code}
/*********************************************************************************
* function sprintf() - written by Kevin van Zonneveld as part of the php to javascript
* conversion project.
*
* More info at: http://kevin.vanzonneveld.net/techblog/article/phpjs_licensing/
*
* This is version: 1.33
* php.js is copyright 2008 Kevin van Zonneveld.
*
* Portions copyright Michael White (http://crestidg.com), _argos, Jonas
* Raoni Soares Silva (http://www.jsfromhell.com), Legaev Andrey, Ates Goral
* (http://magnetiq.com), Philip Peterson, Martijn Wieringa, Webtoolkit.info
* (http://www.webtoolkit.info/), Carlos R. L. Rodrigues
* (http://www.jsfromhell.com), Ash Searle (http://hexmen.com/blog/),
* Erkekjetter, GeekFG (http://geekfg.blogspot.com), Johnny Mast
* (http://www.phpvrouwen.nl), marrtins, Alfonso Jimenez
* (http://www.alfonsojimenez.com), Aman Gupta, Arpad Ray
* (mailto:arpad@php.net), Karol Kowalski, Mirek Slugen, Thunder.m, Tyler
* Akins (http://rumkin.com), d3x, mdsjack (http://www.mdsjack.bo.it), Alex,
* Alexander Ermolaev (http://snippets.dzone.com/user/AlexanderErmolaev),
* Allan Jensen (http://www.winternet.no), Andrea Giammarchi
* (http://webreflection.blogspot.com), Arno, Bayron Guevara, Ben Bryan,
* Benjamin Lupton, Brad Touesnard, Brett Zamir, Cagri Ekin, Cord, David,
* David James, DxGx, FGFEmperor, Felix Geisendoerfer
* (http://www.debuggable.com/felix), FremyCompany, Gabriel Paderni, Howard
* Yeend, J A R, Leslie Hoare, Lincoln Ramsay, Luke Godfrey, MeEtc
* (http://yass.meetcweb.com), Mick@el, Nathan, Nick Callen, Ozh, Pedro Tainha
* (http://www.pedrotainha.com), Peter-Paul Koch
* (http://www.quirksmode.org/js/beat.html), Philippe Baumann, Sakimori,
* Sanjoy Roy, Simon Willison (http://simonwillison.net), Steve Clay, Steve
* Hilder, Steven Levithan (http://blog.stevenlevithan.com), T0bsn, Thiago
* Mata (http://thiagomata.blog.com), Tim Wiel, XoraX (http://www.xorax.info),
* Yannoo, baris ozdil, booeyOH, djmix, dptr1988, duncan, echo is bad, gabriel
* paderni, ger, gorthaur, jakes, john (http://www.jd-tech.net), kenneth,
* loonquawl, penutbutterjelly, stensi
*
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL KEVIN VAN ZONNEVELD BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
// ATTENTION: this method has been masked such that special characters of TeX and javascript
// don't produce problems.
function sprintf( ) {
// Return a formatted string
//
// + discuss at: http://kevin.vanzonneveld.net/techblog/article/javascript_equivalent_for_phps_sprintf/
// + version: 804.1712
// + original by: Ash Searle (http://hexmen.com/blog/)
// + namespaced by: Michael White (http://crestidg.com)
// * example 1: sprintf("\pgfplotsPERCENT01.2f", 123.1);
// * returns 1: 123.10
var regex = /\pgfplotsPERCENT\pgfplotsPERCENT\pgfplotsVERTBAR\pgfplotsPERCENT(\d+\$)?([-+\pgfplotsHASH0 ]*)(\*\d+\$\pgfplotsVERTBAR\*\pgfplotsVERTBAR\d+)?(\.(\*\d+\$\pgfplotsVERTBAR\*\pgfplotsVERTBAR\d+))?([scboxXuidfegEG])/g;
var a = arguments, i = 0, format = a[i++];
// pad()
var pad = function(str, len, chr, leftJustify) {
var padding = (str.length >= len) ? '' : Array(1 + len - str.length >>> 0).join(chr);
return leftJustify ? str + padding : padding + str;
};
// justify()
var justify = function(value, prefix, leftJustify, minWidth, zeroPad) {
var diff = minWidth - value.length;
if (diff > 0) {
if (leftJustify \pgfplotsVERTBAR\pgfplotsVERTBAR !zeroPad) {
value = pad(value, minWidth, ' ', leftJustify);
} else {
value = value.slice(0, prefix.length) + pad('', diff, '0', true) + value.slice(prefix.length);
}
}
return value;
};
// formatBaseX()
var formatBaseX = function(value, base, prefix, leftJustify, minWidth, precision, zeroPad) {
// Note: casts negative numbers to positive ones
var number = value >>> 0;
prefix = prefix && number && {'2': '0b', '8': '0', '16': '0x'}[base] \pgfplotsVERTBAR\pgfplotsVERTBAR '';
value = prefix + pad(number.toString(base), precision \pgfplotsVERTBAR\pgfplotsVERTBAR 0, '0', false);
return justify(value, prefix, leftJustify, minWidth, zeroPad);
};
// formatString()
var formatString = function(value, leftJustify, minWidth, precision, zeroPad) {
if (precision != null) {
value = value.slice(0, precision);
}
return justify(value, '', leftJustify, minWidth, zeroPad);
};
// finalFormat()
var doFormat = function(substring, valueIndex, flags, minWidth, _, precision, type) {
if (substring == '\pgfplotsPERCENT\pgfplotsPERCENT') return '\pgfplotsPERCENT';
// parse flags
var leftJustify = false, positivePrefix = '', zeroPad = false, prefixBaseX = false;
for (var j = 0; flags && j < flags.length; j++) switch (flags.charAt(j)) {
case ' ': positivePrefix = ' '; break;
case '+': positivePrefix = '+'; break;
case '-': leftJustify = true; break;
case '0': zeroPad = true; break;
case '\pgfplotsHASH': prefixBaseX = true; break;
}
// parameters may be null, undefined, empty-string or real valued
// we want to ignore null, undefined and empty-string values
if (!minWidth) {
minWidth = 0;
} else if (minWidth == '*') {
minWidth = +a[i++];
} else if (minWidth.charAt(0) == '*') {
minWidth = +a[minWidth.slice(1, -1)];
} else {
minWidth = +minWidth;
}
// Note: undocumented perl feature:
if (minWidth < 0) {
minWidth = -minWidth;
leftJustify = true;
}
if (!isFinite(minWidth)) {
throw new Error('sprintf: (minimum-)width must be finite');
}
if (!precision) {
precision = 'fFeE'.indexOf(type) > -1 ? 6 : (type == 'd') ? 0 : void(0);
} else if (precision == '*') {
precision = +a[i++];
} else if (precision.charAt(0) == '*') {
precision = +a[precision.slice(1, -1)];
} else {
precision = +precision;
}
// grab value using valueIndex if required?
var value = valueIndex ? a[valueIndex.slice(0, -1)] : a[i++];
switch (type) {
case 's': return formatString(String(value), leftJustify, minWidth, precision, zeroPad);
case 'c': return formatString(String.fromCharCode(+value), leftJustify, minWidth, precision, zeroPad);
case 'b': return formatBaseX(value, 2, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'o': return formatBaseX(value, 8, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'x': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'X': return formatBaseX(value, 16, prefixBaseX, leftJustify, minWidth, precision, zeroPad).toUpperCase();
case 'u': return formatBaseX(value, 10, prefixBaseX, leftJustify, minWidth, precision, zeroPad);
case 'i':
case 'd': {
var number = parseInt(+value);
var prefix = number < 0 ? '-' : positivePrefix;
value = prefix + pad(String(Math.abs(number)), precision, '0', false);
return justify(value, prefix, leftJustify, minWidth, zeroPad);
}
case 'e':
case 'E':
case 'f':
case 'F':
case 'g':
case 'G':
{
var number = +value;
var prefix = number < 0 ? '-' : positivePrefix;
var method = ['toExponential', 'toFixed', 'toPrecision']['efg'.indexOf(type.toLowerCase())];
var textTransform = ['toString', 'toUpperCase']['eEfFgG'.indexOf(type) \pgfplotsPERCENT 2];
value = prefix + Math.abs(number)[method](precision);
return justify(value, prefix, leftJustify, minWidth, zeroPad)[textTransform]();
}
default: return substring;
}
};
return format.replace(regex, doFormat);
}
/*********************************************************************************/
% see https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Inheritance
var lastPoint = null;
var posOnMouseDownX = -1;
var posOnMouseDownY = -1;
// preallocation.
var tmpArray1 = new Array(3);
var tmpArray2 = new Array(3);
var clickablePatternForXY="\pgfkeysvalueof{/pgfplots/annot/xy pattern}";
var clickableStringNoSuchCoord = "\pgfkeysvalueof{/pgfplots/annot/no such coord}";
var nan = Number.NaN;
var NAN = Number.NaN;
var inf = Number.POSITIVE_INFINITY;
var INF = Number.POSITIVE_INFINITY;
var pgfplotsAxisRegistry = new Object();
pgfplotsAxisRegistry["rectangle"] = function( axisAnnotObj ) { return new PGFPlotsAxis( axisAnnotObj ); }
pgfplotsAxisRegistry["ternary"] = function( axisAnnotObj ) { return new PGFPlotsTernaryAxis( axisAnnotObj ); }
function PGFPlotsClassExtend( child, super )
{
for (var property in super.prototype) {
if (typeof child.prototype[property] == "undefined")
child.prototype[property] = super.prototype[property];
}
return child;
}
function PGFPlotsCreateAxisFor( axisAnnotObj, docObject )
{
var ret = null;
if( pgfplotsAxisRegistry[axisAnnotObj.axisType] ) {
ret = pgfplotsAxisRegistry[axisAnnotObj.axisType](axisAnnotObj);
ret.docObject = docObject;
}
return ret;
}
function ClickableCoord(canvasx,canvasy, realx,realy, text)
{
this.dim=2;
this.canvasx=canvasx;
this.canvasy=canvasy;
this.realx=realx;
this.realy=realy;
this.text=text;
}
ClickableCoord.prototype =
{
dim : 0,
canvasx : 0,
canvasy : 0,
realx : 0,
realy : 0,
realz : 0,
text : "",
sourcePlotIdx : -1,
sourceCoordIdx : -1,
isSnapToNearestCoord : function() {
return this.sourcePlotIdx >= 0;
},
/**
* Takes an already existing TextField, changes its value to point.text and places it at (x,y).
* Additional \c displayOpts will be used to format it.
*/
draw : function( docObject, canvas, displayOpts )
{
var charsX = 1;
var charsY = 1.5;
var popupSize = ( this.isSnapToNearestCoord() ? displayOpts.popupSizeSnap : displayOpts.popupSizeGeneric );
if( popupSize == "auto" ) {
charsX = Math.max( 5,this.text.length )/2;
} else {
var commaOff = popupSize.indexOf( "," );
if( commaOff >= 0 ) {
charsX = popupSize.substring( 0, commaOff );
charsY = popupSize.substring( commaOff+1 );
} else
charsX = popupSize;
}
// console.println( this.text );
if( !displayOpts.richText )
canvas.value = ""+this.text;
else {
canvas.richText=true;
var xmlValue = "<?xml version=\"1.0\"?>"+
"<body> " + % xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:APIVersion=\"Acrobat:9.3.2\" xfa:spec=\"2.0.2\">" +
%"<p>"+
"<span>"+ % style="font-size:9.0pt;text-align:left;color:#7E0000;font-weight:normal;font-style:normal;font-family:Helvetica,sans-serif;font-stretch:normal"
this.text +
"</span>"+
%"</p>"+
"</body>";
canvas.richValue = util.xmlToSpans(xmlValue);
% debug helper:
% spans= new Array();
% spans[0] = new Object();
% spans[0].text = this.text;
% spans[0].textColor = ["RGB",0.5,0,0];
% canvas.richValue = spans;
% console.println(util.spansToXML(canvas.richValue));
}
var R = canvas.rect;
R[0] = this.canvasx;
R[1] = this.canvasy;
R[2] = R[0] + charsX*displayOpts.textSize;
R[3] = R[1] - charsY*displayOpts.textSize;
canvas.rect = R;
canvas.textFont = displayOpts.textFont;
canvas.textSize = displayOpts.textSize;
canvas.multiline = true;
canvas.fillColor = displayOpts.fillColor;//["RGB",1,1,.855];
canvas.doNotSpellCheck = true;
canvas.readonly = true;
if( displayOpts.printable )
canvas.display = display.visible;
else
canvas.display = display.noPrint;
var mark = docObject.getField( canvas.name + "mark");
if( mark ) {
R = mark.rect;
R[0]=this.canvasx-2;
R[1]=this.canvasy-2;
R[2]=R[0]+4;
R[3]=R[1]+4;
mark.value="";
mark.rect = R;
mark.fillColor = ["RGB",0,0,0];
mark.doNotSpellCheck = true;
mark.readonly = true;
if( displayOpts.printable )
mark.display = display.visible;
else
mark.display = display.noPrint;
}
}
}
function PGFPlotsAxis(properties) {
for (var property in properties)
this[property] = properties[property];
}
PGFPlotsAxis.prototype = {
/**
* @return an instance of ClickableCoord or null.
* The returned canvas coordinates are NOT yet initialised.
*/
findNearest : function( point, rect, startSearchAt )
{
var actx;
var acty;
var minSoFar = 1e324;
var minPtSoFar = null;
var tmpPt = null;
var dist =0;
var startPlot = 0;
var startCoord = 0;
var collectedPlots = this.collectedPlots;
if( point.dim > 2 )
tmpPt = new ClickableCoord(0,0,0,0,"");
if( startSearchAt != null && startSearchAt.isSnapToNearestCoord() ) {
startPlot = startSearchAt.sourcePlotIdx;
startCoord= startSearchAt.sourceCoordIdx;
}
for( var i = startPlot; i<collectedPlots.length; ++i ) {
for( var j = startCoord; j<collectedPlots[i].length; ++j ) {
if( point.dim == 2 ) {
actx = collectedPlots[i][j][0] - point.realx;
acty = collectedPlots[i][j][1] - point.realy;
} else {
// dim > 2 should be compared using CANVAS coordinates, not real coordinates:
tmpPt.realx = collectedPlots[i][j][0];
tmpPt.realy = collectedPlots[i][j][1];
if( collectedPlots[i][j].length-1 >= 3 )
tmpPt.realz = collectedPlots[i][j][2];
else
tmpPt.realz = 0;
this.computeCanvasFor( tmpPt, rect );
actx = tmpPt.canvasx - point.canvasx;
acty = tmpPt.canvasy - point.canvasy;
}
dist = actx*actx + acty*acty;
if( dist < minSoFar ) {
if( minPtSoFar == null )
minPtSoFar = new ClickableCoord(-1,-1,0,0,"");
minPtSoFar.realx = collectedPlots[i][j][0];
minPtSoFar.realy = collectedPlots[i][j][1];
if( collectedPlots[i][j].length-1 >= 3 )
minPtSoFar.realz = collectedPlots[i][j][2];
else
minPtSoFar.realz = 0;
minPtSoFar.text= collectedPlots[i][j][ collectedPlots[i][j].length-1 ];
minPtSoFar.sourcePlotIdx = i;
minPtSoFar.sourceCoordIdx = j;
minSoFar = dist;
}
}
}
if( minPtSoFar )
this.computeCanvasFor(minPtSoFar,rect);
return minPtSoFar;
},
/**
* Returns either a ClickableCoord describing the point under the mouse cursor or a snap--to--nearest result near the mouse cursor.
*
* @param this the axis in which we shall search.
* @param x,y the input canvas coordinates
* @param canvas a pointer to the Drawing object (TextField) whose 'rect' field is the drawing canvas.
* @param startSearch either null or an instance of ClickableCoord for which isSnapToNearestCoord() returns true.
* If it is not null, the next matching point *after* it will be returned (or null if there is no matching snap--to--nearest coord after it).
* @return an instance of ClickableCoord or null in case the startSearch!=null and there are no further matches.
*/
findClickableCoord : function( x,y, canvas, startSearch )
{
// Get and modify bounding box. The mouse movement is only accurate up to one point
// (mouseX and mouseY are integers), so the bounding box should be an integer as well.
var rect = canvas.rect; // rect = [ mincanvasx mincanvasy maxcanvasx maxcanvasy ]; relative to upper left corner
rect[0] = Math.round(rect[0]);
rect[1] = Math.round(rect[1]);
rect[2] = Math.round(rect[2]);
rect[3] = Math.round(rect[3]);
canvas.rect= rect;
var realx=-1;
var realy=-1;
if( this.dim == 2 ) {
// the following code inverts computeCanvasFor():
var minminminx = rect[0] + this.minminmin[0];
var minminminy = rect[3] + this.minminmin[1];
var vecx = x - minminminx;
var vecy = y - minminminy;
var A = [
[this.xaxis[0], this.yaxis[0]],
[this.xaxis[1], this.yaxis[1]] ];
var b = [ vecx, vecy ];
var rowpermut = [0, 1];
if( Math.abs(A[0][0]) < 0.0001 ) {
rowpermut[0] = 1;
rowpermut[1] = 0;
}
var pivot = -A[rowpermut[1]][0] / A[rowpermut[0]][0];
var unity = (b[rowpermut[1]] + pivot*b[rowpermut[0]]) / (A[rowpermut[1]][1] + pivot * A[rowpermut[0]][1]);
var unitx = (b[rowpermut[0]] - A[rowpermut[0]][1] * unity) / A[rowpermut[0]][0];
realx = this.xmin + unitx * (this.xmax - this.xmin);
realy = this.ymin + unity * (this.ymax - this.ymin);
//console.println( "unitx = " + unitx + "; unity " + unity );
}
var point = new ClickableCoord( x,y, realx, realy, clickablePatternForXY);
point.dim = this.dim;
if( startSearch && !startSearch.isSnapToNearestCoord() ) {
console.println( "WARNING: startSearch().isSnapToNearestCoord() has been expected!" );
startSearch = null;
}
var nearestClickableCoord = this.findNearest( point, rect, startSearch );
if( nearestClickableCoord ) {
if( getDist( point.canvasx,point.canvasy, nearestClickableCoord.canvasx, nearestClickableCoord.canvasy ) < this.snapDist ) {
return nearestClickableCoord;
}
}
if( startSearch )
point = null;
if( this.dim > 2 ) { // we didn't find a snap--to--nearest point.
point.text = clickableStringNoSuchCoord;
}
return point;
},
/**
* Takes point's real coordinates and computes its canvas coordinates. The result is written back into \c point.
*/
computeCanvasFor : function( point, rect)
{
var unitx = (point.realx - this.xmin) / (this.xmax -this.xmin);
var unity = (point.realy - this.ymin) / (this.ymax -this.ymin);
point.canvasx = rect[0] + this.minminmin[0] + this.xaxis[0] * unitx + this.yaxis[0] * unity;
point.canvasy = rect[3] + this.minminmin[1] + this.xaxis[1] * unitx + this.yaxis[1] * unity;
if( this.dim >= 3 ) {
var unitz = (point.realz - this.zmin) / (this.zmax -this.zmin);
point.canvasx += this.zaxis[0] * unitz;
point.canvasy += this.zaxis[1] * unitz;
}
},
handleDragNDrop : function( formName, displayOpts )
{
if( this.dim == 3 )
return;
var result = this.docObject.getField( formName + "-result");
var result2 = this.docObject.getField( formName + "-result2");
var resultmark = this.docObject.getField( formName + "-resultmark");
var result2mark = this.docObject.getField( formName + "-result2mark");
var slope = this.docObject.getField( formName + "-slope" );
if( !result ) {
console.println( "WARNING: there is no TextField \"" + formName + "-result\" to display results for interactive element \"" + formName + "\"");
return;
}
var a = this.docObject.getField(formName);
if( ! a ) {
console.println( "Warning: there is no form named \"" + formName + "\"" );
return;
}
// dragging the mouse results in slope computation:
// placeClickableCoord shows the endpoint coords and returns the (transformed) coordinates into tmpArray1 and tmpArray2:
this.placeClickableCoord(
this.findClickableCoord( posOnMouseDownX, posOnMouseDownY, a, null ),
result, displayOpts, tmpArray1 );
this.placeClickableCoord(
this.findClickableCoord( mouseX, mouseY, a, null ),
result2, displayOpts, tmpArray2 );
var m = ( tmpArray2[1] - tmpArray1[1] ) / ( tmpArray2[0] - tmpArray1[0] );
var n = tmpArray1[1] - m * tmpArray1[0];
var slopePoint = new ClickableCoord(
0.5 * ( mouseX + posOnMouseDownX ),
0.5 * ( mouseY + posOnMouseDownY ),
-1,-1,
sprintf( displayOpts.slopeFormat, m, n ));
slopePoint.draw(
this.docObject,
slope,
displayOpts );
// FIXME! these document rights seem to forbid modifications to annotations, although they work for text fields!?
//var lineobj = this.getAnnot( a.page, formName + '-line' );
//console.println( 'lineobj = ' + lineobj );
//lineobj.points = [[mouseX,mouseY],[posOnMouseDownX,posOnMouseDownY]];
//lineobj.display = display.visible;
},
handleClick : function( formName, displayOpts )
{
var result = this.docObject.getField( formName + "-result");
var result2 = this.docObject.getField( formName + "-result2");
var resultmark = this.docObject.getField( formName + "-resultmark");
var result2mark = this.docObject.getField( formName + "-result2mark");
var slope = this.docObject.getField( formName + "-slope" );
if( !result ) {
console.println( "WARNING: there is no TextField \"" + formName + "-result\" to display results for interactive element \"" + formName + "\"");
return;
}
result2.display = display.hidden;
slope.display = display.hidden;
result2mark.display = display.hidden;
var a = this.docObject.getField(formName);
if( ! a ) {
console.println( "Warning: there is no form named \"" + formName + "\"" );
return;
}
var point = null;
var bSearchPoint = true;
if( lastPoint ) {
if( getDist( mouseX,mouseY, lastPoint.canvasx,lastPoint.canvasy) < this.snapDist ) {
if( lastPoint.isSnapToNearestCoord() )
++lastPoint.sourceCoordIdx;
else
bSearchPoint = false;
} else
lastPoint = null; // no search restriction.
}
if( bSearchPoint )
point = this.findClickableCoord( mouseX, mouseY, a, lastPoint );
lastPoint = point;
// clicking twice onto the same point hides it:
if( point == null ) {
result.display = display.hidden;
resultmark.display = display.hidden;
return;
}
this.placeClickableCoord(
point,
result, displayOpts, null );
},
/**
* Changes all required Field values of \c plotRegionField, inserts the proper
* value and displays it at the pdf positions (x,y) .
*
* @param plotRegionField a reference to a Field object.
* @param x the x canvas coordinate where the annotation shall be placed and which is used to determine
* the annotation text.
* @param y the corresponding y coord.
* @param axis An object containing axis references.
* @param displayOpts An object for display flags.
* @param[out] retCoords will be filled with the point in axis coordinates (should have length axis.dim).
*/
placeClickableCoord : function( point, textField, displayOpts, retCoords )
{
var transformedCoordx = point.realx;
var transformedCoordy = point.realy;
if( this.xscale.length >= 3 && this.xscale.substr(0,3) == "log" ) {
if( this.xscale.length > 4 ) // log:<basis>
point.realx = point.realx * Math.log( this.xscale.substr(4) );
else {
// pgfplots handles log plots base e INTERNALLY, but uses base 10 for display.
// convert to base 10:
transformedCoordx = point.realx / Math.log(10);
}
point.realx = Math.exp(point.realx);
}
if( this.yscale.length >= 3 && this.yscale.substr(0,3) == "log" ) {
if( this.yscale.length > 4 ) // log:<basis>
point.realy = point.realy * Math.log( this.yscale.substr(4) );
else {
// pgfplots handles log plots base e INTERNALLY, but uses base 10 for display.
// convert to base 10:
transformedCoordy = point.realy / Math.log(10);
}
point.realy = Math.exp(point.realy);
}
if( this.dim > 2 ) {
if( this.zscale.length >= 3 && this.zscale.substr(0,3) == "log" ) {
if( this.zscale.length > 4 ) // log:<basis>
point.realz = point.realz * Math.log( this.zscale.substr(4) );
else {
// pgfplots handles log plots base e INTERNALLY, but uses base 10 for display.
// convert to base 10:
transformedCoordz = point.realz / Math.log(10);
}
point.realz = Math.exp(point.realz);
}
}
// replace the text substring "(xy)" with the actual coordinates:
var coordOff = point.text.indexOf(clickablePatternForXY);
if( coordOff >= 0 ) {
point.text =
point.text.substring( 0, coordOff ) +
sprintf( displayOpts.pointFormat, point.realx,point.realy,point.realz) +
point.text.substr( coordOff+clickablePatternForXY.length );
}
point.draw( this.docObject, textField, displayOpts );
if( retCoords ) {
retCoords[0] = transformedCoordx;
retCoords[1] = transformedCoordy;
if( this.dim > 2 )
retCoords[2] = transformedCoordz;
}
}
}
function PGFPlotsTernaryAxis(properties) {
PGFPlotsAxis.call(this,properties);
}
PGFPlotsTernaryAxis.prototype = {
findClickableCoord : function( x,y, canvas, startSearch )
{
// Get and modify bounding box. The mouse movement is only accurate up to one point
// (mouseX and mouseY are integers), so the bounding box should be an integer as well.
var rect = canvas.rect; // rect = [ mincanvasx mincanvasy maxcanvasx maxcanvasy ]; relative to lower left corner
rect[0] = Math.round(rect[0]);
rect[1] = Math.round(rect[1]);
rect[2] = Math.round(rect[2]);
rect[3] = Math.round(rect[3]);
canvas.rect= rect;
var ternaryScale = 1 / ( rect[2] - rect[0] );
var X = ( x - rect[0] ) * ternaryScale;
var Y = ( y - rect[3] ) * ternaryScale;
var realx = 1.15470053837925 * Y; // 2/sqrt(3)
var realz = X - 0.5 * realx;
var realy = 1 - realx - realz;
if( realx < 0 \pgfplotsVERTBAR\pgfplotsVERTBAR realy < 0 \pgfplotsVERTBAR\pgfplotsVERTBAR realz < 0 )
return null;
var point = new ClickableCoord( x,y, realx, realy, clickablePatternForXY);
point.realz = realz;
point.dim = this.dim;
if( startSearch && !startSearch.isSnapToNearestCoord() ) {
console.println( "WARNING: startSearch().isSnapToNearestCoord() has been expected!" );
startSearch = null;
}
var nearestClickableCoord = this.findNearest( point, rect, startSearch );
if( nearestClickableCoord ) {
if( getDist( point.canvasx,point.canvasy, nearestClickableCoord.canvasx, nearestClickableCoord.canvasy ) < this.snapDist ) {
return nearestClickableCoord;
}
}
if( startSearch )
point = null;
return point;
},
/**
* Takes point's real coordinates and computes its canvas coordinates. The result is written back into \c point.
*/
computeCanvasFor : function( point, rect)
{
var unitx = (point.realx - this.xmin) / (this.xmax -this.xmin);
var unity = (point.realy - this.ymin) / (this.ymax -this.ymin);
var unitz = (point.realz - this.zmin) / (this.zmax -this.zmin);
var ternaryScale = ( rect[2] - rect[0] );
point.canvasx = rect[0] + ternaryScale* 0.5 * (unitx + 2 * unitz);
point.canvasy = rect[3] + ternaryScale* 0.866025403784* unitx; // sqrt(3)/2
},
}
PGFPlotsClassExtend( PGFPlotsTernaryAxis, PGFPlotsAxis );
function getVecLen( t1,t2 ) {
return Math.sqrt( t1*t1 + t2*t2);
}
function getDist( x1,y1, x2,y2 ) {
var t1 = (x1-x2);
var t2 = (y1-y2);
return getVecLen(t1,t2);
}
function axisMouseDown(formName )
{
posOnMouseDownX = mouseX;
posOnMouseDownY = mouseY;
}
/**
* @param formName the name of the clickable button. It is expected to be as large as the underlying plot.
* @param axis an object with the fields
* - xmin, xmax
* - ymin, ymax
* - xscale, yscale
* @param displayOpts an object with the fields
* - pointFormat an sprintf format string to format the final point coordinates.
* The default is "(\pgfplotsPERCENT.2f,\pgfplotsPERCENT.2f)"
* - fillColor the fill color for the annotation. Options are
* transparent, gray, RGB or CMYK color. Default is
* ["RGB",1,1,.855]
* - textFont / textSize
*/
function axisMouseUp(formName, axisAnnotObj, displayOpts)
{
var axis = PGFPlotsCreateAxisFor(axisAnnotObj,this);
if( axis == null )
return;
if( Math.abs( mouseX - posOnMouseDownX ) > 6 \pgfplotsVERTBAR\pgfplotsVERTBAR
Math.abs( mouseY - posOnMouseDownY ) > 6 )
{
axis.handleDragNDrop( formName, displayOpts );
} else {
axis.handleClick( formName, displayOpts );
}
}
\end{insDLJS}
%--------------------------------------------------
% function hideClickableTextfields() {
% for (var i = 0; i < this.numFields; i++) {
% var fieldName = this.getNthFieldName(i);
% console.println("checking Field " + fieldName + " ... ");
% if( fieldName.substr( 0, 13 ) == "clickableplot" && fieldName.indexOf( "-result", 12 ) >= 0 ) {
% console.println("hiding Field " + fieldName + " ... ");
% this.getField( fieldName ).display = display.hidden;
% }
% }
% }
% hideClickableTextfields();
%--------------------------------------------------
\pgfkeysdef{/pgfplots/annot/xy pattern}{\pgfplots@clickable@xypat@error}%
\pgfkeysdef{/pgfplots/annot/xy pattern/.initial}{\pgfplots@clickable@xypat@error}%
\def\pgfplots@clickable@xypat@error{\pgfplots@error{Sorry, \string\pgfplotsset{annot/xy pattern/.initial=...} can only be assigned *before* \string\usepgfplotslibrary{clickable}}}%
\pgfkeysdef{/pgfplots/annot/no such coord}{\pgfplots@clickable@nosuchcoord@error}%
\pgfkeysdef{/pgfplots/annot/no such coord/.initial}{\pgfplots@clickable@nosuchcoord@error}%
\def\pgfplots@clickable@nosuchcoord@error{\pgfplots@error{Sorry, \string\pgfplotsset{annot/no such coord/.initial=...} can only be assigned *before* \string\usepgfplotslibrary{clickable}}}%
\def\pgfplots@clickable@beginaxis{%
\pgfplotsapplistXglobalnewempty\pgfplots@clickable@collectedplots
\gdef\pgfplots@clickable@collectedplots@isempty{1}%
}%
\def\pgfplots@clickable@startcoordcollect{%
\pgfplotsapplistXnewempty\pgfplots@clickable@collectedplot
\def\pgfplots@clickable@collectedplot@isempty{1}%
}%
{\catcode`\|=0 |catcode`|\=12 |gdef|pgfplots@clickable@bslash{\}}%
{
\catcode`\"=13
\catcode`\|=13
\catcode`\#=12
\gdef\pgfplots@clickable@coordcollect@handlechars{%
\def"{\string\\\string\"}%
\def\#{#}%
\expandafter\def\csname \string"\endcsname{\string\\\string\"}%
\def|{\string"}%
\def\n{\pgfplots@clickable@bslash\string\n}%
\def\r{\pgfplots@clickable@bslash\string\r}%
\def\t{\pgfplots@clickable@bslash\string\t}%
\def\\{\pgfplots@clickable@bslash\pgfplots@clickable@bslash}%
}%
}
\def\pgfplots@clickable@coordcollect#1{%
\begingroup
\ifx\pgfplots@current@point@x\pgfutil@empty
\def\pgfmathresult{nan}%
\else
\pgfplotscoordmath{x}{tostring}\pgfplots@current@point@x
\fi
\let\pgfplots@current@point@x=\pgfmathresult
%
\ifx\pgfplots@current@point@y\pgfutil@empty
\def\pgfmathresult{nan}%
\else
\pgfplotscoordmath{y}{tostring}\pgfplots@current@point@y
\fi
\let\pgfplots@current@point@y=\pgfmathresult
%
\ifpgfplots@curplot@threedim
\ifx\pgfplots@current@point@z\pgfutil@empty
\def\pgfmathresult{nan}%
\else
\pgfplotscoordmath{z}{tostring}\pgfplots@current@point@z
\fi
\let\pgfplots@current@point@z=\pgfmathresult
\fi
%
\begingroup
\pgfplots@clickable@coordcollect@handlechars
#1%
\xdef\pgfplots@glob@TMPa{\pgfplotsretval}%
%\message{I have '\pgfplotsretval'}%
\endgroup
\xdef\pgfplots@glob@TMPa{\if1\pgfplots@clickable@collectedplot@isempty\else,\fi[\pgfplots@current@point@x,\pgfplots@current@point@y\ifpgfplots@curplot@threedim,\pgfplots@current@point@z\fi,"\pgfplots@glob@TMPa"]}%
\endgroup
\expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@glob@TMPa}\to\pgfplots@clickable@collectedplot
\def\pgfplots@clickable@collectedplot@isempty{0}%
}%
\def\pgfplots@clickable@endcoordcollect{%
\pgfplotsapplistXlet\pgfplots@clickable@collectedplot@=\pgfplots@clickable@collectedplot
\if1\pgfplots@clickable@collectedplots@isempty
\expandafter\pgfplotsapplistXglobalpushback\expandafter{\expandafter[\pgfplots@clickable@collectedplot@]}\to\pgfplots@clickable@collectedplots
\else
\expandafter\pgfplotsapplistXglobalpushback\expandafter{\expandafter,\expandafter[\pgfplots@clickable@collectedplot@]}\to\pgfplots@clickable@collectedplots
\fi
\gdef\pgfplots@clickable@collectedplots@isempty{0}%
}%
% Creates an area which is clickable. A click produces a popup which
% contains information about the point under the cursor.
%
% The complete (!) context needs to be provided using key-value-pairs,
% either in '#1' or set before invocation of \pgfplotsclickablecreate.
%
% This command actually creates an AcroForm which employs javascript
% whenever it is clicked. A javascript Object is created which
% represents the context (axis limits and options). This javascript
% object is available at runtime.
%
% @remark This method is public and it is NOT restricted to pgfplots.
% The pgfplots hook simply initialises the required key-value-pairs in
% '#1'.
% @remark This method does not draw anything. It initialises only a
% clickable area and javascript code.
%
% The required key-value-pairs are documented in the pdf-manual or can
% be seen above.
%
% @attention Complete key-value validation is NOT performed here. It
% can happen that invalid options will produce javascript bugs when
% opened with Acrobat Reader. Use the javascript console to find them.
\def\pgfplotsclickablecreate[#1]{%
\def\pgfplots@loc@TMPa{#1}%
\ifx\pgfplots@loc@TMPa\pgfutil@empty
\else
\pgfqkeys{/pgfplots/annot}{#1}%
\fi
\pgfkeysgetvalue{/pgfplots/annot/jsname}\pgfplots@clickable@uniquename
\ifx\pgfplots@clickable@uniquename\pgfutil@empty
\edef\pgfplots@clickable@uniquename{clickableplot\pgfplots@clickable@no}%
\begingroup
\c@pgf@counta=\pgfplots@clickable@no\relax
\advance\c@pgf@counta by1
\xdef\pgfplots@clickable@no{\the\c@pgf@counta}%
\endgroup
\fi
%
\pgfkeysgetvalue{/pgfplots/annot/collected plots}\pgfplots@clickable@collectedplots@@
\ifx\pgfplots@clickable@collectedplots@@\pgfutil@empty
\def\pgfplots@clickable@collectedplots@@{[]}%
\fi
%
\edef\pgfplots@clickable@expanded@args{%
{\pgfkeysvalueof{/pgfplots/annot/width}}%
{\pgfkeysvalueof{/pgfplots/annot/height}}%
{\pgfplots@clickable@uniquename}%
{{
axisType: "\pgfkeysvalueof{/pgfplots/axis type}",
dim: \pgfkeysvalueof{/pgfplots/annot/dim},
xmin: \pgfkeysvalueof{/pgfplots/annot/xmin},
xmax: \pgfkeysvalueof{/pgfplots/annot/xmax},
ymin: \pgfkeysvalueof{/pgfplots/annot/ymin},
ymax: \pgfkeysvalueof{/pgfplots/annot/ymax},
xscale: "\pgfkeysvalueof{/pgfplots/annot/xscale}",
yscale: "\pgfkeysvalueof{/pgfplots/annot/yscale}",
\ifnum\pgfkeysvalueof{/pgfplots/annot/dim}=3
zmin: \pgfkeysvalueof{/pgfplots/annot/zmin},
zmax: \pgfkeysvalueof{/pgfplots/annot/zmax},
zscale: "\pgfkeysvalueof{/pgfplots/annot/zscale}",
zaxis: \pgfkeysvalueof{/pgfplots/annot/z axis},
\fi
collectedPlots: \pgfplots@clickable@collectedplots@@,
snapDist: \pgfkeysvalueof{/pgfplots/annot/snap dist},
minminmin: \pgfkeysvalueof{/pgfplots/annot/minminmin},
xaxis: \pgfkeysvalueof{/pgfplots/annot/x axis},
yaxis: \pgfkeysvalueof{/pgfplots/annot/y axis}
}}%
{{
pointFormat: "\ifnum\pgfkeysvalueof{/pgfplots/annot/dim}=3 \pgfkeysvalueof{/pgfplots/annot/point format 3d}\else \pgfkeysvalueof{/pgfplots/annot/point format}\fi",
slopeFormat: "\pgfkeysvalueof{/pgfplots/annot/slope format}",
fillColor:\pgfkeysvalueof{/pgfplots/annot/js fillColor},
textFont:\pgfkeysvalueof{/pgfplots/annot/font},
textSize:\pgfkeysvalueof{/pgfplots/annot/textSize},
richText:\pgfkeysvalueof{/pgfplots/annot/richtext},
popupSizeGeneric:"\pgfkeysvalueof{/pgfplots/annot/popup size generic}",
popupSizeSnap:"\pgfkeysvalueof{/pgfplots/annot/popup size snap}",
printable: \ifpgfplots@annot@printable true\else false\fi
}}%
}%
\expandafter\pgfplots@create@clickable@plotarea\pgfplots@clickable@expanded@args
}%
% Defines either \def\pgfplotsretval{1} if the current axis is
% clickable or \def\pgfplotsretval{0} if not.
%
% The initial configuration is `1' for any 2d axis, `1' for 3d axes
% with 'clickable coords' and `0' for 3d axes without `clickable
% coords'.
%
% Overwrite \pgfplotsclickable@check@enable@axistype@<theaxistype> to
% make axis type specific things.
\def\pgfplotsclickable@check@enable{%
\def\pgfplotsretval{1}%
\ifpgfplots@threedim
\ifx\pgfplots@clickable@collectedplots@@\pgfutil@empty
\def\pgfplotsretval{0}%
\fi
\fi
\csname pgfplotsclickable@check@enable@axistype@\pgfkeysvalueof{/pgfplots/axis type}\endcsname
}%
% This thing is invoked from within pgfplots. It prepares and invokes
% \pgfplotsclickablecreate.
%
\def\pgfplots@create@clickable@plotarea@hook{%
\ifpgfplots@clickable
\begingroup
% communicate collected plot coordinates:
\pgfplotsapplistXgloballet\pgfplots@clickable@collectedplots@@=\pgfplots@clickable@collectedplots
\pgfplotsapplistXglobalnewempty\pgfplots@clickable@collectedplots
\t@pgfplots@tokc=\expandafter{\pgfplots@clickable@collectedplots@@}%
\edef\pgfplots@clickable@collectedplots@@{[\the\t@pgfplots@tokc]}%
\pgfkeyslet{/pgfplots/annot/collected plots}\pgfplots@clickable@collectedplots@@
%
\pgfplotsclickable@check@enable
\if1\pgfplotsretval
%
\pgfplotscoordmath{x}{datascaletrafo inverse}{\pgfplots@xmin}%
\pgfplotscoordmath{x}{tostring}{\pgfmathresult}%
\let\pgfplots@clickable@xmin=\pgfmathresult
\pgfplotscoordmath{x}{datascaletrafo inverse}{\pgfplots@xmax}%
\pgfplotscoordmath{x}{tostring}{\pgfmathresult}%
\let\pgfplots@clickable@xmax=\pgfmathresult
%
\pgfplotscoordmath{y}{datascaletrafo inverse}{\pgfplots@ymin}%
\pgfplotscoordmath{y}{tostring}{\pgfmathresult}%
\let\pgfplots@clickable@ymin=\pgfmathresult
\pgfplotscoordmath{y}{datascaletrafo inverse}{\pgfplots@ymax}%
\pgfplotscoordmath{y}{tostring}{\pgfmathresult}%
\let\pgfplots@clickable@ymax=\pgfmathresult
%
\ifpgfplots@threedim
\pgfplotscoordmath{z}{datascaletrafo inverse}{\pgfplots@zmin}%
\pgfplotscoordmath{z}{tostring}{\pgfmathresult}%
\let\pgfplots@clickable@zmin=\pgfmathresult
\pgfplotscoordmath{z}{datascaletrafo inverse}{\pgfplots@zmax}%
\pgfplotscoordmath{z}{tostring}{\pgfmathresult}%
\let\pgfplots@clickable@zmax=\pgfmathresult
\fi
%
% Convert to user interface of clickable lib:
\pgfplotspointbbdiagonal
\edef\pgfplots@clickable@wd{\the\pgf@x}%
\pgfkeyslet{/pgfplots/annot/width}\pgfplots@clickable@wd
\edef\pgfplots@clickable@ht{\the\pgf@y}%
\pgfkeyslet{/pgfplots/annot/height}\pgfplots@clickable@ht
\pgfkeyslet{/pgfplots/annot/xmin}\pgfplots@clickable@xmin
\pgfkeyslet{/pgfplots/annot/xmax}\pgfplots@clickable@xmax
\pgfkeyslet{/pgfplots/annot/ymin}\pgfplots@clickable@ymin
\pgfkeyslet{/pgfplots/annot/ymax}\pgfplots@clickable@ymax
\ifpgfplots@xislinear
\pgfkeyssetvalue{/pgfplots/annot/xscale}{linear}%
\else
\pgfkeyssetvalue{/pgfplots/annot/xscale}{log:\pgfkeysvalueof{/pgfplots/log basis x}}%
\fi
\ifpgfplots@yislinear
\pgfkeyssetvalue{/pgfplots/annot/yscale}{linear}%
\else
\pgfkeyssetvalue{/pgfplots/annot/yscale}{log:\pgfkeysvalueof{/pgfplots/log basis y}}%
\fi
\ifpgfplots@threedim
\pgfkeyslet{/pgfplots/annot/zmin}\pgfplots@clickable@zmin
\pgfkeyslet{/pgfplots/annot/zmax}\pgfplots@clickable@zmax
\ifpgfplots@zislinear
\pgfkeyssetvalue{/pgfplots/annot/zscale}{linear}%
\else
\pgfkeyssetvalue{/pgfplots/annot/zscale}{log:\pgfkeysvalueof{/pgfplots/log basis z}}%
\fi
\fi
%
% note that \pgfplotspointbblowerleft has *not* been
% transformed after \endtikzpicture in pgfplots.code.tex.
% That's why I can use it here:
\pgfpointdiff
\pgfplotspointbblowerleft
{\pgfplotspointminminmin}%
\pgf@sys@bp@correct\pgf@x \pgf@sys@bp@correct\pgf@y
\edef\pgfplots@loc@TMPa{[\pgf@sys@tonumber\pgf@x, \pgf@sys@tonumber\pgf@y]}%
\pgfkeyslet{/pgfplots/annot/minminmin}\pgfplots@loc@TMPa
%
\pgfplotspointxaxis
\pgf@sys@bp@correct\pgf@x \pgf@sys@bp@correct\pgf@y
\edef\pgfplots@loc@TMPa{[\pgf@sys@tonumber\pgf@x, \pgf@sys@tonumber\pgf@y]}%
\pgfkeyslet{/pgfplots/annot/x axis}\pgfplots@loc@TMPa
%
\pgfplotspointyaxis
\pgf@sys@bp@correct\pgf@x \pgf@sys@bp@correct\pgf@y
\edef\pgfplots@loc@TMPa{[\pgf@sys@tonumber\pgf@x, \pgf@sys@tonumber\pgf@y]}%
\pgfkeyslet{/pgfplots/annot/y axis}\pgfplots@loc@TMPa
%
\ifpgfplots@threedim
\pgfplotspointzaxis
\pgf@sys@bp@correct\pgf@x \pgf@sys@bp@correct\pgf@y
\edef\pgfplots@loc@TMPa{[\pgf@sys@tonumber\pgf@x, \pgf@sys@tonumber\pgf@y]}%
\pgfkeyslet{/pgfplots/annot/z axis}\pgfplots@loc@TMPa
\fi
%
\pgfkeyssetvalue{/pgfplots/annot/dim}{\ifpgfplots@threedim 3\else2\fi}%
%
%
\pgfinterruptboundingbox%
\pgftext[left,bottom,at=\lowerleftinnercorner]{\pgfplotsclickablecreate[]}%
\endpgfinterruptboundingbox%
\fi
\endgroup
\fi
}
% This is the low-level method which creates Acroforms and Javascript
% code.
% #1: width
% #2: height
% #3: name
% #4: the axisAnnotObj object (see javascript docs above)
% #5: the displayOpts object (see javascript docs above)
\def\pgfplots@create@clickable@plotarea#1#2#3#4#5{%
%\tracingmacros=2\tracingcommands=2
%\leavevmode
%--------------------------------------------------
% hyperref.sty implementation:
%--------------------------------------------------
% \PushButton[name=#3,borderwidth=0,bordersep=0,
% onclick={processAnnotatedPlot("#3", #4, #5);}]{\vbox to #2{\hsize=#1\vfill\hfill}}%
% \TextField[name=#3-result,hidden=true]{}%
%--------------------------------------------------
%
%--------------------------------------------------
% eforms.sty implementation:
% it allows more customization.
%--------------------------------------------------
%
% Hier kommen Annotation Directories zum Zuge!
% -> siehe Annotations in pdf reference
\def\pushButtonDefaults{
\W{0}% border width
\Border{0 0 0}%
}%
\def\textFieldDefaults{%
\W{1}% border width
\S{B}% border style ( one of SDBIU )
\F{2}% "display" bitflag. 2^1= hidden (see "Annotation Flags" in pdf reference)
%ATTENTION: \F 2 (hidden) produces INCOMPATIBILITIES with figure environment!?
% ---> ok, that has been fixed by recent versions of hyperref.
% (the pdf catalog may be incomplete in older hyperref pdftex drivers)
\Ff{1}% "Field characteristics" bitflag. 2^0 = "read-only"
}%
\pushButton[
%\A{/S/JavaScript/JS(processAnnotatedPlot("#3", #4, #5);)}%
\AA{
% /U = "mouse UP"
% /D = "mouse DOWN"
/U << /S/JavaScript/JS(axisMouseUp("#3", #4, #5);) >>
/D << /S/JavaScript/JS(axisMouseDown("#3");) >>
}%
]
{#3}
{#1}{#2}%
\textField{#3-result}{0pt}{0pt}%
\textField{#3-result2}{0pt}{0pt}%
\textField{#3-resultmark}{0pt}{0pt}%
\textField{#3-result2mark}{0pt}{0pt}%
\textField{#3-slope}{0pt}{0pt}%
% Unfortunately, line annotations can't be created/changed in acrobat
% javascript due to right problems :-(
%--------------------------------------------------
% \hbox to 0pt{\vsize=0pt \pdfannot{
% /Subtype /Line
% /Open /false
% /NM (#3-line)
% /C
% /CA
% /Subj ()
% /Contents ()
% /L [0 0 0 0]
% /LE [/None /OpenArrow] % PDF 1.4
% % /Ff 194
% }}%
%--------------------------------------------------
%
%
%\setLinkBbox[%
% \Border{}%
% \A{/S/JavaScript/JS(processme("#3");)}%
% \rawPDF{/C[1 0 0] /NM (#3)}%
% ]%
% {#1}{#2}{}%
}
\catcode`\"=\pgfplotscatcodeDQ
\endinput
|