rmh@surfer.sbm.temple.edu
2003-Apr-27 07:58 UTC
[Rd] bug and proposed fix in print.trellis 1.7.0 (PR#2859)
This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---1678264062-154654637-1051422990=:2626055 Content-Type: TEXT/PLAIN; charset=US-ASCII ---1678264062-154654637-1051422990=:2626055 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="pt-R.bug.report" Content-Transfer-Encoding: BASE64 Content-ID: <Pine.SGI.4.32.0304270156300.2626055@surfer.sbm.temple.edu> Content-Description: description Content-Disposition: attachment; filename="pt-R.bug.report" IyBZb3VyIG1haWxlciBpcyBzZXQgdG8gIm5vbmUiIChkZWZhdWx0IG9uIFdp bmRvd3MpLA0NCiMgaGVuY2Ugd2UgY2Fubm90IHNlbmQgdGhlIGJ1ZyByZXBv cnQgZGlyZWN0bHkgZnJvbSBSLg0NCiMgUGxlYXNlIGNvcHkgdGhlIGJ1ZyBy ZXBvcnQgKGFmdGVyIGZpbmlzaGluZyBpdCkgdG8NDQojIHlvdXIgZmF2b3Jp dGUgZW1haWwgcHJvZ3JhbSBhbmQgc2VuZCBpdCB0bw0NCiMNDQojICAgICAg IHItYnVnc0ByLXByb2plY3Qub3JnDQ0KIw0NCiMjIyMjIyMjIyMjIyMjIyMj IyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIw0NCg0NCg0N ClRoZSBuZXcgZmVhdHVyZSBkZXNjcmliZWQgaW4gcncxMDcwL2xpYnJhcnkv bGF0dGljZS9DaGFuZ2VzIGlzIHZlcnkNDQp1c2VmdWwgYW5kIGlzIG5lZWRl ZCBmb3Igc2V2ZXJhbCBvZiB0aGUgZXhhbXBsZXMgSSBzaG93ZWQgYXQgRFND LTIwMDMuDQ0KDQ0KPiBzY2FsZXMNDQo+IC0tLS0tLQ0NCj4gSW4gYW50aWNp cGF0aW9uIG9mIGZ1dHVyZSB1c2UgKGluI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ZHJlZywgcGFj a2FnZTpubHMsIHBhY2thZ2U6dHMsIEF1dG9sb2FkcywgcGFja2FnZTpiYXNl DQ0K ---1678264062-154654637-1051422990=:2626055 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="pt-test.r" Content-Transfer-Encoding: BASE64 Content-ID: <Pine.SGI.4.32.0304270156301.2626055@surfer.sbm.temple.edu> Content-Description: illustration Content-Disposition: attachment; filename="pt-test.r" IyMgcHJpbnQudHJlbGxpcyBidWcgaW4gUiAxLjcuMA0KDQp0bXAgPC0gZGF0 YS5mcmFtZShhPWZhY3RvcihjKCJhIiwiYiIsImMiKSksDQogICAgICAgICAg ICAgICAgICBiPWZhY3RvcihjKCJkIiwiZSIsImYiKSksDQogICAgICAgICAg ICAgICAgICBkPWZhY3RvcihjKDEsMSwyKSkpDQoNCnh5cGxvdChhIH4gYiB8 IGQsIGRhdGE9dG1wLCAgIyMgd29ya3MNCiAgICAgICAgc2NhbGVzPWxpc3Qo YWx0ZXJuYXRpbmc9RikpDQoNCnh5cGxvdChhIH4gYiB8IGQsIGRhdGE9dG1w LCAgIyMgSW52YWxpZCB2YWx1ZSBmb3IgbGFiZWxzDQogICAgICAgc2NhbGVz PWxpc3QoeD1saXN0KGxhYmVscz1saXN0KGMoImQiLCJlIiwiIiksYygiIiwi IiwiZiIpKSwNCiAgICAgICAgICAgICAgICAgICAgIGFsdGVybmF0aW5nPUYp KSkNCg0Kc291cmNlKCJwcmludC50cmVsbGlzLnIiKSAgICAjIyBybWggcHJv cG9zZWQgZml4DQoNCnh5cGxvdChhIH4gYiB8IGQsIGRhdGE9dG1wLCAgIyMg bm93IGl0IHdvcmtzDQogICAgICAgc2NhbGVzPWxpc3QoeD1saXN0KGxhYmVs cz1saXN0KGMoImQiLCJlIiwiIiksYygiIiwiIiwiZiIpKSwNCiAgICAgICAg ICAgICAgICAgICAgIGFsdGVybmF0aW5nPUYpKSkNCg=---1678264062-154654637-1051422990=:2626055 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="print.trellis.r" Content-Transfer-Encoding: BASE64 Content-ID: <Pine.SGI.4.32.0304270156302.2626055@surfer.sbm.temple.edu> Content-Description: proposed fix Content-Disposition: attachment; filename="print.trellis.r" cHJpbnQudHJlbGxpcyA8LQ0KZnVuY3Rpb24gKHgsIHBvc2l0aW9uLCBzcGxp dCwgbW9yZSA9IEZBTFNFLCBuZXdwYWdlID0gVFJVRSwgcGFuZWwuaGVpZ2h0 ID0gbGlzdCgxLCANCiAgICAibnVsbCIpLCBwYW5lbC53aWR0aCA9IGxpc3Qo MSwgIm51bGwiKSwgLi4uKSANCnsNCiAgICBpZiAoaXMubnVsbChkZXYubGlz dCgpKSkgDQogICAgICAgIHRyZWxsaXMuZGV2aWNlKCkNCiAgICBlbHNlIGlm IChpcy5udWxsKHRyZWxsaXMucGFyLmdldCgpKSkgDQogICAgICAgIHRyZWxs aXMuZGV2aWNlKGRldmljZSA9IC5EZXZpY2UsIG5ldyA9IEZBTFNFKQ0KICAg IGJnID0gdHJlbGxpcy5wYXIuZ2V0KCJiYWNrZ3JvdW5kIikkY29sDQogICAg bmV3IDwtIFRSVUUNCiAgICBpZiAoLmxhdHRpY2UucHJpbnQubW9yZSB8fCAh bmV3cGFnZSkgDQogICAgICAgIG5ldyA8LSBGQUxTRQ0KICAgIC5sYXR0aWNl LnByaW50Lm1vcmUgPDwtIG1vcmUNCiAgICB1c3VhbCA8LSAobWlzc2luZyhw b3NpdGlvbikgJiBtaXNzaW5nKHNwbGl0KSkNCiAgICBmb250c2l6ZS5kZWZh dWx0IDwtIHRyZWxsaXMucGFyLmdldCgiZm9udHNpemUiKSRkZWZhdWx0DQog ICAgaWYgKCFtaXNzaW5nKHBvc2l0aW9uKSkgew0KICAgICAgICBpZiAobGVu Z3RoKHBvc2l0aW9uKSAhPSA0KSANCiAgICAgICAgICAgIHN0b3AoIkluY29y cmVjdCB2YWx1ZSBvZiBwb3NpdGlvbiIpDQogICAgICAgIGlmIChuZXcpIHsN CiAgICAgICAgICAgIGdyaWQubmV3cGFnZSgpDQogICAgICAgICAgICBncmlk LnJlY3QoZ3AgPSBncGFyKGZpbGwgPSBiZywgY29sID0gInRyYW5zcGFyZW50 IikpDQogICAgICAgIH0NCiAgICAgICAgcHVzaC52aWV3cG9ydCh2aWV3cG9y dCh4ID0gcG9zaXRpb25bMV0sIHkgPSBwb3NpdGlvblsyXSwgDQogICAgICAg ICAgICB3aWR0aCA9IHBvc2l0aW9uWzNdIC0gcG9zaXRpb25bMV0sIGhlaWdo dCA9IHBvc2l0aW9uWzRdIC0gDQogICAgICAgICAgICAgICAgcG9zaXRpb25b Ml0sIGp1c3QgPSBjKCJsZWZ0IiwgImJvdHRvbSIpKSkNCiAgICAgICAgaWYg KCFtaXNzaW5nKHNwbGl0KSkgew0KICAgICAgICAgICAgaWYgKGxlbmd0aChz cGxpdCkgIT0gNCkgDQogICAgICAgICAgICAgICAgc3RvcCgiSW5jb3JyZWN0 IHZhbHVlIG9mIHNwbGl0IikNCiAgICAgICAgICAgIHB1c2gudmlld3BvcnQo dmlld3BvcnQobGF5b3V0ID0gZ3JpZC5sYXlvdXQobnJvdyA9IHNwbGl0WzRd LCANCiAgICAgICAgICAgICAgICBuY29sID0gc3BsaXRbM10pKSkNCiAgICAg ICAgICAgIHB1c2gudmlld3BvcnQodmlld3BvcnQobGF5b3V0LnBvcy5yb3cg PSBzcGxpdFsyXSwgDQogICAgICAgICAgICAgICAgbGF5b3V0LnBvcy5jb2wg PSBzcGxpdFsxXSkpDQogICAgICAgIH0NCiAgICB9DQogICAgZWxzZSBpZiAo IW1pc3Npbmcoc3BsaXQpKSB7DQogICAgICAgIGlmIChsZW5ndGgoc3BsaXQp ICE9IDQpIA0KICAgICAgICAgICAgc3RvcCgiSW5jb3JyZWN0IHZhbHVlIG9m IHNwbGl0IikNCiAgICAgICAgaWYgKG5ldykgew0KICAgICAgICAgICAgZ3Jp ZC5uZXdwYWdlKCkNCiAgICAgICAgICAgIGdyaWQucmVjdChncCA9IGdwY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AgICAgICBrZXkuc3BhY2UgPC0gaWYgKCJzcGFjZSIgJWluJSBuYW1lcyh4 JGtleSkpIA0KICAgICAgICAgICAgeCRrZXkkc3BhY2UNCiAgICAgICAgZWxz ZSBpZiAoIngiICVpbiUgbmFtZXMoeCRrZXkpIHx8ICJjb3JuZXIiICVpbiUg bmFtZXMoeCRrZXkpKSANCiAgICAgICAgICAgICJpbnNpZGUiDQogICAgICAg IGVsc2UgInRvcCINCiAgICB9DQogICAgZWxzZSBpZiAoIWlzLm51bGwoeCRj b2xvcmtleSkpIHsNCiAgICAgICAga2V5LmdmIDwtIGRyYXcuY29sb3JrZXko eCRjb2xvcmtleSkNCiAgICAgICAga2V5LnNwYWNlIDwtIGlmICgic3BhY2Ui ICVpbiUgbmFtZXMoeCRjb2xvcmtleSkpIA0KICAgICAgICAgICAgeCRjb2xv cmtleSRzcGFjZQ0KICAgICAgICBlbHNlICJyaWdodCINCiAgICB9DQogICAg eGF4aXMuY29sIDwtIGlmIChpcy5sb2dpY2FsKHgkeC5zY2FsZXMkY29sKSkg DQogICAgICAgIGF4aXMubGluZSRjb2wNCiAgICBlbHNlIHgkeC5zY2FsZXMk Y29sDQogICAgeGF4aXMuZm9udCA8LSBpZiAoaXMubG9naWNhbCh4JHguc2Nh bGVzJGZvbnQpKSANCiAgICAgICAgMQ0KICAgIGVsc2UgeCR4LnNjYWxlcyRm b250DQogICAgeGF4aXMuY2V4IDwtIHgkeC5zY2FsZXMkY2V4DQogICAgeGF4 aXMucm90IDwtIGlmIChpcy5sb2dpY2FsKHgkeC5zY2FsZXMkcm90KSkgDQog ICAgICAgIGMoMCwgMCkNCiAgICBlbHNlIHgkeC5zY2FsZXMkcm90DQogICAg eWF4aXMuY29sIDwtIGlmIChpcy5sb2dpY2FsKHgkeS5zY2FsZXMkY29sKSkg DQogICAgICAgIGF4aXMubGluZSRjb2wNCiAgICBlbHNlIHgkeS5zY2FsZXMk Y29sDQogICAgeWF4aXMuZm9udCA8LSBpZiAoaXMub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KHgkc3ViJGxhYmVsKSAmJiANCiAgICAgICAgeCRzdWIkbGFiZWwg PT0gIiIpKQ0KICAgIGhhdmUueGxhYiA8LSAhKGlzLm51bGwoeCR4bGFiJGxh YmVsKSB8fCAoaXMuY2hhcmFjdGVyKHgkeGxhYiRsYWJlbCkgJiYgDQogICAg ICAgIHgkeGxhYiRsYWJlbCA9PSAiIikpDQogICAgaGF2ZS55bGFiIDwtICEo aXMubnVsbCh4JHlsYWIkbGFiZWwpIHx8IChpcy5jaGFyYWN0ZXIoeCR5bGFi JGxhYmVsKSAmJiANCiAgICAgICAgeCR5bGFiJGxhYmVsID09ICIiKSkNCiAg ICBuLnJvdyA8LSByb3dzLnBlci5wYWdlICogKG51bWJlci5vZi5jb25kICsg MykgKyAocm93cy5wZXIucGFnZSAtIA0KICAgICAgICAxKSArIDExDQogICAg bi5jb2wgPC0gMyAqIGNvbHMucGVyLnBhZ2UgKyAoY29scy5wZXIucGFnZSAt IDEpICsgOQ0KICAgIGlmIChsYXlvdXQucmVzcGVjdCkgew0KICAgICAgICBs YXlvdXQucmVzcGVjdCA8LSBtYXRyaXgoMCwgbi5yb3csIG4uY29sKQ0KICAg ICAgICBsYXlvdXQucmVzcGVjdFtudW1iZXIub2YuY29uZCArIDYgKyAoMTpy b3dzLnBlci5wYWdlIC0gDQogICAgICAgICAgICAxKSAqIChudW1iZXIub2Yu Y29uZCArIDQpLCAoMTpjb2xzLnBlci5wYWdlIC0gMSkgKiANCiAgICAgICAg ICAgIDQgKyA4XSA8LSAxDQogICAgfQ0KICAgIGhlaWdodHMueCA8LSByZXAo MSwgbi5yb3cpDQogICAgaGVpZ2h0cy51bml0cyA8LSByZXAoImxpbmVzIiwg bi5yb3cpDQogICAgaGVpZ2h0cy5kYXRhIDwtIGFzLmxpc3QoMTpuLnJvdykN CiAgICB3aWR0aHMueCA8LSByZXAoMSwgbi5jb2wpDQogICAgd2lkdGhzLnVu aXRzIDwtIHJlcCgibGluZXMiLCBuLmNvbCkNCiAgICB3aWR0aHMuZGF0YSA8 LSBhcy5saXN0KDE6bi5jb2wpDQogICAgaGVpZ2h0cy54W251bWJlci5vZi5j b25kICsgNiArICgxOnJvd3MucGVyLnBhZ2UgLSAxKSAqIChudW1iZXIub2Yu Y29uZCArIA0KICAgICAgICA0KV0gPC0gcGFuZWwuaGVpZ2h0W1sxXV0NCiAg ICBoZWlnaHRzLnVuaXRzW251bWJlci5vZi5jb25kICsgNiArICgxOnJvd3Mu cGVyLnBhZ2UgLSAxKSAqIA0KICAgICAgICAobnVtYmVyLm9mLmNvbmQgKyA0 KV0gPC0gcGFuZWwuaGVpZ2h0W1syXV0NCiAgICBoZWlnaHRzLnhbbnVtYmVy Lm9mLmNvbmQgKyA3ICsgKDE6cm93cy5wZXIucGFnZSAtIDEpICogKG51bWJl ci5vZi5jb25kICsgDQogICAgICAgIDQpXSA8LSAwDQogICAgaGVpZ2h0cy54 W251bWJlci5vZi5jb25kICsgOCArICgxOnJvd3MucGVyLnBhZ2UgLSAxKSAq IChudW1iZXIub2YuY29uZCArIA0KICAgICAgICA0KV0gPC0gMA0KICAgIGhl aWdodHMueFs0XSA8LSAwDQogICAgaGVpZ2h0cy54WzVdIDwtIDANCiAgICBo ZWlnaHRzLnhbbi5yb3cgLSA0XSA8LSAwDQogICAgaGVpZ2h0cy54W24ucm93 IC0gNV0gPC0gMA0KICAgIGlmIChyb3dzLnBlci5wYWdlID4gMSkgDQogICAg ICAgIGhlaWdodHMueFtudW1iZXIub2YuY29uZCArIDkgKyAoKGlmICh4JGFz LnRhYmxlKSANCiAgICAgICAgICAgIDE6KHJvd3MucGVyLnBhZ2UgLSAxKQ0K ICAgICAgICBlbHNlIChyb3dzLnBlci5wYWdlIC0gMSk6MSkgLSAxKSAqIChu dW1iZXIub2YuY29uZCArIA0KICAgICAgICAgICAgNCldIDwtIHkuYmV0d2Vl bg0KICAgIGhlaWdodHMueFsxXSA8LSAwLjUNCiAgICBoZWlnaHRzLnhbMl0g PC0gaWYgKGhhdmUubWFpbikgDQogICAgICAgIDIgKiB4JG1haW4kY2V4DQog ICAgZWxzZSAwDQogICAgaWYgKGhhdmUubWFpbikgew0KICAgICAgICBoZWln aHRzLnVuaXRzWzJdIDwtICJzdHJoZWlnaHQiDQogICAgICAgIGhlaWdodHMu ZGF0YVtbMl1dIDwtIHgkbWFpbiRsYWINCiAgICB9DQogICAgaGVpZ2h0cy54 W24ucm93XSA8LSAwLjUNCiAgICBoZWlnaHRzLnhbbi5yb3cgLSAxXSA8LSBp ZiAoaGF2ZS5zdWIpIA0KICAgICAgICAyICogeCRzdWIkY2V4DQogICAgZWxz ZSAwDQogICAgaWYgKGhhdmUuc3ViKSB7DQogICAgICAgIGhlaWdodHMudW5p dHNbbi5yb3cgLSAxXSA8LSAic3RyaGVpZ2h0Ig0KICAgICAgICBoZWlnaHRz LmRhdGFbW24ucm93IC0gMV1dIDwtIHgkc3ViJGxhYg0KICAgIH0NCiAgICBo ZWlnaHRzLnhbM10gPC0gMA0KICAgIGhlaWdodHMueFtuLnJvdyAtIDJdIDwt IDANCiAgICBoZWlnaHRzLmluc2VydGxpc3QucG9zaXRpb24gPC0gMA0KICAg IGhlaWdodHMuaW5zZXJ0bGlzdC51bml0IDwtIHVuaXQoMSwgIm51bGwiKQ0K ICAgIGlmICh4JHguc2NhbGVzJGRyYXcpIHsNCiAgICAgICAgaWYgKHgucmVs YXRpb24uc2FtZSkgew0KICAgICAgICAgICAgbGFiIDwtIGNhbGN1bGF0ZUF4 aXNDb21wb25lbnRzKHggPSB4JHgubGltaXRzLCBhdCA9IHgkeC5zY2FsZXMk YXQsIA0KICAgICAgICAgICAgICAgIGxhYmVscyA9IHgkeC5zY2FsZXMkbGFi LCBoYXZlLmxvZyA9IGhhdmUueGxvZywgDQogICAgICAgICAgICAgICAgbG9n YmFzZSA9IHhsb2diYXNlLCBsb2dwYXN0ZSA9IHhsb2dwYXN0ZSwgYWJicmV2 aWF0ZSA9IHgkeC5zY2FsZXMkYWJiciwgDQogICAgICAgICAgICAgICAgbWlu bGVuZ3RoID0geCR4LnNjYWxlcyRtaW5sLCBuID0geCR4LnNjYWxlcyR0aWNr Lm51bWJlcikkbGFiDQojIyAgICAgICAgICBpZiAoaXMuY2hhcmFjdGVyKGxh YikpIA0KICAgICAgICAgICAgaWYgKGFsbChzYXBwbHkobGFiLCBpcy5jaGFy YWN0ZXIpKSkgICMjIHJtaA0KICAgICAgICAgICAgICAgIHN0cmJhciA8LSBh cy5saXN0KGxhYikNCiAgICAgICAgICAgIGVsc2UgaWYgKGlzLmV4cHJlc3Np b24obGFiKSkgew0KICAgICAgICAgICAgICAgIHN0cmJhciA8LSBsaXN0KCkN CiAgICAgICAgICAgICAgICBmb3IgKHNzIGluIHNlcShhbG9uZyA9IGxhYikp IHN0cmJhciA8LSBjKHN0cmJhciwgDQogICAgICAgICAgICAgICAgICBsaXN0 KGxhYltzc10pKQ0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSBz dG9wKCJJbnZhbGlkIHZhbHVlIGZvciBsYWJlbHMiKQ0KICAgICAgICAgICAg aGVpZ2h0cy54WzVdIDwtIDAuNSArIG1heCgwLjAwMSwgeCR4LnNjYWxlcyR0 Y2tbMl0pICogDQogICAgICAgICAgICAgICAgMC4zDQogICAgICAgICAgICBo ZWlnaHRzLnhbbi5yb3cgLSA1XSA8LSAwLjUgKyBtYXgoMC4wMDEsIHgkeC5z Y2FsZXMkdGNrWzFdKSAqIA0KICAgICAgICAgICAgICAgIDAuMw0KICAgICAg ICAgICAgaWYgKGFueSh4LmFsdGVybmF0aW5nID09IDIgfCB4LmFsdGVybmF0 aW5nID09IDMpKSB7DQogICAgICAgICAgICAgICAgaWYgKHhheGlzLnJvdFsy XSAlaW4lIGMoMCwgMTgwKSkgew0KICAgICAgICAgICAgICAgICAgaGVpZ2h0 cy5pbnNlcnRsaXN0LnBvc2l0aW9uIDwtIGMoaGVpZ2h0cy5pbnNlcnRsaXN0 LnBvc2l0aW9uLCANCiAgICAgICAgICAgICAgICAgICAgNCkNCiAgICAgICAg ICAgICAgICAgIGhlaWdodHMuaW5zZXJ0bGlzdC51bml0IDwtIHVuaXQuYyho ZWlnaHRzLmluc2VydGxpc3QudW5pdCwgDQogICAgICAgICAgICAgICAgICAg IG1heCh1bml0KHJlcCgxICogeGF4aXMuY2V4WzJdLCBsZW5ndGgoc3RyYmFy KSksIA0KICAgICAgICAgICAgICAgICAgICAgICJzdHJoZWlnaHQiLCBzdHJi YXIpKSkNCiAgICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgZWxz ZSB7DQogICAgICAgICAgICAgICAgICBoZWlnaHRzLmluc2VydGxpc3QucG9z aXRpb24gPC0gYyhoZWlnaHRzLmluc2VydGxpc3QucG9zaXRpb24sIA0KICAg ICAgICAgICAgICAgICAgICA0KQ0KICAgICAgICAgICAgICAgICAgaGVpZ2h0 cy5pbnNlcnRsaXN0LnVuaXQgPC0gdW5pdC5jKGhlaWdodHMuaW5zZXJ0bGlz dC51bml0LCANCiAgICAgICAgICAgICAgICAgICAgbWF4KHVuaXQocmVwKDEg KiB4YXhpcy5jZXhbMl0gKiBhYnMoc2luKHhheGlzLnJvdFsyXSAqIA0KICAg ICAgICAgICAgICAgICAgICAgIGJhc2U6OnBpLzE4MCkpLCBsZW5ndGgoc3Ry YmFyKSksICJzdHJ3aWR0aCIsIA0KICAgICAgICAgICAgICAgICAgICAgIHN0 cmJhcikpKQ0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgIH0NCiAg ICAgICAgICAgIGlmIChhbnkoeC5hbHRlcm5hdGluZyA9PSAxIHwgeC5hbHRl cm5hdGluZyA9PSAzKSkgew0KICAgICAgICAgICAgICAgIGlmICh4YXhpcy5y b3RbMV0gJWluJSBjKDAsIDE4MCkpIHsNCiAgICAgICAgICAgICAgICAgIGhl aWdodHMuaW5zZXJ0bGlzdC5wb3NpdGlvbiA8LSBjKGhlaWdodHMuaW5zZXJ0 bGlzdC5wb3NpdGlvbiwgDQogICAgICAgICAgICAgICAgICAgIG4ucm93IC0g NCkNCiAgICAgICAgICAgICAgICAgIGhlaWdodHMuaW5zZXJ0bGlzdC51bml0 IDwtIHVuaXQuYyhoZWlnaHRzLmluc2VydGxpc3QudW5pdCwgDQogICAgICAg ICAgICAgICAgICAgIG1heCh1bml0KHJlcCgxICogeGF4aXMuY2V4WzFdLCBs ZW5ndGgoc3RyYmFyKSksIA0KICAgICAgICAgICAgICAgICAgICAgICJzdHJo ZWlnaHQiLCBzdHJiYXIpKSkNCiAgICAgICAgICAgICAgICB9DQogICAgICAg ICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgICBoZWlnaHRzLmlu c2VydGxpc3QucG9zaXRpb24gPC0gYyhoZWlnaHRzLmluc2VydGxpc3QucG9z aXRpb24sIA0KICAgICAgICAgICAgICAgICAgICBuLnJvdyAtIDQpDQogICAg ICAgICAgICAgICAgICBoZWlnaHRzLmluc2VydGxpc3QudW5pdCA8LSB1bml0 LmMoaGVpZ2h0cy5pbnNlcnRsaXN0LnVuaXQsIA0KICAgICAgICAgICAgICAg ICAgICBtYXgodW5pdChyZXAoMSAqIHhheGlzLmNleFsxXSAqIGFicyhzaW4o eGF4aXMucm90WzFdICogDQogICAgICAgICAgICAgICAgICAgICAgYmFzZTo6 cGkvMTgwKSksIGxlbmd0aChzdHJiYXIpKSwgInN0cndpZHRoIiwgDQogICAg ICAgICAgICAgICAgICAgICAgc3RyYmFyKSkpDQogICAgICAgICAgICAgICAg fQ0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQogICAgICAgIGVsc2Ugew0K ICAgICAgICAgICAgbGFiZWxDaGFycyA8LSBjaGFyYWN0ZXIoMCkNCiAgICAg ICAgICAgIGxhYmVsRXhwcnMgPC0gZXhwcmVzc2lvbigwKQ0KICAgICAgICAg ICAgZm9yIChpIGluIHNlcShhbG9uZyA9IHgkeC5saW1pdHMpKSB7DQogICAg ICAgICAgICAgICAgbGFiIDwtIGNhbGN1bGF0ZUF4aXNDb21wb25lbnRzKHgg PSB4JHgubGltaXRzW1tpXV0sIA0KICAgICAgICAgICAgICAgICAgYXQgPSBp ZiAoaXMubGlzdCh4JHguc2NhbGVzJGF0KSkgDQogICAgICAgICAgICAgICAg ICAgIHgkeC5zY2FsZXMkYXRbW2ldXQ0KICAgICAgICAgICAgICAgICAgZWxz ZSB4JHguc2NhbGVzJGF0LCBsYWJlbHMgPSBpZiAoaXMubGlzdCh4JHguc2Nh bGVzJGxhYikpIA0KICAgICAgICAgICAgICAgICAgICB4JHguc2NhbGVzJGxh YltbaV1dDQogICAgICAgICAgICAgICAgICBlbHNlIHgkeC5zY2FsZXMkbGFi LCBoYXZlLmxvZyA9IGhhdmUueGxvZywgDQogICAgICAgICAgICAgICAgICBs b2diYXNlID0geGxvZ2Jhc2UsIGxvZ3Bhc3RlID0geGxvZ3Bhc3RlLCBhYmJy ZXZpYXRlID0geCR4LnNjYWxlcyRhYmJyLCANCiAgICAgICAgICAgICAgICAg IG1pbmxlbmd0aCA9IHgkeC5zY2FsZXMkbWlubCwgbiA9IHgkeC5zY2FsZXMk dGljay5udW1iZXIpJGxhYg0KICAgICAgICAgICAgICAgIGlmIChpcy5jaGFy YWN0ZXIobGFiKSkgDQogICAgICAgICAgICAgICAgICBsYWJlbENoYXJzIDwt IGMobGFiZWxDaGFycywgbGFiKQ0KICAgICAgICAgICAgICAgIGVsc2UgaWYg KGlzLmV4cHJlc3Npb24obGFiKSkgDQogICAgICAgICAgICAgICAgICBsYWJl bEV4cHJzIDwtIGMobGFiZWxFeHBycywgbGFiKQ0KICAgICAgICAgICAgfQ0K ICAgICAgICAgICAgbGFiZWxDaGFycyA8LSB1bmlxdWUobGFiZWxDaGFycykN CiAgICAgICAgICAgIHN0cmJhciA8LSBsaXN0KCkNCiAgICAgICAgICAgIGZv ciAoc3MgaW4gbGFiZWxDaGFycykgc3RyYmFyIDwtIGMoc3RyYmFyLCBsaXN0 KHNzKSkNCiAgICAgICAgICAgIGZvciAoc3MgaW4gc2VxKGFsb25nID0gbGFi ZWxFeHBycykpIHN0cmJhciA8LSBjKHN0cmJhciwgDQogICAgICAgICAgICAg ICAgbGlzdChsYWJlbEV4cHJzW3NzXSkpDQogICAgICAgICAgICBpZiAoeGF4 aXMucm90WzFdICVpbiUgYygwLCAxODApKSB7DQogICAgICAgICAgICAgICAg aGVpZ2h0cy54W251bWJlci5vZi5jb25kICsgNyArICgxOnJvd3MucGVyLnBh Z2UgLSANCiAgICAgICAgICAgICAgICAgIDEpICogKG51bWJlci5vZi5jb25k ICsgNCldIDwtIG1heCgwLjAwMSwgeCR4LnNjYWxlcyR0Y2tbMV0pICogDQog ICAgICAgICAgICAgICAgICAwLjMNCiAgICAgICAgICAgICAgICBoZWlnaHRz Lmluc2VydGxpc3QucG9zaXRpb24gPC0gYyhoZWlnaHRzLmluc2VydGxpc3Qu cG9zaXRpb24sIA0KICAgICAgICAgICAgICAgICAgbnVtYmVyLm9mLmNvbmQg KyA4ICsgKDE6cm93cy5wZXIucGFnZSAtIDEpICogDQogICAgICAgICAgICAg ICAgICAgIChudW1iZXIub2YuY29uZCArIDQpKQ0KICAgICAgICAgICAgICAg IGZvciAoaSBpbiAxOnJvd3MucGVyLnBhZ2UpIGhlaWdodHMuaW5zZXJ0bGlz dC51bml0IDwtIHVuaXQuYyhoZWlnaHRzLmluc2VydGxpc3QudW5pdCwgDQog ICAgICAgICAgICAgICAgICBtYXgodW5pdChyZXAoMS41ICogeGF4aXMuY2V4 WzFdLCBsZW5ndGgoc3RyYmFyKSksIA0KICAgICAgICAgICAgICAgICAgICAi c3RyaGVpZ2h0Iiwgc3RyYmFyKSkpDQogICAgICAgICAgICB9DQogICAgICAg ICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICBoZWlnaHRzLnhbbnVtYmVy Lm9mLmNvbmQgKyA3ICsgKDE6cm93cy5wZXIucGFnZSAtIA0KICAgICAgICAg ICAgICAgICAgMSkgKiAobnVtYmVyLm9mLmNvbmQgKyA0KV0gPC0gbWF4KDAu MDAxLCB4JHguc2NhbGVzJHRja1sxXSkgKiANCiAgICAgICAgICAgICAgICAg IDAuMw0KICAgICAgICAgICAgICAgIGhlaWdodHMuaW5zZXJ0bGlzdC5wb3Np dGlvbiA8LSBjKGhlaWdodHMuaW5zZXJ0bGlzdC5wb3NpdGlvbiwgDQogICAg ICAgICAgICAgICAgICBudW1iZXIub2YuY29uZCArIDggKyAoMTpyb3dzLnBl ci5wYWdlIC0gMSkgKiANCiAgICAgICAgICAgICAgICAgICAgKG51bWJlci5v Zi5jb25kICsgNCkpDQogICAgICAgICAgICAgICAgZm9yIChpIGluIDE6cm93 cy5wZXIucGFnZSkgaGVpZ2h0cy5pbnNlcnRsaXN0LnVuaXQgPC0gdW5pdC5j KGhlaWdodHMuaW5zZXJ0bGlzdC51bml0LCANCiAgICAgICAgICAgICAgICAg IG1heCh1bml0KHJlcCgxLjUgKiB4YXhpcy5jZXhbMV0gKiBhYnMoc2luKHhh eGlzLnJvdFsxXSAqIA0KICAgICAgICAgICAgICAgICAgICBiYXNlOjpwaS8x ODApKSwgbGVuZ3RoKHN0cmJhcikpLCAic3Ryd2lkdGgiLCANCiAgICAgICAg ICAgICAgICAgICAgc3RyYmFyKSkpDQogICAgICAgICAgICB9DQogICAgICAg IH0NCiAgICB9DQogICAgaGVpZ2h0cy54W24ucm93IC0gM10gPC0gaWYgKGhh dmUueGxhYikgDQogICAgICAgIDIgKiB4JHhsYWIkY2V4DQogICAgZWxzZSAw DQogICAgaWYgKGhhdmUueGxhYikgew0KICAgICAgICBoZWlnaHRzLnVuaXRz W24ucm93IC0gM10gPC0gInN0cmhlaWdodCINCiAgICAgICAgaGVpZ2h0cy5k YXRhW1tuLnJvdyAtIDNdXSA8LSB4JHhsYWIkbGFiDQogICAgfQ0KICAgIGZv ciAoY3JyIGluIDE6bnVtYmVyLm9mLmNvbmQpIGhlaWdodHMueFtudW1iZXIu b2YuY29uZCArIA0KICAgICAgICA2ICsgKDE6cm93cy5wZXIucGFnZSAtIDEp IC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kdGhzLnhbbi5jb2wgLSAxXSA8LSAwDQog ICAgd2lkdGhzLmluc2VydGxpc3QucG9zaXRpb24gPC0gMA0KICAgIHdpZHRo cy5pbnNlcnRsaXN0LnVuaXQgPC0gdW5pdCgxLCAibnVsbCIpDQogICAgaWYg KHgkeS5zY2FsZXMkZHJhdykgew0KICAgICAgICBpZiAoeS5yZWxhdGlvbi5z YW1lKSB7DQogICAgICAgICAgICBsYWIgPC0gY2FsY3VsYXRlQXhpc0NvbXBv bmVudHMoeCA9IHgkeS5saW1pdHMsIGF0ID0geCR5LnNjYWxlcyRhdCwgDQog ICAgICAgICAgICAgICAgbGFiZWxzID0geCR5LnNjYWxlcyRsYWIsIGhhdmUu bG9nID0gaGF2ZS55bG9nLCANCiAgICAgICAgICAgICAgICBsb2diYXNlID0g eWxvZ2Jhc2UsIGxvZ3Bhc3RlID0geWxvZ3Bhc3RlLCBhYmJyZXZpYXRlID0g eCR5LnNjYWxlcyRhYmJyLCANCiAgICAgICAgICAgICAgICBtaW5sZW5ndGgg PSB4JHkuc2NhbGVzJG1pbmwsIG4gPSB4JHkuc2NhbGVzJHRpY2subnVtYmVy KSRsYWINCiMjICAgICAgICAgIGlmIChpcy5jaGFyYWN0ZXIobGFiKSkgDQog ICAgICAgICAgICBpZiAoYWxsKHNhcHBseShsYWIsIGlzLmNoYXJhY3Rlcikp KSAgIyMgcm1oDQogICAgICAgICAgICAgICAgc3RyYmFyIDwtIGFzLmxpc3Qo bGFiKQ0KICAgICAgICAgICAgZWxzZSBpZiAoaXMuZXhwcmVzc2lvbihsYWIp KSB7DQogICAgICAgICAgICAgICAgc3RyYmFyIDwtIGxpc3QoKQ0KICAgICAg ICAgICAgICAgIGZvciAoc3MgaW4gc2VxKGFsb25nID0gbGFiKSkgc3RyYmFy IDwtIGMoc3RyYmFyLCANCiAgICAgICAgICAgICAgICAgIGxpc3QobGFiW3Nz XSkpDQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHN0b3AoIklu dmFsaWQgdmFsdWUgZm9yIGxhYmVscyIpDQogICAgICAgICAgICB3aWR0aHMu eFs1XSA8LSAwLjUgKyBtYXgoMC4wMDEsIHgkeS5zY2FsZXMkdGNrWzFdKSAq IA0KICAgICAgICAgICAgICAgIDAuMw0KICAgICAgICAgICAgd2lkdGhzLnhb bi5jb2wgLSAzXSA8LSBtYXgoMSwgeCR5LnNjYWxlcyR0Y2tbMl0pICogDQog ICAgICAgICAgICAgICAgMC41DQogICAgICAgICAgICBpZiAoYW55KHkuYWx0 ZXJuYXRpbmcgPT0gMSB8IHkuYWx0ZXJuYXRpbmcgPT0gMykpIHsNCiAgICAg ICAgICAgICAgICBpZiAoYWJzKHlheGlzLnJvdFsxXSkgPT0gOTApIHsNCiAg ICAgICAgICAgICAgICAgIHdpZHRocy5pbnNlcnRsaXN0LnBvc2l0aW9uIDwt IGMod2lkdGhzLmluc2VydGxpc3QucG9zaXRpb24sIA0KICAgICAgICAgICAg ICAgICAgICA0KQ0KICAgICAgICAgICAgICAgICAgd2lkdGhzLmluc2VydGxp c3QudW5pdCA8LSB1bml0LmMod2lkdGhzLmluc2VydGxpc3QudW5pdCwgDQog ICAgICAgICAgICAgICAgICAgIG1heCh1bml0KDEgKiByZXAoeWF4aXMuY2V4 WzFdLCBsZW5ndGgoc3RyYmFyKSksIA0KICAgICAgICAgICAgICAgICAgICAg ICJzdHJoZWlnaHQiLCBkYXRhID0gc3RyYmFyKSkpDQogICAgICAgICAgICAg ICAgfQ0KICAgICAgICAgICAgICAgIGVsc2Ugew0KICAgICAgICAgICAgICAg ICAgd2lkdGhzLmluc2VydGxpc3QucG9zaXRpb24gPC0gYyh3aWR0aHMuaW5z ZXJ0bGlzdC5wb3NpdGlvbiwgDQogICAgICAgICAgICAgICAgICAgIDQpDQog ICAgICAgICAgICAgICAgICB3aWR0aHMuaW5zZXJ0bGlzdC51bml0IDwtIHVu aXQuYyh3aWR0aHMuaW5zZXJ0bGlzdC51bml0LCANCiAgICAgICAgICAgICAg ICAgICAgbWF4KHVuaXQocmVwKDEgKiB5YXhpcy5jZXhbMV0gKiBhYnMoY29z KHlheGlzLnJvdFsxXSAqIA0KICAgICAgICAgICAgICAgICAgICAgIGJhc2U6 OnBpLzE4MCkpLCBsZW5ndGgoc3RyYmFyKSksICJzdHJ3aWR0aCIsIA0KICAg ICAgICAgICAgICAgICAgICAgIHN0cmJhcikpKQ0KICAgICAgICAgICAgICAg IH0NCiAgICAgICAgICAgIH0NCiAgICAgICAgICAgIGlmIChhbnkoeS5hbHRl cm5hdGluZyA9PSAyIHwgeS5hbHRlcm5hdGluZyA9PSAzKSkgew0KICAgICAg ICAgICAgICAgIGlmIChhYnMoeWF4aXMucm90WzJdKSA9PSA5MCkgew0KICAg ICAgICAgICAgICAgICAgd2lkdGhzLmluc2VydGxpc3QucG9zaXRpb24gPC0g Yyh3aWR0aHMuaW5zZXJ0bGlzdC5wb3NpdGlvbiwgDQogICAgICAgICAgICAg ICAgICAgIG4uY29sIC0gMikNCiAgICAgICAgICAgICAgICAgIHdpZHRocy5p bnNlcnRsaXN0LnVuaXQgPC0gdW5pdC5jKHdpZHRocy5pbnNlcnRsaXN0LnVu aXQsIA0KICAgICAgICAgICAgICAgICAgICBtYXgodW5pdChyZXAoMSAqIHlh eGlzLmNleFsyXSwgbGVuZ3RoKHN0cmJhcikpLCANCiAgICAgICAgICAgICAg ICAgICAgICAic3RyaGVpZ2h0Iiwgc3RyYmFyKSkpDQogICAgICAgICAgICAg ICAgfQ0KICAgICAgICAgICAgICAgIGVsc2Ugew0KICAgICAgICAgICAgICAg ICAgd2lkdGhzLmluc2VydGxpc3QucG9zaXRpb24gPC0gYyh3aWR0aHMuaW5z ZXJ0bGlzdC5wb3NpdGlvbiwgDQogICAgICAgICAgICAgICAgICAgIG4uY29s IC0gMikNCiAgICAgICAgICAgICAgICAgIHdpZHRocy5pbnNlcnRsaXN0LnVu aXQgPC0gdW5pdC5jKHdpZHRocy5pbnNlcnRsaXN0LnVuaXQsIA0KICAgICAg ICAgICAgICAgICAgICBtYXgodW5pdChyZXAoMSAqIHlheGlzLmNleFsyXSAq IGFicyhjb3MoeWF4aXMucm90WzJdICogDQogICAgICAgICAgICAgICAgICAg ICAgYmFzZTo6cGkvMTgwKSksIGxlbmd0aChzdHJiYXIpKSwgInN0cndpZHRo IiwgDQogICAgICAgICAgICAgICAgICAgICAgc3RyYmFyKSkpDQogICAgICAg ICAgICAgICAgfQ0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQogICAgICAg IGVsc2Ugew0KICAgICAgICAgICAgbGFiZWxDaGFycyA8LSBjaGFyYWN0ZXIo MCkNCiAgICAgICAgICAgIGxhYmVsRXhwcnMgPC0gZXhwcmVzc2lvbigwKQ0K ICAgICAgICAgICAgZm9yIChpIGluIHNlcShhbG9uZyA9IHgkeS5saW1pdHMp KSB7DQogICAgICAgICAgICAgICAgbGFiIDwtIGNhbGN1bGF0ZUF4aXNDb21w b25lbnRzKHggPSB4JHkubGltaXRzW1tpXV0sIA0KICAgICAgICAgICAgICAg ICAgYXQgPSBpZiAoaXMubGlzdCh4JHkuc2NhbGVzJGF0KSkgDQogICAgICAg ICAgICAgICAgICAgIHgkeS5zY2FsZXMkYXRbW2ldXQ0KICAgICAgICAgICAg ICAgICAgZWxzZSB4JHkuc2NhbGVzJGF0LCBsYWJlbHMgPSBpZiAoaXMubGlz dCh4JHkuc2NhbGVzJGxhYikpIA0KICAgICAgICAgICAgICAgICAgICB4JHku c2NhbGVzJGxhYltbaV1dDQogICAgICAgICAgICAgICAgICBlbHNlIHgkeS5z Y2FsZXMkbGFiLCBoYXZlLmxvZyA9IGhhdmUueWxvZywgDQogICAgICAgICAg ICAgICAgICBsb2diYXNlID0geWxvZ2Jhc2UsIGxvZ3Bhc3RlID0geWxvZ3Bh c3RlLCBhYmJyZXZpYXRlID0geCR5LnNjYWxlcyRhYmJyLCANCiAgICAgICAg ICAgICAgICAgIG1pbmxlbmd0aCA9IHgkeS5zY2FsZXMkbWlubCwgbiA9IHgk eS5zY2FsZXMkdGljay5udW1iZXIpJGxhYg0KICAgICAgICAgICAgICAgIGlm IChpcy5jaGFyYWN0ZXIobGFiKSkgDQogICAgICAgICAgICAgICAgICBsYWJl bENoYXJzIDwtIGMobGFiZWxDaGFycywgbGFiKQ0KICAgICAgICAgICAgICAg IGVsc2UgaWYgKGlzLmV4cHJlc3Npb24obGFiKSkgDQogICAgICAgICAgICAg ICAgICBsYWJlbEV4cHJzIDwtIGMobGFiZWxFeHBycywgbGFiKQ0KICAgICAg ICAgICAgfQ0KICAgICAgICAgICAgbGFiZWxDaGFycyA8LSB1bmlxdWUobGFi ZWxDaGFycykNCiAgICAgICAgICAgIHN0cmJhciA8LSBsaXN0KCkNCiAgICAg ICAgICAgIGZvciAoc3MgaW4gbGFiZWxDaGFycykgc3RyYmFyIDwtIGMoc3Ry YmFyLCBsaXN0KHNzKSkNCiAgICAgICAgICAgIGZvciAoc3MgaW4gc2VxKGFs b25nID0gbGFiZWxFeHBycykpIHN0cmJhciA8LSBjKHN0cmJhciwgDQogICAg ICAgICAgICAgICAgbGlzdChsYWJlbEV4cHJzW3NzXSkpDQogICAgICAgICAg ICBpZiAoYWJzKHlheGlzLnJvdFsxXSkgPT0gOTApIHsNCiAgICAgICAgICAg ICAgICB3aWR0aHMueFsoMTpjb2xzLnBlci5wYWdlIC0gMSkgKiA0ICsgN10g PC0gbWF4KDAuMDAxLCANCiAgICAgICAgICAgICAgICAgIHgkeS5zY2FsZXMk dGNrWzFdKSAqIDAuMw0KICAgICAgICAgICAgICAgIHdpZHRocy5pbnNlcnRs aXN0LnBvc2l0aW9uIDwtIGMod2lkdGhzLmluc2VydGxpc3QucG9zaXRpb24s IA0KICAgICAgICAgICAgICAgICAgKDE6Y29scy5wZXIucGFnZSAtIDEpICog NCArIDYpDQogICAgICAgICAgICAgICAgZm9yIChpIGluIDE6Y29scy5wZXIu cGFnZSkgd2lkdGhzLmluc2VydGxpc3QudW5pdCA8LSB1bml0LmMod2lkdGhz Lmluc2VydGxpc3QudW5pdCwgDQogICAgICAgICAgICAgICAgICBtYXgodW5p dChyZXAoMS41ICogeWF4aXMuY2V4WzFdLCBsZW5ndGgoc3RyYmFyKSksIA0K ICAgICAgICAgICAgICAgICAgICAic3RyaGVpZ2h0Iiwgc3RyYmFyKSkpDQog ICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAg ICAgICB3aWR0aHMueFsoMTpjb2xzLnBlci5wYWdlIC0gMSkgKiA0ICsgN10g PC0gbWF4KDAuMDAxLCANCiAgICAgICAgICAgICAgICAgIHgkeS5zY2FsZXMk dGNrWzFdKSAqIDAuMw0KICAgICAgICAgICAgICAgIHdpZHRocy5pbnNlcnRs aXN0LnBvc2l0aW9uIDwtIGMod2lkdGhzLmluc2VydGxpc3QucG9zaXRpb24s IA0KICAgICAgICAgICAgICAgICAgKDE6Y29scy5wZXIucGFnZSAtIDEpICog NCArIDYpDQogICAgICAgICAgICAgICAgZm9yIChpIGluIDE6Y29scy5wZXIu cGFnZSkgd2lkdGhzLmluc2VydGxpc3QudW5pdCA8LSB1bml0LmMod2lkdGhz Lmluc2VydGxpc3QudW5pdCwgDQogICAgICAgICAgICAgICAgICBtYXgodW5p dChyZXAoMS4yICogeWF4aXMuY2V4WzFdICogYWJzKGNvcyh5YXhpcy5yb3Rb MV0gKiANCiAgICAgICAgICAgICAgICAgICAgYmFzZTo6cGkvMTgwKSksIGxl bmd0aChzdHJiYXIpKSwgInN0cndpZHRoIiwgDQogICAgICAgICAgICAgICAg ICAgIHN0cmJhcikpKQ0KICAgICAgICAgICAgfQ0KICAgICAgICB9DQogICAg fQ0KICAgIGlmICghaXMubnVsbCh4JGtleSkgfHwgIWlzLm51bGwoeCRjb2xv cmtleSkpIHsNCiAgICAgICAgaWYgKGtleS5zcGFjZSA9PSAibGVmdCIpIHsN CiAgICAgICAgICAgIHdpZHRocy54WzJdIDwtIDEuMg0KICAgICAgICAgICAg d2lkdGhzLnVuaXRzWzJdIDw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lnaHRzIDwt IHJlYXJyYW5nZVVuaXQobGF5b3V0LmhlaWdodHMsIA0KICAgICAgICAgICAg aGVpZ2h0cy5pbnNlcnRsaXN0LnBvc2l0aW9uW2luZHhdLCBoZWlnaHRzLmlu c2VydGxpc3QudW5pdFtpbmR4XSkNCiAgICBsYXlvdXQud2lkdGhzIDwtIHVu aXQod2lkdGhzLngsIHdpZHRocy51bml0cywgZGF0YSA9IHdpZHRocy5kYXRh KQ0KICAgIGlmIChsZW5ndGgod2lkdGhzLmluc2VydGxpc3QucG9zaXRpb24p ID4gMSkgDQogICAgICAgIGZvciAoaW5keCBpbiAyOmxlbmd0aCh3aWR0aHMu aW5zZXJ0bGlzdC5wb3NpdGlvbikpIGxheW91dC53aWR0aHMgPC0gcmVhcnJh bmdlVW5pdChsYXlvdXQud2lkdGhzLCANCiAgICAgICAgICAgIHdpZHRocy5p bnNlcnRsaXN0LnBvc2l0aW9uW2luZHhdLCB3aWR0aHMuaW5zZXJ0bGlzdC51 bml0W2luZHhdKQ0KICAgIHBhZ2UubGF5b3V0IDwtIGdyaWQubGF5b3V0KG5y b3cgPSBuLnJvdywgbmNvbCA9IG4uY29sLCB3aWR0aHMgPSBsYXlvdXQud2lk dGhzLCANCiAgICAgICAgaGVpZ2h0cyA9IGxheW91dC5oZWlnaHRzLCByZXNw ZWN0ID0gbGF5b3V0LnJlc3BlY3QpDQogICAgY29uZC5jdXJyZW50LmxldmVs IDwtIHJlcCgxLCBudW1iZXIub2YuY29uZCkNCiAgICBwYW5lbC5udW1iZXIg PC0gMQ0KICAgIGZvciAocGFnZS5udW1iZXIgaW4gMTpudW1iZXIub2YucGFn ZXMpIGlmICghYW55KGNvbmQubWF4LmxldmVsIC0gDQogICAgICAgIGNvbmQu Y3VycmVudC5sZXZlbCA8IDApKSB7DQogICAgICAgIGlmICh1c3VhbCkgew0K ICAgICAgICAgICAgaWYgKG5ldykgDQogICAgICAgICAgICAgICAgZ3JpZC5u ZXdwYWdlKCkNCiAgICAgICAgICAgIGdyaWQucmVjdChncCA9IGdwYXIoZmls bCA9IGJnLCBjb2wgPSAidHJhbnNwYXJlbnQiKSkNCiAgICAgICAgICAgIG5l dyA8LSBUUlVFDQogICAgICAgIH0NCiAgICAgICAgcHVzaC52aWV3cG9ydCh2 aWV3cG9ydChsYXlvdXQgPSBwYWdlLmxheW91dCwgZ3AgPSBncGFyKGZvbnRz aXplID0gZm9udHNpemUuZGVmYXVsdCwgDQogICAgICAgICAgICBjb2wgPSBh eGlzLmxpbmUkY29sLCBsdHkgPSBheGlzLmxpbmUkbHR5LCBsd2QgPSBheGlz LmxpbmUkbHdkKSkpDQogICAgICAgIGlmIChoYXZlLm1haW4pIA0KICAgICAg ICAgICAgZ3JpZC50ZXh0KGxhYmVsID0geCRtYWluJGxhYmVsLCBncCA9IGdw YXIoY29sID0geCRtYWluJGNvbCwgDQogICAgICAgICAgICAgICAgZm9udCA9 IHgkbWFpbiRmb250LCBmb250c2l6ZSA9IGZvbnRzaXplLmRlZmF1bHQgKiAN CiAgICAgICAgICAgICAgICAgIHgkbWFpbiRjZXgpLCB2cCA9IHZpZXdwb3J0 KGxheW91dC5wb3Mucm93ID0gMikpDQogICAgICAgIGlmIChoYXZlLnN1Yikg DQogICAgICAgICAgICBncmlkLnRleHQobGFiZWwgPSB4JHN1YiRsYWJlbCwg Z3AgPSBncGFyKGNvbCA9IHgkc3ViJGNvbCwgDQogICAgICAgICAgICAgICAg Zm9udCA9IHgkc3ViJGZvbnQsIGZvbnRzaXplID0gZm9udHNpemUuZGVmYXVs dCAqIA0KICAgICAgICAgICAgICAgICAgeCRzdWIkY2V4KSwgdnAgPSB2aWV3 cG9ydChsYXlvdXQucG9zLnJvdyA9IG4ucm93IC0gDQogICAgICAgICAgICAg ICAgMSkpDQogICAgICAgIGlmIChoYXZlLnhsYWIpIA0KICAgICAgICAgICAg Z3JpZC50ZXh0KGxhYmVsID0geCR4bGFiJGxhYmVsLCBncCA9IGdwYXIoY29s ID0geCR4bGFiJGNvbCwgDQogICAgICAgICAgICAgICAgZm9udCA9IHgkeGxh YiRmb250LCBmb250c2l6ZSA9IGZvbnRzaXplLmRlZmF1bHQgKiANCiAgICAg ICAgICAgICAgICAgIHgkeGxhYiRjZXgpLCB2cCA9IHZpZXdwb3J0KGxheW91 dC5wb3Mucm93ID0gbi5yb3cgLSANCiAgICAgICAgICAgICAgICAzLCBsYXlv dXQucG9zLmNvbCA9IGMoNiwgbi5jb2wgLSA0KSkpDQogICAgICAgIGlmICho YXZlLnlsYWIpIA0KICAgICAgICAgICAgZ3JpZC50ZXh0KGxhYmVsID0geCR5 bGFiJGxhYmVsLCByb3QgPSA5MCwgZ3AgPSBncGFyKGNvbCA9IHgkeWxhYiRj b2wsIA0KICAgICAgICAgICAgICAgIGZvbnQgPSB4JHlsYWIkZm9udCwgZm9u dHNpemUgPSBmb250c2l6ZS5kZWZhdWx0ICogDQogICAgICAgICAgICAgICAg ICB4JHlsYWIkY2V4KSwgdnAgPSB2aWV3cG9ydChsYXlvdXQucG9zLmNvbCA9 IDMsIA0KICAgICAgICAgICAgICAgIGxheW91dC5wb3Mucm93ID0gYyg2LCBu LnJvdyAtIDYpKSkNCiAgICAgICAgZm9yIChyb3cgaW4gMTpyb3dzLnBlci5w YWdlKSBmb3IgKGNvbHVtbiBpbiAxOmNvbHMucGVyLnBhZ2UpIGlmICghYW55 KGNvbmQubWF4LmxldmVsIC0gDQogICAgICAgICAgICBjb25kLmN1cnJlbnQu bGV2ZWwgPCAwKSAmJiAocm93IC0gMSkgKiBjb2xzLnBlci5wYWdlICsgDQog ICAgICAgICAgICBjb2x1bW4gPD0gcGxvdHMucGVyLnBhZ2UpIHsNCiAgICAg ICAgICAgIGlmICghaXMubGlzdCh4JHBhbmVsLmFyZ3NbW3BhbmVsLm51bWJl cl1dKSkgDQogICAgICAgICAgICAgICAgcGFuZWwubnVtYmVyIDwtIHBhbmVs Lm51bWJlciArIDENCiAgICAgICAgICAgIGVsc2Ugew0KICAgICAgICAgICAg ICAgIGFjdHVhbC5yb3cgPC0gaWYgKHgkYXMudGFibGUpIA0KICAgICAgICAg ICAgICAgICAgKHJvd3MucGVyLnBhZ2UgLSByb3cgKyAxKQ0KICAgICAgICAg ICAgICAgIGVsc2Ugcm93DQogICAgICAgICAgICAgICAgcG9zLnJvdyA8LSA2 ICsgbnVtYmVyLm9mLmNvbmQgKyAocm93cy5wZXIucGFnZSAtIA0KICAgICAg ICAgICAgICAgICAgYWN0dWFsLnJvdykgKiAobnVtYmVyLm9mLmNvbmQgKyA0 KQ0KICAgICAgICAgICAgICAgIHBvcy5jb2wgPC0gKGNvbHVtbiAtIDEpICog NCArIDgNCiAgICAgICAgICAgICAgICB4bGFiZWxpbmZvIDwtIGNhbGN1bGF0 ZUF4aXNDb21wb25lbnRzKHggPSBpZiAoeC5yZWxhdGlvbi5zYW1lKSANCiAg ICAgICAgICAgICAgICAgIHgkeC5saW1pdHMNCiAgICAgICAgICAgICAgICBl bHNlIHgkeC5saW1pdHNbW3BhbmVsLm51bWJlcl1dLCBhdCA9IGlmIChpcy5s aXN0KHgkeC5zY2FsZXMkYXQpKSANCiAgICAgICAgICAgICAgICAgIHgkeC5z Y2FsZXMkYXRbW3BhbmVsLm51bWJlcl1dDQogICAgICAgICAgICAgICAgZWxz ZSB4JHguc2NhbGVzJGF0LCBsYWJlbHMgPSBpZiAoaXMubGlzdCh4JHguc2Nh bGVzJGxhYikpIA0KICAgICAgICAgICAgICAgICAgeCR4LnNjYWxlcyRsYWJb W3BhbmVsLm51bWJlcl1dDQogICAgICAgICAgICAgICAgZWxzZSB4JHguc2Nh bGVzJGxhYiwgaGF2ZS5sb2cgPSBoYXZlLnhsb2csIGxvZ2Jhc2UgPSB4bG9n YmFzZSwgDQogICAgICAgICAgICAgICAgICBsb2dwYXN0ZSA9IHhsb2dwYXN0 ZSwgYWJicmV2aWF0ZSA9IHgkeC5zY2FsZXMkYWJiciwgDQogICAgICAgICAg ICAgICAgICBtaW5sZW5ndGggPSB4JHguc2NhbGVzJG1pbmwsIG4gPSB4JHgu c2NhbGVzJHRpY2subnVtYmVyKQ0KICAgICAgICAgICAgICAgIHlsYWJlbGlu Zm8gPC0gY2FsY3VsYXRlQXhpc0NvbXBvbmVudHMoeCA9IGlmICh5LnJlbGF0 aW9uLnNhbWUpIA0KICAgICAgICAgICAgICAgICAgeCR5LmxpbWl0cw0KICAg ICAgICAgICAgICAgIGVsc2UgeCR5LmxpbWl0c1tbcGFuZWwubnVtYmVyXV0s IGF0ID0gaWYgKGlzLmxpc3QoeCR5LnNjYWxlcyRhdCkpIA0KICAgICAgICAg ICAgICAgICAgeCR5LnNjYWxlcyRhdFtbcGFuZWwubnVtYmVyXV0NCiAgICAg ICAgICAgICAgICBlbHNlIHgkeS5zY2FsZXMkYXQsIGxhYmVscyA9IGlmIChp cy5saXN0KHgkeS5zY2FsZXMkbGFiKSkgDQogICAgICAgICAgICAgICAgICB4 JHkuc2NhbGVzJGxhYltbcGFuZWwubnVtYmVyXV0NCiAgICAgICAgICAgICAg ICBlbHNlIHgkeS5zY2FsZXMkbGFiLCBoYXZlLmxvZyA9IGhhdmUueWxvZywg bG9nYmFzZSA9IHlsb2diYXNlLCANCiAgICAgICAgICAgICAgICAgIGxvZ3Bh c3RlID0geWxvZ3Bhc3RlLCBhYmJyZXZpYXRlID0geCR5LnNjYWxlcyRhYmJy LCANCiAgICAgICAgICAgICAgICAgIG1pbmxlbmd0aCA9IHgkeS5zY2FsZXMk bWlubCwgbiA9IHgkeS5zY2FsZXMkdGljay5udW1iZXIpDQogICAgICAgICAg ICAgICAgeHNjYWxlIDwtIHhsYWJlbGluZm8kbnVtLmxpbWl0DQogICAgICAg ICAgICAgICAgeXNjYWxlIDwtIHlsYWJlbGluZm8kbnVtLmxpbWl0DQogICAg ICAgICAgICAgICAgcHVzaC52aWV3cG9ydCh2aWV3cG9ydChsYXlvdXQucG9z LnJvdyA9IHBvcy5yb3csIA0KICAgICAgICAgICAgICAgICAgbGF5b3V0LnBv cy5jb2wgPSBwb3MuY29sLCB4c2NhbGUgPSB4c2NhbGUsIA0KICAgICAgICAg ICAgICAgICAgeXNjYWxlID0geXNjYWxlLCBjbGlwID0gVFJVRSwgZ3AgPSBn cGFyKGZvbnRzaXplID0gZm9udHNpemUuZGVmYXVsdCkpKQ0KICAgICAgICAg ICAgICAgIHBhcmdzIDwtIGMoeCRwYW5lbC5hcmdzW1twYW5lbC5udW1iZXJd XSwgeCRwYW5lbC5hcmdzLmNvbW1vbiwgDQogICAgICAgICAgICAgICAgICBs aXN0KHBhbmVsLm51bWJlciA9IHBhbmVsLm51bWJlcikpDQogICAgICAgICAg ICAgICAgaWYgKCEoIi4uLiIgJWluJSBuYW1lcyhmb3JtYWxzKHBhbmVsKSkp KSANCiAgICAgICAgICAgICAgICAgIHBhcmdzIDwtIHBhcmdzW25hbWVzKGZv cm1hbHMocGFuZWwpKV0NCiAgICAgICAgICAgICAgICBkby5jYWxsKCJwYW5l bCIsIHBhcmdzKQ0KICAgICAgICAgICAgICAgIGdyaWQucmVjdCgpDQogICAg ICAgICAgICAgICAgcG9wLnZpZXdwb3J0KCkNCiAgICAgICAgICAgICAgICBp ZiAoIXgucmVsYXRpb24uc2FtZSAmJiB4JHguc2NhbGVzJGRyYXcpIHsNCiAg ICAgICAgICAgICAgICAgIGF4cyA8LSB4JHguc2NhbGVzDQogICAgICAgICAg ICAgICAgICBvayA8LSAoeGxhYmVsaW5mbyRhdCA+PSB4c2NhbGVbMV0gJiB4 bGFiZWxpbmZvJGF0IDw9IA0KICAgICAgICAgICAgICAgICAgICB4c2NhbGVb Ml0pDQogICAgICAgICAgICAgICAgICBwdXNoLnZpZXdwb3J0KHZpZXdwb3J0 KGxheW91dC5wb3Mucm93ID0gcG9zLnJvdyArIA0KICAgICAgICAgICAgICAg ICAgICAxLCBsYXlvdXQucG9zLmNvbCA9IHBvcy5jb2wsIHhzY2FsZSA9IHhz Y2FsZSkpDQogICAgICAgICAgICAgICAgICBpZiAoYXhzJHRja1sxXSAhPSAw ICYmIGFueShvaykpIA0KICAgICAgICAgICAgICAgICAgICBncmlkLnNlZ21l bnRzKHkwID0gdW5pdChyZXAoMSwgc3VtKG9rKSksIA0KICAgICAgICAgICAg ICAgICAgICAgICJucGMiKSwgeTEgPSB1bml0KHJlcCgxLCBzdW0ob2spKSwg Im5wYyIpIC0gDQogICAgICAgICAgICAgICAgICAgICAgdW5pdChyZXAoMC4z ICogYXhzJHRja1sxXSwgc3VtKG9rKSksICJsaW5lcyIpLCANCiAgICAgICAg ICAgICAgICAgICAgICB4MCA9IHVuaXQoeGxhYmVsaW5mbyRhdFtva10sICJu YXRpdmUiKSwgDQogICAgICAgICAgICAgICAgICAgICAgeDEgPSB1bml0KHhs YWJlbGluZm8kYXRbb2tdLCAibmF0aXZlIiksIA0KICAgICAgICAgICAgICAg ICAgICAgIGdwID0gZ3Bhcihjb2wgPSB4YXhpcy5jb2wpKQ0KICAgICAgICAg ICAgICAgICAgcG9wLnZpZXdwb3J0KCkNCiAgICAgICAgICAgICAgICAgIGlm IChhbnkob2spKSANCiAgICAgICAgICAgICAgICAgICAgZ3JpZC50ZXh0KGxh YmVsID0geGxhYmVsaW5mbyRsYWJlbFtva10sIHggPSB1bml0KHhsYWJlbGlu Zm8kYXRbb2tdLCANCiAgICAgICAgICAgICAgICAgICAgICAibmF0aXZlIiks IHkgPSB1bml0KGlmICh4YXhpcy5yb3RbMV0gJWluJSANCiAgICAgICAgICAg ICAgICAgICAgICBjKDAsIDE4MCkpIA0KICAgICAgICAgICAgICAgICAgICAg IDAuNQ0KICAgICAgICAgICAgICAgICAgICBlbHNlIDAuOTUsICJucGMiKSwg anVzdCA9IGlmICh4YXhpcy5yb3RbMV0gPT0gDQogICAgICAgICAgICAgICAg ICAgICAgMCkgDQogICAgICAgICAgICAgICAgICAgICAgYygiY2VudHJlIiwg ImNlbnRyZSIpDQogICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgKHhheGlz LnJvdFsxXSA9PSAxODApIA0KICAgICAgICAgICAgICAgICAgICAgIGMoImNl bnRyZSIsICJjZW50cmUiKQ0KICAgICAgICAgICAgICAgICAgICBlbHNlIGlm ICh4YXhpcy5yb3RbMV0gPiAwKSANCiAgICAgICAgICAgICAgICAgICAgICBj KCJyaWdodCIsICJjZW50cmUiKQ0KICAgICAgICAgICAgICAgICAgICBlbHNl IGMoImxlZnQiLCAiY2VudHJlIiksIHJvdCA9IHhheGlzLnJvdFsxXSwgDQog ICAgICAgICAgICAgICAgICAgICAgY2hlY2sub3ZlcmxhcCA9IHhsYWJlbGlu Zm8kY2hlY2sub3ZlcmxhcCwgDQogICAgICAgICAgICAgICAgICAgICAgZ3Ag PSBncGFyKGNvbCA9IHhheGlzLmNvbCwgZm9udCA9IHhheGlzLmZvbnQsIA0K ICAgICAgICAgICAgICAgICAgICAgICAgZm9udHNpemUgPSBheHMkY2V4WzFd ICogZm9udHNpemUuZGVmYXVsdCksIA0KICAgICAgICAgICAgICAgICAgICAg IHZwID0gdmlld3BvcnQobGF5b3V0LnBvcy5yb3cgPSBwb3Mucm93ICsgDQog ICAgICAgICAgICAgICAgICAgICAgICAyLCBsYXlvdXQucG9zLmNvbCA9IHBv cy5jb2wsIHhzY2FsZSA9IHhzY2FsZSkpDQogICAgICAgICAgICAgICAgfQ0K ICAgICAgICAgICAgICAgIGlmICgheS5yZWxhdGlvbi5zYW1lICYmIHgkeS5z Y2FsZXMkZHJhdykgew0KICAgICAgICAgICAgICAgICAgYXhzIDwtIHgkeS5z Y2FsZXMNCiAgICAgICAgICAgICAgICAgIG9rIDwtICh5bGFiZWxpbmZvJGF0 ID49IHlzY2FsZVsxXSAmIHlsYWJlbGluZm8kYXQgPD0gDQogICAgICAgICAg ICAgICAgICAgIHlzY2FsZVsyXSkNCiAgICAgICAgICAgICAgICAgIHB1c2gu dmlld3BvcnQodmlld3BvcnQobGF5b3V0LnBvcy5yb3cgPSBwb3Mucm93LCAN CiAgICAgICAgICAgICAgICAgICAgbGF5b3V0LnBvcy5jb2wgPSBwb3MuY29s IC0gMSwgeXNjYWxlID0geXNjYWxlKSkNCiAgICAgICAgICAgICAgICAgIGlm IChheHMkdGNrWzFdICE9IDAgJiYgYW55KG9rKSkgDQogICAgICAgICAgICAg ICAgICAgIGdyaWQuc2VnbWVudHMoeDAgPSB1bml0KHJlcCgxLCBzdW0ob2sp KSwgDQogICAgICAgICAgICAgICAgICAgICAgIm5wYyIpLCB4MSA9IHVuaXQo cmVwKDEsIHN1bShvaykpLCAibnBjIikgLSANCiAgICAgICAgICAgICAgICAg ICAgICB1bml0KHJlcCgwLjMgKiBheHMkdGNrWzFdLCBzdW0ob2spKSwgImxp bmVzIiksIA0KICAgICAgICAgICAgICAgICAgICAgIHkwID0gdW5pdCh5bGFi ZWxpbmZvJGF0W29rXSwgIm5hdGl2ZSIpLCANCiAgICAgICAgICAgICAgICAg ICAgICB5MSA9IHVuaXQoeWxhYmVsaW5mbyRhdFtva10sICJuYXRpdmUiKSwg DQogICAgICAgICAgICAgICAgICAgICAgZ3AgPSBncGFyKGNvbCA9IHlheGlz LmNvbCkpDQogICAgICAgICAgICAgICAgICBwb3Audmlld3BvcnQoKQ0KICAg ICAgICAgICAgICAgICAgaWYgKGFueShvaykpIA0KICAgICAgICAgICAgICAg ICAgICBncmlkLnRleHQobGFiZWwgPSB5bGFiZWxpbmZvJGxhYmVsW29rXSwg eSA9IHVuaXQoeWxhYmVsaW5mbyRhdFtva10sIA0KICAgICAgICAgICAgICAg ICAgICAgICJuYXRpdmUiKSwgeCA9IHVuaXQoaWYgKGFicyh5YXhpcy5yb3Rb MV0pID09IA0KICAgICAgICAgICAgICAgICAgICAgIDkwKSANCiAgICAgICAg ICAgICAgICAgICAgICAwLjUNCiAgICAgICAgICAgICAgICAgICAgZWxzZSAw Ljk1LCAibnBjIiksIGp1c3QgPSBpZiAoeWF4aXMucm90WzFdID09IA0KICAg ICAgICAgICAgICAgICAgICAgIDkwKSANCiAgICAgICAgICAgICAgICAgICAg ICBjKCJjZW50cmUiLCAiY2VudHJlIikNCiAgICAgICAgICAgICAgICAgICAg ZWxzZSBpZiAoeWF4aXMucm90WzFdID09IC05MCkgDQogICAgICAgICAgICAg ICAgICAgICAgYygiY2VudHJlIiwgImNlbnRyZSIpDQogICAgICAgICAgICAg ICAgICAgIGVsc2UgaWYgKHlheGlzLnJvdFsxXSA+IC05MCAmJiB5YXhpcy5y b3RbMV0gPCANCiAgICAgICAgICAgICAgICAgICAgICA5MCkgDQogICAgICAg ICAgICAgICAgICAgICAgYygicmlnaHQiLCAiY2VudHJlIikNCiAgICAgICAg ICAgICAgICAgICAgZWxzZSBjKCJsZWZ0IiwgImNlbnRyZSIpLCByb3QgPSB5 YXhpcy5yb3RbMV0sIA0KICAgICAgICAgICAgICAgICAgICAgIGNoZWNrLm92 ZXJsYXAgPSB5bGFiZWxpbmZvJGNoZWNrLm92ZXJsYXAsIA0KICAgICAgICAg ICAgICAgICAgICAgIGdwID0gZ3Bhcihjb2wgPSB5YXhpcy5jb2wsIGZvbnQg PSB4YXhpcy5mb250LCANCiAgICAgICAgICAgICAgICAgICAgICAgIGZvbnRz aXplID0gYXhzJGNleFsxXSAqIGZvbnRzaXplLmRlZmF1bHQpLCANCiAgICAg ICAgICAgICAgICAgICAgICB2cCA9IHZpZXdwb3J0KGxheW91dC5wb3Mucm93 ID0gcG9zLnJvdywgDQogICAgICAgICAgICAgICAgICAgICAgICBsYXlvdXQu cG9zLmNvbCA9IHBvcy5jb2wgLSAyLCB5c2NhbGUgPSB5c2NhbGUpKQ0KICAg ICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAoeS5yZWxhdGlv bi5zYW1lICYmIHgkeS5zY2FsZXMkZHJhdykgew0KICAgICAgICAgICAgICAg ICAgaWYgKGNvbHVtbiA9PSAxKSB7DQogICAgICAgICAgICAgICAgICAgIGF4 cyA8LSB4JHkuc2NhbGVzDQogICAgICAgICAgICAgICAgICAgIG9rIDwtICh5 bGFiZWxpbmZvJGF0ID49IHlzY2FsZVsxXSAmIHlsYWJlbGluZm8kYXQgPD0g DQogICAgICAgICAgICAgICAgICAgICAgeXNjYWxlWzJdKQ0KICAgICAgICAg ICAgICAgICAgICBwdXNoLnZpZXdwb3J0KHZpZXdwb3J0KGxheW91dC5wb3Mu cm93ID0gcG9zLnJvdywgDQogICAgICAgICAgICAgICAgICAgICAgbGF5b3V0 LnBvcy5jb2wgPSBwb3MuY29sIC0gMywgeXNjYWxlID0geXNjYWxlKSkNCiAg ICAgICAgICAgICAgICAgICAgaWYgKGF4cyR0Y2tbMV0gIT0gMCAmJiBhbnko b2spKSANCiAgICAgICAgICAgICAgICAgICAgICBncmlkLnNlZ21lbnRzKHgw ID0gdW5pdChyZXAoMSwgc3VtKG9rKSksIA0KICAgICAgICAgICAgICAgICAg ICAgICAgIm5wYyIpLCB4MSA9IHVuaXQocmVwKDEsIHN1bShvaykpLCAibnBj IikgLSANCiAgICAgICAgICAgICAgICAgICAgICAgIHVuaXQocmVwKDAuMyAq IGF4cyR0Y2tbMV0sIHN1bShvaykpLCANCiAgICAgICAgICAgICAgICAgICAg ICAgICAgImxpbmVzIiksIHkwID0gdW5pdCh5bGFiZWxpbmZvJGF0W29rXSwg DQogICAgICAgICAgICAgICAgICAgICAgICAibmF0aXZlIiksIHkxID0gdW5p dCh5bGFiZWxpbmZvJGF0W29rXSwgDQogICAgICAgICAgICAgICAgICAgICAg ICAibmF0aXZlIiksIGdwID0gZ3Bhcihjb2wgPSB5YXhpcy5jb2wpKQ0KICAg ICAgICAgICAgICAgICAgICBwb3Audmlld3BvcnQoKQ0KICAgICAgICAgICAg ICAgICAgICBpZiAoeS5hbHRlcm5hdGluZ1thY3R1YWwucm93XSA9PSAxIHx8 IHkuYWx0ZXJuYXRpbmdbYWN0dWFsLnJvd10gPT0gDQogICAgICAgICAgICAg ICAgICAgICAgMykgDQogICAgICAgICAgICAgICAgICAgICAgaWYgKGFueShv aykpIA0KICAgICAgICAgICAgICAgICAgICAgICAgZ3JpZC50ZXh0KGxhYmVs ID0geWxhYmVsaW5mbyRsYWJbb2tdLCANCiAgICAgICAgICAgICAgICAgICAg ICAgICAgeSA9IHVuaXQoeWxhYmVsaW5mbyRhdFtva10sICJuYXRpdmUiKSwg DQogICAgICAgICAgICAgICAgICAgICAgICAgIHggPSB1bml0KGlmIChhYnMo eWF4aXMucm90WzFdKSA9PSA5MCkgDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgMC41DQogICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgMSwg Im5wYyIpLCBqdXN0ID0gaWYgKHlheGlzLnJvdFsxXSA9PSANCiAgICAgICAg ICAgICAgICAgICAgICAgICAgICAtOTApIA0KICAgICAgICAgICAgICAgICAg ICAgICAgICAgIGMoImNlbnRyZSIsICJjZW50cmUiKQ0KICAgICAgICAgICAg ICAgICAgICAgICAgICBlbHNlIGlmICh5YXhpcy5yb3RbMV0gPT0gOTApIA0K ICAgICAgICAgICAgICAgICAgICAgICAgICAgIGMoImNlbnRyZSIsICJjZW50 cmUiKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIGlmICh5YXhp cy5yb3RbMV0gPiAtOTAgJiYgeWF4aXMucm90WzFdIDwgDQogICAgICAgICAg ICAgICAgICAgICAgICAgICAgOTApIA0KICAgICAgICAgICAgICAgICAgICAg ICAgICAgIGMoInJpZ2h0IiwgImNlbnRyZSIpDQogICAgICAgICAgICAgICAg ICAgICAgICAgIGVsc2UgYygibGVmdCIsICJjZW50cmUiKSwgcm90ID0geWF4 aXMucm90WzFdLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2su b3ZlcmxhcCA9IHlsYWJlbGluZm8kY2hlY2sub3ZlcmxhcCwgDQogICAgICAg ICAgICAgICAgICAgICAgICAgIGdwID0gZ3Bhcihjb2wgPSB5YXhpcy5jb2ws IGZvbnQgPSB5YXhpcy5mb250LCANCiAgICAgICAgICAgICAgICAgICAgICAg ICAgICBmb250c2l6ZSA9IGF4cyRjZXhbMV0gKiBmb250c2l6ZS5kZWZhdWx0 KSwgDQogICAgICAgICAgICAgICAgICAgICAgICAgIHZwID0gdmlld3BvcnQo bGF5b3V0LnBvcy5yb3cgPSBwb3Mucm93LCANCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICBsYXlvdXQucG9zLmNvbCA9IHBvcy5jb2wgLSA0LCB5c2Nh bGUgPSB5c2NhbGUpKQ0KICAgICAgICAgICAgICAgICAgfQ0KICAgICAgICAg ICAgICAgICAgaWYgKGNvbHVtbiA9PSBjb2xzLnBlci5wYWdlKSB7DQogICAg ICAgICAgICAgICAgICAgIGF4cyA8LSB4JHkuc2NhbGVzDQogICAgICAgICAg ICAgICAgICAgIG9rIDwtICh5bGFiZWxpbmZvJGF0ID49IHlzY2FsZVsxXSAm IHlsYWJlbGluZm8kYXQgPD0gDQogICAgICAgICAgICAgICAgICAgICAgeXNj YWxlWzJdKQ0KICAgICAgICAgICAgICAgICAgICBwdXNoLnZpZXdwb3J0KHZp ZXdwb3J0KGxheW91dC5wb3Mucm93ID0gcG9zLnJvdywgDQogICAgICAgICAg ICAgICAgICAgICAgbGF5b3V0LnBvcy5jb2wgPSBwb3MuY29sICsgMSwgeXNj YWxlID0geXNjYWxlKSkNCiAgICAgICAgICAgICAgICAgICAgaWYgKGF4cyR0 Y2tbMl0gIT0gMCAmJiBhbnkob2spKSANCiAgICAgICAgICAgICAgICAgICAg ICBncmlkLnNlZ21lbnRzKHgwID0gdW5pdChyZXAoMCwgc3VtKG9rKSksIA0K ICAgICAgICAgICAgICAgICAgICAgICAgIm5wYyIpLCB4MSA9IHVuaXQocmVw KDAuMyAqIGF4cyR0Y2tbMl0sIA0KICAgICAgICAgICAgICAgICAgICAgICAg c3VtKG9rKSksICJsaW5lcyIpLCB5MCA9IHVuaXQoeWxhYmVsaW5mbyRhdFtv a10sIA0KICAgICAgICAgICAgICAgICAgICAgICAgIm5hdGl2ZSIpLCB5MSA9 IHVuaXQoeWxhYmVsaW5mbyRhdFtva10sIA0KICAgICAgICAgICAgICAgICAg ICAgICAgIm5hdGl2ZSIpLCBncCA9IGdwYXIoY29sID0geWF4aXMuY29sKSkN CiAgICAgICAgICAgICAgICAgICAgcG9wLnZpZXdwb3J0KCkNCiAgICAgICAg ICAgICAgICAgICAgaWYgKHkuYWx0ZXJuYXRpbmdbYWN0dWFsLnJvd10gPT0g MiB8fCB5LmFsdGVybmF0aW5nW2FjdHVhbC5yb3ddID09IA0KICAgICAgICAg ICAgICAgICAgICAgIDMpIA0KICAgICAgICAgICAgICAgICAgICAgIGlmIChh bnkob2spKSANCiAgICAgICAgICAgICAgICAgICAgICAgIGdyaWQudGV4dChs YWJlbCA9IHlsYWJlbGluZm8kbGFiZWxbb2tdLCANCiAgICAgICAgICAgICAg ICAgICAgICAgICAgeSA9IHVuaXQoeWxhYmVsaW5mbyRhdFtva10sICJuYXRp dmUiKSwgDQogICAgICAgICAgICAgICAgICAgICAgICAgIHggPSB1bml0KGlm IChhYnMoeWF4aXMucm90WzJdKSA9PSA5MCkgDQogICAgICAgICAgICAgICAg ICAgICAgICAgICAgMC41DQogICAgICAgICAgICAgICAgICAgICAgICAgIGVs c2UgMCwgIm5wYyIpLCBqdXN0ID0gaWYgKHlheGlzLnJvdFsyXSA9PSANCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAtOTApIA0KICAgICAgICAgICAg ICAgICAgICAgICAgICAgIGMoImNlbnRyZSIsICJjZW50cmUiKQ0KICAgICAg ICAgICAgICAgICAgICAgICAgICBlbHNlIGlmICh5YXhpcy5yb3RbMl0gPT0g OTApIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIGMoImNlbnRyZSIs ICJjZW50cmUiKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIGlm ICh5YXhpcy5yb3RbMl0gPiAtOTAgJiYgeWF4aXMucm90WzJdIDwgDQogICAg ICAgICAgICAgICAgICAgICAgICAgICAgOTApIA0KICAgICAgICAgICAgICAg ICAgICAgICAgICAgIGMoImxlZnQiLCAiY2VudHJlIikNCiAgICAgICAgICAg ICAgICAgICAgICAgICAgZWxzZSBjKCJyaWdodCIsICJjZW50cmUiKSwgcm90 ID0geWF4aXMucm90WzJdLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAg Y2hlY2sub3ZlcmxhcCA9IHlsYWJlbGluZm8kY2hlY2sub3ZlcmxhcCwgDQog ICAgICAgICAgICAgICAgICAgICAgICAgIGdwID0gZ3Bhcihjb2wgPSB5YXhp cy5jb2wsIGZvbnQgPSB5YXhpcy5mb250LCANCiAgICAgICAgICAgICAgICAg ICAgICAgICAgICBmb250c2l6ZSA9IGF4cyRjZXhbMl0gKiBmb250c2l6ZS5k ZWZhdWx0KSwgDQogICAgICAgICAgICAgICAgICAgICAgICAgIHZwID0gdmll d3BvcnQobGF5b3V0LnBvcy5yb3cgPSBwb3Mucm93LCANCiAgICAgICAgICAg ICAgICAgICAgICAgICAgICBsYXlvdXQucG9zLmNvbCA9IHBvcy5jb2wgKyAy LCB5c2NhbGUgPSB5c2NhbGUpKQ0KICAgICAgICAgICAgICAgICAgfQ0KICAg ICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAoeC5yZWxhdGlv bi5zYW1lICYmIHgkeC5zY2FsZXMkZHJhdykgew0KICAgICAgICAgICAgICAg ICAgaWYgKGFjdHVhbC5yb3cgPT0gMSkgew0KICAgICAgICAgICAgICAgICAg ICBheHMgPC0geCR4LnNjYWxlcw0KICAgICAgICAgICAgICAgICAgICBvayA8 LSAoeGxhYmVsaW5mbyRhdCA+PSB4c2NhbGVbMV0gJiB4bGFiZWxpbmZvJGF0 IDw9IA0KICAgICAgICAgICAgICAgICAgICAgIHhzY2FsZVsyXSkNCiAgICAg ICAgICAgICAgICAgICAgcHVzaC52aWV3cG9ydCh2aWV3cG9ydChsYXlvdXQu cG9zLnJvdyA9IHBvcy5yb3cgKyANCiAgICAgICAgICAgICAgICAgICAgICAz LCBsYXlvdXQucG9zLmNvbCA9IHBvcy5jb2wsIHhzY2FsZSA9IHhzY2FsZSkp DQogICAgICAgICAgICAgICAgICAgIGlmIChheHMkdGNrWzFdICE9IDAgJiYg YW55KG9rKSkgDQogICAgICAgICAgICAgICAgICAgICAgZ3JpZC5zZWdtZW50 cyh5MCA9IHVuaXQocmVwKDEsIHN1bShvaykpLCANCiAgICAgICAgICAgICAg ICAgICAgICAgICJucGMiKSwgeTEgPSB1bml0KHJlcCgxLCBzdW0ob2spKSwg Im5wYyIpIC0gDQogICAgICAgICAgICAgICAgICAgICAgICB1bml0KHJlcCgw LjMgKiBheHMkdGNrWzFdLCBzdW0ob2spKSwgDQogICAgICAgICAgICAgICAg ICAgICAgICAgICJsaW5lcyIpLCB4MCA9IHVuaXQoeGxhYmVsaW5mbyRhdFtv a10sIA0KICAgICAgICAgICAgICAgICAgICAgICAgIm5hdGl2ZSIpLCB4MSA9 IHVuaXQoeGxhYmVsaW5mbyRhdFtva10sIA0KICAgICAgICAgICAgICAgICAg ICAgICAgIm5hdGl2ZSIpLCBncCA9IGdwYXIoY29sID0geGF4aXMuY29sKSkN CiAgICAgICAgICAgICAgICAgICAgcG9wLnZpZXdwb3J0KCkNCiAgICAgICAg ICAgICAgICAgICAgaWYgKHguYWx0ZXJuYXRpbmdbY29sdW1uXSA9PSAxIHx8 IHguYWx0ZXJuYXRpbmdbY29sdW1uXSA9PSANCiAgICAgICAgICAgICAgICAg ICAgICAzKSANCiAgICAgICAgICAgICAgICAgICAgICBpZiAoYW55KG9rKSkg ew0KICAgICAgICAgICAgICAgICAgICAgICAgZ3JpZC50ZXh0KGxhYmVsID0g eGxhYmVsaW5mbyRsYWJbb2tdLCANCiAgICAgICAgICAgICAgICAgICAgICAg ICAgeCA9IHVuaXQoeGxhYmVsaW5mbyRhdFtva10sICJuYXRpdmUiKSwgDQog ICAgICAgICAgICAgICAgICAgICAgICAgIHkgPSB1bml0KGlmICh4YXhpcy5y b3RbMV0gJWluJSBjKDAsIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAg IDE4MCkpIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIDAuNQ0KICAg ICAgICAgICAgICAgICAgICAgICAgICBlbHNlIDEsICJucGMiKSwganVzdCA9 IGlmICh4YXhpcy5yb3RbMV0gPT0gDQogICAgICAgICAgICAgICAgICAgICAg ICAgICAgMCkgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYygiY2Vu dHJlIiwgImNlbnRyZSIpDQogICAgICAgICAgICAgICAgICAgICAgICAgIGVs c2UgaWYgKHhheGlzLnJvdFsxXSA9PSAxODApIA0KICAgICAgICAgICAgICAg ICAgICAgICAgICAgIGMoImNlbnRyZSIsICJjZW50cmUiKQ0KICAgICAgICAg ICAgICAgICAgICAgICAgICBlbHNlIGlmICh4YXhpcy5yb3RbMV0gPiAwKSAN CiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjKCJyaWdodCIsICJjZW50 cmUiKQ0KICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIGMoImxlZnQi LCAiY2VudHJlIiksIHJvdCA9IHhheGlzLnJvdFsxXSwgDQogICAgICAgICAg ICAgICAgICAgICAgICAgIGNoZWNrLm92ZXJsYXAgPSB4bGFiZWxpbmZvJGNo ZWNrLm92ZXJsYXAsIA0KICAgICAgICAgICAgICAgICAgICAgICAgICBncCA9 IGdwYXIoY29sID0geGF4aXMuY29sLCBmb250ID0geGF4aXMuZm9udCwgDQog ICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9udHNpemUgPSBheHMkY2V4 WzFdICogZm9udHNpemUuZGVmYXVsdCksIA0KICAgICAgICAgICAgICAgICAg ICAgICAgICB2cCA9IHZpZXdwb3J0KGxheW91dC5wb3Mucm93ID0gcG9zLnJv dyArIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIDQsIGxheW91dC5w b3MuY29sID0gcG9zLmNvbCwgeHNjYWxlID0geHNjYWxlKSkNCiAgICAgICAg ICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgICB9DQogICAgICAg ICAgICAgICAgfQ0KICAgICAgICAgICAgICAgIGlmICghaXMubG9naWNhbCh4 JHN0cmlwKSkgDQogICAgICAgICAgICAgICAgICBmb3IgKGkgaW4gMTpudW1i ZXIub2YuY29uZCkgew0KICAgICAgICAgICAgICAgICAgICBwdXNoLnZpZXdw b3J0KHZpZXdwb3J0KGxheW91dC5wb3Mucm93ID0gcG9zLnJvdyAtIA0KICAg ICAgICAgICAgICAgICAgICAgIGksIGxheW91dC5wb3MuY29sID0gcG9zLmNv bCwgY2xpcCA9IFRSVUUsIA0KICAgICAgICAgICAgICAgICAgICAgIGdwID0g Z3Bhcihmb250c2l6ZSA9IGZvbnRzaXplLmRlZmF1bHQpKSkNCiAgICAgICAg ICAgICAgICAgICAgZ3JpZC5yZWN0KCkNCiAgICAgICAgICAgICAgICAgICAg eCRzdHJpcCh3aGljaC5naXZlbiA9IGksIHdoaWNoLnBhbmVsID0gY29uZC5j dXJyZW50LmxldmVsLCANCiAgICAgICAgICAgICAgICAgICAgICB2YXIubmFt ZSA9IG5hbWVzKHgkY29uZCksIGZhY3Rvci5sZXZlbHMgPSBpZiAoIWlzLmxp c3QoeCRjb25kW1tpXV0pKSANCiAgICAgICAgICAgICAgICAgICAgICAgIHgk Y29uZFtbaV1dDQogICAgICAgICAgICAgICAgICAgICAgZWxzZSBOVUxMLCBz aGluZ2xlLmludGVydmFscyA9IGlmIChpcy5saXN0KHgkY29uZFtbaV1dKSkg DQogICAgICAgICAgICAgICAgICAgICAgICBkby5jYWxsKCJyYmluZCIsIHgk Y29uZFtbaV1dKQ0KICAgICAgICAgICAgICAgICAgICAgIGVsc2UgTlVMTCwg YmcgPSBzdHJpcC5jb2wuZGVmYXVsdC5iZ1tpXSwgDQogICAgICAgICAgICAg ICAgICAgICAgZmcgPSBzdHJpcC5jb2wuZGVmYXVsdC5mZ1tpXSwgcGFyLnN0 cmlwLnRleHQgPSB4JHBhci5zdHJpcC50ZXh0KQ0KICAgICAgICAgICAgICAg ICAgICBwb3Audmlld3BvcnQoKQ0KICAgICAgICAgICAgICAgICAgfQ0KICAg ICAgICAgICAgICAgIGlmICh4LnJlbGF0aW9uLnNhbWUgJiYgeCR4LnNjYWxl cyRkcmF3KSANCiAgICAgICAgICAgICAgICAgIGlmIChhY3R1YWwucm93ID09 IHJvd3MucGVyLnBhZ2UpIHsNCiAgICAgICAgICAgICAgICAgICAgYXhzIDwt IHgkeC5zY2FsZXMNCiAgICAgICAgICAgICAgICAgICAgb2sgPC0gKHhsYWJl bGluZm8kYXQgPj0geHNjYWxlWzFdICYgeGxhYmVsaW5mbyRhdCA8PSANCiAg ICAgICAgICAgICAgICAgICAgICB4c2NhbGVbMl0pDQogICAgICAgICAgICAg ICAgICAgIHB1c2gudmlld3BvcnQodmlld3BvcnQobGF5b3V0LnBvcy5yb3cg PSBwb3Mucm93IC0gDQogICAgICAgICAgICAgICAgICAgICAgMSAtIG51bWJl ci5vZi5jb25kLCBsYXlvdXQucG9zLmNvbCA9IHBvcy5jb2wsIA0KICAgICAg ICAgICAgICAgICAgICAgIHhzY2FsZSA9IHhzY2FsZSkpDQogICAgICAgICAg ICAgICAgICAgIGlmIChheHMkdGNrWzJdICE9IDAgJiYgYW55KG9rKSkgDQog ICAgICAgICAgICAgICAgICAgICAgZ3JpZC5zZWdtZW50cyh5MCA9IHVuaXQo cmVwKDAsIHN1bShvaykpLCANCiAgICAgICAgICAgICAgICAgICAgICAgICJu cGMiKSwgeTEgPSB1bml0KHJlcCgwLjMgKiBheHMkdGNrWzJdLCANCiAgICAg ICAgICAgICAgICAgICAgICAgIHN1bShvaykpLCAibGluZXMiKSwgeDAgPSB1 bml0KHhsYWJlbGluZm8kYXRbb2tdLCANCiAgICAgICAgICAgICAgICAgICAg ICAgICJuYXRpdmUiKSwgeDEgPSB1bml0KHhsYWJlbGluZm8kYXRbb2tdLCAN CiAgICAgICAgICAgICAgICAgICAgICAgICJuYXRpdmUiKSwgZ3AgPSBncGFy KGNvbCA9IHhheGlzLmNvbCkpDQogICAgICAgICAgICAgICAgICAgIHBvcC52 aWV3cG9ydCgpDQogICAgICAgICAgICAgICAgICAgIGlmICh4LmFsdGVybmF0 aW5nW2NvbHVtbl0gPT0gMiB8fCB4LmFsdGVybmF0aW5nW2NvbHVtbl0gPT0g DQogICAgICAgICAgICAgICAgICAgICAgMykgDQogICAgICAgICAgICAgICAg ICAgICAgaWYgKGFueShvaykpIA0KICAgICAgICAgICAgICAgICAgICAgICAg Z3JpZC50ZXh0KGxhYmVsID0geGxhYmVsaW5mbyRsYWJlbFtva10sIA0KICAg ICAgICAgICAgICAgICAgICAgICAgICB4ID0gdW5pdCh4bGFiZWxpbmZvJGF0 W29rXSwgIm5hdGl2ZSIpLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAg eSA9IHVuaXQoaWYgKHhheGlzLnJvdFsyXSAlaW4lIGMoMCwgDQogICAgICAg ICAgICAgICAgICAgICAgICAgICAgMTgwKSkgDQogICAgICAgICAgICAgICAg ICAgICAgICAgICAgMC41DQogICAgICAgICAgICAgICAgICAgICAgICAgIGVs c2UgMCwgIm5wYyIpLCBqdXN0ID0gaWYgKHhheGlzLnJvdFsyXSA9PSANCiAg ICAgICAgICAgICAgICAgICAgICAgICAgICAwKSANCiAgICAgICAgICAgICAg ICAgICAgICAgICAgICBjKCJjZW50cmUiLCAiY2VudHJlIikNCiAgICAgICAg ICAgICAgICAgICAgICAgICAgZWxzZSBpZiAoeGF4aXMucm90WzJdID09IDE4 MCkgDQogICAgICAgICAgICAgICAgICAgICAgICAgICAgYygiY2VudHJlIiwg ImNlbnRyZSIpDQogICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYg KHhheGlzLnJvdFsyXSA+IDApIA0KICAgICAgICAgICAgICAgICAgICAgICAg ICAgIGMoImxlZnQiLCAiY2VudHJlIikNCiAgICAgICAgICAgICAgICAgICAg ICAgICAgZWxzZSBjKCJyaWdodCIsICJjZW50cmUiKSwgcm90ID0geGF4aXMu cm90WzJdLCANCiAgICAgICAgICAgICAgICAgICAgICAgICAgY2hlY2sub3Zl cmxhcCA9IHhsYWJlbGluZm8kY2hlY2sub3ZlcmxhcCwgDQogICAgICAgICAg ICAgICAgICAgICAgICAgIGdwID0gZ3Bhcihjb2wgPSB4YXhpcy5jb2wsIGZv bnQgPSB4YXhpcy5mb250LCANCiAgICAgICAgICAgICAgICAgICAgICAgICAg ICBmb250c2l6ZSA9IGF4cyRjZXhbMl0gKiBmb250c2l6ZS5kZWZhdWx0KSwg DQogICAgICAgICAgICAgICAgICAgICAgICAgIHZwID0gdmlld3BvcnQobGF5 b3V0LnBvcy5yb3cgPSBwb3Mucm93IC0gDQogICAgICAgICAgICAgICAgICAg ICAgICAgICAgMiAtIG51bWJlci5vZi5jb25kLCBsYXlvdXQucG9zLmNvbCA9 IHBvcy5jb2wsIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgIHhzY2Fs ZSA9IHhzY2FsZSkpDQogICAgICAgICAgICAgICAgICB9DQogICAgICAgICAg ICAgICAgY29uZC5jdXJyZW50LmxldmVsIDwtIGN1cGRhdGUoY29uZC5jdXJy ZW50LmxldmVsLCANCiAgICAgICAgICAgICAgICAgIGNvbmQubWF4LmxldmVs KQ0KICAgICAgICAgICAgICAgIHBhbmVsLm51bWJlciA8LSBwYW5lbC5udW1i ZXIgKyAxDQogICAgICAgICAgICB9DQogICAgICAgIH0NCiAgICAgICAgaWYg KCFpcy5udWxsKHgka2V5KSB8fCAhaXMubnVsbCh4JGNvbG9ya2V5KSkgew0K ICAgICAgICAgICAgaWYgKGtleS5zcGFjZSA9PSAibGVmdCIpIHsNCiAgICAg ICAgICAgICAgICBwdXNoLnZpZXdwb3J0KHZpZXdwb3J0KGxheW91dC5wb3Mu Y29sID0gMiwgbGF5b3V0LnBvcy5yb3cgPSBjKDYsIA0KICAgICAgICAgICAg ICAgICAgbi5yb3cgLSA2KSkpDQogICAgICAgICAgICAgICAgZ3JpZC5kcmF3 KGtleS5nZikNCiAgICAgICAgICAgICAgICBwb3Audmlld3BvcnQoKQ0KICAg ICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSBpZiAoa2V5LnNwYWNlID09 ICJyaWdodCIpIHsNCiAgICAgICAgICAgICAgICBwdXNoLnZpZXdwb3J0KHZp ZXdwb3J0KGxheW91dC5wb3MuY29sID0gbi5jb2wgLSANCiAgICAgICAgICAg ICAgICAgIDEsIGxheW91dC5wb3Mucm93ID0gYyg2LCBuLnJvdyAtIDYpKSkN CiAgICAgICAgICAgICAgICBncmlkLmRyYXcoa2V5LmdmKQ0KICAgICAgICAg ICAgICAgIHBvcC52aWV3cG9ydCgpDQogICAgICAgICAgICB9DQogICAgICAg ICAgICBlbHNlIGlmIChrZXkuc3BhY2UgPT0gInRvcCIpIHsNCiAgICAgICAg ICAgICAgICBwdXNoLnZpZXdwb3J0KHZpZXdwb3J0KGxheW91dC5wb3Mucm93 ID0gMywgbGF5b3V0LnBvcy5jb2wgPSBjKDYsIA0KICAgICAgICAgICAgICAg ICAgbi5jb2wgLSA0KSkpDQogICAgICAgICAgICAgICAgZ3JpZC5kcmF3KGtl eS5nZikNCiAgICAgICAgICAgICAgICBwb3Audmlld3BvcnQoKQ0KICAgICAg ICAgICAgfQ0KICAgICAgICAgICAgZWxzZSBpZiAoa2V5LnNwYWNlID09ICJi b3R0b20iKSB7DQogICAgICAgICAgICAgICAgcHVzaC52aWV3cG9ydCh2aWV3 cG9ydChsYXlvdXQucG9zLnJvdyA9IG4ucm93IC0gDQogICAgICAgICAgICAg ICAgICAyLCBsYXlvdXQucG9zLmNvbCA9IGMoNiwgbi5jb2wgLSA0KSkpDQog ICAgICAgICAgICAgICAgZ3JpZC5kcmF3KGtleS5nZikNCiAgICAgICAgICAg ICAgICBwb3Audmlld3BvcnQoKQ0KICAgICAgICAgICAgfQ0KICAgICAgICAg ICAgZWxzZSBpZiAoa2V5LnNwYWNlID09ICJpbnNpZGUiKSB7DQogICAgICAg ICAgICAgICAgcHVzaC52aWV3cG9ydCh2aWV3cG9ydChsYXlvdXQucG9zLnJv dyA9IGMoMSwgDQogICAgICAgICAgICAgICAgICBuLnJvdyksIGxheW91dC5w b3MuY29sID0gYygxLCBuLmNvbCkpKQ0KICAgICAgICAgICAgICAgIGlmIChp cy5udWxsKHgka2V5JGNvcm5lcikpIA0KICAgICAgICAgICAgICAgICAgeCRr ZXkkY29ybmVyIDwtIGMoMCwgMSkNCiAgICAgICAgICAgICAgICBpZiAoaXMu bnVsbCh4JGtleSR4KSkgDQogICAgICAgICAgICAgICAgICB4JGtleSR4IDwt IHgka2V5JGNvcm5lclsxXQ0KICAgICAgICAgICAgICAgIGlmIChpcy5udWxs KHgka2V5JHkpKSANCiAgICAgICAgICAgICAgICAgIHgka2V5JHkgPC0geCRr ZXkkY29ybmVyWzJdDQogICAgICAgICAgICAgICAgaWYgKGFsbCh4JGtleSRj b3JuZXIgPT0gYygwLCAxKSkpIHsNCiAgICAgICAgICAgICAgICAgIHB1c2gu dmlld3BvcnQodmlld3BvcnQobGF5b3V0ID0gZ3JpZC5sYXlvdXQobnJvdyA9 IDMsIA0KICAgICAgICAgICAgICAgICAgICBuY29sID0gMywgd2lkdGhzID0g dW5pdChjKHgka2V5JHgsIDEsIDEpLCANCiAgICAgICAgICAgICAgICAgICAg ICBjKCJucGMiLCAiZ3JvYndpZHRoIiwgIm51bGwiKSwgbGlzdCgxLCANCiAg ICAgICAgICAgICAgICAgICAgICAgIGtleS5nZiwgMSkpLCBoZWlnaHRzID0g dW5pdChjKDEgLSB4JGtleSR5LCANCiAgICAgICAgICAgICAgICAgICAgICAx LCAxKSwgYygibnBjIiwgImdyb2JoZWlnaHQiLCAibnVsbCIpLCANCiAgICAg ICAgICAgICAgICAgICAgICBsaXN0KDEsIGtleS5nZiwgMSkpKSkpDQogICAg ICAgICAgICAgICAgICBwdXNoLnZpZXdwb3J0KHZpZXdwb3J0KGxheW91dC5w b3Mucm93ID0gMiwgDQogICAgICAgICAgICAgICAgICAgIGxheW91dC5wb3Mu Y29sID0gMikpDQogICAgICAgICAgICAgICAgICBncmlkLmRyYXcoa2V5Lmdm KQ0KICAgICAgICAgICAgICAgICAgcG9wLnZpZXdwb3J0KCkNCiAgICAgICAg ICAgICAgICAgIHBvcC52aWV3cG9ydCgpDQogICAgICAgICAgICAgICAgfQ0K ICAgICAgICAgICAgICAgIGlmIChhbGwoeCRrZXkkY29ybmVyID09IGMoMSwg MSkpKSB7DQogICAgICAgICAgICAgICAgICBwdXNoLnZpZXdwb3J0KHZpZXdw b3J0KGxheW91dCA9IGdyaWQubGF5b3V0KG5yb3cgPSAzLCANCiAgICAgICAg ICAgICAgICAgICAgbmNvbCA9IDMsIGhlaWdodHMgPSB1bml0KGMoMSAtIHgk a2V5JHksIDEsIA0KICAgICAgICAgICAgICAgICAgICAgIDEpLCBjKCJucGMi LCAiZ3JvYmhlaWdodCIsICJudWxsIiksIGxpc3QoMSwgDQogICAgICAgICAg ICAgICAgICAgICAga2V5LmdmLCAxKSksIHdpZHRocyA9IHVuaXQoYygxLCAx LCAxIC0gDQogICAgICAgICAgICAgICAgICAgICAgeCRrZXkkeCksIGMoIm51 bGwiLCAiZ3JvYndpZHRoIiwgIm5wYyIpLCANCiAgICAgICAgICAgICAgICAg ICAgICBsaXN0KDEsIGtleS5nZiwgMSkpKSkpDQogICAgICAgICAgICAgICAg ICBwdXNoLnZpZXdwb3J0KHZpZXdwb3J0KGxheW91dC5wb3Mucm93ID0gMiwg DQogICAgICAgICAgICAgICAgICAgIGxheW91dC5wb3MuY29sID0gMikpDQog ICAgICAgICAgICAgICAgICBncmlkLmRyYXcoa2V5LmdmKQ0KICAgICAgICAg ICAgICAgICAgcG9wLnZpZXdwb3J0KCkNCiAgICAgICAgICAgICAgICAgIHBv cC52aWV3cG9ydCgpDQogICAgICAgICAgICAgICAgfQ0KICAgICAgICAgICAg ICAgIGlmIChhbGwoeCRrZXkkY29ybmVyID09IGMoMCwgMCkpKSB7DQogICAg ICAgICAgICAgICAgICBwdXNoLnZpZXdwb3J0KHZpZXdwb3J0KGxheW91dCA9 IGdyaWQubGF5b3V0KG5yb3cgPSAzLCANCiAgICAgICAgICAgICAgICAgICAg bmNvbCA9IDMsIHdpZHRocyA9IHVuaXQoYyh4JGtleSR4LCAxLCAxKSwgDQog ICAgICAgICAgICAgICAgICAgICAgYygibnBjIiwgImdyb2J3aWR0aCIsICJu dWxsIiksIGxpc3QoMSwgDQogICAgICAgICAgICAgICAgICAgICAgICBrZXku Z2YsIDEpKSwgaGVpZ2h0cyA9IHVuaXQoYygxLCAxLCB4JGtleSR5KSwgDQog ICAgICAgICAgICAgICAgICAgICAgYygibnVsbCIsICJncm9iaGVpZ2h0Iiwg Im5wYyIpLCBsaXN0KDEsIA0KICAgICAgICAgICAgICAgICAgICAgICAga2V5 LmdmLCAxKSkpKSkNCiAgICAgICAgICAgICAgICAgIHB1c2gudmlld3BvcnQo dmlld3BvcnQobGF5b3V0LnBvcy5yb3cgPSAyLCANCiAgICAgICAgICAgICAg ICAgICAgbGF5b3V0LnBvcy5jb2wgPSAyKSkNCiAgICAgICAgICAgICAgICAg IGdyaWQuZHJhdyhrZXkuZ2YpDQogICAgICAgICAgICAgICAgICBwb3Audmll d3BvcnQoKQ0KICAgICAgICAgICAgICAgICAgcG9wLnZpZXdwb3J0KCkNCiAg ICAgICAgICAgICAgICB9DQogICAgICAgICAgICAgICAgaWYgKGFsbCh4JGtl eSRjb3JuZXIgPT0gYygxLCAwKSkpIHsNCiAgICAgICAgICAgICAgICAgIHB1 c2gudmlld3BvcnQodmlld3BvcnQobGF5b3V0ID0gZ3JpZC5sYXlvdXQobnJv dyA9IDMsIA0KICAgICAgICAgICAgICAgICAgICBuY29sID0gMywgd2lkdGhz ID0gdW5pdChjKDEsIDEsIDEgLSB4JGtleSR4KSwgDQogICAgICAgICAgICAg ICAgICAgICAgYygibnVsbCIsICJncm9id2lkdGgiLCAibnBjIiksIGxpc3Qo MSwgDQogICAgICAgICAgICAgICAgICAgICAgICBrZXkuZ2YsIDEpKSwgaGVp Z2h0cyA9IHVuaXQoYygxLCAxLCB4JGtleSR5KSwgDQogICAgICAgICAgICAg ICAgICAgICAgYygibnVsbCIsICJncm9iaGVpZ2h0IiwgIm5wYyIpLCBsaXN0 KDEsIA0KICAgICAgICAgICAgICAgICAgICAgICAga2V5LmdmLCAxKSkpKSkN CiAgICAgICAgICAgICAgICAgIHB1c2gudmlld3BvcnQodmlld3BvcnQobGF5 b3V0LnBvcy5yb3cgPSAyLCANCiAgICAgICAgICAgICAgICAgICAgbGF5b3V0 LnBvcy5jb2wgPSAyKSkNCiAgICAgICAgICAgICAgICAgIGdyaWQuZHJhdyhr ZXkuZ2YpDQogICAgICAgICAgICAgICAgICBwb3Audmlld3BvcnQoKQ0KICAg ICAgICAgICAgICAgICAgcG9wLnZpZXdwb3J0KCkNCiAgICAgICAgICAgICAg ICB9DQogICAgICAgICAgICAgICAgcG9wLnZpZXdwb3J0KCkNCiAgICAgICAg ICAgIH0NCiAgICAgICAgfQ0KICAgICAgICBwdXNoLnZpZXdwb3J0KHZpZXdw b3J0KGxheW91dC5wb3Mucm93ID0gYygxLCBuLnJvdyksIA0KICAgICAgICAg ICAgbGF5b3V0LnBvcy5jb2wgPSBjKDEsIG4uY29sKSkpDQogICAgICAgIGlm ICghaXMubnVsbCh4JHBhZ2UpKSANCiAgICAgICAgICAgIHgkcGFnZShwYWdl Lm51bWJlcikNCiAgICAgICAgcG9wLnZpZXdwb3J0KCkNCiAgICAgICAgcG9w LnZpZXdwb3J0KCkNCiAgICB9DQogICAgaWYgKCFtaXNzaW5nKHBvc2l0aW9u KSkgew0KICAgICAgICBpZiAoIW1pc3Npbmcoc3BsaXQpKSB7DQogICAgICAg ICAgICBwb3Audmlld3BvcnQoKQ0KICAgICAgICAgICAgcG9wLnZpZXdwb3J0 KCkNCiAgICAgICAgfQ0KICAgICAgICBwb3Audmlld3BvcnQoKQ0KICAgIH0N CiAgICBlbHNlIGlmICghbWlzc2luZyhzcGxpdCkpIHsNCiAgICAgICAgcG9w LnZpZXdwb3J0KCkNCiAgICAgICAgcG9wLnZpZXdwb3J0KCkNCiAgICB9DQog ICAgaW52aXNpYmxlKHBhZ2UubGF5b3V0KQ0KfQ0K ---1678264062-154654637-1051422990=:2626055--
rmh@surfer.sbm.temple.edu
2003-Apr-27 16:44 UTC
[Rd] bug and proposed fix in print.trellis 1.7.0 (PR#2859)
sent again without attachments at Peter Dalgaard's request description: # Your mailer is set to "none" (default on Windows), # hence we cannot send the bug report directly from R. # Please copy the bug report (after finishing it) to # your favorite email program and send it to # # r-bugs@r-project.org # ###################################################### The new feature described in rw1070/library/lattice/Changes is very useful and is needed for several of the examples I showed at DSC-2003.> scales > ------ > In anticipation of future use (in nlme, for example), the at and > labels components of scales can now be a list. Each element > corresponds to a panel. This is thoroughly untested and not guaranteed > to work.It currently rejects correctly formed user labels. I attach an example of the problem and a proposed fix. Rich --please do not edit the information below-- Version: platform = i386-pc-mingw32 arch = i386 os = mingw32 system = i386, mingw32 status = major = 1 minor = 7.0 year = 2003 month = 04 day = 16 language = R Windows XP Home Edition (build 2600) Service Pack 1.0 Search Path: .GlobalEnv, file:c:/HOME/rmh/hh/splus.library/.RData, package:grid, package:lattice, package:methods, package:ctest, package:mva, package:modreg, package:nls, package:ts, Autoloads, package:base example: ## print.trellis bug in R 1.7.0 tmp <- data.frame(a=factor(c("a","b","c")), b=factor(c("d","e","f")), d=factor(c(1,1,2))) xyplot(a ~ b | d, data=tmp, ## works scales=list(alternating=F)) xyplot(a ~ b | d, data=tmp, ## Invalid value for labels scales=list(x=list(labels=list(c("d","e",""),c("","","f")), alternating=F))) source("print.trellis.r") ## rmh proposed fix xyplot(a ~ b | d, data=tmp, ## now it works scales=list(x=list(labels=list(c("d","e",""),c("","","f")), alternating=F))) proposed fix: print.trellis <- function (x, position, split, more = FALSE, newpage = TRUE, panel.height = list(1, "null"), panel.width = list(1, "null"), ...) { if (is.null(dev.list())) trellis.device() else if (is.null(trellis.par.get())) trellis.device(device = .Device, new = FALSE) bg = trellis.par.get("background")$col new <- TRUE if (.lattice.print.more || !newpage) new <- FALSE .lattice.print.more <<- more usual <- (missing(position) & missing(split)) fontsize.default <- trellis.par.get("fontsize")$default if (!missing(position)) { if (length(position) != 4) stop("Incorrect value of position") if (new) { grid.newpage() grid.rect(gp = gpar(fill = bg, col = "transparent")) } push.viewport(viewport(x = position[1], y = position[2], width = position[3] - position[1], height = position[4] - position[2], just = c("left", "bottom"))) if (!missing(split)) { if (length(split) != 4) stop("Incorrect value of split") push.viewport(viewport(layout = grid.layout(nrow = split[4], ncol = split[3]))) push.viewport(viewport(layout.pos.row = split[2], layout.pos.col = split[1])) } } else if (!missing(split)) { if (length(split) != 4) stop("Incorrect value of split") if (new) { grid.newpage() grid.rect(gp = gpar(fill = bg, col = "transparent")) } push.viewport(viewport(layout = grid.layout(nrow = split[4], ncol = split[3]))) push.viewport(viewport(layout.pos.row = split[2], layout.pos.col = split[1])) } panel <- if (is.function(x$panel)) x$panel else if (is.character(x$panel)) get(x$panel) else eval(x$panel) x$strip <- if (is.function(x$strip)) x$strip else if (is.character(x$strip)) get(x$strip) else eval(x$strip) axis.line <- trellis.par.get("axis.line") number.of.cond <- length(x$condlevels) layout.respect <- !x$aspect.fill if (layout.respect) panel.height[[1]] <- x$aspect.ratio * panel.width[[1]] if (!is.null(x$key)) { key.gf <- draw.key(x$key) key.space <- if ("space" %in% names(x$key)) x$key$space else if ("x" %in% names(x$key) || "corner" %in% names(x$key)) "inside" else "top" } else if (!is.null(x$colorkey)) { key.gf <- draw.colorkey(x$colorkey) key.space <- if ("space" %in% names(x$colorkey)) x$colorkey$space else "right" } xaxis.col <- if (is.logical(x$x.scales$col)) axis.line$col else x$x.scales$col xaxis.font <- if (is.logical(x$x.scales$font)) 1 else x$x.scales$font xaxis.cex <- x$x.scales$cex xaxis.rot <- if (is.logical(x$x.scales$rot)) c(0, 0) else x$x.scales$rot yaxis.col <- if (is.logical(x$y.scales$col)) axis.line$col else x$y.scales$col yaxis.font <- if (is.logical(x$y.scales$font)) 1 else x$y.scales$font yaxis.cex <- x$y.scales$cex yaxis.rot <- if (!is.logical(x$y.scales$rot)) x$y.scales$rot else if (x$y.scales$relation != "same" && is.logical(x$y.scales$labels)) c(90, 90) else c(0, 0) strip.col.default.bg <- rep(trellis.par.get("strip.background")$col, length = number.of.cond) strip.col.default.fg <- rep(trellis.par.get("strip.shingle")$col, length = number.of.cond) cond.max.level <- integer(number.of.cond) for (i in 1:number.of.cond) { cond.max.level[i] <- length(x$condlevels[[i]]) } if (x$layout[1] == 0) { ddim <- par("din") device.aspect <- ddim[2]/ddim[1] panel.aspect <- panel.height[[1]]/panel.width[[1]] plots.per.page <- x$layout[2] m <- max(1, round(sqrt(x$layout[2] * device.aspect/panel.aspect))) n <- ceiling(plots.per.page/m) m <- ceiling(plots.per.page/n) x$layout[1] <- n x$layout[2] <- m } else plots.per.page <- x$layout[1] * x$layout[2] cols.per.page <- x$layout[1] rows.per.page <- x$layout[2] number.of.pages <- x$layout[3] if (cols.per.page > 1) x.between <- rep(x$x.between, length = cols.per.page - 1) if (rows.per.page > 1) y.between <- rep(x$y.between, length = rows.per.page - 1) x.alternating <- rep(x$x.scales$alternating, length = cols.per.page) y.alternating <- rep(x$y.scales$alternating, length = rows.per.page) x.relation.same <- x$x.scales$relation == "same" y.relation.same <- x$y.scales$relation == "same" xlog <- x$x.scales$log ylog <- x$y.scales$log if (is.logical(xlog) && xlog) xlog <- 10 if (is.logical(ylog) && ylog) ylog <- 10 have.xlog <- !is.logical(xlog) || xlog have.ylog <- !is.logical(ylog) || ylog xlogbase <- if (is.numeric(xlog)) xlog else exp(1) ylogbase <- if (is.numeric(ylog)) ylog else exp(1) xlogpaste <- if (have.xlog) paste(as.character(xlog), "^", sep = "") else "" ylogpaste <- if (have.ylog) paste(as.character(ylog), "^", sep = "") else "" have.main <- !(is.null(x$main$label) || (is.character(x$main$label) && x$main$label == "")) have.sub <- !(is.null(x$sub$label) || (is.character(x$sub$label) && x$sub$label == "")) have.xlab <- !(is.null(x$xlab$label) || (is.character(x$xlab$label) && x$xlab$label == "")) have.ylab <- !(is.null(x$ylab$label) || (is.character(x$ylab$label) && x$ylab$label == "")) n.row <- rows.per.page * (number.of.cond + 3) + (rows.per.page - 1) + 11 n.col <- 3 * cols.per.page + (cols.per.page - 1) + 9 if (layout.respect) { layout.respect <- matrix(0, n.row, n.col) layout.respect[number.of.cond + 6 + (1:rows.per.page - 1) * (number.of.cond + 4), (1:cols.per.page - 1) * 4 + 8] <- 1 } heights.x <- rep(1, n.row) heights.units <- rep("lines", n.row) heights.data <- as.list(1:n.row) widths.x <- rep(1, n.col) widths.units <- rep("lines", n.col) widths.data <- as.list(1:n.col) heights.x[number.of.cond + 6 + (1:rows.per.page - 1) * (number.of.cond + 4)] <- panel.height[[1]] heights.units[number.of.cond + 6 + (1:rows.per.page - 1) * (number.of.cond + 4)] <- panel.height[[2]] heights.x[number.of.cond + 7 + (1:rows.per.page - 1) * (number.of.cond + 4)] <- 0 heights.x[number.of.cond + 8 + (1:rows.per.page - 1) * (number.of.cond + 4)] <- 0 heights.x[4] <- 0 heights.x[5] <- 0 heights.x[n.row - 4] <- 0 heights.x[n.row - 5] <- 0 if (rows.per.page > 1) heights.x[number.of.cond + 9 + ((if (x$as.table) 1:(rows.per.page - 1) else (rows.per.page - 1):1) - 1) * (number.of.cond + 4)] <- y.between heights.x[1] <- 0.5 heights.x[2] <- if (have.main) 2 * x$main$cex else 0 if (have.main) { heights.units[2] <- "strheight" heights.data[[2]] <- x$main$lab } heights.x[n.row] <- 0.5 heights.x[n.row - 1] <- if (have.sub) 2 * x$sub$cex else 0 if (have.sub) { heights.units[n.row - 1] <- "strheight" heights.data[[n.row - 1]] <- x$sub$lab } heights.x[3] <- 0 heights.x[n.row - 2] <- 0 heights.insertlist.position <- 0 heights.insertlist.unit <- unit(1, "null") if (x$x.scales$draw) { if (x.relation.same) { lab <- calculateAxisComponents(x = x$x.limits, at = x$x.scales$at, labels = x$x.scales$lab, have.log = have.xlog, logbase = xlogbase, logpaste = xlogpaste, abbreviate = x$x.scales$abbr, minlength = x$x.scales$minl, n = x$x.scales$tick.number)$lab ## if (is.character(lab)) if (all(sapply(lab, is.character))) ## rmh strbar <- as.list(lab) else if (is.expression(lab)) { strbar <- list() for (ss in seq(along = lab)) strbar <- c(strbar, list(lab[ss])) } else stop("Invalid value for labels") heights.x[5] <- 0.5 + max(0.001, x$x.scales$tck[2]) * 0.3 heights.x[n.row - 5] <- 0.5 + max(0.001, x$x.scales$tck[1]) * 0.3 if (any(x.alternating == 2 | x.alternating == 3)) { if (xaxis.rot[2] %in% c(0, 180)) { heights.insertlist.position <- c(heights.insertlist.position, 4) heights.insertlist.unit <- unit.c(heights.insertlist.unit, max(unit(rep(1 * xaxis.cex[2], length(strbar)), "strheight", strbar))) } else { heights.insertlist.position <- c(heights.insertlist.position, 4) heights.insertlist.unit <- unit.c(heights.insertlist.unit, max(unit(rep(1 * xaxis.cex[2] * abs(sin(xaxis.rot[2] * base::pi/180)), length(strbar)), "strwidth", strbar))) } } if (any(x.alternating == 1 | x.alternating == 3)) { if (xaxis.rot[1] %in% c(0, 180)) { heights.insertlist.position <- c(heights.insertlist.position, n.row - 4) heights.insertlist.unit <- unit.c(heights.insertlist.unit, max(unit(rep(1 * xaxis.cex[1], length(strbar)), "strheight", strbar))) } else { heights.insertlist.position <- c(heights.insertlist.position, n.row - 4) heights.insertlist.unit <- unit.c(heights.insertlist.unit, max(unit(rep(1 * xaxis.cex[1] * abs(sin(xaxis.rot[1] * base::pi/180)), length(strbar)), "strwidth", strbar))) } } } else { labelChars <- character(0) labelExprs <- expression(0) for (i in seq(along = x$x.limits)) { lab <- calculateAxisComponents(x = x$x.limits[[i]], at = if (is.list(x$x.scales$at)) x$x.scales$at[[i]] else x$x.scales$at, labels = if (is.list(x$x.scales$lab)) x$x.scales$lab[[i]] else x$x.scales$lab, have.log = have.xlog, logbase = xlogbase, logpaste = xlogpaste, abbreviate = x$x.scales$abbr, minlength = x$x.scales$minl, n = x$x.scales$tick.number)$lab if (is.character(lab)) labelChars <- c(labelChars, lab) else if (is.expression(lab)) labelExprs <- c(labelExprs, lab) } labelChars <- unique(labelChars) strbar <- list() for (ss in labelChars) strbar <- c(strbar, list(ss)) for (ss in seq(along = labelExprs)) strbar <- c(strbar, list(labelExprs[ss])) if (xaxis.rot[1] %in% c(0, 180)) { heights.x[number.of.cond + 7 + (1:rows.per.page - 1) * (number.of.cond + 4)] <- max(0.001, x$x.scales$tck[1]) * 0.3 heights.insertlist.position <- c(heights.insertlist.position, number.of.cond + 8 + (1:rows.per.page - 1) * (number.of.cond + 4)) for (i in 1:rows.per.page) heights.insertlist.unit <- unit.c(heights.insertlist.unit, max(unit(rep(1.5 * xaxis.cex[1], length(strbar)), "strheight", strbar))) } else { heights.x[number.of.cond + 7 + (1:rows.per.page - 1) * (number.of.cond + 4)] <- max(0.001, x$x.scales$tck[1]) * 0.3 heights.insertlist.position <- c(heights.insertlist.position, number.of.cond + 8 + (1:rows.per.page - 1) * (number.of.cond + 4)) for (i in 1:rows.per.page) heights.insertlist.unit <- unit.c(heights.insertlist.unit, max(unit(rep(1.5 * xaxis.cex[1] * abs(sin(xaxis.rot[1] * base::pi/180)), length(strbar)), "strwidth", strbar))) } } } heights.x[n.row - 3] <- if (have.xlab) 2 * x$xlab$cex else 0 if (have.xlab) { heights.units[n.row - 3] <- "strheight" heights.data[[n.row - 3]] <- x$xlab$lab } for (crr in 1:number.of.cond) heights.x[number.of.cond + 6 + (1:rows.per.page - 1) * (number.of.cond + 4) - crr] <- if (is.logical(x$strip)) 0 else 1.1 * x$par.strip.text$cex * x$par.strip.text$lines widths.x[3] <- if (have.ylab) 2 * x$ylab$cex else 0 if (have.ylab) { widths.units[3] <- "strheight" widths.data[[3]] <- x$ylab$lab } widths.x[(1:cols.per.page - 1) * 4 + 8] <- panel.width[[1]] widths.units[(1:cols.per.page - 1) * 4 + 8] <- panel.width[[2]] widths.x[(1:cols.per.page - 1) * 4 + 7] <- 0 widths.x[(1:cols.per.page - 1) * 4 + 6] <- 0 widths.x[4] <- 0 widths.x[5] <- 0 widths.x[n.col - 2] <- 0 widths.x[n.col - 3] <- 0 if (cols.per.page > 1) widths.x[(1:(cols.per.page - 1) - 1) * 4 + 9] <- x.between widths.x[1] <- 0.5 widths.x[n.col] <- 0.5 widths.x[2] <- 0 widths.x[n.col - 1] <- 0 widths.insertlist.position <- 0 widths.insertlist.unit <- unit(1, "null") if (x$y.scales$draw) { if (y.relation.same) { lab <- calculateAxisComponents(x = x$y.limits, at = x$y.scales$at, labels = x$y.scales$lab, have.log = have.ylog, logbase = ylogbase, logpaste = ylogpaste, abbreviate = x$y.scales$abbr, minlength = x$y.scales$minl, n = x$y.scales$tick.number)$lab ## if (is.character(lab)) if (all(sapply(lab, is.character))) ## rmh strbar <- as.list(lab) else if (is.expression(lab)) { strbar <- list() for (ss in seq(along = lab)) strbar <- c(strbar, list(lab[ss])) } else stop("Invalid value for labels") widths.x[5] <- 0.5 + max(0.001, x$y.scales$tck[1]) * 0.3 widths.x[n.col - 3] <- max(1, x$y.scales$tck[2]) * 0.5 if (any(y.alternating == 1 | y.alternating == 3)) { if (abs(yaxis.rot[1]) == 90) { widths.insertlist.position <- c(widths.insertlist.position, 4) widths.insertlist.unit <- unit.c(widths.insertlist.unit, max(unit(1 * rep(yaxis.cex[1], length(strbar)), "strheight", data = strbar))) } else { widths.insertlist.position <- c(widths.insertlist.position, 4) widths.insertlist.unit <- unit.c(widths.insertlist.unit, max(unit(rep(1 * yaxis.cex[1] * abs(cos(yaxis.rot[1] * base::pi/180)), length(strbar)), "strwidth", strbar))) } } if (any(y.alternating == 2 | y.alternating == 3)) { if (abs(yaxis.rot[2]) == 90) { widths.insertlist.position <- c(widths.insertlist.position, n.col - 2) widths.insertlist.unit <- unit.c(widths.insertlist.unit, max(unit(rep(1 * yaxis.cex[2], length(strbar)), "strheight", strbar))) } else { widths.insertlist.position <- c(widths.insertlist.position, n.col - 2) widths.insertlist.unit <- unit.c(widths.insertlist.unit, max(unit(rep(1 * yaxis.cex[2] * abs(cos(yaxis.rot[2] * base::pi/180)), length(strbar)), "strwidth", strbar))) } } } else { labelChars <- character(0) labelExprs <- expression(0) for (i in seq(along = x$y.limits)) { lab <- calculateAxisComponents(x = x$y.limits[[i]], at = if (is.list(x$y.scales$at)) x$y.scales$at[[i]] else x$y.scales$at, labels = if (is.list(x$y.scales$lab)) x$y.scales$lab[[i]] else x$y.scales$lab, have.log = have.ylog, logbase = ylogbase, logpaste = ylogpaste, abbreviate = x$y.scales$abbr, minlength = x$y.scales$minl, n = x$y.scales$tick.number)$lab if (is.character(lab)) labelChars <- c(labelChars, lab) else if (is.expression(lab)) labelExprs <- c(labelExprs, lab) } labelChars <- unique(labelChars) strbar <- list() for (ss in labelChars) strbar <- c(strbar, list(ss)) for (ss in seq(along = labelExprs)) strbar <- c(strbar, list(labelExprs[ss])) if (abs(yaxis.rot[1]) == 90) { widths.x[(1:cols.per.page - 1) * 4 + 7] <- max(0.001, x$y.scales$tck[1]) * 0.3 widths.insertlist.position <- c(widths.insertlist.position, (1:cols.per.page - 1) * 4 + 6) for (i in 1:cols.per.page) widths.insertlist.unit <- unit.c(widths.insertlist.unit, max(unit(rep(1.5 * yaxis.cex[1], length(strbar)), "strheight", strbar))) } else { widths.x[(1:cols.per.page - 1) * 4 + 7] <- max(0.001, x$y.scales$tck[1]) * 0.3 widths.insertlist.position <- c(widths.insertlist.position, (1:cols.per.page - 1) * 4 + 6) for (i in 1:cols.per.page) widths.insertlist.unit <- unit.c(widths.insertlist.unit, max(unit(rep(1.2 * yaxis.cex[1] * abs(cos(yaxis.rot[1] * base::pi/180)), length(strbar)), "strwidth", strbar))) } } } if (!is.null(x$key) || !is.null(x$colorkey)) { if (key.space == "left") { widths.x[2] <- 1.2 widths.units[2] <- "grobwidth" widths.data[[2]] <- key.gf } else if (key.space == "right") { widths.x[n.col - 1] <- 1.2 widths.units[n.col - 1] <- "grobwidth" widths.data[[n.col - 1]] <- key.gf } else if (key.space == "top") { heights.x[3] <- 1.2 heights.units[3] <- "grobheight" heights.data[[3]] <- key.gf } else if (key.space == "bottom") { heights.x[n.row - 2] <- 1.2 heights.units[n.row - 2] <- "grobheight" heights.data[[n.row - 2]] <- key.gf } } layout.heights <- unit(heights.x, heights.units, data = heights.data) if (length(heights.insertlist.position) > 1) for (indx in 2:length(heights.insertlist.position)) layout.heights <- rearrangeUnit(layout.heights, heights.insertlist.position[indx], heights.insertlist.unit[indx]) layout.widths <- unit(widths.x, widths.units, data = widths.data) if (length(widths.insertlist.position) > 1) for (indx in 2:length(widths.insertlist.position)) layout.widths <- rearrangeUnit(layout.widths, widths.insertlist.position[indx], widths.insertlist.unit[indx]) page.layout <- grid.layout(nrow = n.row, ncol = n.col, widths = layout.widths, heights = layout.heights, respect = layout.respect) cond.current.level <- rep(1, number.of.cond) panel.number <- 1 for (page.number in 1:number.of.pages) if (!any(cond.max.level - cond.current.level < 0)) { if (usual) { if (new) grid.newpage() grid.rect(gp = gpar(fill = bg, col = "transparent")) new <- TRUE } push.viewport(viewport(layout = page.layout, gp = gpar(fontsize = fontsize.default, col = axis.line$col, lty = axis.line$lty, lwd = axis.line$lwd))) if (have.main) grid.text(label = x$main$label, gp = gpar(col = x$main$col, font = x$main$font, fontsize = fontsize.default * x$main$cex), vp = viewport(layout.pos.row = 2)) if (have.sub) grid.text(label = x$sub$label, gp = gpar(col = x$sub$col, font = x$sub$font, fontsize = fontsize.default * x$sub$cex), vp = viewport(layout.pos.row = n.row - 1)) if (have.xlab) grid.text(label = x$xlab$label, gp = gpar(col = x$xlab$col, font = x$xlab$font, fontsize = fontsize.default * x$xlab$cex), vp = viewport(layout.pos.row = n.row - 3, layout.pos.col = c(6, n.col - 4))) if (have.ylab) grid.text(label = x$ylab$label, rot = 90, gp = gpar(col = x$ylab$col, font = x$ylab$font, fontsize = fontsize.default * x$ylab$cex), vp = viewport(layout.pos.col = 3, layout.pos.row = c(6, n.row - 6))) for (row in 1:rows.per.page) for (column in 1:cols.per.page) if (!any(cond.max.level - cond.current.level < 0) && (row - 1) * cols.per.page + column <= plots.per.page) { if (!is.list(x$panel.args[[panel.number]])) panel.number <- panel.number + 1 else { actual.row <- if (x$as.table) (rows.per.page - row + 1) else row pos.row <- 6 + number.of.cond + (rows.per.page - actual.row) * (number.of.cond + 4) pos.col <- (column - 1) * 4 + 8 xlabelinfo <- calculateAxisComponents(x = if (x.relation.same) x$x.limits else x$x.limits[[panel.number]], at = if (is.list(x$x.scales$at)) x$x.scales$at[[panel.number]] else x$x.scales$at, labels = if (is.list(x$x.scales$lab)) x$x.scales$lab[[panel.number]] else x$x.scales$lab, have.log = have.xlog, logbase = xlogbase, logpaste = xlogpaste, abbreviate = x$x.scales$abbr, minlength = x$x.scales$minl, n = x$x.scales$tick.number) ylabelinfo <- calculateAxisComponents(x = if (y.relation.same) x$y.limits else x$y.limits[[panel.number]], at = if (is.list(x$y.scales$at)) x$y.scales$at[[panel.number]] else x$y.scales$at, labels = if (is.list(x$y.scales$lab)) x$y.scales$lab[[panel.number]] else x$y.scales$lab, have.log = have.ylog, logbase = ylogbase, logpaste = ylogpaste, abbreviate = x$y.scales$abbr, minlength = x$y.scales$minl, n = x$y.scales$tick.number) xscale <- xlabelinfo$num.limit yscale <- ylabelinfo$num.limit push.viewport(viewport(layout.pos.row = pos.row, layout.pos.col = pos.col, xscale = xscale, yscale = yscale, clip = TRUE, gp = gpar(fontsize = fontsize.default))) pargs <- c(x$panel.args[[panel.number]], x$panel.args.common, list(panel.number = panel.number)) if (!("..." %in% names(formals(panel)))) pargs <- pargs[names(formals(panel))] do.call("panel", pargs) grid.rect() pop.viewport() if (!x.relation.same && x$x.scales$draw) { axs <- x$x.scales ok <- (xlabelinfo$at >= xscale[1] & xlabelinfo$at <= xscale[2]) push.viewport(viewport(layout.pos.row = pos.row + 1, layout.pos.col = pos.col, xscale = xscale)) if (axs$tck[1] != 0 && any(ok)) grid.segments(y0 = unit(rep(1, sum(ok)), "npc"), y1 = unit(rep(1, sum(ok)), "npc") - unit(rep(0.3 * axs$tck[1], sum(ok)), "lines"), x0 = unit(xlabelinfo$at[ok], "native"), x1 = unit(xlabelinfo$at[ok], "native"), gp = gpar(col = xaxis.col)) pop.viewport() if (any(ok)) grid.text(label = xlabelinfo$label[ok], x = unit(xlabelinfo$at[ok], "native"), y = unit(if (xaxis.rot[1] %in% c(0, 180)) 0.5 else 0.95, "npc"), just = if (xaxis.rot[1] == 0) c("centre", "centre") else if (xaxis.rot[1] == 180) c("centre", "centre") else if (xaxis.rot[1] > 0) c("right", "centre") else c("left", "centre"), rot = xaxis.rot[1], check.overlap = xlabelinfo$check.overlap, gp = gpar(col = xaxis.col, font = xaxis.font, fontsize = axs$cex[1] * fontsize.default), vp = viewport(layout.pos.row = pos.row + 2, layout.pos.col = pos.col, xscale = xscale)) } if (!y.relation.same && x$y.scales$draw) { axs <- x$y.scales ok <- (ylabelinfo$at >= yscale[1] & ylabelinfo$at <= yscale[2]) push.viewport(viewport(layout.pos.row = pos.row, layout.pos.col = pos.col - 1, yscale = yscale)) if (axs$tck[1] != 0 && any(ok)) grid.segments(x0 = unit(rep(1, sum(ok)), "npc"), x1 = unit(rep(1, sum(ok)), "npc") - unit(rep(0.3 * axs$tck[1], sum(ok)), "lines"), y0 = unit(ylabelinfo$at[ok], "native"), y1 = unit(ylabelinfo$at[ok], "native"), gp = gpar(col = yaxis.col)) pop.viewport() if (any(ok)) grid.text(label = ylabelinfo$label[ok], y = unit(ylabelinfo$at[ok], "native"), x = unit(if (abs(yaxis.rot[1]) == 90) 0.5 else 0.95, "npc"), just = if (yaxis.rot[1] == 90) c("centre", "centre") else if (yaxis.rot[1] == -90) c("centre", "centre") else if (yaxis.rot[1] > -90 && yaxis.rot[1] < 90) c("right", "centre") else c("left", "centre"), rot = yaxis.rot[1], check.overlap = ylabelinfo$check.overlap, gp = gpar(col = yaxis.col, font = xaxis.font, fontsize = axs$cex[1] * fontsize.default), vp = viewport(layout.pos.row = pos.row, layout.pos.col = pos.col - 2, yscale = yscale)) } if (y.relation.same && x$y.scales$draw) { if (column == 1) { axs <- x$y.scales ok <- (ylabelinfo$at >= yscale[1] & ylabelinfo$at <= yscale[2]) push.viewport(viewport(layout.pos.row = pos.row, layout.pos.col = pos.col - 3, yscale = yscale)) if (axs$tck[1] != 0 && any(ok)) grid.segments(x0 = unit(rep(1, sum(ok)), "npc"), x1 = unit(rep(1, sum(ok)), "npc") - unit(rep(0.3 * axs$tck[1], sum(ok)), "lines"), y0 = unit(ylabelinfo$at[ok], "native"), y1 = unit(ylabelinfo$at[ok], "native"), gp = gpar(col = yaxis.col)) pop.viewport() if (y.alternating[actual.row] == 1 || y.alternating[actual.row] == 3) if (any(ok)) grid.text(label = ylabelinfo$lab[ok], y = unit(ylabelinfo$at[ok], "native"), x = unit(if (abs(yaxis.rot[1]) == 90) 0.5 else 1, "npc"), just = if (yaxis.rot[1] == -90) c("centre", "centre") else if (yaxis.rot[1] == 90) c("centre", "centre") else if (yaxis.rot[1] > -90 && yaxis.rot[1] < 90) c("right", "centre") else c("left", "centre"), rot = yaxis.rot[1], check.overlap = ylabelinfo$check.overlap, gp = gpar(col = yaxis.col, font = yaxis.font, fontsize = axs$cex[1] * fontsize.default), vp = viewport(layout.pos.row = pos.row, layout.pos.col = pos.col - 4, yscale = yscale)) } if (column == cols.per.page) { axs <- x$y.scales ok <- (ylabelinfo$at >= yscale[1] & ylabelinfo$at <= yscale[2]) push.viewport(viewport(layout.pos.row = pos.row, layout.pos.col = pos.col + 1, yscale = yscale)) if (axs$tck[2] != 0 && any(ok)) grid.segments(x0 = unit(rep(0, sum(ok)), "npc"), x1 = unit(rep(0.3 * axs$tck[2], sum(ok)), "lines"), y0 = unit(ylabelinfo$at[ok], "native"), y1 = unit(ylabelinfo$at[ok], "native"), gp = gpar(col = yaxis.col)) pop.viewport() if (y.alternating[actual.row] == 2 || y.alternating[actual.row] == 3) if (any(ok)) grid.text(label = ylabelinfo$label[ok], y = unit(ylabelinfo$at[ok], "native"), x = unit(if (abs(yaxis.rot[2]) == 90) 0.5 else 0, "npc"), just = if (yaxis.rot[2] == -90) c("centre", "centre") else if (yaxis.rot[2] == 90) c("centre", "centre") else if (yaxis.rot[2] > -90 && yaxis.rot[2] < 90) c("left", "centre") else c("right", "centre"), rot = yaxis.rot[2], check.overlap = ylabelinfo$check.overlap, gp = gpar(col = yaxis.col, font = yaxis.font, fontsize = axs$cex[2] * fontsize.default), vp = viewport(layout.pos.row = pos.row, layout.pos.col = pos.col + 2, yscale = yscale)) } } if (x.relation.same && x$x.scales$draw) { if (actual.row == 1) { axs <- x$x.scales ok <- (xlabelinfo$at >= xscale[1] & xlabelinfo$at <= xscale[2]) push.viewport(viewport(layout.pos.row = pos.row + 3, layout.pos.col = pos.col, xscale = xscale)) if (axs$tck[1] != 0 && any(ok)) grid.segments(y0 = unit(rep(1, sum(ok)), "npc"), y1 = unit(rep(1, sum(ok)), "npc") - unit(rep(0.3 * axs$tck[1], sum(ok)), "lines"), x0 = unit(xlabelinfo$at[ok], "native"), x1 = unit(xlabelinfo$at[ok], "native"), gp = gpar(col = xaxis.col)) pop.viewport() if (x.alternating[column] == 1 || x.alternating[column] == 3) if (any(ok)) { grid.text(label = xlabelinfo$lab[ok], x = unit(xlabelinfo$at[ok], "native"), y = unit(if (xaxis.rot[1] %in% c(0, 180)) 0.5 else 1, "npc"), just = if (xaxis.rot[1] == 0) c("centre", "centre") else if (xaxis.rot[1] == 180) c("centre", "centre") else if (xaxis.rot[1] > 0) c("right", "centre") else c("left", "centre"), rot = xaxis.rot[1], check.overlap = xlabelinfo$check.overlap, gp = gpar(col = xaxis.col, font = xaxis.font, fontsize = axs$cex[1] * fontsize.default), vp = viewport(layout.pos.row = pos.row + 4, layout.pos.col = pos.col, xscale = xscale)) } } } if (!is.logical(x$strip)) for (i in 1:number.of.cond) { push.viewport(viewport(layout.pos.row = pos.row - i, layout.pos.col = pos.col, clip = TRUE, gp = gpar(fontsize = fontsize.default))) grid.rect() x$strip(which.given = i, which.panel = cond.current.level, var.name = names(x$cond), factor.levels = if (!is.list(x$cond[[i]])) x$cond[[i]] else NULL, shingle.intervals = if (is.list(x$cond[[i]])) do.call("rbind", x$cond[[i]]) else NULL, bg = strip.col.default.bg[i], fg = strip.col.default.fg[i], par.strip.text = x$par.strip.text) pop.viewport() } if (x.relation.same && x$x.scales$draw) if (actual.row == rows.per.page) { axs <- x$x.scales ok <- (xlabelinfo$at >= xscale[1] & xlabelinfo$at <= xscale[2]) push.viewport(viewport(layout.pos.row = pos.row - 1 - number.of.cond, layout.pos.col = pos.col, xscale = xscale)) if (axs$tck[2] != 0 && any(ok)) grid.segments(y0 = unit(rep(0, sum(ok)), "npc"), y1 = unit(rep(0.3 * axs$tck[2], sum(ok)), "lines"), x0 = unit(xlabelinfo$at[ok], "native"), x1 = unit(xlabelinfo$at[ok], "native"), gp = gpar(col = xaxis.col)) pop.viewport() if (x.alternating[column] == 2 || x.alternating[column] == 3) if (any(ok)) grid.text(label = xlabelinfo$label[ok], x = unit(xlabelinfo$at[ok], "native"), y = unit(if (xaxis.rot[2] %in% c(0, 180)) 0.5 else 0, "npc"), just = if (xaxis.rot[2] == 0) c("centre", "centre") else if (xaxis.rot[2] == 180) c("centre", "centre") else if (xaxis.rot[2] > 0) c("left", "centre") else c("right", "centre"), rot = xaxis.rot[2], check.overlap = xlabelinfo$check.overlap, gp = gpar(col = xaxis.col, font = xaxis.font, fontsize = axs$cex[2] * fontsize.default), vp = viewport(layout.pos.row = pos.row - 2 - number.of.cond, layout.pos.col = pos.col, xscale = xscale)) } cond.current.level <- cupdate(cond.current.level, cond.max.level) panel.number <- panel.number + 1 } } if (!is.null(x$key) || !is.null(x$colorkey)) { if (key.space == "left") { push.viewport(viewport(layout.pos.col = 2, layout.pos.row = c(6, n.row - 6))) grid.draw(key.gf) pop.viewport() } else if (key.space == "right") { push.viewport(viewport(layout.pos.col = n.col - 1, layout.pos.row = c(6, n.row - 6))) grid.draw(key.gf) pop.viewport() } else if (key.space == "top") { push.viewport(viewport(layout.pos.row = 3, layout.pos.col = c(6, n.col - 4))) grid.draw(key.gf) pop.viewport() } else if (key.space == "bottom") { push.viewport(viewport(layout.pos.row = n.row - 2, layout.pos.col = c(6, n.col - 4))) grid.draw(key.gf) pop.viewport() } else if (key.space == "inside") { push.viewport(viewport(layout.pos.row = c(1, n.row), layout.pos.col = c(1, n.col))) if (is.null(x$key$corner)) x$key$corner <- c(0, 1) if (is.null(x$key$x)) x$key$x <- x$key$corner[1] if (is.null(x$key$y)) x$key$y <- x$key$corner[2] if (all(x$key$corner == c(0, 1))) { push.viewport(viewport(layout = grid.layout(nrow = 3, ncol = 3, widths = unit(c(x$key$x, 1, 1), c("npc", "grobwidth", "null"), list(1, key.gf, 1)), heights = unit(c(1 - x$key$y, 1, 1), c("npc", "grobheight", "null"), list(1, key.gf, 1))))) push.viewport(viewport(layout.pos.row = 2, layout.pos.col = 2)) grid.draw(key.gf) pop.viewport() pop.viewport() } if (all(x$key$corner == c(1, 1))) { push.viewport(viewport(layout = grid.layout(nrow = 3, ncol = 3, heights = unit(c(1 - x$key$y, 1, 1), c("npc", "grobheight", "null"), list(1, key.gf, 1)), widths = unit(c(1, 1, 1 - x$key$x), c("null", "grobwidth", "npc"), list(1, key.gf, 1))))) push.viewport(viewport(layout.pos.row = 2, layout.pos.col = 2)) grid.draw(key.gf) pop.viewport() pop.viewport() } if (all(x$key$corner == c(0, 0))) { push.viewport(viewport(layout = grid.layout(nrow = 3, ncol = 3, widths = unit(c(x$key$x, 1, 1), c("npc", "grobwidth", "null"), list(1, key.gf, 1)), heights = unit(c(1, 1, x$key$y), c("null", "grobheight", "npc"), list(1, key.gf, 1))))) push.viewport(viewport(layout.pos.row = 2, layout.pos.col = 2)) grid.draw(key.gf) pop.viewport() pop.viewport() } if (all(x$key$corner == c(1, 0))) { push.viewport(viewport(layout = grid.layout(nrow = 3, ncol = 3, widths = unit(c(1, 1, 1 - x$key$x), c("null", "grobwidth", "npc"), list(1, key.gf, 1)), heights = unit(c(1, 1, x$key$y), c("null", "grobheight", "npc"), list(1, key.gf, 1))))) push.viewport(viewport(layout.pos.row = 2, layout.pos.col = 2)) grid.draw(key.gf) pop.viewport() pop.viewport() } pop.viewport() } } push.viewport(viewport(layout.pos.row = c(1, n.row), layout.pos.col = c(1, n.col))) if (!is.null(x$page)) x$page(page.number) pop.viewport() pop.viewport() } if (!missing(position)) { if (!missing(split)) { pop.viewport() pop.viewport() } pop.viewport() } else if (!missing(split)) { pop.viewport() pop.viewport() } invisible(page.layout) }
deepayan@stat.wisc.edu
2003-May-13 22:27 UTC
[Rd] bug and proposed fix in print.trellis 1.7.0 (PR#2859)
Hi, sorry for the delay, I didn't have time to look at this earlier. On Sunday 27 April 2003 09:44, rmh@surfer.sbm.temple.edu wrote:> The new feature described in rw1070/library/lattice/Changes is very > useful and is needed for several of the examples I showed at DSC-2003. > > > scales > > ------ > > In anticipation of future use (in nlme, for example), the at and > > labels components of scales can now be a list. Each element > > corresponds to a panel. This is thoroughly untested and not guaranteed > > to work.It's not at all clear from this entry, but I meant to do this only when relation="free" or "sliced" in scales, because those are the only cases in which different tick positions and labels can be guaranteed to be associated with each panel. In the relation = "same" case, changing the layout changes which labels go with which panel (and if alternating = 0 or 3, it's even ambiguous). I notice now that your first example (with the 'at' but no 'labels') does produce some output that seems to take the list into account, but that was unintended. My preference would be to produce an error in such cases, but I'm open to other suggestions. Do you really need this ? I think relation="free" would suit your purpose quite well, at least in the given example. Perhaps I could additionally allow 'limits' (which is ignored now for relation="free") to be a list as well. Deepayan> It currently rejects correctly formed user labels. I attach an > example of the problem and a proposed fix. > > Rich > > --please do not edit the information below-- > > Version: > platform = i386-pc-mingw32 > arch = i386 > os = mingw32 > system = i386, mingw32 > status > major = 1 > minor = 7.0 > year = 2003 > month = 04 > day = 16 > language = R > > Windows XP Home Edition (build 2600) Service Pack 1.0 > > Search Path: > .GlobalEnv, file:c:/HOME/rmh/hh/splus.library/.RData, package:grid, > package:lattice, package:methods, package:ctest, package:mva, > package:modreg, package:nls, package:ts, Autoloads, package:base > > > example: > ## print.trellis bug in R 1.7.0 > > tmp <- data.frame(a=factor(c("a","b","c")), > b=factor(c("d","e","f")), > d=factor(c(1,1,2))) > > xyplot(a ~ b | d, data=tmp, ## works > scales=list(alternating=F)) > > xyplot(a ~ b | d, data=tmp, ## Invalid value for labels > scales=list(x=list(labels=list(c("d","e",""),c("","","f")), > alternating=F))) > > source("print.trellis.r") ## rmh proposed fix > > xyplot(a ~ b | d, data=tmp, ## now it works > scales=list(x=list(labels=list(c("d","e",""),c("","","f")), > alternating=F)))