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.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core.jar
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 @@
20180916165130
20180917232142
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.2/SwingJS-site.zip
Binary file not shown.
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.2/net.sf.j2s.core.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.core/dist/swingjs/ver/3.2.2/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20180916165130
20180917232142
41 changes: 22 additions & 19 deletions sources/net.sf.j2s.core/src/net/sf/j2s/core/Java2ScriptVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public class Java2ScriptVisitor extends ASTVisitor {
* parameterized
*
*/
private boolean temp_addUnqualifiedMethod;
private boolean temp_add$UnqualifiedMethod;

// the three key elements of any class

Expand Down Expand Up @@ -1001,15 +1001,10 @@ private void processMethodDeclaration(IMethodBinding mBinding, List<ASTNode> par
boolean isPrivate = !isPublic && !isConstructor && isPrivate(mBinding);
boolean isStatic = isStatic(mBinding);
int qualification = (lambdaType != NOT_LAMBDA ? METHOD_FULLY_QUALIFIED
: temp_addUnqualifiedMethod ? METHOD_$_QUALIFIED
: isUserApplet && !isConstructor && !isStatic && isPublic ? METHOD_UNQUALIFIED
: temp_add$UnqualifiedMethod ? METHOD_$_QUALIFIED
: METHOD_FULLY_QUALIFIED);

// boolean addUnqualified = lambdaType == NOT_LAMBDA && (temp_addUnqualifiedMethod // method call to lambda
// || isUserApplet && !isConstructor && !isStatic && isPublic
// // public applet methods could never be overloaded in
// // JavaScript anyway.
// );
if (isUserApplet && lambdaType == NOT_LAMBDA && !isConstructor && !isStatic && isPublic)
qualification |= METHOD_UNQUALIFIED;
String finalName = getFinalMethodNameOrArrayForDeclaration(mBinding, isConstructor, qualification);
boolean isMain = isStatic && isPublic && mBinding.getName().equals("main")
&& mBinding.getKey().endsWith(";.main([Ljava/lang/String;)V");
Expand Down Expand Up @@ -2020,15 +2015,14 @@ private void addClassOrInterface(ASTNode node, ITypeBinding binding, List<?> bod
log("default method " + method.getKey());
defpt = buffer.length();
}
boolean addUnqualifiedCurrent = temp_addUnqualifiedMethod;
boolean addUnqualifiedCurrent = temp_add$UnqualifiedMethod;
if (unqualifiedMethods != null) {
// check for all methods that override a functional interface abstract method,
// as those
// methods are not to be qualified
// as those methods are to be qualified only with $

for (int i = unqualifiedMethods.size(); --i >= 0;) {
if (method.overrides(unqualifiedMethods.get(i))) {
temp_addUnqualifiedMethod = true;
temp_add$UnqualifiedMethod = true;
break;
}
}
Expand All @@ -2038,7 +2032,7 @@ private void addClassOrInterface(ASTNode node, ITypeBinding binding, List<?> bod
defaults.append(buffer.substring(defpt));
buffer.setLength(defpt);
}
temp_addUnqualifiedMethod = addUnqualifiedCurrent;
temp_add$UnqualifiedMethod = addUnqualifiedCurrent;
}
}
}
Expand Down Expand Up @@ -4847,19 +4841,28 @@ private String getFinalMethodNameOrArrayForDeclaration(IMethodBinding mBinding,
ITypeBinding methodClass = mBinding.getDeclaringClass();
List<String> names = null;
List<String[]> methodList = getGenericMethodList(methodClass, nodeName);

if (methodList != null) {
names = new ArrayList<String>();
for (int i = methodList.size(); --i >= 0;) {
String pname = getFinalMethodNameWith$Params(methodName, null, mBinding, methodList.get(i), false,
METHOD_NOTSPECIAL);
if (pname != null)
names.add(pname);
if (qualification == METHOD_FULLY_QUALIFIED)
if (qualification != METHOD_FULLY_QUALIFIED)
names.add(ensureMethod$Name(methodName, mBinding, getJavaClassNameQualified(methodClass)));
}
} else if (qualification != METHOD_FULLY_QUALIFIED && !methodName.equals(qname) && !classHasMethod(methodClass, methodName)) {
names = new ArrayList<String>();
names.add(methodName + (qualification == METHOD_UNQUALIFIED || methodName.indexOf("$") >= 0 ? "" : "$"));
}
if ((qualification & METHOD_$_QUALIFIED) != 0 && !methodName.equals(qname)
&& !classHasNoParameterMethod(methodClass, methodName)) {
if (names == null)
names = new ArrayList<String>();
names.add(methodName + (methodName.indexOf("$") >= 0 ? "" : "$"));
}
if ((qualification & METHOD_UNQUALIFIED) != 0) {
if (names == null)
names = new ArrayList<String>();
names.add(methodName);
}
if (names == null || names.size() == 0)
return "'" + qname + "'";
Expand All @@ -4872,7 +4875,7 @@ private String getFinalMethodNameOrArrayForDeclaration(IMethodBinding mBinding,
return "[" + qname.substring(1) + "]";
}

private static boolean classHasMethod(ITypeBinding methodClass, String methodName) {
private static boolean classHasNoParameterMethod(ITypeBinding methodClass, String methodName) {
while (methodClass != null) {
IMethodBinding[] methods = methodClass.getDeclaredMethods();
for (int i = methods.length; --i >= 0;) {
Expand Down
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
13 changes: 13 additions & 0 deletions sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,17 @@ public void validateComponent() {

}

/**
* Paint this component, checking to see if the background got painted, and if so, make the
* div background transparent so that that underlying HTML5 canvas shows through.
*
* @param g
*/
public void paintWithBackgroundCheck(Graphics g) {
checkBackgroundPainted(null);
paint(g);
checkBackgroundPainted(getJSGraphic2D(g));
}


}
4 changes: 1 addition & 3 deletions sources/net.sf.j2s.java.core/src/javax/swing/JComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -4573,9 +4573,7 @@ void _paintImmediately(int x, int y, int w, int h) {
// jpanel.repaint() and then draws on the background,
// the JPanel's background is made transparent
// (so that the underlying JRootPane canvas can show).
checkBackgroundPainted(null);
paintingComponent.paint(g);
checkBackgroundPainted(getJSGraphic2D(g));
paintingComponent.paintWithBackgroundCheck(g);
}
} finally {
g.dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ private void paintDirtyRegions1(
if (g != null) {
// SwingJS not clipping, for performance g.setClip(rect.x, rect.y, rect.width, rect.height);
try {
((Container) dirtyComponent).paint(g); // SwingJS was paintContainer, but that bypasses user's paint(g)?? 9/15/18
((Container) dirtyComponent).paintWithBackgroundCheck(g); // SwingJS was paintContainer, but that bypasses user's paint(g) and does not do the background check?? 9/15/18
} finally {
g.dispose();
}
Expand Down
12 changes: 7 additions & 5 deletions sources/net.sf.j2s.java.core/src/swingjs/JSGraphics2D.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,12 @@ public JSGraphics2D(Object canvas) { // this must be Object, because we are
hints = new RenderingHints(new Hashtable());
this.canvas = (HTML5Canvas) canvas;
ctx = this.canvas.getContext("2d");
// reduce antialiasing, thank you,
// http://www.rgraph.net/docs/howto-get-crisp-lines-with-no- antialias.html
if (!isShifted)
ctx.translate(-0.5, -0.5);
isShifted = true;
// removed - caused blurriness 9/17/2018
// // reduce antialiasing, thank you,
// // http://www.rgraph.net/docs/howto-get-crisp-lines-with-no- antialias.html
// if (!isShifted)
// ctx.translate(-0.5, -0.5);
// isShifted = true;
transform = new AffineTransform();
setStroke(new BasicStroke());
/**
Expand Down Expand Up @@ -498,6 +499,7 @@ public boolean drawImagePriv(Image img, int x, int y, ImageObserver observer) {

public void drawDirectRGBA(int[] pixels) {
// this can go VERY fast - for writing directly to the canvas context
backgroundPainted = true;
drawDirect(pixels, 0, 0, width, height, false);
}

Expand Down
6 changes: 5 additions & 1 deletion sources/net.sf.j2s.java.core/srcjs/js/j2sClazz.js
Original file line number Diff line number Diff line change
Expand Up @@ -1625,6 +1625,7 @@ Clazz._getStackTrace = function(n) {
estack.pop();
}
var s = "\n";
try {
var c = arguments.callee;
for (var i = 0; i < n; i++) {
if (!(c = c.caller))
Expand All @@ -1646,7 +1647,7 @@ Clazz._getStackTrace = function(n) {
s += getArgs(c);
}
}

} catch(e){}
s += estack.join("\n");
if (Clazz._stack.length) {
s += "\nsee Clazz._stack";
Expand Down Expand Up @@ -5128,6 +5129,7 @@ m$(C$, ['printStackTrace$java_io_PrintStream','printStackTrace$java_io_PrintWrit

Clazz.newMeth(C$, 'fillInStackTrace$', function () {
this.stackTrace = Clazz.array(StackTraceElement);
try {
var caller = arguments.callee.caller;
var superCaller = null;
var callerList = [];
Expand Down Expand Up @@ -5162,6 +5164,8 @@ while (index < 20 && caller != null) {
}
caller = (superCaller && superCaller.arguments && superCaller.arguments.callee) ? superCaller.arguments.callee.caller : null;
}
} catch (e) {};

Clazz.initializingException = false;
return this;
});
Expand Down
6 changes: 5 additions & 1 deletion sources/net.sf.j2s.java.core/srcjs/swingjs2.js
Original file line number Diff line number Diff line change
Expand Up @@ -15169,6 +15169,7 @@ Clazz._getStackTrace = function(n) {
estack.pop();
}
var s = "\n";
try {
var c = arguments.callee;
for (var i = 0; i < n; i++) {
if (!(c = c.caller))
Expand All @@ -15190,7 +15191,7 @@ Clazz._getStackTrace = function(n) {
s += getArgs(c);
}
}

} catch(e){}
s += estack.join("\n");
if (Clazz._stack.length) {
s += "\nsee Clazz._stack";
Expand Down Expand Up @@ -18672,6 +18673,7 @@ m$(C$, ['printStackTrace$java_io_PrintStream','printStackTrace$java_io_PrintWrit

Clazz.newMeth(C$, 'fillInStackTrace$', function () {
this.stackTrace = Clazz.array(StackTraceElement);
try {
var caller = arguments.callee.caller;
var superCaller = null;
var callerList = [];
Expand Down Expand Up @@ -18706,6 +18708,8 @@ while (index < 20 && caller != null) {
}
caller = (superCaller && superCaller.arguments && superCaller.arguments.callee) ? superCaller.arguments.callee.caller : null;
}
} catch (e) {};

Clazz.initializingException = false;
return this;
});
Expand Down