1 Clazz.declarePackage ("javajs.img");
\r
2 Clazz.load (["javajs.img.ImageEncoder"], "javajs.img.PdfEncoder", ["java.util.Hashtable", "javajs.export.PDFCreator"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
4 this.isLandscape = false;
\r
7 Clazz.instantialize (this, arguments);
\r
8 }, javajs.img, "PdfEncoder", javajs.img.ImageEncoder);
\r
9 Clazz.makeConstructor (c$,
\r
11 Clazz.superConstructor (this, javajs.img.PdfEncoder, []);
\r
13 Clazz.overrideMethod (c$, "setParams",
\r
15 this.isLandscape = (this.quality > 1);
\r
16 this.comment = "Jmol " + params.get ("comment");
\r
17 }, "java.util.Map");
\r
18 Clazz.overrideMethod (c$, "generate",
\r
20 this.pdf = new javajs["export"].PDFCreator ();
\r
21 var pageWidth = 576;
\r
22 var pageHeight = 792;
\r
23 this.pdf.setOutputStream (this.out);
\r
24 this.pdf.newDocument (pageWidth, pageHeight, this.isLandscape);
\r
25 this.addMyImage (pageWidth, pageHeight);
\r
26 var ht = new java.util.Hashtable ();
\r
27 if (this.comment != null) ht.put ("Producer", this.comment);
\r
28 ht.put ("Author", "JMol");
\r
29 ht.put ("CreationDate", this.date);
\r
30 this.pdf.addInfo (ht);
\r
31 this.pdf.closeDocument ();
\r
33 Clazz.defineMethod (c$, "addMyImage",
\r
34 ($fz = function (pageWidth, pageHeight) {
\r
35 this.pdf.addImageResource ("img1", this.width, this.height, this.pixels, true);
\r
36 var w = (this.isLandscape ? pageHeight : pageWidth);
\r
37 var h = (this.isLandscape ? pageWidth : pageHeight);
\r
38 var iw = this.width;
\r
39 var ih = this.height;
\r
41 ih = Clazz.doubleToInt (ih * 0.9 * w / iw);
\r
42 iw = Clazz.doubleToInt (w * 0.9);
\r
43 }if (ih > 0.9 * h) {
\r
44 iw = Clazz.doubleToInt (iw * 0.9 * h / ih);
\r
45 ih = Clazz.doubleToInt (h * 0.9);
\r
51 x = Clazz.doubleToInt ((w - iw) / 2);
\r
54 y = Clazz.doubleToInt ((h - ih) / 2);
\r
56 }this.pdf.drawImage ("img1", x, y, x1, y1, 0, 0, this.width, this.height);
\r
57 }, $fz.isPrivate = true, $fz), "~N,~N");
\r