X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=bin%2Fjavajs%2Fimg%2FPdfEncoder.js;h=664879ffe06c4f6b9e7941019212021c28571fa4;hp=0a468dc64b1eae20fc0d8459b598dc667fd30c38;hb=8ffd05b3abe52c0b6b79b011c0966361f82d5fe6;hpb=6154cb57a6eac3bb1344b8342495f5bb701ee921 diff --git a/bin/javajs/img/PdfEncoder.js b/bin/javajs/img/PdfEncoder.js index 0a468dc..664879f 100644 --- a/bin/javajs/img/PdfEncoder.js +++ b/bin/javajs/img/PdfEncoder.js @@ -1,58 +1,58 @@ -Clazz.declarePackage ("javajs.img"); -Clazz.load (["javajs.img.ImageEncoder"], "javajs.img.PdfEncoder", ["java.util.Hashtable", "javajs.export.PDFCreator"], function () { -c$ = Clazz.decorateAsClass (function () { -this.isLandscape = false; -this.pdf = null; -this.comment = null; -Clazz.instantialize (this, arguments); -}, javajs.img, "PdfEncoder", javajs.img.ImageEncoder); -Clazz.makeConstructor (c$, -function () { -Clazz.superConstructor (this, javajs.img.PdfEncoder, []); -}); -Clazz.overrideMethod (c$, "setParams", -function (params) { -this.isLandscape = (this.quality > 1); -this.comment = "Jmol " + params.get ("comment"); -}, "java.util.Map"); -Clazz.overrideMethod (c$, "generate", -function () { -this.pdf = new javajs["export"].PDFCreator (); -var pageWidth = 576; -var pageHeight = 792; -this.pdf.setOutputStream (this.out); -this.pdf.newDocument (pageWidth, pageHeight, this.isLandscape); -this.addMyImage (pageWidth, pageHeight); -var ht = new java.util.Hashtable (); -if (this.comment != null) ht.put ("Producer", this.comment); -ht.put ("Author", "JMol"); -ht.put ("CreationDate", this.date); -this.pdf.addInfo (ht); -this.pdf.closeDocument (); -}); -Clazz.defineMethod (c$, "addMyImage", -($fz = function (pageWidth, pageHeight) { -this.pdf.addImageResource ("img1", this.width, this.height, this.pixels, true); -var w = (this.isLandscape ? pageHeight : pageWidth); -var h = (this.isLandscape ? pageWidth : pageHeight); -var iw = this.width; -var ih = this.height; -if (iw > 0.9 * w) { -ih = Clazz.doubleToInt (ih * 0.9 * w / iw); -iw = Clazz.doubleToInt (w * 0.9); -}if (ih > 0.9 * h) { -iw = Clazz.doubleToInt (iw * 0.9 * h / ih); -ih = Clazz.doubleToInt (h * 0.9); -}var x = 0; -var y = 0; -var x1 = iw; -var y1 = ih; -if (w > iw) { -x = Clazz.doubleToInt ((w - iw) / 2); -x1 = iw + x; -}if (h > ih) { -y = Clazz.doubleToInt ((h - ih) / 2); -y1 = ih + y; -}this.pdf.drawImage ("img1", x, y, x1, y1, 0, 0, this.width, this.height); -}, $fz.isPrivate = true, $fz), "~N,~N"); -}); +Clazz.declarePackage ("javajs.img"); +Clazz.load (["javajs.img.ImageEncoder"], "javajs.img.PdfEncoder", ["java.util.Hashtable", "javajs.export.PDFCreator"], function () { +c$ = Clazz.decorateAsClass (function () { +this.isLandscape = false; +this.pdf = null; +this.comment = null; +Clazz.instantialize (this, arguments); +}, javajs.img, "PdfEncoder", javajs.img.ImageEncoder); +Clazz.makeConstructor (c$, +function () { +Clazz.superConstructor (this, javajs.img.PdfEncoder, []); +}); +Clazz.overrideMethod (c$, "setParams", +function (params) { +this.isLandscape = (this.quality > 1); +this.comment = "Jmol " + params.get ("comment"); +}, "java.util.Map"); +Clazz.overrideMethod (c$, "generate", +function () { +this.pdf = new javajs["export"].PDFCreator (); +var pageWidth = 576; +var pageHeight = 792; +this.pdf.setOutputStream (this.out); +this.pdf.newDocument (pageWidth, pageHeight, this.isLandscape); +this.addMyImage (pageWidth, pageHeight); +var ht = new java.util.Hashtable (); +if (this.comment != null) ht.put ("Producer", this.comment); +ht.put ("Author", "JMol"); +ht.put ("CreationDate", this.date); +this.pdf.addInfo (ht); +this.pdf.closeDocument (); +}); +Clazz.defineMethod (c$, "addMyImage", +($fz = function (pageWidth, pageHeight) { +this.pdf.addImageResource ("img1", this.width, this.height, this.pixels, true); +var w = (this.isLandscape ? pageHeight : pageWidth); +var h = (this.isLandscape ? pageWidth : pageHeight); +var iw = this.width; +var ih = this.height; +if (iw > 0.9 * w) { +ih = Clazz.doubleToInt (ih * 0.9 * w / iw); +iw = Clazz.doubleToInt (w * 0.9); +}if (ih > 0.9 * h) { +iw = Clazz.doubleToInt (iw * 0.9 * h / ih); +ih = Clazz.doubleToInt (h * 0.9); +}var x = 0; +var y = 0; +var x1 = iw; +var y1 = ih; +if (w > iw) { +x = Clazz.doubleToInt ((w - iw) / 2); +x1 = iw + x; +}if (h > ih) { +y = Clazz.doubleToInt ((h - ih) / 2); +y1 = ih + y; +}this.pdf.drawImage ("img1", x, y, x1, y1, 0, 0, this.width, this.height); +}, $fz.isPrivate = true, $fz), "~N,~N"); +});