biojs-vis-pdbviewer
Version:
A BioJS 2.0 component to view protein structures
128 lines (127 loc) • 3.43 kB
JavaScript
Clazz.declarePackage ("JU");
Clazz.load (null, "JU.ZStream", ["JU.Adler32"], function () {
c$ = Clazz.decorateAsClass (function () {
this.next_in = null;
this.next_in_index = 0;
this.avail_in = 0;
this.total_in = 0;
this.next_out = null;
this.next_out_index = 0;
this.avail_out = 0;
this.total_out = 0;
this.msg = null;
this.dstate = null;
this.istate = null;
this.data_type = 0;
this.checksum = null;
Clazz.instantialize (this, arguments);
}, JU, "ZStream");
Clazz.defineMethod (c$, "setAdler32",
function () {
this.checksum = new JU.Adler32 ();
});
Clazz.defineMethod (c$, "inflate",
function (f) {
if (this.istate == null) return -2;
return this.istate.inflate (f);
}, "~N");
Clazz.defineMethod (c$, "deflate",
function (flush) {
if (this.dstate == null) {
return -2;
}return this.dstate.deflate (flush);
}, "~N");
Clazz.defineMethod (c$, "flush_pending",
function () {
var len = this.dstate.pending;
if (len > this.avail_out) len = this.avail_out;
if (len == 0) return;
System.arraycopy (this.dstate.pending_buf, this.dstate.pending_out, this.next_out, this.next_out_index, len);
this.next_out_index += len;
this.dstate.pending_out += len;
this.total_out += len;
this.avail_out -= len;
this.dstate.pending -= len;
if (this.dstate.pending == 0) {
this.dstate.pending_out = 0;
}});
Clazz.defineMethod (c$, "read_buf",
function (buf, start, size) {
var len = this.avail_in;
if (len > size) len = size;
if (len == 0) return 0;
this.avail_in -= len;
if (this.dstate.wrap != 0) {
this.checksum.update (this.next_in, this.next_in_index, len);
}System.arraycopy (this.next_in, this.next_in_index, buf, start, len);
this.next_in_index += len;
this.total_in += len;
return len;
}, "~A,~N,~N");
Clazz.defineMethod (c$, "getAdler",
function () {
return this.checksum.getValue ();
});
Clazz.defineMethod (c$, "free",
function () {
this.next_in = null;
this.next_out = null;
this.msg = null;
});
Clazz.defineMethod (c$, "setOutput",
function (buf, off, len) {
this.next_out = buf;
this.next_out_index = off;
this.avail_out = len;
}, "~A,~N,~N");
Clazz.defineMethod (c$, "setInput",
function (buf, off, len, append) {
if (len <= 0 && append && this.next_in != null) return;
if (this.avail_in > 0 && append) {
var tmp = Clazz.newByteArray (this.avail_in + len, 0);
System.arraycopy (this.next_in, this.next_in_index, tmp, 0, this.avail_in);
System.arraycopy (buf, off, tmp, this.avail_in, len);
this.next_in = tmp;
this.next_in_index = 0;
this.avail_in += len;
} else {
this.next_in = buf;
this.next_in_index = off;
this.avail_in = len;
}}, "~A,~N,~N,~B");
Clazz.defineMethod (c$, "getAvailIn",
function () {
return this.avail_in;
});
Clazz.defineMethod (c$, "getTotalOut",
function () {
return this.total_out;
});
Clazz.defineMethod (c$, "getTotalIn",
function () {
return this.total_in;
});
c$.getBytes = Clazz.defineMethod (c$, "getBytes",
function (s) {
{
var x = [];
for (var i = 0; i < s.length;i++) {
var pt = s.charCodeAt(i);
if (pt <= 0x7F) {
x.push(pt);
} else if (pt <= 0x7FF) {
x.push(0xC0|((pt>>6)&0x1F));
x.push(0x80|(pt&0x3F));
} else if (pt <= 0xFFFF) {
x.push(0xE0|((pt>>12)&0xF));
x.push(0x80|((pt>>6)&0x3F));
x.push(0x80|(pt&0x3F));
} else {
x.push(0x3F); // '?'
}
}
return (Int32Array != Array ? new Int32Array(x) : x);
}}, "~S");
Clazz.defineStatics (c$,
"Z_STREAM_ERROR", -2);
});