';
}
t += J2S._getWrapper(this, false);
if (Info.addSelectionOptions)
t += J2S._getGrabberOptions(this);
if (J2S._debugAlert && !J2S._document)
alert(t);
this._code = J2S._documentWrite(t);
};
proto._newCanvas = function(doReplace) {
if (this._is2D)
this._createCanvas2d(doReplace);
else
this._GLmol.create();
};
// ////// swingjs.api.HTML5Applet interface
proto._getHtml5Canvas = function() {
return this._canvas
};
proto._getWidth = function() {
return (this._canvas ? this._canvas.width : 0)
};
proto._getHeight = function() {
return (this._canvas ? this._canvas.height : 0)
};
proto._getContentLayer = function() {
return J2S.$(this, "contentLayer")[0]
};
proto.repaintNow = function() {
J2S.repaint(this, false)
};
// //////
proto._createCanvas2d = function(doReplace) {
var container = J2S.$(this, "appletdiv");
// if (doReplace) {
if (this._canvas) {
try {
container[0].removeChild(this._canvas);
if (this._canvas.frontLayer)
container[0].removeChild(this._canvas.frontLayer);
if (this._canvas.rearLayer)
container[0].removeChild(this._canvas.rearLayer);
if (this._canvas.contentLayer)
container[0].removeChild(this._canvas.contentLayer);
J2S.unsetMouse(this._mouseInterface);
} catch (e) {
}
}
var w = Math.round(container.width());
var h = Math.round(container.height());
var canvas = document.createElement('canvas');
canvas.applet = this;
this._canvas = canvas;
canvas.style.width = "100%";
canvas.style.height = "100%";
canvas.width = w;
canvas.height = h; // w and h used in setScreenDimension
canvas.id = this._id + "_canvas2d";
container.append(canvas);
J2S._$(canvas.id).css({
"z-index" : J2S.getZ(this, "main")
});
if (this._isLayered) {
var content = document.createElement("div");
canvas.contentLayer = content;
content.id = this._id + "_contentLayer";
container.append(content);
J2S._$(content.id).css({
zIndex : J2S.getZ(this, "content"),
position : "absolute",
left : "0px",
top : "0px",
width : (this._isSwing ? w : 0) + "px",
height : (this._isSwing ? h : 0) + "px",
overflow : "hidden"
});
if (this._isSwing) {
this._mouseInterface = content;
content.applet = this;
} else {
this._mouseInterface = this._getLayer("front", container,
w, h, false);
}
} else {
this._mouseInterface = canvas;
}
J2S.setMouse(this._mouseInterface, this._isSwing);
}
proto._getLayer = function(name, container, w, h, isOpaque) {
var c = document.createElement("canvas");
this._canvas[name + "Layer"] = c;
c.style.width = "100%";
c.style.height = "100%";
c.id = this._id + "_" + name + "Layer";
c.width = w;
c.height = h; // w and h used in setScreenDimension
container.append(c);
c.applet = this;
J2S._$(c.id).css({
background : (isOpaque ? "rgb(0,0,0,1)" : "rgb(0,0,0,0.001)"),
"z-index" : J2S.getZ(this, name),
position : "absolute",
left : "0px",
top : "0px",
overflow : "hidden"
});
return c;
}
proto._setupJS = function() {
J2S.setWindowVar("j2s.lib", {
base : this._j2sPath + "/",
alias : ".",
console : this._console,
monitorZIndex : J2S.getZ(this, "monitorZIndex")
});
var isFirst = (__execStack.length == 0);
if (isFirst)
J2S._addExec([ this, __loadClazz, null, "loadClazz" ]);
this._addCoreFiles();
J2S._addExec([ this, this.__startAppletJS, null, "start applet" ])
this._isSigned = true; // access all files via URL hook
this._ready = false;
this._applet = null;
this._canScript = function(script) {
return true;
};
this._savedOrientations = [];
__execTimer && clearTimeout(__execTimer);
__execTimer = setTimeout(__nextExecution, __execDelayMS);
};
proto.__startAppletJS = function(applet) {
if (J2S._version.indexOf("$Date: ") == 0)
J2S._version = (J2S._version.substring(7) + " -").split(" -")[0]
+ " (J2S)";
Clazz.load("java.lang.Class");
J2S._registerApplet(applet._id, applet);
if (!applet.__Info.args || applet.__Info.args == "?") {
var s = J2S.getURIField("j2sargs", null);
if (s !== null)
applet.__Info.args = decodeURIComponent(s);
}
var isApp = applet._isApp = !!applet.__Info.main;
try {
var clazz = (applet.__Info.main || applet.__Info.code);
try {
if (clazz.indexOf(".") < 0) {
clazz = "_." + clazz;
if (isApp)
applet.__Info.main = clazz;
else
applet.__Info.code = clazz;
}
var cl = Clazz.load(clazz);
if (clazz.indexOf("_.") == 0)
J2S.setWindowVar(clazz.substring(2), cl);
if (isApp && cl.j2sHeadless)
applet.__Info.headless = true;
} catch (e) {
alert("Java class " + clazz + " was not found.");
return;
}
if (isApp && applet.__Info.headless) {
cl.main$SA(applet.__Info.args || []);
} else {
applet.__Info.main
var viewerOptions = Clazz.new_(Clazz
.load("java.util.Hashtable"));
viewerOptions.put = viewerOptions.put$TK$TV;
J2S._setAppletParams(applet._availableParams,
viewerOptions, applet.__Info, true);
viewerOptions.put("name", applet._id);// + "_object");
viewerOptions.put("syncId", J2S._syncId);
viewerOptions.put("fullName", applet._id + "__" + J2S._syncId + "__");
if (J2S._isAsync)
viewerOptions.put("async", true);
if (applet._startupScript)
viewerOptions.put("script", applet._startupScript)
viewerOptions.put("platform", applet._platform);
viewerOptions.put("documentBase", document.location.href);
var codePath = applet._j2sPath + "/";
if (codePath.indexOf("://") < 0) {
var base = document.location.href.split("#")[0]
.split("?")[0].split("/");
if (codePath.indexOf("/") == 0)
base = [ base[0], codePath.substring(1) ];
else
base[base.length - 1] = codePath;
codePath = base.join("/");
}
if (applet.__Info.code)
codePath += applet.__Info.code.replace(/\./g, "/");
codePath = codePath.substring(0,
codePath.lastIndexOf("/") + 1);
viewerOptions.put("codePath", codePath);
viewerOptions.put("appletReadyCallback",
"J2S.readyCallback");
viewerOptions.put("applet", true);
if (applet._color)
viewerOptions.put("bgcolor", applet._color);
if (J2S._syncedApplets.length)
viewerOptions
.put("synccallback", "J2S._mySyncCallback");
viewerOptions.put("signedApplet", "true");
if (applet._is2D && !isApp)
viewerOptions.put("display", applet._id + "_canvas2d");
var w = applet.__Info.width;
var h = applet.__Info.height;
if (w > 0 && h > 0 && (!applet._canvas || w != applet._canvas.width
|| h != applet._canvas.height)) {
// developer has used static { J2S.thisApplet.__Info.width=...}
J2S.$(applet, "appletinfotablediv").width(w).height(h);
applet._newCanvas(true);
}
applet._newApplet(viewerOptions);
}
} catch (e) {
System.out.println((J2S._isAsync ? "normal async abort from "
: "")
+ e + (e.stack ? "\n" + e.stack : ""));
return;
}
//applet._jsSetScreenDimensions();
__nextExecution();
};
if (!proto._restoreState)
proto._restoreState = function(clazzName, state) {
// applet-dependent
}
proto._jsSetScreenDimensions = function() {
if (!this._appletPanel)
return
// strangely, if CTRL+/CTRL- are used repeatedly, then the
// applet div can be not the same size as the canvas if there
// is a border in place.
var d = J2S._getElement(this, (this._is2D ? "canvas2d" : "canvas"));
this._appletPanel.setScreenDimension$I$I(d.width, d.height);
};
proto._show = function(tf) {
J2S.$setVisible(J2S.$(this, "appletdiv"), tf);
if (tf && !this._isSwing) // SwingJS applets will handle their own
// repainting
J2S.repaint(this, true);
};
proto._canScript = function(script) {
return true
};
proto._processGesture = function(touches, frameViewer) {
(frameViewer || this._appletPanel)
.processTwoPointGesture$FAAA(touches);
}
proto._processEvent = function(type, xym, ev, frameViewer) {
// xym is [x,y,modifiers,wheelScroll]
// also processes key events
(frameViewer || this._appletPanel).processMouseEvent$I$I$I$I$J$O$I(
type, xym[0], xym[1], xym[2], System.currentTimeMillis$(),
ev, xym[3]);
}
proto._resize = function() {
var s = "__resizeTimeout_" + this._id;
// only at end
if (J2S[s])
clearTimeout(J2S[s]);
var me = this;
J2S[s] = setTimeout(function() {
J2S.repaint(me, true);
J2S[s] = null
}, 100);
}
return proto;
};
J2S.repaint = function(applet, asNewThread) {
// JmolObjectInterface
// asNewThread: true is from RepaintManager.repaintNow()
// false is from Repaintmanager.requestRepaintAndWait()
// called from apiPlatform Display.repaint()
// alert("repaint " + Clazz._getStackTrace())
if (!applet || !applet._appletPanel)
return;
// asNewThread = false;
var container = J2S.$(applet, "appletdiv");
var w = Math.round(container.width());
var h = Math.round(container.height());
if (applet._is2D && !applet._isApp
&& (applet._canvas.width != w || applet._canvas.height != h)) {
applet._newCanvas(true);
applet._appletPanel
.setDisplay$swingjs_api_js_HTML5Canvas(applet._canvas);
}
applet._appletPanel.setScreenDimension$I$I(w, h);
var f = function() {
// if (applet._appletPanel.top) {
// System.out.println("j2sApplet invalidate");
// applet._appletPanel.top.invalidate$();
// System.out.println("j2sApplet repaint");
// applet._appletPanel.top.repaint$();
// }
};
//if (asNewThread) {
//self.setTimeout(f,20); // requestAnimationFrame
//} else {
f();
//}
}
/**
* loadImage is called for asynchronous image loading. If bytes are not
* null, they are from a ZIP file. They are processed sychronously here
* using an image data URI. Can all browsers handle MB of data in data URI?
*
*/
J2S.loadImage = function(platform, echoName, path, bytes, fOnload, image) {
// JmolObjectInterface
var id = "echo_" + echoName + path + (bytes ? "_" + bytes.length : "");
var canvas = J2S.getHiddenCanvas(platform.vwr.html5Applet, id, 0, 0,
false, true);
if (canvas == null) {
if (image == null) {
image = new Image();
if (bytes == null) {
image.onload = function() {
J2S.loadImage(platform, echoName, path, null, fOnload,
image)
};
image.src = path;
return null;
} else {
System.out
.println("Jsmol.js J2S.loadImage using data URI for "
+ id)
}
image.src = (typeof bytes == "string" ? bytes : "data:"
+ Clazz.load("javajs.util.Rdr")
.guessMimeTypeForBytes$BA(bytes) + ";base64,"
+ Clazz.load("javajs.util.Base64").getBase64$BA(bytes));
}
var width = image.width;
var height = image.height;
if (echoName == "webgl") {
// will be antialiased
width /= 2;
height /= 2;
}
canvas = J2S.getHiddenCanvas(platform.vwr.html5Applet, id, width,
height, true, false);
canvas.imageWidth = width;
canvas.imageHeight = height;
canvas.id = id;
canvas.image = image;
J2S.setCanvasImage(canvas, width, height);
// return a null canvas and the error in path if there is a problem
} else {
System.out.println("J2S.loadImage reading cached image for " + id)
}
return (bytes == null ? fOnload(canvas, path) : canvas);
};
J2S._canvasCache = {};
J2S.getHiddenCanvas = function(applet, id, width, height, forceNew,
checkOnly) {
id = applet._id + "_" + id;
var d = J2S._canvasCache[id];
if (checkOnly)
return d;
if (forceNew || !d || d.width != width || d.height != height) {
d = document.createElement('canvas');
// for some reason both these need to be set, or maybe just d.width?
d.width = d.style.width = width;
d.height = d.style.height = height;
d.id = id;
J2S._canvasCache[id] = d;
}
return d;
}
J2S.setCanvasImage = function(canvas, width, height) {
// called from org.J2S.awtjs2d.Platform
canvas.buf32 = null;
canvas.width = width;
canvas.height = height;
canvas.getContext("2d").drawImage(canvas.image, 0, 0,
canvas.image.width, canvas.image.height, 0, 0, width, height);
};
J2S.applyFunc = function(f, a) {
// J2SObjectInterface
return f(a);
}
J2S.setDraggable = function(tag, targetOrArray) {
// draggable tag object; target is itself
// J2S.setDraggable(tag)
// J2S.setDraggable(tag, true)
// draggable tag object that controls another target,
// either given as a DOM element or jQuery selector or function
// returning such
// J2S.setDraggable(tag, target)
// J2S.setDraggable(tag, fTarget)
// draggable tag object simply loade=s/reports mouse position as
// fDown({x:x,y:y,dx:dx,dy:dy,ev:ev}) should fill x and y with starting
// points
// fDrag(xy) and fUp(xy) will get {x:x,y:y,dx:dx,dy:dy,ev:ev} to use as
// desired
// J2S.setDraggable(tag, [fAll])
// J2S.setDraggable(tag, [fDown, fDrag, fUp])
// unbind tag
// J2S.setDraggable(tag, false)
// draggable frames by their titles.
// activation of dragging with a mouse down action
// deactivates all other mouse operation in SwingJS
// until the mouse is released.
// uses jQuery outside events - v1.1 - 3/16/2010 (see j2sJQueryExt.js)
// J2S.setDraggable(titlebar, fGetFrameParent), for example, is issued
// in swingjs.plaf.JSFrameUI.js
var drag, up;
var dragBind = function(isBind) {
$tag.unbind('mousemoveoutjsmol');
$tag.unbind('touchmoveoutjsmol');
$tag.unbind('mouseupoutjsmol');
$tag.unbind('touchendoutjsmol');
J2S._dmouseOwner = null;
tag.isDragging = false;
tag._isDragger = false;
if (isBind) {
$tag.bind('mousemoveoutjsmol touchmoveoutjsmol', function(ev) {
drag && drag(ev);
});
$tag.bind('mouseupoutjsmol touchendoutjsmol', function(ev) {
up && up(ev);
});
}
};
var $tag = $(tag);
tag = $tag[0];
if (tag._isDragger)
return;
var target, fDown, fDrag, fUp;
if (targetOrArray === false) {
dragBind(tag, false);
return;
}
if (targetOrArray instanceof Array) {
// J2S.setDraggable(tag, [fAll])
// J2S.setDraggable(tag, [fDown, fDrag, fUp])
fDown = targetOrArray[0];
fDrag = targetOrArray[1] || fDown;
fUp = targetOrArray[2] || fDown;
} else {
// J2S.setDraggable(tag)
// J2S.setDraggable(tag, true)
// J2S.setDraggable(tag, target)
// J2S.setDraggable(tag, fTarget)
target = (targetOrArray !== true && targetOrArray || tag);
// allow for a function to return the target
// this allows the target to be created after the call to
// J2S.setDraggable()
if (!(typeof target == "function")) {
var t = target;
target = function() {
return $(t).parent()
}
}
}
tag._isDragger = true;
var x, y, dx, dy, pageX0, pageY0, pageX, pageY;
var down = function(ev) {
J2S._dmouseOwner = tag;
J2S._dmouseDrag = drag;
tag.isDragging = true; // used by J2S mouse event business
pageX = ev.pageX;
pageY = ev.pageY;
var xy = {
x : 0,
y : 0,
dx : 0,
dy : 0,
ev : ev
};
if (fDown) {
fDown(xy, 501);
} else if (target) {
var o = $(target(501)).position();
xy = {
x : o.left,
y : o.top
};
}
pageX0 = xy.x;
pageY0 = xy.y;
return false;
}, drag = function(ev) {
// we will move the frame's parent node and take the frame along
// with it
var ev0 = ev.ev0 || ev;
if (ev0.buttons == 0 && ev0.button == 0)
tag.isDragging = false;
var mode = (tag.isDragging ? 506 : 503);
if (!J2S._dmouseOwner || tag.isDragging && J2S._dmouseOwner == tag) {
x = pageX0 + (dx = ev.pageX - pageX);
y = pageY0 + (dy = ev.pageY - pageY);
if (fDrag) {
fDrag({
x : x,
y : y,
dx : dx,
dy : dy,
ev : ev
}, mode);
} else if (target) {
var frame = target(mode, x, y);
if (frame)
$(frame).css({ top : y + 'px', left : x + 'px'})
}
}
}, up = function(ev) {
J2S._dmouseDrag = null;
if (J2S._dmouseOwner == tag) {
tag.isDragging = false;
J2S._dmouseOwner = null
fUp && fUp({
x : x,
y : y,
dx : dx,
dy : dy,
ev : ev
}, 502);
return false;
} else {
}
};
$tag.bind('mousedown touchstart', function(ev) {
return down && down(ev);
});
$tag.bind('mousemove touchmove', function(ev) {
return drag && drag(ev);
});
$tag.bind('mouseup touchend', function(ev) {
return up && up(ev);
});
dragBind(true);
}
J2S.setWindowZIndex = function(node, z) {
// on frame show or mouse-down, create a stack of frames and sort by
// z-order
if (!node)
return
var zbase = J2S._z.rear + 2000;
var a = [];
var zmin = 1e10
var zmax = -1e10
var $windows = $(".swingjs-window");
$windows.each(function(c, b) {
if (b != node)
a.push([ +b.style.zIndex, b ]);
});
a.sort(function(a, b) {
return a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0
})
var z0 = zbase;
var z0 = zbase;
for (var i = 0; i < a.length; i++) {
if (!a[i][1].ui || !a[i][1].ui.embeddingNode)
a[i][1].style.zIndex = zbase;
zbase += 1000;
}
z = (z > 0 ? zbase : z0);
if (!node.ui || !node.ui.embeddingNode) // could be popupMenu, with no ui
node.style.zIndex = z;
node.style.position = "absolute";
if (J2S._checkLoading)
System.out.println("setting z-index to " + z + " for " + node.id);
return z;
}
J2S.say = function(msg) {
alert(msg);
}
J2S.Swing = {
// a static class for menus and other resources
count : 0,
menuInitialized : 0,
menuCounter : 0
};
J2S.getSwing = function() {
return J2S.Swing
}
J2S.showInfo = function(applet, tf) {
applet._showInfo(tf);
}
J2S.Loaded = {};
J2S.isResourceLoaded = function(resource, done) {
path = J2S.getResourcePath(resource, true);
var r = J2S.Loaded[resource];
if (done)
J2S.Loaded[resource] = 1;
return r;
}
J2S.getResourcePath = function(path, isJavaPath) {
if (!path || path.indexOf("https:/") != 0
&& path.indexOf("https:/") != 0 && path.indexOf("file:/") != 0) {
var applet = J2S._applets[Clazz.loadClass("java.lang.Thread").currentThread$()
.getName$()];
path = (!isJavaPath && applet.__Info.resourcePath || applet.__Info.j2sPath)
+ "/" + (path || "");
}
return path;
}
J2S._newGrayScaleImage = function(context, image, width, height, grayBuffer) {
var c;
image || (image = Jmol.$(context.canvas.applet, "image")[0]);
if (image == null) {
var appId = context.canvas.applet._id;
var id = appId + "_imagediv";
c = document.createElement("canvas");
c.id = id;
c.style.width = width + "px";
c.style.height = height + "px";
c.width = width;
c.height = height;
var layer = document.getElementById(appId + "_contentLayer");
image = new Image();
image.canvas = c;
image.appId = appId;
image.id = appId + "_image";
image.layer = layer;
image.w = width;
image.h = height;
image.onload = function(e) {
try {
URL.revokeObjectURL(image.src);
} catch (e) {}
};
var div = document.createElement("div");
image.div = div;
div.style.position="absolute";
layer.appendChild(div);
div.appendChild(image);
}
c = image.canvas.getContext("2d");
var imageData = c.getImageData(0, 0, width, height);
var buf = imageData.data;
var ng = grayBuffer.length;
var pt = 0;
for (var i = 0; i < ng; i++) {
buf[pt++] = buf[pt++] = buf[pt++] = grayBuffer[i];
buf[pt++] = 0xFF;
}
c.putImageData(imageData, 0, 0);
image.canvas.toBlob(function(blob){image.src = URL.createObjectURL(blob)});
return image;
}
})(J2S);
// j2sClazz.js
// NOTE: updates to this file should be copies to j2sjmol.js
// latest author: Bob Hanson, St. Olaf College, hansonr@stolaf.edu
// NOTES by Bob Hanson
// Google closure compiler cannot handle Clazz.new or Clazz.super
// TODO: still a lot of references to window[...]
// BH 2019.05.21 changes Clazz.isClassDefined to Clazz._isClassDefined for compression
// BH 2019.05.13 fixes for Math.getExponent, Math.IEEERemainder, Array.equals(Object)
// BH 2019.02.16 fixes typo in Integer.parseInt(s,radix)
// BH 2019.02.07 fixes radix|10 should be radix||10
// BH 1/29/2019 adds String.join$CharSequence$Iterable, String.join$CharSequence$CharSequenceA
// BH 1/13/2019 3.2.4.07 adds Character.to[Title|Lower|Upper]Case(int)
// BH 1/8/2019 3.2.4.07 fixes String.prototype.to[Upper|Lower]Case$java_util_Locale - using toLocal[Upper|Lower]Case()
// BH 1/3/2019 3.2.4.07 adds ByteBuffer/CharBuffer support, proper CharSet encoding, including GBK (Standard Chinese)
// see earlier notes at net.sf.j2s.java.core.srcjs/js/devnotes.txt
LoadClazz = function() {
if (!window["j2s.clazzloaded"])
window["j2s.clazzloaded"] = false;
if (window["j2s.clazzloaded"])return;
window["j2s.clazzloaded"] = true;
//window["j2s.object.native"] = true;
/* http://j2s.sf.net/ *//******************************************************************************
* Copyright (c) 2007 java2script.org and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Zhou Renjian - initial API and implementation
*****************************************************************************/
/*******
* @author zhou renjian
* @create Nov 5, 2005
*******/
/**
* Class Clazz. All the methods are static in this class.
*/
/* static */
/*Class = */ Clazz = {
_isQuiet: true,
_debugging: false,
_loadcore: true,
_nooutput: 0,
_VERSION_R: "3.2.4.07", //runtime
_VERSION_T: "3.2.4.07", //transpiler
};
;(function(Clazz, J2S) {
try {
Clazz._debugging = (document.location.href.indexOf("j2sdebug") >= 0);
Clazz._loadcore = (document.location.href.indexOf("j2snocore") < 0);
Clazz._quiet = (document.location.href.indexOf("j2sverbose") < 0);
} catch (e) {}
try {
// will alert in system.out.println with a message
Clazz._traceOutput =
(document.location.href.indexOf("j2strace=") >= 0 ? decodeURI(document.location.href.split("j2strace=")[1].split("&")[0]) : null);
Clazz._traceFilter =
(document.location.href.indexOf("j2sfilter=") >= 0 ? decodeURI(document.location.href.split("j2sfilter=")[1].split("&")[0]) : null);
} catch (e) {}
Clazz.setTVer = function(ver) {
if (Clazz._VERSION_T != ver) {
System.err.println("transpiler was " + Clazz._VERSION_T + " now " + ver + " for " + lastLoaded);
}
Clazz._VERSION_T = ver;
}
var lastLoaded;
Clazz.ClassFilesLoaded = [];
Clazz.popup = Clazz.log = Clazz.error = window.alert;
/* can be set by page JavaScript */
Clazz.defaultAssertionStatus = true;
/* can be set by page JavaScript */
Clazz._assertFunction = null;
//////// 16 methods called from code created by the transpiler ////////
var getArrayClass = function(name){
// "[C" "[[C"
var n = 0;
while (name.charAt(n) == "[") n++;
var type = name.substring(n);
var clazz = (type.length == 1 ? primTypes[type].TYPE : Clazz._4Name(type.split(";")[0].substring(1)).$clazz$);
return Clazz.array(clazz,-n);
}
Clazz.array = function(baseClass, paramType, ndims, params, isClone) {
var t0 = (_profileNew ? window.performance.now() : 0);
var ret = _array.apply(null, arguments);
_profileNew && addProfileNew(baseClass, t0 - window.performance.now() - 0.01);
return ret;
}
var _array = function(baseClass, paramType, ndims, params, isClone) {
// int[][].class Clazz.array(Integer.TYPE, -2)
// new int[] {3, 4, 5} Clazz.array(Integer.TYPE, -1, [3, 4, 5])
// new int[][]{new int[] {3, 4, 5}, {new int[] {3, 4, 5}}
// Clazz.array(Integer.TYPE, -2, Clazz.array(Integer.TYPE, -1, [3, 4, 5]), Clazz.array(Integer.TYPE, -1, [3, 4, 5]) )
// new int[3] Clazz.array(Integer.TYPE, [3])
// new int[3][3] Clazz.array(Integer.TYPE, [3, 3])
// new int[3][] Clazz.array(Integer.TYPE, [3, null])
// new char[3] Clazz.array(Character.TYPE, [3])
// new String[3] Clazz.array(java.lang.String, [3])
if (arguments[0] === -1) {
// four-parameter option from JU.AU.arrayCopyObject;
// truncate array using slice
// Clazz.array(-1, array, ifirst, ilast+1)
var a = arguments[1];
var b = a.slice(arguments[2], arguments[3]);
return copyArrayProps(a, b);
}
var prim = Clazz._getParamCode(baseClass);
var dofill = true;
if (arguments.length < 4) {
// one-parameter option just for convenience, same as array(String, 0)
// two-parameter options for standard new foo[n],
// Array.newInstance(class, length), and
// Array.newInstance(class, [dim1, dim2, dim3....])
// three-parameter option for (Integer.TYPE, -1, [3, 4, 5])
var cl = arguments[0];
var baseClass = cl.__BASECLASS || cl;
var haveDims = (typeof arguments[1] == "number");
var vals = arguments[haveDims ? 2 : 1];
var ndims = (arguments.length == 1 ? 0 : !haveDims ? vals.length : arguments[1] || 0);
if (ndims < 0 && arguments.length == 2) {
return arrayClass(baseClass, -ndims);
}
if (ndims == 0) {
ndims = -1;
vals = [];
}
if (haveDims && ndims >= -1) {
if (ndims == -1) {
// new int[] {3, 4, 5};
return _array(baseClass, prim + "A", -1, vals);
}
// Array.newInstance(int[][].class, 3);
return _array(baseClass, prim + "A", (cl.__NDIM || 0) + 1, [ndims]);
}
params = vals;
paramType = prim;
for (var i = Math.abs(ndims); --i >= 0;) {
paramType += "A";
if (!haveDims && params[i] === null) {
params.length--;
dofill = false;
}
}
if (haveDims) {
// new int[][] { {0, 1, 2}, {3, 4, 5} , {3, 4, 5} , {3, 4, 5} };
return setArray(vals, baseClass, paramType, -ndims);
}
}
if (ndims < 0) {
params = [-1, params];
} else {
var initValue = null;
if (ndims >= 1 && dofill) {
switch (prim) {
case "B":
case "H": // short
case "I":
case "L":
case "F":
case "D":
initValue = 0;
break;
case "C":
initValue = '\0';
break;
case "Z":
initValue = false;
break;
}
}
params.push(initValue);
}
params.push(paramType);
var nbits = 0;
if (ndims != 0) {
switch (prim) {
case "B":
nbits = 8;
break;
case "H":
nbits = 16;
break;
case "I":
case "L":
nbits = 32;
break;
case "F":
case "D":
nbits = 64;
break;
}
}
return newTypedA(baseClass, params, nbits, (dofill ? ndims : -ndims), isClone);
}
Clazz.assert = function(clazz, obj, tf, msg) {
if (!clazz.$_ASSERT_ENABLED_)return;
var ok = true;
try {
ok = tf.apply(obj)
if (!ok)
msg = msg.apply(obj);
} catch (e) {
ok = false;
}
if (!ok) {
doDebugger();
if (Clazz._assertFunction) {
return Clazz._assertFunction(clazz, obj, msg || Clazz._getStackTrace());
}
Clazz.load("java.lang.AssertionError");
if (msg == null)
throw Clazz.new_(AssertionError.c$);
else
throw Clazz.new_(AssertionError.c$$S, [msg]);
}
}
Clazz.clone = function(me) {
// BH allows @j2sNative access without super constructor
if (me.__ARRAYTYPE) {
return appendMap(Clazz.array(me.__BASECLASS, me.__ARRAYTYPE, -1, me, true), me);
}
me = appendMap(new me.constructor(inheritArgs), me);
me.__JSID__ = ++_jsid;
return me;
}
/**sgurin
* Implements Java's keyword "instanceof" in JavaScript's way **for exception objects**.
*
* calls Clazz.instanceOf if e is a Java exception. If not, try to detect known native
* exceptions, like native NullPointerExceptions and wrap it into a Java exception and
* call Clazz.instanceOf again. if the native exception can't be wrapped, false is returned.
*
* @param obj the object to be tested
* @param clazz the class to be checked
* @return whether the object is an instance of the class
* @author: sgurin
*/
Clazz.exceptionOf = function(e, clazz) {
if (typeof clazz == "string")
clazz = Clazz.load(clazz);
if(e.__CLASS_NAME__)
return Clazz.instanceOf(e, clazz);
if (!e.getMessage) {
e.getMessage = function() {return "" + e};
}
if (!e.printStackTrace$) {
e.printStackTrace$ = function(){System.err.println$S(e + "\n" + this.stack)};
e.printStackTrace$java_io_PrintStream = function(stream){
stream.println$S(e + "\n" + e.stack);
};
//alert(e + " try/catch path:" + Clazz._getStackTrace(-10));
}
if(clazz == Error) {
if (("" + e).indexOf("Error") < 0)
return false;
System.err.println$O(Clazz._getStackTrace());
return true;
// everything here is a Java Exception, not a Java Error
}
return (clazz == Exception || clazz == Throwable
|| clazz == NullPointerException && _isNPEExceptionPredicate(e));
};
Clazz.forName = function(name, initialize, loader, isQuiet) {
// we need to consider loading a class from the path of the calling class.
var cl = null;
if (loader) {
try {
isQuiet = true;
var className = loader.baseClass.getName$(); // set in java.lang.Class.getClassLoader$()
var i = className.lastIndexOf(".");
var name1 = className.substring(0, i + 1) + name;
cl = Clazz._4Name(name1, null, null, false, initialize, true);
} catch (e) {}
}
return cl || Clazz._4Name(name, null, null, false, initialize, isQuiet);
}
Clazz.getClass = function(cl, methodList) {
// $Class$ is the java.lang.Class object wrapper
// $clazz$ is the unwrapped JavaScript object
cl = getClazz(cl) || cl;
if (cl.$Class$)
return cl.$Class$;
java.lang.Class || Clazz.load("java.lang.Class");
var Class_ = cl.$Class$ = new java.lang.Class();
Class_.$clazz$ = cl; // for arrays - a bit of a hack
Class_.$methodList$ = methodList;
return Class_;
}
/**
* Implements Java's keyword "instanceof" in JavaScript's way.
* Also alows for obj to be a class itself
*
* @param obj the object to be tested
* @param clazz the class to be checked
* @return whether the object is an instance of the class
*/
/* public */
Clazz.instanceOf = function (obj, clazz) {
// allows obj to be a class already, from arrayX.getClass().isInstance(y)
// unwrap java.lang.Class to JavaScript clazz using $clazz$
if (typeof clazz == "string") {
clazz = window[clazz];
}
if (obj == null || !clazz)
return false;
// check for object being a java.lang.Class and the other not
if (obj.$clazz$ && !clazz.$clazz$) return false;
obj.$clazz$ && (obj = obj.$clazz$);
clazz.$clazz$ && (clazz = clazz.$clazz$);
if (obj == clazz)
return true;
if (obj.__ARRAYTYPE || clazz.__ARRAYTYPE)
return (obj.__ARRAYTYPE == clazz.__ARRAYTYPE
|| obj.__ARRAYTYPE && clazz.__ARRAYTYPE && obj.__NDIM == clazz.__NDIM
&& isInstanceOf(obj.__BASECLASS, clazz.__BASECLASS));
return (obj instanceof clazz || isInstanceOf(getClassName(obj, true), clazz, true));
};
/**
* Load a class by name or an array representing a nested list of inner classes.
* Just finalize this class if from $clinit$.
*/
Clazz.load = function(cName, from$clinit$) {
if (!cName)
return null;
if (from$clinit$) {
// C$.$clinit$ call to finalize all dependencies
var cl = cName;
delete cl.$clinit$;
var ld = cl.$load$;
setSuperclass(cl, (ld && ld[0] ? Clazz.load(ld[0]) : null));
ld[1] && addInterface(cl, ld[1]);
delete cl.$load$;
return;
}
// allow for nested calling: ["foo",".foo_inner1",".foo_inner2"]
if (cName instanceof Array) {
var cl1 = null;
var name;
for (var i = 0; i < cName.length; i++) {
var cn = cName[i];
cl1 = Clazz.load(name = (cn.indexOf(".") == 0 ? name + cn : cn));
}
return cl1;
}
// allow for a clazz itself
if (cName.__CLASS_NAME__) {
var cl2 = cName;
cl2.$clinit$ && cl2.$clinit$();
return cl2;
}
// standard load of class by name
if (cName.indexOf("Thread.") == 0)
Clazz._4Name("java.lang.Thread", null, null, true)
if (cName.indexOf("Thread") == 0)
cName = "java.lang." + cName;
return Clazz._4Name(cName, null, null, true);
}
Clazz._newCount = 0;
/**
* Create a new instance of a class.
* Accepts:
* a string Clazz.new_("java.util.Hashtable")
* a clazz (has .__CLASS_NAME__ and a default contructor)
* a specific class constructor such as c$$S
* a constructor from a one class (c, anonymous constructor) and a class to create, cl
*
*/
Clazz.new_ = function(c, args, cl) {
if (!c)
return new Clazz._O();
var haveArgs = !!args;
args || (args = [[]]);
Clazz._newCount++;
var t0 = (_profileNew ? window.performance.now() : 0);
if (c.__CLASS_NAME__ && c.c$)
c = c.c$;
else if (typeof c == "string")
return Clazz.new_(Clazz.load(c));
// an inner class will attach arguments to the arguments returned
// Integer will be passed as is here, without c.exClazz, or cl
var clInner = cl;
cl = cl || c.exClazz || c;
cl.$clinit$ && cl.$clinit$();
var obj = new (Function.prototype.bind.apply(cl, arguments));
if (args[2] != inheritArgs) {
// cl.$init0$ && cl.$init0$.apply(obj);
if (haveArgs) {
c.apply(obj, args);
}
clInner && clInner.$init$.apply(obj);
}
_profileNew && addProfileNew(cl, window.performance.now() - t0);
return obj;
}
Clazz.newClass = function (prefix, name, clazz, clazzSuper, interfacez, type) {
if (J2S._debugCore) {
var qualifiedName = (prefix ? (prefix.__PKG_NAME__ || prefix.__CLASS_NAME__) + "." : "") + name;
checkDeclared(qualifiedName, type);
}
clazz || (clazz = function () {Clazz.newInstance(this,arguments,0,clazz)});
clazz.__NAME__ = name;
// prefix class means this is an inner class, and $this$0 refers to the outer class.
// no prefix class but a super class that is an inner class, then $this$0 refers to its $this$0.
// there can be a conflict here.
prefix.__CLASS_NAME__ && (clazz.$this$0 = prefix.__CLASS_NAME__) || clazzSuper && clazzSuper.$this$0 && (clazz.$this$0 = clazzSuper.$this$0);
clazz.$load$ = [clazzSuper, interfacez];
clazz.$isEnum = clazzSuper == 'Enum';
// get qualifed name, and for inner classes, the name to use to refer to this
// class in the synthetic reference array b$[].
var qName, bName;
if (!prefix) {
// e.g. Clazz.declareInterface (null, "ICorePlugin", org.eclipse.ui.IPlugin);
qName = name;
Clazz.setGlobal(name, clazz);
} else if (prefix.__PKG_NAME__) {
// e.g. Clazz.declareInterface (org.eclipse.ui, "ICorePlugin", org.eclipse.ui.IPlugin);
qName = prefix.__PKG_NAME__ + "." + name;
prefix[name] = clazz;
if (prefix === java.lang) {
Clazz.setGlobal(name, clazz);
}
} else {
// is an inner class
qName = prefix.__CLASS_NAME__ + "." + name;
bName = prefix.__CLASS_NAME__ + "$" + name;
prefix[name] = clazz;
}
finalizeClazz(clazz, qName, bName, type, false);
// for (var i = minimalObjNames.length; --i >= 0;) {
// var name = minimalObjNames[i];
// clazz[name] = objMethods[name];
// }
Clazz.setGlobal(qName, clazz);
return clazz;
};
Clazz.newEnumConst = function(vals, c, enumName, enumOrdinal, args, cl) {
var clazzEnum = c.exClazz;
var e = clazzEnum.$init$$ || (clazzEnum.$init$$ = clazzEnum.$init$);
clazzEnum.$init$ = function() {e.apply(this); this.name = this.$name = enumName; this.ordinal = enumOrdinal;this.$isEnumConst = true;}
vals.push(clazzEnum[enumName] = clazzEnum.prototype[enumName] = Clazz.new_(c, args, cl));
}
Clazz.newInstance = function (objThis, args, isInner, clazz) {
if (args && (
args[0] == inheritArgs
|| args[1] == inheritArgs
|| args[2] == inheritArgs
)) {
// Just declaring a class, not creating an instance or doing field preparation.
// That is, we are just generating the prototypes for this method using new superClass()
return;
}
if (objThis.__VAL0__) {
// Integer, Long, Byte, Float, Double
// .instantialize(val)
objThis.valueOf = function () {
return this;
};
}
objThis.__JSID__ = ++_jsid;
if (!isInner) {
clazz && clazz.$clinit$ && clazz.$clinit$();
clazz && clazz.$init0$ && clazz.$init0$.apply(objThis);
if ((!args || args.length == 0) && objThis.c$) {
// allow for direct default call "new foo()" to run with its default constructor
objThis.c$.apply(objThis);
args && (args[2] = Clazz.inheritArgs)
}
return;
}
// args[0] = outerObject
// args[1] = b$ array
// args[2-n] = actual arguments
var outerObj = shiftArray(args, 0, 1);
var finalVars = shiftArray(args, 0, 1);
var haveFinals = (finalVars || outerObj && outerObj.$finals$);
if (!outerObj || !objThis)
return;
var clazz1 = getClazz(outerObj);
if (clazz1 == outerObj) {
outerObj = objThis;
}
if (haveFinals) {
// f$ is short for the once-chosen "$finals$"
var of$ = outerObj.$finals$;
objThis.$finals$ = (finalVars ?
(of$ ? appendMap(appendMap({}, of$), finalVars) : finalVars)
: of$ ? of$ : null);
}
// BH: For efficiency: Save the b$ array with the OUTER class as $b$,
// as its keys are properties of it and can be used again.
var b = outerObj.$b$;
var isNew = false;
var innerName = getClassName(objThis, true);
if (!b) {
b = outerObj.b$;
// Inner class of an inner class must inherit all outer object references. Note that this
// can cause conflicts. For example, b$["java.awt.Component"] could refer to the wrong
// object if I did this wrong.
//
if (!b) {
// the outer class is not itself an inner class - start a new map
b = {};
isNew = true;
} else if (b["$ " + innerName]) {
// this inner class is already in the map pointing to a different object. Clone the map.
b = appendMap({},b);
isNew = true;
}
// add all superclass references for outer object
addB$Keys(clazz1, isNew, b, outerObj, objThis);
}
var clazz2 = (clazz.superclazz == clazz1 ? null : clazz.superclazz || null);
if (clazz2) {
// we have an inner object that subclasses a different object
// clone the map and overwrite with the correct values
b = appendMap({},b);
addB$Keys(clazz2, true, b, objThis, objThis);
} else if (isNew) {
// it is new, save this map with the OUTER object as $b$
// 12018.12.20 but only if it is clean
outerObj.$b$ = b;
}
// final objective: save this map for the inner object
// add a flag to disallow any other same-class use of this map.
b["$ " + innerName] = 1;
objThis.b$ = b;
clazz.$this$0 && (objThis.this$0 = b[clazz.$this$0]);
clazz.$clinit$ && clazz.$clinit$();
clazz.$init0$ && clazz.$init0$.apply(objThis);
};
var addB$Keys = function(clazz, isNew, b, outerObj, objThis) {
var cl = clazz;
do {
var key = getClassName(cl, true);
if (!isNew && b[key])
break;
b[key] = outerObj;
if (key.indexOf("java.lang.") == 0)
b[key.substring(10)] = outerObj;
if (cl.implementz) {
var impl = cl.implementz;
for (var i = impl.length; --i >= 0;) {
var key = getClassName(impl[i], true);
if (isNew || !b[key]) {
b[key] = outerObj;
if (key.indexOf("java.lang.") == 0)
b[key.substring(10)] = outerObj;
}
}
}
} while ((cl = cl.superclazz));
};
/**
// arg1 is the package name
// arg2 is the full class name in quotes
// arg3 is the class definition function, C$, which is called in Clazz.new_().
// arg4 is the superclass
// arg5 is the superinterface(s)
// arg6 is the type: anonymous(1), local(2), or absent
*/
Clazz.newInterface = function (prefix, name, _null1, _null2, interfacez, _0) {
return Clazz.newClass(prefix, name, function(){}, null, interfacez, 0);
};
// An interesting idea, but too complicated, and probably not that effective anyway.
//var lambdaCache = {};
//Clazz.newLambda = function(fc, m, lambdaType) {
// var key = (fc.__CLASS_NAME__ || fc) + "." + (m||0) + "." + lambdaType;
// var ret = lambdaCache[key];
// if (ret)
// return ret;
// // creates a new functional interface
// // fc is either an executable method from i -> fc() or a class or object from Class::meth
// // m is the method name
// // lambdaType is 'S', 'F', 'C', or 'P' (Supplier, Function, Consumer, or Predicate)
// // note that we should be taking into account Boolean,Int,Double,Long here, and
// // we are not fully elaborating the classes. For example getClass() does not work here.
// var fAction;
// if (m) { // Lambda_M
// var g = fc[m];
// var f = g||fc.prototype[m];
// fAction = function(t) {return f.apply(f == g ? fc : t,[t])};
// } else { // Lambda_E, Lambda_S, Lambda_C, Lambda_T
// fAction = fc;
// }
// switch(lambdaType) {
// case 'S':
// ret = {get$: fAction,
// __CLASS_NAME__:"java_util_function_Supplier"
// };
// // this is a rough-in
// ret.getAsBoolean$ = ret.getAsDouble$ = ret.getAsInt$ = ret.getAsLong$ = ret.get$;
// break;
// case 'C':
// ret = {accept$: fAction,
// andThen$java_util_function_Function: function(after) {
// if (!after) throw new NullPointerException();
// return function(t,u) { fAction(t,u); after.accept$(t,u);}
// },
// __CLASS_NAME__:"java_util_function_Consumer"
// };
// break;
// case 'F':
// ret = {
// apply$: fAction,
// andThen$java_util_function_Function: function(after) {
// if (!after) throw new NullPointerException();
// return function(t,u) { return after.apply$(fAction(t,u));}
// },
// compose$java_util_function_Function: function(before) {
// if (!before) throw new NullPointerException();
// return function(t,u) { return fAction(before.apply$(t,u));}
// },
// identity$: function(t) { return t},
// __CLASS_NAME__:"java_util_function_Function"
// };
// break;
// case 'P':
// ret = {test$: fAction,
// and$java_util_function_predicate: function(other) {
// if (!other) throw new NullPointerException();
// return function(t,u) { return fAction(t,u) && other.test$(t,u);}
// },
// or$java_util_function_predicate: function(other) {
// if (!other) throw new NullPointerException();
// return function(t,u) { return fAction(t,u) || other.test$(t,u);}
// },
// negate$: function() {
// return function(t,u) { return !fAction(t,u) }
// },
// isEqual$O: function(target) {
// return function(t) { return (target == null) == (t == null)
// && (t == null || t.equals$O(target));}
// },
// __CLASS_NAME__:"java_util_function_Predicate"
// };
// break;
// }
//
// return lambdaCache[key] = ret;
//};
var __allowOverwriteClass = true;
Clazz.newMeth = function (clazzThis, funName, funBody, modifiers) {
if (!__allowOverwriteClass && clazzThis.prototype[funName])
return;
// modifiers: 1: static, 2: native, p3 -- private holder
if (arguments.length == 1) {
return Clazz.newMeth(clazzThis, 'c$', function(){
Clazz.super_(clazzThis, this,1);
clazzThis.$init$.apply(this);
}, 1);
}
if (funName.constructor == Array) {
// If funName is an array, we are setting aliases for generic calls.
// For example: ['compareTo$S', 'compareTo$TK', 'compareTo$TA']
// where K and A are generic types that are from a class
* _Loader.packageClasspath ("org.eclipse.swt", "...", true);
* _Loader.packageClasspath ("java", "...", true);
*
* which is not recommended. But _Loader should try to adjust orders
* which requires "java" to be declared before normal _Loader
* #packageClasspath call before that line! And later that line
* should never initialize "java/package.js" again!
*/
var isPkgDeclared = (isIndex && map["@" + pkg]);
if (mode == 0 && isIndex && !map["@java"] && pkg.indexOf ("java") != 0 && needPackage("java")) {
_Loader.loadPackage("java", fSuccess ? function(_package){_Loader.loadPackageClasspath(pkg, base, isIndex, fSuccess, 1)} : null);
if (fSuccess)
return;
}
if (pkg instanceof Array) {
unwrapArray(pkg);
if (fSuccess) {
if (pt < pkg.length)
_Loader.loadPackageClasspath(pkg[pt], base, isIndex, function(_loadPackageClassPath){_Loader.loadPackageClasspath(pkg, base, isIndex, fSuccess, 1, pt + 1)}, 1);
else
fSuccess();
} else {
for (var i = 0; i < pkg.length; i++)
_Loader.loadPackageClasspath(pkg[i], base, isIndex, null);
}
return;
}
switch (pkg) {
case "java.*":
pkg = "java";
// fall through
case "java":
if (base) {
// support ajax for default
var key = "@net.sf.j2s.ajax";
if (!map[key])
map[key] = base;
key = "@net.sf.j2s";
if (!map[key])
map[key] = base;
}
break;
case "swt":
pkg = "org.eclipse.swt";
break;
case "ajax":
pkg = "net.sf.j2s.ajax";
break;
case "j2s":
pkg = "net.sf.j2s";
break;
default:
if (pkg.lastIndexOf(".*") == pkg.length - 2)
pkg = pkg.substring(0, pkg.length - 2);
break;
}
if (base) // critical for multiple applets
map["@" + pkg] = base;
if (isIndex && !isPkgDeclared && !window[pkg + ".registered"]) {
//pkgRefCount++;
if (pkg == "java")
pkg = "core" // JSmol -- moves java/package.js to core/package.js
_Loader.loadClass(pkg + ".package", function () {
//if (--pkgRefCount == 0)
//runtimeLoaded();
//fSuccess && fSuccess();
}, true, true, 1);
return;
}
fSuccess && fSuccess();
};
/**
* BH: allows user/developer to load classes even though wrapping and Google
* Closure Compiler has not been run on the class.
*
*
*
*/
Clazz.loadClass = function (name, onLoaded, async) {
if (!self.Class) {
Class = Clazz;
Class.forName = Clazz.forName;
// maybe more here
}
if (!name)
return null;
if (!async)
return Clazz.load(name);
_Loader.loadClass(name, function() {
var cl = Clazz.allClasses[name];
cl && cl.$load$ && cl.$load$();
onLoaded(cl);
}, true, async, 1);
return true;
}
/**
* Load the given class ant its related classes.
*/
/* public */
_Loader.loadClass = _Loader.prototype.loadClass = function (name, onLoaded, forced, async, mode) {
mode || (mode = 0); // BH: not implemented
(async == null) && (async = false);
if (typeof onLoaded == "boolean")
return evalType(name);
//System.out.println("loadClass " + name)
var path = _Loader.getClasspathFor(name);
lastLoaded = name;
Clazz.ClassFilesLoaded.push(name.replace(/\./g,"/") + ".js");
Clazz.loadScript(path);//(n, n.path, n.requiredBy, false, onLoaded ? function(_loadClass){ isLoadingEntryClass = bSave; onLoaded()}: null);
}
/* private */
_Loader.loadPackage = function(pkg, fSuccess) {
fSuccess || (fSuccess = null);
window[pkg + ".registered"] = false;
_Loader.loadPackageClasspath(pkg,
(_Loader.J2SLibBase || (_Loader.J2SLibBase = (_Loader.getJ2SLibBase() || "j2s/"))),
true, fSuccess);
};
/**
* Register classes to a given *.z.js path, so only a single *.z.js is loaded
* for all those classes.
*/
/* public */
_Loader.jarClasspath = function (jar, clazzes) {
if (!(clazzes instanceof Array))
clazzes = [clazzes];
unwrapArray(clazzes);
if (J2S._debugCore)
jar = jar.replace(/\.z\./, ".")
for (var i = clazzes.length; --i >= 0;) {
clazzes[i] = clazzes[i].replace(/\//g,".").replace(/\.js$/g,"")
classpathMap["#" + clazzes[i]] = jar;
}
classpathMap["$" + jar] = clazzes;
};
_Loader.setClasspathFor = function(clazzes) {
// Clazz._Loader.setClasspathFor("edu/colorado/phet/idealgas/model/PressureSensingBox.ChangeListener");
if (!(clazzes instanceof Array))
clazzes = [clazzes];
for (var i = clazzes.length; --i >= 0;) {
path = clazzes[i];
var jar = _Loader.getJ2SLibBase() + path.split(".")[0]+".js";
path = path.replace(/\//g,".");
classpathMap["#" + path] = jar;
var a = classpathMap["$" + jar] || (classpathMap["$" + jar] = []);
a.push(path);
}
}
/**
* Usually be used in .../package.js. All given packages will be registered
* to the same classpath of given prefix package.
*/
/* public */
_Loader.registerPackages = function (prefix, pkgs) {
//_Loader.checkInteractive ();
var base = _Loader.getClasspathFor (prefix + ".*", true);
for (var i = 0; i < pkgs.length; i++) {
if (window["Clazz"]) {
Clazz.newPackage(prefix + "." + pkgs[i]);
}
_Loader.loadPackageClasspath (prefix + "." + pkgs[i], base);
}
};
/**
* Return the *.js path of the given class. Maybe the class is contained
* in a *.z.js jar file.
* @param clazz Given class that the path is to be calculated for. May
* be java.package, or java.lang.String
* @param forRoot Optional argument, if true, the return path will be root
* of the given classs' package root path.
* @param ext Optional argument, if given, it will replace the default ".js"
* extension.
*/
/* public */
_Loader.getClasspathFor = function (clazz, forRoot, ext) {
var path = classpathMap["#" + clazz];
if (!path || forRoot || ext) {
var base;
var idx;
if (path) {
clazz = clazz.replace(/\./g, "/");
if ((idx = path.lastIndexOf(clazz)) >= 0
|| (idx = clazz.lastIndexOf("/")) >= 0
&& (idx = path.lastIndexOf(clazz.substring(0, idx))) >= 0)
base = path.substring(0, idx);
} else {
idx = clazz.length + 2;
while ((idx = clazz.lastIndexOf(".", idx - 2)) >= 0)
if ((base = classpathMap["@" + clazz.substring(0, idx)]))
break;
if (!forRoot)
clazz = clazz.replace (/\./g, "/");
}
if (base == null) {
var bins = "binaryFolders";
base = (window["Clazz"] && Clazz[bins] && Clazz[bins].length ? Clazz[bins][0]
: _Loader[bins] && _Loader[bins].length ? _Loader[bins][0]
: "j2s");
}
path = (base.lastIndexOf("/") == base.length - 1 ? base : base + "/") + (forRoot ? ""
: clazz.lastIndexOf("/*") == clazz.length - 2 ? clazz.substring(0, idx + 1)
: clazz + (!ext ? ".js" : ext.charAt(0) != '.' ? "." + ext : ext));
}
return path;//_Loader.multipleSites(path);
};
/**
* page-customizable callbacks
*
*/
/* public */
_Loader.onScriptLoading = function (file){Clazz._quiet || System.out.println("Classloader.onscriptloading " + file);};
/* public */
_Loader.onScriptLoaded = function (file, isError, data){};
/* public */
_Loader.onScriptInitialized = function (file){}; // not implemented
/* public */
_Loader.onScriptCompleted = function (file){}; // not implemented
/* public */
_Loader.onClassUnloaded = function (clazz){}; // not implemented
/* private */
var isClassExcluded = function (clazz) {
return excludeClassMap["@" + clazz];
};
/* Used to keep ignored classes */
/* private */
var excludeClassMap = {};
Clazz._lastEvalError = null;
/* private */
var evaluate = function(file, js) {
try {
eval(js + ";//# sourceURL="+file);
} catch (e) {
var s = "[Java2Script] The required class file \n\n" + file + (js.indexOf("data: no") ?
"\nwas not found.\n"
: "\ncould not be loaded. Script error: " + e.message + " \n\ndata:\n\n" + js) + "\n\n"
+ (e.stack ? e.stack : Clazz._getStackTrace());
Clazz._lastEvalError = s;
if (Clazz._isQuiet)
return;
Clazz.alert(s);
throw e;
}
}
Clazz._4Name = function(clazzName, applet, state, asClazz, initialize, isQuiet) {
if (clazzName.indexOf("[") == 0)
return getArrayClass(clazzName);
if (clazzName.indexOf(".") < 0)
clazzName = "java.lang." + clazzName;
var isok = Clazz._isClassDefined(clazzName);
if (isok && asClazz) {
var cl1 = Clazz.allClasses[clazzName];
cl1.$clinit$ && cl1.$clinit$();
return cl1;
}
if (!isok) {
var name2 = null;
if (clazzName.indexOf("$") >= 0) {
// BH we allow Java's java.swing.JTable.$BooleanRenderer as a stand-in for java.swing.JTable.BooleanRenderer
// when the static nested class is created using declareType
name2 = clazzName.replace(/\$/g,".");
if (Clazz._isClassDefined(name2)) {
clazzName = name2;
} else {
name2 = null;
}
}
if (name2 == null) {
var f = (J2S._isAsync && applet ? applet._restoreState(clazzName, state) : null);
if (f == 1)
return null; // must be already being created
if (_Loader.setLoadingMode(f ? _Loader.MODE_SCRIPT : "xhr.sync")) {
_Loader.loadClass(clazzName, f, false, true, 1);
return null; // this will surely throw an error, but that is OK
}
//alert ("Using Java reflection: " + clazzName + " for " + applet._id + " \n"+ Clazz._getStackTrace());
_Loader.loadClass(clazzName);
}
}
var cl = evalType(clazzName);
if (!cl){
if (isQuiet || Clazz._isQuiet)
return null;
alert(clazzName + " could not be loaded");
doDebugger();
}
Clazz.allClasses[clazzName] = cl;
if (initialize !== false)
cl.$clinit$ && cl.$clinit$();
return (asClazz ? cl : Clazz.getClass(cl));
};
/**
* BH: possibly useful for debugging
*/
Clazz.currentPath= "";
Clazz.loadScript = function(file) {
Clazz.currentPath = file;
//loadedScripts[file] = true;
// also remove from queue
//removeArrayItem(classQueue, file);
var file0 = file;
if (Clazz._debugging) {
file = file.replace(/\.z\.js/,".js");
}
var data = "";
try{
_Loader.onScriptLoading(file);
data = J2S.getFileData(file);
evaluate(file, data);
_Loader.onScriptLoaded(file, null, data);
}catch(e) {
_Loader.onScriptLoaded(file, e, data);
var s = ""+e;
if (data.indexOf("Error") >= 0)
s = data;
if (s.indexOf("missing ] after element list")>= 0)
s = "File not found";
if (file.indexOf("/j2s/core/") >= 0) {
System.out.println(s + " loading " + file);
} else {
alert(s + " loading file " + file + "\n\n" + e.stack);
doDebugger()
}
}
}
/**
* Used in package
/* public */
var runtimeKeyClass = _Loader.runtimeKeyClass = "java.lang.String";
/* private */
var J2sLibBase;
/**
* Return J2SLib base path from existed SCRIPT src attribute.
*/
/* public */
_Loader.getJ2SLibBase = function () {
var o = window["j2s.lib"];
return (o ? o.base + (o.alias == "." ? "" : (o.alias ? o.alias : (o.version ? o.version : "1.0.0")) + "/") : null);
};
/**
* Indicate whether _Loader is loading script synchronously or
* asynchronously.
*/
/* private */
var isAsynchronousLoading = true;
/* private */
var isUsingXMLHttpRequest = false;
/* private */
var loadingTimeLag = -1;
_Loader.MODE_SCRIPT = 4;
_Loader.MODE_XHR = 2;
_Loader.MODE_SYNC = 1;
/**
* String mode:
* asynchronous modes:
* async(...).script, async(...).xhr, async(...).xmlhttprequest,
* script.async(...), xhr.async(...), xmlhttprequest.async(...),
* script
*
* synchronous modes:
* sync(...).xhr, sync(...).xmlhttprequest,
* xhr.sync(...), xmlhttprequest.sync(...),
* xmlhttprequest, xhr
*
* Integer mode:
* Script 4; XHR 2; SYNC bit 1;
*/
/* public */
_Loader.setLoadingMode = function (mode, timeLag) {
var async = true;
var ajax = true;
if (typeof mode == "string") {
mode = mode.toLowerCase();
if (mode.indexOf("script") >= 0)
ajax = false;
else
async = (mode.indexOf("async") >=0);
async = false; // BH
} else {
if (mode & _Loader.MODE_SCRIPT)
ajax = false;
else
async = !(mode & _Loader.MODE_SYNC);
}
isUsingXMLHttpRequest = ajax;
isAsynchronousLoading = async;
loadingTimeLag = (async && timeLag >= 0 ? timeLag: -1);
return async;
};
/*
* Load those key *.z.js. This *.z.js will be surely loaded before other
* queued *.js.
*/
/* public */
_Loader.loadZJar = function (zjarPath, keyClass) {
// used only by package.js for core.z.js
var f = null;
var isArr = (keyClass instanceof Array);
if (isArr)
keyClass = keyClass[keyClass.length - 1];
// else
// f = (keyClass == runtimeKeyClass ? runtimeLoaded : null);
_Loader.jarClasspath(zjarPath, isArr ? keyClass : [keyClass]);
// BH note: runtimeKeyClass is java.lang.String
_Loader.loadClass(keyClass, null, true);
};
Clazz.binaryFolders = _Loader.binaryFolders = [ _Loader.getJ2SLibBase() ];
})(Clazz, Clazz._Loader);
//}
/******************************************************************************
* Copyright (c) 2007 java2script.org and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Zhou Renjian - initial API and implementation
*****************************************************************************/
/*******
* @author zhou renjian
* @create Jan 11, 2007
*******/
Clazz._LoaderProgressMonitor = {};
;(function(CLPM, J2S) {
var fadeOutTimer = null;
var fadeAlpha = 0;
var monitorEl = null;
var lastScrollTop = 0;
var bindingParent = null;
CLPM.DEFAULT_OPACITY = (J2S && J2S._j2sLoadMonitorOpacity ? J2S._j2sLoadMonitorOpacity : 55);
/* public */
CLPM.hideMonitor = function () {
monitorEl.style.display = "none";
}
/* public */
CLPM.showStatus = function (msg, fading) {
if (!monitorEl) {
createHandle ();
if (!attached) {
attached = true;
//Clazz.addEvent (window, "unload", cleanup);
// window.attachEvent ("onunload", cleanup);
}
}
clearChildren(monitorEl);
if (msg == null) {
if (fading) {
fadeOut();
} else {
CLPM.hideMonitor();
}
return;
}
monitorEl.appendChild(document.createTextNode ("" + msg));
if (monitorEl.style.display == "none") {
monitorEl.style.display = "";
}
setAlpha(CLPM.DEFAULT_OPACITY);
var offTop = getFixedOffsetTop();
if (lastScrollTop != offTop) {
lastScrollTop = offTop;
monitorEl.style.bottom = (lastScrollTop + 4) + "px";
}
if (fading) {
fadeOut();
}
};
/* private static */
var clearChildren = function (el) {
if (!el)
return;
for (var i = el.childNodes.length; --i >= 0;) {
var child = el.childNodes[i];
if (!child)
continue;
if (child.childNodes && child.childNodes.length)
clearChildren (child);
try {
el.removeChild (child);
} catch (e) {};
}
};
/* private */
var setAlpha = function (alpha) {
if (fadeOutTimer && alpha == CLPM.DEFAULT_OPACITY) {
window.clearTimeout (fadeOutTimer);
fadeOutTimer = null;
}
fadeAlpha = alpha;
//monitorEl.style.filter = "Alpha(Opacity=" + alpha + ")";
monitorEl.style.opacity = alpha / 100.0;
};
/* private */
var hidingOnMouseOver = function () {
CLPM.hideMonitor();
};
/* private */
var attached = false;
/* private */
var cleanup = function () {
//if (monitorEl) {
// monitorEl.onmouseover = null;
//}
monitorEl = null;
bindingParent = null;
//Clazz.removeEvent (window, "unload", cleanup);
//window.detachEvent ("onunload", cleanup);
attached = false;
};
/* private */
var createHandle = function () {
var div = document.createElement ("DIV");
div.id = "_Loader-status";
div.style.cssText = "position:absolute;bottom:4px;left:4px;padding:2px 8px;"
+ "z-index:" + (window["j2s.lib"].monitorZIndex || 10000) + ";background-color:#8e0000;color:yellow;"
+ "font-family:Arial, sans-serif;font-size:10pt;white-space:nowrap;";
div.onmouseover = hidingOnMouseOver;
monitorEl = div;
if (bindingParent) {
bindingParent.appendChild(div);
} else {
document.body.appendChild(div);
}
return div;
};
/* private */
var fadeOut = function () {
if (monitorEl.style.display == "none") return;
if (fadeAlpha == CLPM.DEFAULT_OPACITY) {
fadeOutTimer = window.setTimeout(function () {
fadeOut();
}, 750);
fadeAlpha -= 5;
} else if (fadeAlpha - 10 >= 0) {
setAlpha(fadeAlpha - 10);
fadeOutTimer = window.setTimeout(function () {
fadeOut();
}, 40);
} else {
monitorEl.style.display = "none";
}
};
/* private */
var getFixedOffsetTop = function (){
if (bindingParent) {
var b = bindingParent;
return b.scrollTop;
}
var dua = navigator.userAgent;
var b = document.body;
var p = b.parentNode;
var pcHeight = p.clientHeight;
var bcScrollTop = b.scrollTop + b.offsetTop;
var pcScrollTop = p.scrollTop + p.offsetTop;
return (dua.indexOf("Opera") < 0 && document.all ? (pcHeight == 0 ? bcScrollTop : pcScrollTop)
: dua.indexOf("Gecko") < 0 ? (pcHeight == p.offsetHeight
&& pcHeight == p.scrollHeight ? bcScrollTop : pcScrollTop) : bcScrollTop);
};
/* not used in Jmol
if (window["ClazzLoader"]) {
_Loader.onScriptLoading = function(file) {
CLPM.showStatus("Loading " + file + "...");
};
_Loader.onScriptLoaded = function(file, isError) {
CLPM.showStatus(file + (isError ? " loading failed." : " loaded."), true);
};
_Loader.onGlobalLoaded = function(file) {
CLPM.showStatus("Application loaded.", true);
};
_Loader.onClassUnloaded = function(clazz) {
CLPM.showStatus("Class " + clazz + " is unloaded.", true);
};
}
*/
})(Clazz._LoaderProgressMonitor, J2S);
//}
/******************************************************************************
* Copyright (c) 2007 java2script.org and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Zhou Renjian - initial API and implementation
*****************************************************************************/
/*******
* @author zhou renjian
* @create Nov 5, 2005
*******/
Clazz.Console = {};
;(function(Con) {
/**
* Setting maxTotalLines to -1 will not limit the console result
*/
Con.maxTotalLines = 10000;
Con.setMaxTotalLines = function (lines) {
Con.maxTotalLines = (lines > 0 ? lines : 999999);
}
Con.maxLatency = 40;
Con.setMaxLatency = function (latency) {
Con.maxLatency = (latency > 0 ? latency : 40);
};
Con.pinning = false;
Con.enablePinning = function (enabled) {
Con.pinning = enabled;
};
Con.linesCount = 0;
Con.metLineBreak = false;
/*
* Give an extension point so external script can create and bind the console
* themself.
*
* TODO: provide more template of binding console window to browser.
*/
/* protected */
Con.createConsoleWindow = function (parentEl) {
var console = document.createElement ("DIV");
console.style.cssText = "font-family:monospace, Arial, sans-serif;";
document.body.appendChild (console);
return console;
};
var c160 = String.fromCharCode(160); //nbsp;
c160 += c160+c160+c160;
Con.consoleOutput = function (s, color) {
var o = window["j2s.lib"];
var con = (o && o.console);
if (!con) {
return false; // BH this just means we have turned off all console action
}
if (con == window.console) {
if (color == "red")
con.err(s);
else
con.log(s);
return;
}
if (con && typeof con == "string")
con = document.getElementById(con)
if (Con.linesCount > Con.maxTotalLines) {
for (var i = 0; i < Con.linesCount - Con.maxTotalLines; i++) {
if (con && con.childNodes.length > 0) {
con.removeChild (con.childNodes[0]);
}
}
Con.linesCount = Con.maxTotalLines;
}
var willMeetLineBreak = false;
s = (typeof s == "undefined" ? "" : s == null ? "null" : "" + s);
s = s.replace (/\t/g, c160);
if (s.length > 0)
switch (s.charAt(s.length - 1)) {
case '\n':
case '\r':
s = (s.length > 1 ? s.substring (0, s.length - (s.charAt(s.length - 2) == '\r' ? 2 : 1)) : "");
willMeetLineBreak = true;
break;
}
var lines = null;
s = s.replace (/\t/g, c160);
lines = s.split(/\r\n|\r|\n/g);
for (var i = 0, last = lines.length - 1; i <= last; i++) {
var lastLineEl = null;
if (Con.metLineBreak || Con.linesCount == 0
|| con.childNodes.length < 1) {
lastLineEl = document.createElement ("DIV");
con.appendChild (lastLineEl);
lastLineEl.style.whiteSpace = "nowrap";
Con.linesCount++;
} else {
try {
lastLineEl = con.childNodes[con.childNodes.length - 1];
} catch (e) {
lastLineEl = document.createElement ("DIV");
con.appendChild (lastLineEl);
lastLineEl.style.whiteSpace = "nowrap";
Con.linesCount++;
}
}
var el = document.createElement ("SPAN");
lastLineEl.appendChild (el);
el.style.whiteSpace = "nowrap";
if (color)
el.style.color = color;
var l = lines[i]
if (l.length == 0)
l = c160;
el.appendChild(document.createTextNode(l));
if (!Con.pinning)
con.scrollTop += 100;
Con.metLineBreak = (i != last || willMeetLineBreak);
}
var cssClazzName = con.parentNode.className;
if (!Con.pinning && cssClazzName
&& cssClazzName.indexOf ("composite") != -1) {
con.parentNode.scrollTop = con.parentNode.scrollHeight;
}
Con.lastOutputTime = new Date ().getTime ();
};
/*
* Clear all contents inside the console.
*/
/* public */
Con.clear = function () {
try {
Con.metLineBreak = true;
var o = window["j2s.lib"];
var console = o && o.console;
if (!console || !(console = document.getElementById (console)))
return;
console.innerHTML = "";
Con.linesCount = 0;
} catch(e){};
};
/* public */
Clazz.alert = function (s) {
Con.consoleOutput (s + "\r\n");
};
})(Clazz.Console);
Clazz._setDeclared("java.lang.System",
java.lang.System = System = {
props : null, //new java.util.Properties (),
$props : {},
arraycopy$O$I$O$I$I : function (src, srcPos, dest, destPos, length) {
if (src !== dest || srcPos > destPos) {
for (var i = length; --i >= 0;)
dest[destPos++] = src[srcPos++];
} else {
destPos += length;
srcPos += length;
for (var i = length; --i >= 0;)
src[--destPos] = src[--srcPos];
}
},
currentTimeMillis$ : function () {
return new Date ().getTime ();
},
exit$ : function() {
swingjs.JSToolkit && swingjs.JSToolkit.exit$()
},
gc$ : function() {}, // bh
getProperties$ : function () {
return System.props;
},
getProperty$S$S : function (key, def) {
if (System.props)
return System.props.getProperty$S$S (key, def);
var v = System.$props[key];
if (typeof v != "undefined")
return v;
if (key.indexOf(".") > 0) {
v = null;
switch (key) {
case "java.awt.printerjob":
v = "swingjs.JSPrinterJob";
break;
case "java.class.version":
v = "50";
break;
case "user.home":
v = "https://.";
break;
case "java.vendor":
v = "SwingJS/OpenJDK";
break;
case "java.version":
v = "1.6-1.8";
break;
case "file.separator":
case "path.separator":
v = "/";
break;
case "line.separator":
v = (navigator.userAgent.indexOf("Windows") >= 0 ? "\r\n" : "\n");
break;
case "os.name":
case "os.version":
v = navigator.userAgent;
break;
case "javax.xml.datatype.DatatypeFactory":
v = "org.apache.xerces.jaxp.datatype";
break;
case "javax.xml.bind.JAXBContextFactory":
v = "swingjs.xml.JSJAXBContextFactory";
break;
}
if (v)
return System.$props[key] = v;
}
return (arguments.length == 1 ? null : def == null ? key : def); // BH
},
getSecurityManager$ : function() { return null }, // bh
identityHashCode$O : function(obj){return obj==null ? 0 : obj._$hashcode || (obj._$hashcode = ++hashCode)},
lineSeparator$ : function() { return '\n' }, // bh
nanoTime$: function() {
return Math.round(window.performance.now() * 1e6)
},
setProperties$java_util_Properties : function (props) {
System.props = props;
},
setProperty$S$S : function (key, val) {
if (!System.props)
return System.$props[key] = val; // BH
System.props.setProperty (key, val);
}
});
;(function(Con, Sys) {
Sys.getProperty$S = Sys.getProperty$S$S;
Sys.exit$I = Sys.exit$;
Sys.out = new Clazz._O ();
Sys.out.__CLASS_NAME__ = "java.io.PrintStream";
Sys.out.print = Sys.out.print$O = Sys.out.print$Z = Sys.out.print$I = Sys.out.println$J = Sys.out.print$S = Sys.out.print$C = Sys.out.print = function (s) {
Con.consoleOutput (s);
};
Sys.out.printf = Sys.out.printf$S$OA = Sys.out.format = Sys.out.format$S$OA = function (f, args) {
Sys.out.print(String.format$S$OA.apply(null, arguments));
}
Sys.out.flush$ = function() {}
Sys.out.println = Sys.out.println$ = Sys.out.println$O = Sys.out.println$Z = Sys.out.println$I = Sys.out.println$J = Sys.out.println$S = Sys.out.println$C = function(s) {
s = (typeof s == "undefined" ? "" : "" + s);
if (Clazz._nooutput || Clazz._traceFilter && s.indexOf(Clazz._traceFilter) < 0) return;
if (!Clazz._traceFilter && Clazz._traceOutput && s && (s.indexOf(Clazz._traceOutput) >= 0 || '"' + s + '"' == Clazz._traceOutput)) {
alert(s + "\n\n" + Clazz._getStackTrace());
doDebugger();
}
Con.consoleOutput(typeof s == "undefined" ? "\r\n" : s == null ? s = "null\r\n" : s + "\r\n");
};
Sys.out.println$F = Sys.out.println$D = function(f) {var s = "" + f; Sys.out.println(s.indexOf(".") < 0 && s.indexOf("Inf") < 0 ? s + ".0" : s)};
Sys.out.write$BA$I$I = function (buf, offset, len) {
Sys.out.print(String.instantialize(buf).substring(offset, offset+len));
};
Sys.err = new Clazz._O ();
Sys.err.__CLASS_NAME__ = "java.io.PrintStream";
Sys.err.print = Sys.err.print$S = function (s) {
Con.consoleOutput (s, "red");
};
Sys.err.printf = Sys.err.printf$S$OA = Sys.err.format = Sys.err.format$S$OA = Sys.err.format = function (f, args) {
Sys.out.print(String.format$S$OA.apply(null, arguments));
}
Sys.err.println = Sys.err.println$O = Sys.err.println$Z = Sys.err.println$I = Sys.err.println$S = Sys.err.println$C = Sys.err.println = function (s) {
if (Clazz._traceOutput && s && ("" + s).indexOf(Clazz._traceOutput) >= 0) {
alert(s + "\n\n" + Clazz._getStackTrace());
doDebugger();
}
Con.consoleOutput (typeof s == "undefined" ? "\r\n" : s == null ? s = "null\r\n" : s + "\r\n", "red");
};
Sys.err.println$F = Sys.err.println$D = function(f) {var s = "" + f; Sys.err.println(s.indexOf(".") < 0 && s.indexOf("Inf") < 0 ? s + ".0" : s)};
Sys.err.write$BA$I$I = function (buf, offset, len) {
Sys.err.print(String.instantialize(buf).substring(offset, offset+len));
};
Sys.err.flush$ = function() {}
})(Clazz.Console, System);
Clazz._Loader.registerPackages("java", [ "io", "lang", "lang.reflect", "util" ]);
if (!window["java.registered"])
window["java.registered"] = false;
(function (ClazzLoader) {
if (window["java.packaged"]) return;
window["java.packaged"] = true;
}) (Clazz._Loader);
window["java.registered"] = true;
///////////////// special definitions of standard Java class methods ///////////
var C$, m$ = Clazz.newMeth;
Clazz._setDeclared("java.lang.Math", java.lang.Math = Math);
Math.rint || (Math.rint = function(a) {
var b;
return Math.round(a) + ((b = a % 1) != 0.5 && b != -0.5 ? 0 : (b = Math.round(a % 2)) > 0 ? b - 2 : b);
});
Math.log10||(Math.log10=function(a){return Math.log(a)/Math.E});
Math.hypot||(Math.hypot=function(x,y){return Math.sqrt(Math.pow(x,2)+Math.pow(y,2))});
Math.toDegrees||(Math.toDegrees=function(angrad){return angrad*180.0/Math.PI;});
Math.toRadians||(Math.toRadians=function(angdeg){return angdeg/180.0*Math.PI});
Math.copySign||(Math.copySign=function(mag,sign){return((sign>0?1:-1)*Math.abs(mag))});
//could use Math.sign(), but this was used to preserve cross-brower compatability (not in Internet Explorer)
Math.signum||(Math.signum=function(d){return(d==0.0||isNaN(d))?d:d < 0 ? -1 : 1});
Math.scalb||(Math.scalb=function(d,scaleFactor){return d*Math.pow(2,scaleFactor)});
//var
a64 = null, a32 = null, i32 = null, i64 = null;
Math.nextAfter||
(Math.nextAfter=function(start,direction){
if (isNaN(start) || isNaN(direction))
return NaN;
if (direction == start)
return start;
if (start == Double.MAX_VALUE && direction == Double.POSITIVE_INFINITY)
return Double.POSITIVE_INFINITY;
if (start == -Double.MAX_VALUE && direction == Double.NEGATIVE_INFINITY)
return Double.NEGATIVE_INFINITY;
if (start == Double.POSITIVE_INFINITY && direction == Double.NEGATIVE_INFINITY)
return Double.MAX_VALUE;
if (start == Double.NEGATIVE_INFINITY && direction == Double.POSITIVE_INFINITY)
return -Double.MAX_VALUE;
if (start == 0)
return (direction > 0 ? Double.MIN_VALUE : -Double.MIN_VALUE);
if (!a64) {
a64 = new Float64Array(1);
i64 = new Uint32Array(a64.buffer);
}
a64[0] = start;
var i0 = i64[0];
var i1 = i64[1];
var carry;
if ((direction > start) == (start >= 0)) {
i64[0]++;
carry = (i64[0] == 0 ? 1 : 0);
} else {
i64[0]--;
carry = (i64[0] == 4294967295 ? -1 : 0);
}
if (carry)
i64[1]+=carry;
return a64[0];
});
Math.nextAfter$D$D = Math.nextAfter;
Math.nextAfter$F$D =function(start,direction){
if (isNaN(start) || isNaN(direction))
return NaN;
if (direction == start)
return start;
if (start == Float.MAX_VALUE && direction == Float.POSITIVE_INFINITY)
return Float.POSITIVE_INFINITY;
if (start == -Float.MAX_VALUE && direction == Float.NEGATIVE_INFINITY)
return Float.NEGATIVE_INFINITY;
if (start == Float.POSITIVE_INFINITY && direction == Float.NEGATIVE_INFINITY)
return Float.MAX_VALUE;
if (start == Float.NEGATIVE_INFINITY && direction == Float.POSITIVE_INFINITY)
return -Float.MAX_VALUE;
if (start == 0 && direction < 0)
return -Float.MIN_VALUE;
if (start == 0)
return (direction > 0 ? Float.MIN_VALUE : -Float.MIN_VALUE);
if (!i32) {
a32 = new Float32Array(1);
i32 = new Int32Array(a32.buffer);
}
a32[0] = start;
i32[0] += ((direction > start) == (start >= 0) ? 1 : -1);
return a32[0];
};
Math.nextUp||(Math.nextUp=function(d){ return Math.nextAfter(d, Double.POSITIVE_INFINITY); });
Math.nextUP$D=Math.nextUp;
Math.nextUp$F = function(f){ return Math.nextAfter$F$D(f, Double.NEGATIVE_INFINITY); };
Math.nextDown||(Math.nextDown=function(d){ return Math.nextAfter(d, Double.NEGATIVE_INFINITY); });
Math.nextDown$D=Math.nextDown;
Math.nextDown$F = function(f){ return Math.nextAfter$F$D(f, Double.NEGATIVE_INFINITY); };
Math.ulp||(Math.ulp=function(d){
if (isNaN(d)) {
return Double.NaN;
}
if (isInfinite(d)) {
return Double.POSITIVE_INFINITY;
}
if (d == Double.MAX_VALUE || d == -Double.MAX_VALUE) {
return Math.pow(2, 971);
}
return Math.nextUp(Math.abs(d));
});
Math.ulp$D = Math.ulp;
Math.ulp$F = function(f){
if (isNaN(f)) {
return Float.NaN;
}
if (isInfinite(f)) {
return Float.POSITIVE_INFINITY;
}
if (f == Float.MAX_VALUE || f == -Float.MAX_VALUE) {
return Math.pow(2, 104);
}
return Math.nextUp$F(Math.abs(f));
};
Math.getExponent = Math.getExponent$D = function(d) {
if (!a64) {
a64 = new Float64Array(1);
i64 = new Uint32Array(a64.buffer);
}
a64[0] = d;
return ((i64[1] & 0x7ff00000) >> 20) - 1023;
};
Math.getExponent$F=function(f){
return ((Float.floatToRawIntBits$F(f) & 0x7f800000) >> 23) - 127;
}
Math.IEEEremainder||(Math.IEEEremainder=function (x, y) {
if (Double.isNaN$D(x) || Double.isNaN$D(y) || Double.isInfinite$D(x) || y == 0)
return NaN;
if (!Double.isInfinite$D(x) && Double.isInfinite$D(y))
return x;
var modxy = x % y;
if (modxy == 0) return modxy;
var rem = modxy - Math.abs(y) * Math.signum(x);
if (Math.abs(rem) == Math.abs(modxy)) {
var div = x / y;
return (Math.abs(Math.round(div)) > Math.abs(div) ? rem : modxy);
}
return (Math.abs(rem) < Math.abs(modxy) ? rem : modxy);
});
Clazz._setDeclared("java.lang.Number", java.lang.Number=Number);
Number.prototype._numberToString=Number.prototype.toString;
extendObject(Array, EXT_NO_HASHCODE);
extendObject(Number, EXT_NO_HASHCODE);
Number.__CLASS_NAME__="Number";
addInterface(Number,java.io.Serializable);
//extendPrototype(Number, true, false);
Number.prototype.compareTo$ = Number.prototype.compareTo$Number = Number.prototype.compareTo$TT = function(x) { var a = this.valueOf(), b = x.valueOf(); return (a < b ? -1 : a == b ? 0 : 1) };
var $b$ = new Int8Array(1);
var $s$ = new Int16Array(1);
var $i$ = new Int32Array(1);
// short forms, for the actual numbers in JavaScript
m$(Number,["byteValue"],function(){return ($b$[0] = this, $b$[0]);});
m$(Number,["shortValue"],function(){return ($s$[0] = this, $s$[0]);});
m$(Number,["intValue"],function(){return ($i$[0] = this, $i$[0]);});
m$(Number,["longValue"],function(){return (this|0);});
// Object values
m$(Number,["byteValue$"],function(){return this.valueOf().byteValue();});
m$(Number,["shortValue$"],function(){return this.valueOf().shortValue();});
m$(Number,["intValue$"],function(){return this.valueOf().intValue();});
m$(Number,["longValue$"],function(){return this.valueOf().longValue();});
m$(Number,["floatValue$", "doubleValue$", "hashCode$"],function(){return this.valueOf();});
Clazz._setDeclared("java.lang.Integer", java.lang.Integer=Integer=function(){
if (typeof arguments[0] != "object")this.c$(arguments[0]);
});
var primTypes = {};
var setJ2STypeclass = function(cl, type, paramCode) {
// TODO -- should be a proper Java.lang.Class
primTypes[paramCode] = cl;
cl.TYPE = {
isPrimitive: function() { return true },
type:type,
__PARAMCODE:paramCode,
__PRIMITIVE:1 // referenced in java.lang.Class
};
cl.TYPE.toString = cl.TYPE.getName$ = cl.TYPE.getTypeName$
= cl.TYPE.getCanonicalName$ = cl.TYPE.getSimpleName$ = function() {return type}
}
var decorateAsNumber = function (clazz, qClazzName, type, PARAMCODE) {
clazz.prototype.valueOf=function(){return 0;};
clazz.prototype.__VAL0__ = 1;
finalizeClazz(clazz, qClazzName, null, 0, true);
extendPrototype(clazz, true, true);
setSuperclass(clazz, Number);
addInterface(clazz, Comparable);
setJ2STypeclass(clazz, type, PARAMCODE);
return clazz;
};
decorateAsNumber(Integer, "Integer", "int", "I");
Integer.toString=Integer.toString$I=Integer.toString$I$I=Integer.prototype.toString=function(i,radix){
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Integer ? "class java.lang.Integer" : ""+this.valueOf());
}
};
m$(Integer, ["c$", "c$$S", "c$$I"], function(v){
v == null && (v = 0);
if (typeof v != "number")
v = Integer.parseIntRadix$S$I(v, 10);
v = v.intValue();
this.valueOf=function(){return v;};
}, 1);
Integer.MIN_VALUE=Integer.prototype.MIN_VALUE=-0x80000000;
Integer.MAX_VALUE=Integer.prototype.MAX_VALUE=0x7fffffff;
//Integer.TYPE=Integer.prototype.TYPE=Integer;
m$(Integer,"highestOneBit$I",
function(i) {
i |= (i >> 1);
i |= (i >> 2);
i |= (i >> 4);
i |= (i >> 8);
i |= (i >> 16);
return i - (i >>> 1);
}, 1);
m$(Integer,"lowestOneBit$I",
function(i) { return i & -i;}, 1);
m$(Integer,"rotateLeft$I$I",
function(i, distance) { return (i << distance) | (i >>> -distance); }, 1);
m$(Integer,"rotateRight$I$I",
function(i, distance) { return (i >>> distance) | (i << -distance); }, 1);
m$(Integer,"reverse$I",
function(i) {
i = (i & 0x55555555) << 1 | (i >>> 1) & 0x55555555;
i = (i & 0x33333333) << 2 | (i >>> 2) & 0x33333333;
i = (i & 0x0f0f0f0f) << 4 | (i >>> 4) & 0x0f0f0f0f;
i = (i << 24) | ((i & 0xff00) << 8) |
((i >>> 8) & 0xff00) | (i >>> 24);
return i;}, 1);
Integer.reverseBytes = m$(Integer,"reverseBytes$I",
function(i) {
return ((i >>> 24) ) |
((i >> 8) & 0xFF00) |
((i << 8) & 0xFF0000) |
((i << 24));
}, 1);
m$(Integer,"signum$I", function(i){ return i < 0 ? -1 : i > 0 ? 1 : 0; }, 1);
m$(Integer,"bitCount$I",
function(i) {
i = i - ((i >>> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
i = (i + (i >>> 4)) & 0x0f0f0f0f;
i = i + (i >>> 8);
i = i + (i >>> 16);
return i & 0x3f;
}, 1);
m$(Integer,"numberOfLeadingZeros$I",
function(i) {
if (i == 0) return 32;
var n = 1;
if (i >>> 16 == 0) { n += 16; i <<= 16; }
if (i >>> 24 == 0) { n += 8; i <<= 8; }
if (i >>> 28 == 0) { n += 4; i <<= 4; }
if (i >>> 30 == 0) { n += 2; i <<= 2; }
n -= i >>> 31;
return n;
}, 1);
m$(Integer,"numberOfTrailingZeros$I",
function(i) {
if (i == 0) return 32;
var n = 31;
var y = i <<16; if (y != 0) { n = n -16; i = y; }
y = i << 8; if (y != 0) { n = n - 8; i = y; }
y = i << 4; if (y != 0) { n = n - 4; i = y; }
y = i << 2; if (y != 0) { n = n - 2; i = y; }
return n - ((i << 1) >>> 31);
}, 1);
var radixChar = "0123456789abcdefghijklmnopqrstuvwxyz";
m$(Integer,"parseIntRadix$S$I",
function(s,radix){
var v = parseInt(s, radix);
if (isNaN(v)){
throw Clazz.new_(NumberFormatException.c$$S, ["parsing " + s + " radix " + radix]);
}
return v;
}, 1);
m$(Integer,["parseInt$S","parseInt$S$I"],
function(s,radix){
return Integer.parseIntRadix$S$I(s, radix || 10);
}, 1);
m$(Integer,["valueOf$S","valueOf$I"],
function(s, radix){
return Clazz.new_(Integer.c$, [s]);
}, 1);
m$(Integer,["valueOf$S$I"],
function(s, radix){
return Integer.parseIntRadix$S$I(s, radix || 10);
}, 1);
m$(Integer,"equals$O",
function(s){
return (s instanceof Integer) && s.valueOf()==this.valueOf();
});
Integer.toHexString$I=function(d){
if (d < 0) {
var b = d & 0xFFFFFF;
var c = ((d>>24)&0xFF);
return c._numberToString(16) + (b = "000000" + b._numberToString(16)).substring(b.length - 6);
}
return d._numberToString(16);
};
Integer.toOctalString$I=function(d){return d._numberToString(8);};
Integer.toBinaryString$I=function(d){return d._numberToString(2);};
m$(Integer,"decodeRaw$S", function(n){
if (n.indexOf(".") >= 0)n = "";
var i = (n.startsWith("-") ? 1 : 0);
n = n.replace(/\#/, "0x").toLowerCase();
var radix=(n.startsWith("0x", i) ? 16 : n.startsWith("0", i) ? 8 : 10);
// The general problem with parseInt is that is not strict -- ParseInt("10whatever") == 10.
// Number is strict, but Number("055") does not work, though ParseInt("055", 8) does.
// need to make sure negative numbers are negative
if (n == "")
return NaN
n = Number(n) & 0xFFFFFFFF;
return (radix == 8 ? parseInt(n, 8) : n);
}, 1);
m$(Integer,"decode$S", function(n){
if (isNaN(n = Integer.decodeRaw$S(n)) || n < Integer.MIN_VALUE|| n > Integer.MAX_VALUE)
throw Clazz.new_(NumberFormatException.c$$S,["Invalid Integer"]);
return Clazz.new_(Integer.c$, [n]);
}, 1);
m$(Integer,"hashCode$",
function(){
return this.valueOf();
});
// Note that Long is problematic in JavaScript
Clazz._setDeclared("java.lang.Long", java.lang.Long=Long=function(){
if (typeof arguments[0] != "object")this.c$(arguments[0]);
});
decorateAsNumber(Long, "Long", "long", "L");
Long.toString=Long.toString$J=Long.toString$J$I = Long.prototype.toString=function(i, radix){
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Long ? "class java.lang.Long" : ""+this.valueOf());
}
};
m$(Long, ["c$", "c$$S", "c$$J"], function(v){
v == null && (v = 0);
v = (typeof v == "number" ? Math.round(v) : Integer.parseIntRadix$S$I(v, 10));
this.valueOf=function(){return v;};
}, 1);
//Long.MIN_VALUE=Long.prototype.MIN_VALUE=-0x8000000000000000;
//Long.MAX_VALUE=Long.prototype.MAX_VALUE=0x7fffffffffffffff;
//Long.TYPE=Long.prototype.TYPE=Long;
m$(Long,["parseLong$S", "parseLong$S$I"],
function(s,radix){
return Integer.parseIntRadix$S$I(s, radix || 10);
}, 1);
m$(Long,["valueOf$S","valueOf$J","valueOf$S$I"],
function(s, radix){
return Clazz.new_(Long.c$, [s, radix||10]);
}, 1);
m$(Long,"equals$O",
function(s){
return (s instanceof Long) && s.valueOf()==this.valueOf();
}, 1);
Long.toHexString$J=function(i){
return i.toString(16);
};
Long.toOctalString$J=function(i){
return i.toString(8);
};
Long.toBinaryString$J=function(i){
return i.toString(2);
};
m$(Long,"decode$S",
function(n){
if (isNaN(n = Integer.decodeRaw$S(n)))
throw Clazz.new_(NumberFormatException.c$$S, ["Invalid Long"]);
return Clazz.new_(Long.c$, [n]);
}, 1);
Long.sum$J$J = Integer.sum$I$I;
m$(Long,"signum$J", function(i){ return i < 0 ? -1 : i > 0 ? 1 : 0; }, 1);
Clazz._setDeclared("java.lang.Short", java.lang.Short = Short = function(){
if (typeof arguments[0] != "object")this.c$(arguments[0]);
});
decorateAsNumber(Short, "Short", "short", "H");
m$(Short, ["c$", "c$$S", "c$$H"],
function (v,radix) {
v == null && (v = 0);
if (typeof v != "number")
v = Integer.parseIntRadix$S$I(v, radix||10);
v = v.shortValue();
this.valueOf = function () {return v;};
}, 1);
Short.toString = Short.toString$H = Short.toString$H$I = Short.prototype.toString = function (i,radix) {
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Short ? "class java.lang.Short" : ""+this.valueOf());
}
};
Short.MIN_VALUE = Short.prototype.MIN_VALUE = -32768;
Short.MAX_VALUE = Short.prototype.MAX_VALUE = 32767;
//Short.TYPE = Short.prototype.TYPE = Short;
m$(Short, "parseShortRadix$S$I",function (s, radix) {
return Integer.parseIntRadix$S$I(s, radix).shortValue();
}, 1);
m$(Short, "parseShort$S",function (s) {
return Short.parseShortRadix$S$I(s, 10);
}, 1);
m$(Short, ["valueOf$S","valueOf$H","valueOf$S$I"],
function (s,radix) {
return Clazz.new_(Short.c$, [s,radix||10]);
}, 1);
m$(Short, "equals$O",
function (s) {
return (s instanceof Short) && s.valueOf() == this.valueOf();
});
Short.toHexString$H = function (i) {
return i.toString(16);
};
Short.toOctalString$H = function (i) {
return i.toString(8);
};
Short.toBinaryString$H = function (i) {
return i.toString (2);
};
m$(Short, "decode$S",
function(n){
if (isNaN(n = Integer.decodeRaw$S(n)) || n < -32768|| n > 32767)
throw Clazz.new_(NumberFormatException.c$$S, ["Invalid Short"]);
return Clazz.new_(Short.c$, [n]);
}, 1);
Clazz._setDeclared("java.lang.Byte", java.lang.Byte=Byte=function(){
if (typeof arguments[0] != "object")this.c$(arguments[0]);
});
decorateAsNumber(Byte,"Byte", "byte", "B");
m$(Byte, ["c$", "c$$S", "c$$B"], function(v,radix){
if (typeof v != "number")
v = Integer.parseIntRadix$S$I(v, radix||10);
v = v.byteValue();
this.valueOf=function(){return v;};
this.byteValue = function(){return v};
}, 1);
Byte.toString=Byte.toString$B=Byte.toString$B$I=Byte.prototype.toString=function(i,radix){
switch(arguments.length) {
case 2:
return i.toString(radix);
case 1:
return "" +i;
case 0:
return (this===Byte ? "class java.lang.Byte" : ""+this.valueOf());
}
};
Byte.serialVersionUID=Byte.prototype.serialVersionUID=-7183698231559129828;
Byte.MIN_VALUE=Byte.prototype.MIN_VALUE=-128;
Byte.MAX_VALUE=Byte.prototype.MAX_VALUE=127;
Byte.SIZE=Byte.prototype.SIZE=8;
//Byte.TYPE=Byte.prototype.TYPE=Byte;
m$(Byte,"parseByteRadix$S$I",
function(s,radix){
return Integer.parseIntRadix$S$I(s, radix).byteValue$();
}, 1);
m$(Byte,"parseByte$S",
function(s){
return Byte.parseByteRadix$S$I(s,10);
}, 1);
m$(Byte, ["valueOf$S","valueOf$B","valueOf$S$I"],
function (s,radix) {
return Clazz.new_(Byte.c$, [s, radix||10]);
}, 1);
m$(Byte,"equals$O",
function(s){
return (s instanceof Byte) && s.valueOf()==this.valueOf();
});
Byte.toHexString$B=function(i){return i.toString(16);};
Byte.toOctalString$B=function(i){return i.toString(8);};
Byte.toBinaryString$B=function(i){return i.toString(2);};
m$(Byte,"decode$S",
function(n){
if (isNaN(n = Integer.decodeRaw$S(n)) || n < -128|| n > 127)
throw Clazz.new_(NumberFormatException.c$$S, ["Invalid Byte"]);
return Clazz.new_(Byte.c$, [n]);
}, 1);
Clazz._floatToString = function(f) {
var check57 = (Math.abs(f) >= 1e-6 && Math.abs(f) < 1e-3);
if (check57)
f/=1e7;
var s = (""+f).replace('e','E');
if (s.indexOf(".") < 0 && s.indexOf("Inf") < 0 && s.indexOf("NaN") < 0) {
if(s.indexOf('E') < 0)
s += ".0";
else {
s = s.replace('E', '.0E');
}
}
if (check57) {
s = s.substring(0, s.length - 2) + (parseInt(s.substring(s.length - 2)) - 7);
s = s.replace(".0000000000000001",".0");
}
return s;
}
Clazz._setDeclared("java.lang.Float", java.lang.Float=Float=function(){
if (typeof arguments[0] != "object")this.c$(arguments[0]);
});
decorateAsNumber(Float,"Float", "float", "F");
m$(Float, ["c$", "c$$S", "c$$F", "c$$D"], function(v){
v == null && (v = 0);
if (typeof v != "number")
v = Number(v);
this.valueOf=function(){return v;}
}, 1);
Float.toString=Float.toString$F=Float.prototype.toString=function(){
if(arguments.length!=0){
return Clazz._floatToString(arguments[0]);
}else if(this===Float){
return"class java.lang.Float";
}
return Clazz._floatToString(this.valueOf());
};
var a32, i32;
Float.floatToIntBits$F = function(f) {
if (isNaN(f))
return
return Float.floatToRawIntBits$F(f);
}
Float.floatToRawIntBits$F = function(f) {
i32 || (a32 = new Float32Array(1), i32 = new Int32Array(a32.buffer));
a32[0] = f;
return i32[0];
}
Float.intBitsToFloat$I = function(i) {
i32 || (a32 = new Float32Array(1), i32 = new Int32Array(a32.buffer));
i32[0] = i;
return a32[0];
}
Float.serialVersionUID=Float.prototype.serialVersionUID=-2671257302660747028;
Float.MIN_VALUE=Float.prototype.MIN_VALUE=1.4e-45;
Float.MAX_VALUE=Float.prototype.MAX_VALUE=3.4028235e+38;
Float.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY;
Float.POSITIVE_INFINITY=Number.POSITIVE_INFINITY;
Float.NaN=Number.NaN;
//Float.TYPE=Float.prototype.TYPE=Float;
m$(Float,"parseFloat$S",
function(s){
if(s==null){
throw Clazz.new_(NumberFormatException.c$$S, ["null"]);
}
if (typeof s == "number")return s; // important -- typeof NaN is "number" and is OK here
var floatVal=Number(s);
if(isNaN(floatVal)){
throw Clazz.new_(NumberFormatException.c$$S, ["Not a Number : "+s]);
}
return floatVal;
}, 1);
m$(Float,["valueOf$S","valueOf$F"],
function(s){
return Clazz.new_(Float.c$, [s]);
}, 1);
Float.isNaN$F = m$(Float,"isNaN$",
function(num){
return isNaN(arguments.length == 1 ? num : this.valueOf());
});
Float.isInfinite$F = m$(Float,"isInfinite$",
function(num){
return !Number.isFinite(arguments.length == 1 ? num : this.valueOf());
});
m$(Float,"equals$O",
function(s){
return (s instanceof Float) && s.valueOf()==this.valueOf();
});
Clazz._setDeclared("java.lang.Double", java.lang.Double=Double=function(){
if (typeof arguments[0] != "object")this.c$(arguments[0]);
});
decorateAsNumber(Double,"Double", "double", "D");
Double.toString=Double.toString$D=Double.prototype.toString=function(){
if(arguments.length!=0){
return Clazz._floatToString(arguments[0]);
}else if(this===Double){
return"class java.lang.Double";
}
return Clazz._floatToString(this.valueOf());
};
m$(Double, ["c$", "c$$S", "c$$D"], function(v){
v == null && (v = 0);
if (typeof v != "number")
v = Double.parseDouble$S(v);
this.valueOf=function(){return v;};
}, 1);
Double.serialVersionUID=Double.prototype.serialVersionUID=-9172774392245257468;
Double.MIN_VALUE=Double.prototype.MIN_VALUE=4.9e-324;
Double.MAX_VALUE=Double.prototype.MAX_VALUE=1.7976931348623157e+308;
Double.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY;
Double.POSITIVE_INFINITY=Number.POSITIVE_INFINITY;
Double.NaN=Number.NaN;
//Double.TYPE=Double.prototype.TYPE=Double;
Double.isNaN$D = m$(Double,"isNaN$",
function(num){
return isNaN(arguments.length == 1 ? num : this.valueOf());
});
Float.prototype.hashCode$ = Double.prototype.hashCode$ = function() {("" + this.valueOf()).hashCode$()}
Double.isInfinite$D = m$(Double,"isInfinite$",
function(num){
return!Number.isFinite(arguments.length == 1 ? num : this.valueOf());
});
m$(Double,"parseDouble$S",
function(s){
if(s==null){
throw Clazz.new_(NumberFormatException.c$$S, ["null"]);
}
if (typeof s == "number")return s; // important -- typeof NaN is "number" and is OK here
var doubleVal=Number(s);
if(isNaN(doubleVal)){
throw Clazz.new_(NumberFormatException.c$$S, ["Not a Number : "+s]);
}
return doubleVal;
}, 1);
m$(Double,["valueOf$S","valueOf$D"],
function(v){
return Clazz.new_(Double.c$, [v]);
}, 1);
Double.prototype.equals = m$(Double,"equals$O",
function(s){
return (s instanceof Double) && s.valueOf()==this.valueOf();
});
Clazz._setDeclared("java.lang.Boolean",
Boolean = java.lang.Boolean = Boolean || function(){
if (typeof arguments[0] != "object")this.c$(arguments[0]);
});
extendObject(Boolean);
Boolean.__CLASS_NAME__="Boolean";
addInterface(Boolean,[java.io.Serializable,java.lang.Comparable]);
setJ2STypeclass(Boolean, "boolean", "Z");
//extendPrototype(Boolean, true, false);
Boolean.serialVersionUID=Boolean.prototype.serialVersionUID=-3665804199014368530;
m$(Boolean, ["c$", "c$$S", "c$$Z"],
function(s){
var b = ((typeof s == "string" ? Boolean.toBoolean(s) : s) ? true : false);
this.valueOf=function(){return b;};
}, 1);
m$(Boolean,["booleanValue","booleanValue$"], function(){ return this.valueOf(); });
m$(Boolean,"compare$Z$Z", function(a,b){return(a == b ? 0 : a ? 1 : -1);}, 1);
m$(Boolean,["compareTo$Boolean","compareTo$TT"],
function(b){
return(b.valueOf() == this.valueOf() ? 0 : this.valueOf() ? 1 : -1);
});
Boolean.prototype.equals = m$(Boolean,"equals$O",
function(obj){
return obj instanceof Boolean && this.booleanValue()==obj.booleanValue();
});
m$(Boolean,"getBoolean$S",
function(name){
var result=false;
try{
result=Boolean.toBoolean(System.getProperty$S(name));
}catch(e){
if(Clazz.instanceOf(e,IllegalArgumentException)){
}else if(Clazz.instanceOf(e,NullPointerException)){
}else{
throw e;
}
}
return result;
}, 1);
m$(Boolean,"hashCode$", function(){ return this.valueOf()?1231:1237;});
m$(Boolean,"hashCode$Z", function(b){ return b?1231:1237;}, 1);
m$(Boolean,"logicalAnd$Z$Z", function(a,b){return(a && b);}, 1);
m$(Boolean,"logicalOr$Z$Z", function(a,b){return(a || b);}, 1);
m$(Boolean,"logicalXor$Z$Z", function(a,b){return !!(a ^ b);}, 1);
m$(Boolean,"parseBoolean$S", function(s){return Boolean.toBoolean(s);}, 1);
m$(Boolean,"toString",function(){return this.valueOf()?"true":"false";});
m$(Boolean,"toString$Z",function(b){return "" + b;}, 1);
m$(Boolean,"valueOf$S",function(s){ return("true".equalsIgnoreCase$S(s)?Boolean.TRUE:Boolean.FALSE);}, 1);
m$(Boolean,"valueOf$Z",function(b){ return(b?Boolean.TRUE:Boolean.FALSE);}, 1);
//the need is to have new Boolean(string), but that won't work with native Boolean
//so instead we have to do a lexical switch from "new Boolean" to "Boolean.from"
//note no $ here
m$(Boolean,"toBoolean",
function(name){
return(typeof name == "string" ? name.equalsIgnoreCase$S("true") : !!name);
}, 1);
m$(Boolean,"from",
function(name){
return Boolean.toBoolean(name) ? Boolean.TRUE : Boolean.FALSE;
}, 1);
Boolean.TRUE=Boolean.prototype.TRUE=Clazz.new_(Boolean.c$, [true]);
Boolean.FALSE=Boolean.prototype.FALSE=Clazz.new_(Boolean.c$, [false]);
Clazz._Encoding={
UTF8:"utf-8",
UTF16:"utf-16",
ASCII:"ascii"
};
(function(Encoding) {
Encoding.guessEncoding=function(str){
return (str.charCodeAt(0)==0xEF&&str.charCodeAt(1)==0xBB&&str.charCodeAt(2)==0xBF ? Encoding.UTF8
: str.charCodeAt(0)==0xFF&&str.charCodeAt(1)==0xFE ? Encoding.UTF16
: Encoding.ASCII);
};
Encoding.guessEncodingArray=function(a, offset){
return (a[offset]==0xEF&&a[offset + 1]==0xBB&&a[offset + 2]==0xBF ? Encoding.UTF8
: a[offset + 0]==0xFF&&a[offset + 1]==0xFE ? Encoding.UTF16 : Encoding.ASCII);
};
Encoding.readUTF8Array=function(a, offset, length){
if (arguments.length == 1) {
offset = 0;
length = a.length;
}
var encoding=Encoding.guessEncodingArray(a);
var startIdx=0;
if(encoding==Encoding.UTF8){
startIdx=3;
}else if(encoding==Encoding.UTF16){
startIdx=2;
}
var arrs=new Array();
for(var i=offset + startIdx, endIdx = offset + length; i < endIdx; i++){
var charCode=a[i];
if(charCode<0x80){
arrs[arrs.length]=String.fromCharCode(charCode);
}else if(charCode>0xc0&&charCode<0xe0){
var c1=charCode&0x1f;
var c2=a[++i]&0x3f;
var c=(c1<<6)+c2;
arrs[arrs.length]=String.fromCharCode(c);
}else if(charCode>=0xe0){
var c1=charCode&0x0f;
var c2=a[++i]&0x3f;
var c3=a[++i]&0x3f;
var c=(c1<<12)+(c2<<6)+c3;
arrs[arrs.length]=String.fromCharCode(c);
}
}
return arrs.join('');
};
Encoding.convert2UTF8=function(str){
var encoding=this.guessEncoding(str);
var startIdx=0;
if(encoding==Encoding.UTF8){
return str;
}else if(encoding==Encoding.UTF16){
startIdx=2;
}
var offset=0;
var arrs=new Array(offset+str.length-startIdx);
for(var i=startIdx;i
browser or your browser is blocking this applet.
\
Check the warning message from your browser and/or enable Java applets in
\
your web browser preferences, or install the Java Runtime Environment from www.java.com";
Applet._setCommonMethods = function(p) {
p._showInfo = proto._showInfo;
/// p._search = proto._search;
p._getName = proto._getName;
p.readyCallback = proto.readyCallback;
}
Applet._createApplet = function(applet, Info, params) {
applet._initialize(Info.jarPath, Info.jarFile);
var jarFile = applet._jarFile;
var jnlp = ""
if (J2S._isFile) {
jarFile = jarFile.replace(/0\.jar/,".jar");
}
// size is set to 100% of containers' size, but only if resizable.
// Note that resizability in MSIE requires:
//
var w = (applet._containerWidth.indexOf("px") >= 0 ? applet._containerWidth : "100%");
var h = (applet._containerHeight.indexOf("px") >= 0 ? applet._containerHeight : "100%");
var widthAndHeight = " style=\"width:" + w + ";height:" + h + "\" ";
var attributes = "name='" + applet._id + "_object' id='" + applet._id + "_object' " + "\n"
+ widthAndHeight + jnlp + "\n"
params.codebase = applet._jarPath;
params.codePath = params.codebase + "/";
if (params.codePath.indexOf("://") < 0) {
var base = document.location.href.split("#")[0].split("?")[0].split("/");
base[base.length - 1] = params.codePath;
params.codePath = base.join("/");
}
params.archive = jarFile;
params.mayscript = 'true';
params.java_arguments = "-Xmx" + Math.round(Info.memoryLimit || applet._memoryLimit) + "m";
params.permissions = (applet._isSigned ? "all-permissions" : "sandbox");
params.documentLocation = document.location.href;
params.documentBase = document.location.href.split("#")[0].split("?")[0];
params.jarPath = Info.jarPath;
J2S._syncedApplets.length && (params.synccallback = "J2S._mySyncCallback");
applet._startupScript && (params.script = applet._startupScript);
var t = "\n";
for (var i in params)
if(params[i])
t += " \n";
if (J2S.featureDetection.useIEObject || J2S.featureDetection.useHtml4Object) {
t = "\n";
} else { // use applet tag
t = "\n";
}
if (applet._deferApplet)
applet._javaCode = t, t="";
t = J2S._getWrapper(applet, true) + t + J2S._getWrapper(applet, false)
+ (Info.addSelectionOptions ? J2S._getGrabberOptions(applet) : "");
if (J2S._debugAlert)
alert (t);
applet._code = J2S._documentWrite(t);
}
proto._newApplet = function(viewerOptions) {
this._viewerOptions = viewerOptions;
// for now assigning this._applet here instead of in readyCallback
Clazz.loadClass("swingjs.JSAppletViewer");
this._appletPanel = Clazz.new_(swingjs.JSAppletViewer.c$$java_util_Hashtable, [viewerOptions]);
this._appletPanel.start$();
}
proto._addCoreFiles = function() {
if (this.__Info.core != "NONE" && this.__Info.core != "none" && !J2S._debugCode)
J2S._addCoreFile((this.__Info.core || "swingjs"), this._j2sPath, this.__Info.preloadCore);
// if (J2S._debugCode) {
// // no min package for that
// J2S._addExec([this, null, "swingjs.JSAppletViewer", "load " + this.__Info.code]);
//
// }
}
proto._create = function(id, Info){
J2S._setObject(this, id, Info);
var params = {
syncId: J2S._syncId,
progressbar: "true",
progresscolor: "blue",
boxbgcolor: this._color || "black",
boxfgcolor: "white",
boxmessage: "Downloading Applet ...",
//script: (this._color ? "background \"" + this._color +"\"": ""),
code: Info.appletClass + ".class"
};
J2S._setAppletParams(this._availableParams, params, Info);
function sterilizeInline(model) {
model = model.replace(/\r|\n|\r\n/g, (model.indexOf("|") >= 0 ? "\\/n" : "|")).replace(/'/g, "'");
if(J2S._debugAlert)
alert ("inline model:\n" + model);
return model;
}
params.loadInline = (Info.inlineModel ? sterilizeInline(Info.inlineModel) : "");
params.appletReadyCallback = "J2S.readyCallback";
if (J2S._syncedApplets.length)
params.synccallback = "J2S._mySyncCallback";
params.java_arguments = "-Xmx" + Math.round(Info.memoryLimit || this._memoryLimit) + "m";
this._initialize(Info.jarPath, Info.jarFile);
Applet._createApplet(this, Info, params);
}
proto._restoreState = function(clazzName, state) {
// applet-dependent
}
proto.readyCallback = function(id, fullid, isReady) {
if (!isReady)
return; // ignore -- page is closing
J2S._setDestroy(this);
this._ready = true;
this._showInfo(true);
this._showInfo(false);
J2S.Cache.setDragDrop(this);
this._readyFunction && this._readyFunction(this);
J2S._setReady(this);
var app = this._2dapplet;
if (app && app._isEmbedded && app._ready && app.__Info.visible)
this._show2d(true);
}
proto._showInfo = function(tf) {
if(this._isJNLP)return;
if(tf && this._2dapplet)
this._2dapplet._show(false);
J2S.$html(J2S.$(this, "infoheaderspan"), this._infoHeader);
if (this._info)
J2S.$html(J2S.$(this, "infodiv"), this._info);
if ((!this._isInfoVisible) == (!tf))
return;
this._isInfoVisible = tf;
// 1px does not work for MSIE
if (this._isJava) {
var x = (tf ? 2 : "100%");
J2S.$setSize(J2S.$(this, "appletdiv"), x, x);
}
J2S.$setVisible(J2S.$(this, "infotablediv"), tf);
J2S.$setVisible(J2S.$(this, "infoheaderdiv"), tf);
this._show(!tf);
}
proto._show = function(tf) {
var x = (!tf ? 2 : "100%");
J2S.$setSize(J2S.$(this, "object"), x, x);
if (!this._isJava)
J2S.$setVisible(J2S.$(this, "appletdiv"), tf);
}
proto._clearConsole = function () {
if (this._console == this._id + "_infodiv")
this.info = "";
if (!self.Clazz)return;
J2S._setConsoleDiv(this._console);
Clazz.Console.clear();
}
proto._resizeApplet = function(size) {
// See _jmolGetAppletSize() for the formats accepted as size [same used by jmolApplet()]
// Special case: an empty value for width or height is accepted, meaning no change in that dimension.
/*
* private functions
*/
function _getAppletSize(size, units) {
/* Accepts single number, 2-value array, or object with width and height as mroperties, each one can be one of:
percent (text string ending %), decimal 0 to 1 (percent/100), number, or text string (interpreted as nr.)
[width, height] array of strings is returned, with units added if specified.
Percent is relative to container div or element (which should have explicitly set size).
*/
var width, height;
if(( typeof size) == "object" && size != null) {
width = size[0]||size.width;
height = size[1]||size.height;
} else {
width = height = size;
}
return [J2S.fixDim(width, units), J2S.fixDim(height, units)];
}
var sz = _getAppletSize(size, "px");
var d = J2S._getElement(this, "appletinfotablediv");
d.style.width = sz[0];
d.style.height = sz[1];
this._containerWidth = sz[0];
this._containerHeight = sz[1];
if (this._is2D)
J2S.repaint(this, true);
}
proto._cover = function (doCover) {
// from using getAppletHtml()
this._newCanvas(false);
this._showInfo(false);
this._init();
};
})(SwingJS._Applet, SwingJS._Applet.prototype);
})(SwingJS, jQuery, J2S);
} // SwingJS undefined
Add ?j2snocore to URL to see full class list; ?j2sdebug to use uncompressed j2s/core files
get _j2sClassList.txt