Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified sources/net.sf.j2s.core/dist/swingjs/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20191122095542
20191126232346
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.5/SwingJS-site.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.5/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20191122095542
20191126232346
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
70 changes: 35 additions & 35 deletions sources/net.sf.j2s.java.core/src/java/lang/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,41 +245,41 @@ public boolean removeShutdownHook(Thread hook) {
return ApplicationShutdownHooks.remove(hook);
}

/**
* Forcibly terminates the currently running Java virtual machine. This
* method never returns normally.
*
* <p> This method should be used with extreme caution. Unlike the
* <tt>{@link #exit exit}</tt> method, this method does not cause shutdown
* hooks to be started and does not run uninvoked finalizers if
* finalization-on-exit has been enabled. If the shutdown sequence has
* already been initiated then this method does not wait for any running
* shutdown hooks or finalizers to finish their work. <p>
*
* @param status
* Termination status. By convention, a nonzero status code
* indicates abnormal termination. If the <tt>{@link Runtime#exit
* exit}</tt> (equivalently, <tt>{@link System#exit(int)
* System.exit}</tt>) method has already been invoked then this
* status code will override the status code passed to that method.
*
* @throws SecurityException
* If a security manager is present and its <tt>{@link
* SecurityManager#checkExit checkExit}</tt> method does not permit
* an exit with the specified status
*
* @see #exit
* @see #addShutdownHook
* @see #removeShutdownHook
* @since 1.3
*/
public void halt(int status) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkExit(status);
}
Shutdown.halt(status);
}
/**
* Forcibly terminates the currently running Java virtual machine. This method
* never returns normally.
*
* <p>
* This method should be used with extreme caution. Unlike the
* <tt>{@link #exit exit}</tt> method, this method does not cause shutdown hooks
* to be started and does not run uninvoked finalizers if finalization-on-exit
* has been enabled. If the shutdown sequence has already been initiated then
* this method does not wait for any running shutdown hooks or finalizers to
* finish their work.
* <p>
*
* @param status Termination status. By convention, a nonzero status code
* indicates abnormal termination. If the <tt>{@link Runtime#exit
* exit}</tt> (equivalently, <tt>{@link System#exit(int)
* System.exit}</tt>) method has already been invoked then this status
* code will override the status code passed to that method.
*
* @throws SecurityException If a security manager is present and its <tt>{@link
* SecurityManager#checkExit checkExit}</tt> method does not permit an
* exit with the specified status
*
* @see #exit
* @see #addShutdownHook
* @see #removeShutdownHook
* @since 1.3
*/
public void halt(int status) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkExit(status);
}
Shutdown.halt(status);
}

/**
* Enable or disable finalization on exit; doing so specifies that the
Expand Down
23 changes: 14 additions & 9 deletions sources/net.sf.j2s.java.core/src/java/lang/Shutdown.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Shutdown {

/* Lock object for the native halt method */
private static Object haltLock = null;//new Lock();
private static boolean 秘isHalted;

/* Invoked by Runtime.runFinalizersOnExit */
static void setRunFinalizersOnExit(boolean run) {
Expand Down Expand Up @@ -158,16 +159,20 @@ private static void runHooks() {
}
}

/* The halt method is synchronized on the halt lock
* to avoid corruption of the delete-on-shutdown file list.
* It invokes the true native halt method.
*/
static void halt(int status) {
synchronized (haltLock) {
System.out.println("Shutdown(" + status + ") on " + Thread.currentThread().getThreadGroup().getName());
/*
* The halt method is synchronized on the halt lock to avoid corruption of the
* delete-on-shutdown file list. It invokes the true native halt method.
*/
static void halt(int status) {
synchronized (haltLock) {

if (!秘isHalted) {
秘isHalted = true;
System.out.println("Shutdown(" + status + ") on " + Thread.currentThread().getThreadGroup().getName());
// halt0(status);
}
}
}
}
}

// static native void halt0(int status);

Expand Down
15 changes: 8 additions & 7 deletions sources/net.sf.j2s.java.core/src/java/lang/ThreadGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -1056,14 +1056,15 @@ public String toString() {

public void 秘exit() {
ArrayList<Object> q = 秘getTimerQueue();
for (int i = q.size(); --i >= 0;) {
Timer t = (Timer) q.get(i);
try {
t.stop();
} catch (Throwable e) {
// ignore
if (q != null)
for (int i = q.size(); --i >= 0;) {
Timer t = (Timer) q.get(i);
try {
t.stop();
} catch (Throwable e) {
// ignore
}
}
}
秘systemExited = true;
}

Expand Down
13 changes: 13 additions & 0 deletions sources/net.sf.j2s.java.core/src/javajs/util/V3d.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,17 @@ public final double length() {
return Math.sqrt(lengthSquared());
}

public final double angle(V3d v1) {
// return (double)Math.acos(dot(v1)/v1.length()/v.length());
// Numerically, near 0 and PI are very bad condition for acos.
// In 3-space, |atan2(sin,cos)| is much stable.

double xx = y * v1.z - z * v1.y;
double yy = z * v1.x - x * v1.z;
double zz = x * v1.y - y * v1.x;
double cross = Math.sqrt(xx * xx + yy * yy + zz * zz);

return Math.abs(Math.atan2(cross, dot(v1)));
}

}
11 changes: 6 additions & 5 deletions sources/net.sf.j2s.java.core/src/swingjs/plaf/JSComponentUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ public void setDraggable(JSFunction f) {
/**
* processed text (local to setIconAndText) is HTML
*/
private boolean isHTML;
protected boolean isHTML;

/**
* set false for tool tip or other non-label object that has text
Expand Down Expand Up @@ -1754,7 +1754,8 @@ protected Dimension setHTMLSize1(DOMNode node, boolean addCSS, boolean usePrefer
dim.height += h;
DOMNode.setStyles(node, "position", null);
if (w0 != null) {
DOMNode.setStyles(node, "width", w0, "height", h0);
DOMNode.setStyles(node, "width",
(isHTML && isLabel ? "inherit" : w0), "height", h0);
}
if (position != null) {
DOMNode.setStyles(node, "position", position);
Expand Down Expand Up @@ -2382,7 +2383,8 @@ protected void setIconAndText(String prop, Icon icon, int gap, String text) {
if (text == "\0") {
isPaintedOnly = true; // this cannot be undone
}
DOMNode.setStyles(textNode, "white-space", "nowrap");
if (!isHTML || !isLabel)
DOMNode.setStyles(textNode, "white-space", "nowrap");
if (icon == null) {
// tool tip does not allow text alignment
if (iconNode != null && allowTextAlignment
Expand Down Expand Up @@ -2648,11 +2650,10 @@ protected void setAlignments(AbstractButton b, boolean justGetPreferred) {
Object cssTxt = getJSObject();
Object cssIcon = getJSObject();

addJSKeyVal(cssCtr, "position", "absolute", "top", null, "left", null, "transform", null, "width", wCtr + "px",
addJSKeyVal(cssCtr, "position", "absolute", "top", null, "left", null, "transform", null, "width", (isHTML && isLabel ? "inherit" : wCtr + "px"),
"height", hCtr + "px");
addJSKeyVal(cssIcon, "position", "absolute", "top", null, "left", null, "transform", null);
addJSKeyVal(cssTxt, "position", "absolute", "top", null, "left", null, "transform", null);

isFullyCentered = (alignHCenter && alignVCenter && wIcon == 0 || wText == 0 && margins.left == margins.right
&& margins.top == margins.bottom && myInsets.left == myInsets.right && myInsets.top == myInsets.bottom);
if (isFullyCentered) {
Expand Down
7 changes: 6 additions & 1 deletion sources/net.sf.j2s.java.core/src/swingjs/plaf/JSLabelUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ public void paint(Graphics g, JComponent c) {
DOMNode.setStyles(centeringNode, "visibility", "visible");
super.paint(g, c);
// TODO: implement this for buttons?
DOMNode.setStyles(textNode, "overflow", "hidden", "white-space", "nowrap");
if (isHTML)
DOMNode.setStyles(textNode, "overflow", null, "white-space", null);
else
DOMNode.setStyles(textNode, "overflow", "hidden", "white-space", "nowrap");
if (icon != null) {
// The graphics object is translated to the label,
// not the image, at this point. In order to get
Expand All @@ -110,6 +113,8 @@ public void paint(Graphics g, JComponent c) {
@Override
public Dimension getPreferredSize(JComponent jc) {
updateDOMNode();
if (isHTML)
return null;
return (isAWT ? getMinimumSizePeer(jc, label)
: label == null ? super.getPreferredSize(jc)
: JSGraphicsUtils.getPreferredButtonSize(((AbstractButton) jc),
Expand Down
15 changes: 9 additions & 6 deletions sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// Google closure compiler cannot handle Clazz.new or Clazz.super

// BH 2019.11.26 3.2.5.v1 errant if (args) in newInstance
// BH 2019.11.07 3.2.5.v0 full encapsulation
// BH 2019.11.07 3.2.5.v0 adds encapsulation for window
// BH 2019.11.07 3.2.5.v0 splitting off $static$ from $clinit$ (see Java2ScriptVisitor notes)
Expand Down Expand Up @@ -464,13 +465,15 @@ Clazz.new_ = function(c, args, cl) {
// Integer will be passed as is here, without c.exClazz, or cl
var clInner = cl;
cl = cl || c.exClazz || c;
Clazz._initClass(cl,1,0,0); // critical here; next will call (0,1,0)
Clazz._initClass(cl,1,0,0);
// BH note: Critical here that the above is not 1,1,0;
// static init is the responsibility of newInstance
// or a static field or method call (which is handled
// by the $I$(n) handler in the function initializer in
// the newClass() call.
var obj = new (Function.prototype.bind.apply(cl, arguments));
if (args[2] != inheritArgs) {
if (haveArgs) {
// Clazz._initClass(cl,0,1,0);
c.apply(obj, args);
}
haveArgs && c.apply(obj, args);
clInner && clInner.$init$.apply(obj);
}

Expand Down Expand Up @@ -563,7 +566,7 @@ Clazz.newInstance = function (objThis, args, isInner, clazz) {
objThis.__JSID__ = ++_jsid;

if (!isInner) {
if (args)
// if (args)
clazz && Clazz._initClass(clazz,1,1,objThis);
if ((!args || args.length == 0) && objThis.c$) {
// allow for direct default call "new foo()" to run with its default constructor
Expand Down
15 changes: 9 additions & 6 deletions sources/net.sf.j2s.java.core/srcjs/swingjs2.js
Original file line number Diff line number Diff line change
Expand Up @@ -13863,6 +13863,7 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {

// Google closure compiler cannot handle Clazz.new or Clazz.super

// BH 2019.11.26 3.2.5.v1 errant if (args) in newInstance
// BH 2019.11.07 3.2.5.v0 full encapsulation
// BH 2019.11.07 3.2.5.v0 adds encapsulation for window
// BH 2019.11.07 3.2.5.v0 splitting off $static$ from $clinit$ (see Java2ScriptVisitor notes)
Expand Down Expand Up @@ -14320,13 +14321,15 @@ Clazz.new_ = function(c, args, cl) {
// Integer will be passed as is here, without c.exClazz, or cl
var clInner = cl;
cl = cl || c.exClazz || c;
Clazz._initClass(cl,1,0,0); // critical here; next will call (0,1,0)
Clazz._initClass(cl,1,0,0);
// BH note: Critical here that the above is not 1,1,0;
// static init is the responsibility of newInstance
// or a static field or method call (which is handled
// by the $I$(n) handler in the function initializer in
// the newClass() call.
var obj = new (Function.prototype.bind.apply(cl, arguments));
if (args[2] != inheritArgs) {
if (haveArgs) {
// Clazz._initClass(cl,0,1,0);
c.apply(obj, args);
}
haveArgs && c.apply(obj, args);
clInner && clInner.$init$.apply(obj);
}

Expand Down Expand Up @@ -14419,7 +14422,7 @@ Clazz.newInstance = function (objThis, args, isInner, clazz) {
objThis.__JSID__ = ++_jsid;

if (!isInner) {
if (args)
// if (args)
clazz && Clazz._initClass(clazz,1,1,objThis);
if ((!args || args.length == 0) && objThis.c$) {
// allow for direct default call "new foo()" to run with its default constructor
Expand Down