Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cef1a4d
Merge pull request #9 from BobHanson/master
BobHanson Feb 17, 2018
461ea72
readme updates; removing site.zip
BobHanson Feb 17, 2018
b22213f
html5 compliant template file
BobHanson Feb 17, 2018
0ff9856
fixes for AWT scrollbar and textfield event handling
BobHanson Feb 18, 2018
b8ce9db
update after Physlets.minkowski
BobHanson Feb 18, 2018
9f7dada
Adds java.awt.image.ImageFilter
BobHanson Feb 20, 2018
c82acb2
adds Checkbox.setCheckboxGroup
BobHanson Feb 20, 2018
18ef44b
fixes for j2sApplet and J2sClazz
BobHanson Feb 20, 2018
f50e002
j2sApplet, j2sClazz
BobHanson Feb 20, 2018
5c35e56
fix for array.clone(), missing classes, unimplemented code for images
BobHanson Feb 22, 2018
f24d8cc
adds J2S._getKeyModifier
BobHanson Feb 22, 2018
ce1cb82
new site zip
BobHanson Feb 22, 2018
47cf74c
better check for having pixels in an image
BobHanson Feb 22, 2018
a0d38f3
BufferedImage work; fixes old java.util.Random
BobHanson Feb 24, 2018
01bc9fd
fixes java.util.Random.nextInt(n)
BobHanson Feb 25, 2018
6d9e8fa
moves doc/differences.txt to net.sf.j2s.java.core; adds MediaTracker
BobHanson Feb 27, 2018
8574afe
allows for applet.resize(width,height) in JavaScript or Java
BobHanson Feb 28, 2018
193a059
JSGraphics2D.setPaintMode, setXORMode working
BobHanson Feb 28, 2018
02e8e81
JSGraphics2D setPaintMode, setXORMode
BobHanson Feb 28, 2018
b060a69
Adds netscape to list of nonQualified packages
BobHanson Mar 8, 2018
5ab9c43
adds netscape to nonqualified packages
BobHanson Mar 8, 2018
3e3ccc5
Applet resizing
BobHanson Mar 8, 2018
f2adc17
updated preliminary netscape.javascript.JSObject
BobHanson Mar 9, 2018
5e8bb2a
Compiler debug comments removed
BobHanson Mar 14, 2018
5e386e9
Key Event work -- unfinished; JSThread fix Clazz.new_; init() size fix
BobHanson Mar 14, 2018
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
18 changes: 17 additions & 1 deletion sources/net.sf.j2s.core/README.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
The net.sf.j2s.core Eclipse project creates the Java2Script transpiler for SwingJS.

See the dist/dropins folder for the latest distribution and installation notes.
See the dist/dropins folder for the latest distribution and installation notes.

The seed Eclipse project site/ directory for all SwingJS projects can be found at

https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.java.core/SwingJS-site.zip?raw=true


Known issues: 2/2018

Background and drawing using g.fill

Drawing to a canvas and setting background color can be incompatible. It is recommended that
if the canvas is being painted using graphic calls, that the background color also be painted that way
rather than using setBackground



82 changes: 82 additions & 0 deletions sources/net.sf.j2s.core/dist/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
SwingJS distribution README.txt

SwingJS has been successfully tested in Eclipse Neon and Oxygen on Mac and Windows platforms.
(No reason to believe it would not also work for Linux; just haven't tried that recently.)

INSTALLATION INSTRUCTIONS

Eclipse Neon or higher is necessary.

1. net.sf.j2s.core_3.1.1.jar should be copied to the eclipse/dropins
directory **AS net.sf.j2s.core.jar dropping the version info**
because otherwise Eclipse will not recognize an update.

We do not know why this is necessary, but it appears to be. If you leave
the version in the name, Eclipse will not be able to replace it with a
newer version later. From what we can tell.

On Mac systems, this directory is

/Applications/Eclipse.app/Contents/Eclipse/dropins

2. restart Eclipse and check for the presence of the plug-in at
help...about Eclipse...installation details...Plug-ins...(wait several seconds for tabulation)

search for "j2s" to find j2s.sourceforge.net Java2Script Core

If that is not there, you don't have net.sf.j2s.core.jar in the proper directory.

3. Create an Eclipse Java project for your work, if you have not done so already.
If your source code is not all already in src/, navigate to the project...properties...Java Build Path...source
and add all the source directories you need.

4. Create in the Eclipse project the file:

.j2s

containing simply:

j2s.compiler.status=enable

5. Modify the .project file to indicate the j2s transpiler is to be used,
changing the buildSpec buildCommand from

org.eclipse.jdt.core.javabuilder

to

net.sf.j2s.core.java2scriptbuilder

6. All of the JavaScript produced will be in the project site/ directory.
You must prepopulate this site with all the JavaScript required by the
JavaScript version of the JVM. The most recent version of site/ is at

https://github.com/BobHanson/java2script/blob/master/sources/net.sf.j2s.java.core/SwingJS-site.zip?raw=true

Occasional additions to the java.* classes are made to the above-mentioned zip file.

If you find you are missing a class, please contact me (Bob Hanson) at hansonr@stolaf.edu.
You can try adding these yourself by **temporarily** adding one or more of the
Java classes found at http://grepcode.com to the proper package. If you do that, be sure
to use the OpenJDK version. Most of the code in the SwingJS project started with Java 6-b14 or 6-b27.
Build your project, then delete these Java files, because you do not necessarily want your Java
code using that version, just JavaScript.

A full site with many examples is at https://chemapps.stolaf.edu/swingjs/site

VARNA development is at https://github.com/BobHanson/VARNA
working site is https://chemapps.stolaf.edu/swingjs/varna

Physlets development is at https://github.com/BobHanson/Physlets-SwingJS
working site is https://chemapps.stolaf.edu/swingjs/physlets

As of Feb. 17, 2018, we are actively converting a variety of functioning Java applets.

The physlets Animator, Doppler, and Optics are working.

As of Jan. 2, 2018, all known Java-to-JavaScript issues have been dealt with.
Efficient Google Closure Compiler compression is in place.

As of Dec. 17, 2017, SwingJS is fully operational in its "version 2" format,
which includes fully qualified method, array, and number typing.

47 changes: 0 additions & 47 deletions sources/net.sf.j2s.core/dist/dropins/README.txt

This file was deleted.

Binary file modified sources/net.sf.j2s.core/dist/dropins/net.sf.j2s.core.jar
Binary file not shown.
Binary file not shown.
Binary file removed sources/net.sf.j2s.core/site_versions/site.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ private static boolean isObjectOrNull(ITypeBinding type) {

private final static String CHARCODEAT0 = ".$c()";

private final static String defaultNonQualified = "javajs.api.js;swingjs.api.js;swingjs.JSToolkit;";
private final static String defaultNonQualified = "javajs.api.js;swingjs.api.js;swingjs.JSToolkit;netscape;";

private static String[] nonQualifiedPackages;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,10 @@ private static void writeToFile(File file, String data) {
* @return default template with _NAME_, _CODE_, and _MAIN_ to fill in.
*/
private String getDefaultHTMLTemplate() {
String ret = "<!DOCTYPE html>\n<html><title>SwingJS test _NAME_</title>\n"
+"<head><meta charset=\"utf-8\" />\n"
String ret = "<!DOCTYPE html>\n<html>\n"
+"<head>\n"
+"<title>SwingJS test _NAME_</title>"
+"<meta charset=\"utf-8\" />\n"
+"<script src=\"swingjs/swingjs2.js\"></script>\n"
+"<script>\n"
+"if (!self.SwingJS)alert('swingjs2.js was not found. It needs to be in swingjs folder in the same directory as ' + document.location.href)\n"
Expand All @@ -320,6 +322,7 @@ private String getDefaultHTMLTemplate() {
+" main: _MAIN_,\n"
+" width: 850,\n"
+" height: 550,\n"
+" readyFunction: null,\n"
+" serverURL: 'https://chemapps.stolaf.edu/jmol/jsmol/php/jsmol.php',\n"
+" j2sPath: 'swingjs/j2s',\n"
+" console:'sysoutdiv',\n"
Expand All @@ -330,7 +333,7 @@ private String getDefaultHTMLTemplate() {
+"getClassList = function(){J2S._saveFile('_j2sclasslist.txt', Clazz.ClassFilesLoaded.sort().join('\\n'))}\n"
+"</script>\n"
+"<div style=\"position:absolute;left:900px;top:30px;width:600px;height:300px;\">\n"
+"<div id=sysoutdiv style=\"border:1px solid green;width:100%;height:95%;overflow:auto\"></div>\n"
+"<div id=\"sysoutdiv\" style=\"border:1px solid green;width:100%;height:95%;overflow:auto\"></div>\n"
+"This is System.out. <a href=\"javascript:testApplet._clearConsole()\">clear it</a> <br>Add ?j2snocore to URL to see full class list; ?j2sdebug to use uncompressed j2s/core files <br><a href=\"javascript:getClassList()\">get _j2sClassList.txt</a>\n"
+"</div>\n"
+"</body>\n"
Expand Down Expand Up @@ -366,6 +369,7 @@ private static void addHTML(ArrayList<String> appList, String siteFolder, String

@Override
public boolean accept(File pathname) {
//System.out.println("accept " + pathname + " " +pathname.isDirectory());
return pathname.isDirectory() || !pathname.getName().endsWith(".java");
}

Expand All @@ -379,6 +383,7 @@ private static void copyNonclassFiles(File dir, File target) {
if (dir.equals(target))
return;
File[] files = dir.listFiles(filter);
System.err.println("copy nonclassFiles " + dir + " to " + target + " [" + (files != null ? files.length : "") + "]");
File f = null;
if (files != null)
try {
Expand All @@ -393,7 +398,7 @@ private static void copyNonclassFiles(File dir, File target) {
} else {
Files.copy(f.toPath(), new File(target, f.getName()).toPath(),
StandardCopyOption.REPLACE_EXISTING);
System.err.println("copied " + f + " to " + target);
System. err.println("copied " + f + " to " + target);
}
}
} catch (IOException e1) {
Expand Down
Binary file modified sources/net.sf.j2s.java.core/SwingJS-site.zip
Binary file not shown.
Loading