Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0ef61f1
BufferedImage fix for TYPE_4BYTE_HTML5 raster
Sep 14, 2020
3f21cc0
create peer for Component.getLocationOnScreen()
Sep 14, 2020
1a59d3b
DataBuffer && not &
Sep 14, 2020
84f7045
EventDispatchThread better coding
Sep 14, 2020
66330c7
simple Date.ISOString() for FileTime.toString()
Sep 14, 2020
58f1d78
HTML5LookAndFeel TextField.caretForeground
Sep 14, 2020
9f1dfbb
JCheckBoxMenuItem fix for icon
Sep 14, 2020
353c1d5
JComponent getInputMap public
Sep 14, 2020
9eee0c4
JSCheckBoxMenuItemUI fix for action + icon
Sep 14, 2020
c387917
allow no paint for empty border
Sep 14, 2020
354a98e
force new cellHeights calc
Sep 14, 2020
70d2ac9
TextUI carets color, padding
Sep 14, 2020
a3a3a83
passing image reference to dataBuffer from Raster
Sep 14, 2020
725e5de
tests
Sep 14, 2020
cb0ce2a
SwingJS-site.zip update
Sep 15, 2020
9fadd43
DocumentParsr fix for text/html; charset... JSTreeUI fix
Sep 30, 2020
0317686
HTML5Video adds seekToNextFrame().then(fsuccess, ffail)
Oct 1, 2020
0684981
HTML5Video adds onerror catch
Oct 4, 2020
de3a8d5
javajs.util.VideoReader
Oct 4, 2020
ed15bde
SwingJS HTML5Video update
Oct 4, 2020
8db66fd
BufferedImage, JSGraphics2D fix for TYPE_INT_RGB
Oct 10, 2020
55b6c22
Allowing non-breaking space only every other character JSEditorPaneUI.
Oct 10, 2020
f286470
Allowing non-breaking space only every other character JSEditorPaneUI.
Oct 10, 2020
c0bc82c
a2s adds super. for superclass calls
Oct 22, 2020
b39255e
site update
Nov 7, 2020
333e8cb
adds AsyncDialog.showMessageDialog(frame, message, title, action)
Nov 17, 2020
eb16603
adds canvas.crossOrigin="Anonymous"
Nov 17, 2020
cdd1380
swingjs site update
Nov 17, 2020
197bff9
// BH 2020.11.20 -- 3.2.9-v1q
Nov 20, 2020
d7178ed
Java 9/10 List/Set static methods
Nov 20, 2020
a94c206
Java 9/10 updates, including Math.floorMod
Nov 20, 2020
c73a3cb
transpiler fix for Java 9 List.of syntax
Nov 22, 2020
f414fb0
Merge pull request #180 from BobHanson/hanson1
BobHanson Nov 27, 2020
98aa96f
Executors.submit(Runnable) not returning a Future
Nov 27, 2020
0f99b47
Merge pull request #181 from BobHanson/hanson1
BobHanson Nov 27, 2020
0b8b02b
Swingjs-Site.zip updated
Nov 27, 2020
a737bf2
Merge pull request #182 from BobHanson/hanson1
BobHanson Nov 27, 2020
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.
4 changes: 4 additions & 0 deletions sources/net.sf.j2s.core/dist/swingjs/differences.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,10 @@ and so are not implmented. javax.swing.text.View and its subclasses are not impl

The JS document model does not allow two text fields to address the same underlying document.

JavaScript is slightly different from Java in that the field value is changed asynchronously after
the keypressed event, so Java actions that are keyed to KEY_PRESSED may not pick up the new
key value even after SwingUtilities.invokeLater() is called. Thus, key pressed actions may need
to be recorded after a key released event instead.

Formatter/Regex limitations
---------------------------
Expand Down
Binary file modified sources/net.sf.j2s.core/dist/swingjs/net.sf.j2s.core-j11.jar
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 @@
20200813222737
20201127044806
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,10 @@ and so are not implmented. javax.swing.text.View and its subclasses are not impl

The JS document model does not allow two text fields to address the same underlying document.

JavaScript is slightly different from Java in that the field value is changed asynchronously after
the keypressed event, so Java actions that are keyed to KEY_PRESSED may not pick up the new
key value even after SwingUtilities.invokeLater() is called. Thus, key pressed actions may need
to be recorded after a key released event instead.

Formatter/Regex limitations
---------------------------
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20200623075216
20201127032339
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/SwingJS-site.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,10 @@ and so are not implmented. javax.swing.text.View and its subclasses are not impl

The JS document model does not allow two text fields to address the same underlying document.

JavaScript is slightly different from Java in that the field value is changed asynchronously after
the keypressed event, so Java actions that are keyed to KEY_PRESSED may not pick up the new
key value even after SwingUtilities.invokeLater() is called. Thus, key pressed actions may need
to be recorded after a key released event instead.

Formatter/Regex limitations
---------------------------
Expand Down
Binary file modified sources/net.sf.j2s.core/dist/swingjs/ver/3.2.9/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.9/timestamp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20200813222737
20201127044806
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class CorePlugin extends Plugin {
// j2sApplet.js and also (Bob only) update.bat, update-clean.bat


// BH 2020.11.20 -- 3.2.9-v1q fix for new ImmutableCollections.ListN<>(E...) should use Object[]
// BH 2020.08.03 -- 3.2.9-v1p fix for boxing boolean should be Boolean.valueOf$, not new Boolean
// BH 2020.08.01 -- 3.2.9-v1o fix for lambda expressions too static
// BH 2020.07.08 -- 3.2.9-v1n fix for try with resources and adds option varOrLet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@

// TODO: superclass inheritance for JAXB XmlAccessorType

//BH 2020.11.20 -- 3.2.9-v1q fix for new ImmutableCollections.ListN<>(E...) should use Object[]
//BH 2020.08.03 -- 3.2.9-v1p fix for boxing boolean should be Boolean.valueOf$, not new Boolean
//BH 2020.08.01 -- 3.2.9-v1o fix for lambda expressions too static
//BH 2020.07.08 -- 3.2.9-v1n fix for try with resources and adds option varOrLet
Expand Down Expand Up @@ -4258,6 +4259,8 @@ private String clazzArray(ITypeBinding type, int dimFlag) {
ITypeBinding ebinding = type.getElementType();
if (ebinding == null)
ebinding = type; // creating for Enum

System.out.println("J2S.clazzArray " + type + " k=" + type.getKey() + " n=" + type.getName());
String params = (ebinding.isPrimitive() ? NameMapper.getPrimitiveTYPE(ebinding.getName()) + ".TYPE"
: getFinalJ2SClassNameQualifier(null, ebinding, null, FINAL_ESCAPECACHE))
+ (dimFlag == ARRAY_DIM_ONLY ? "" : ", " + (Math.abs(dimFlag) * type.getDimensions() * -1));
Expand Down Expand Up @@ -5133,13 +5136,22 @@ String getFinalJ2SClassNameQualifier(Name methodQualifier, ITypeBinding declarin
// It will require synchronous loading,
// but it will ensure that a class is only
// loaded when it is really needed.

if (declaringJavaClassName == null)
declaringJavaClassName = getUnreplacedJavaClassNameQualified(declaringJavaClass);

boolean isStatic = ((flags & FINAL_STATIC) == FINAL_STATIC);
boolean doEscape = isStatic || ((flags & FINAL_ESCAPE) == FINAL_ESCAPE);
boolean doCache = ((flags & FINAL_CACHE) == FINAL_CACHE);
String name = removeBracketsAndFixNullPackageName(declaringJavaClassName);
if (name.equals("_.")) {
// 2020.11.20 -- 3.2.9-v1q generated by
// static <E> java.util.List<E> of(E e1, E e2, E e3, E e4) {
// return new ImmutableCollections.ListN<>(e1, e2, e3, e4);
// }

return "java.lang.Object";
}
doEscape &= !NameMapper.isClassKnown(name);
if (!doEscape) {
if (methodQualifier != null) {
Expand Down
Binary file modified sources/net.sf.j2s.java.core/dist/SwingJS-site.zip
Binary file not shown.
4 changes: 4 additions & 0 deletions sources/net.sf.j2s.java.core/dist/differences.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,10 @@ and so are not implmented. javax.swing.text.View and its subclasses are not impl

The JS document model does not allow two text fields to address the same underlying document.

JavaScript is slightly different from Java in that the field value is changed asynchronously after
the keypressed event, so Java actions that are keyed to KEY_PRESSED may not pick up the new
key value even after SwingUtilities.invokeLater() is called. Thus, key pressed actions may need
to be recorded after a key released event instead.

Formatter/Regex limitations
---------------------------
Expand Down
4 changes: 4 additions & 0 deletions sources/net.sf.j2s.java.core/doc/Differences.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,10 @@ and so are not implmented. javax.swing.text.View and its subclasses are not impl

The JS document model does not allow two text fields to address the same underlying document.

JavaScript is slightly different from Java in that the field value is changed asynchronously after
the keypressed event, so Java actions that are keyed to KEY_PRESSED may not pick up the new
key value even after SwingUtilities.invokeLater() is called. Thus, key pressed actions may need
to be recorded after a key released event instead.

Formatter/Regex limitations
---------------------------
Expand Down
2 changes: 1 addition & 1 deletion sources/net.sf.j2s.java.core/src/java/awt/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -1881,7 +1881,7 @@ final Point getLocationOnScreen_NoTreeLock() {
}
return pt;
} else {
if (peer == null)
if (getOrCreatePeer() == null)
return null;
Point pt = peer.getLocationOnScreen();
return pt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,8 @@ protected boolean isLooping() {
@Override
protected boolean myLoop() {
final int myid = id;
Runnable r = new Runnable() {
@Override
public void run() {
pumpOneEventForFilters(myid);
}
};
JSThread me = this;
int mode = LOOP;
JSFunction f = /** @j2sNative function() {r.run$();me.run1$I(mode)} || */ null;
JSToolkit.dispatch(f, 0, 0);
dispatchAndReturn(()->{pumpOneEventForFilters(myid);}, LOOP);
// handling sleepAndReturn myself
// and once through only
return (doDispatch = false);
Expand Down
4 changes: 3 additions & 1 deletion sources/net.sf.j2s.java.core/src/java/awt/JSComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.AbstractBorder;
import javax.swing.border.EmptyBorder;
import javax.swing.plaf.BorderUIResource;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.FontUIResource;
Expand Down Expand Up @@ -691,7 +692,8 @@ public void removeKeyListener(KeyListener l) {
protected boolean 秘paintsBorder() {
// default ButtonBorders are not painted by default; this happens to also include internal frames
return (秘border != null
&& !(秘border instanceof BorderUIResource.CompoundBorderUIResource));
&& !(秘border instanceof BorderUIResource.CompoundBorderUIResource)
&& !(秘border instanceof EmptyBorder));
}

/**
Expand Down
62 changes: 33 additions & 29 deletions sources/net.sf.j2s.java.core/src/java/awt/image/BufferedImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,20 @@ public class BufferedImage extends Image implements RenderedImage, Transparency
{

private static final int STATE_UNINITIALIZED = 0;

private static final int STATE_IMAGENODE = 1 << 0;
private static final int STATE_RASTER = 1 << 1;
private static final int STATE_GRAPHICS = 1 << 2;
private static final int STATE_VIDEO = 1 << 3;

private static final int STATE_IMAGENODE = 1 << 0;
private static final int STATE_RASTER = 1 << 1;
private static final int STATE_GRAPHICS = 1 << 2;
private static final int STATE_VIDEO = 1 << 3;

private static final int STATE_HAVE_PIXELS8 = 1 << 4; // byte[]
private static final int STATE_HAVE_PIXELS32 = 1 << 5; // int[]
private static final int STATE_HAVE_PIXELS = STATE_HAVE_PIXELS8 | STATE_HAVE_PIXELS32;

private int 秘state = STATE_UNINITIALIZED;

private static final String[] states = new String[] { "ImageOnly", "Raster", "Graphics", "Video",
"8-bitPixels", "32-bitPixels" };
private static final String[] states = new String[] { "ImageOnly", "Raster", "Graphics", "Video", "8-bitPixels",
"32-bitPixels" };

public String getStateString() {
int[] data = /** @j2sNative this.raster.data || */
Expand All @@ -141,8 +140,8 @@ public String getStateString() {
if ((秘state & (1 << i)) != 0)
s += states[i] + ";";
}
return "rasterStolen=" + 秘isDataStolen() + " " + (s == "" ? "UNINITIALIZED" : s) + " unDisposedGraphicCount=" + gCount
+ " data[0]=" + (data == null ? null : Integer.toHexString(data[0]));
return "rasterStolen=" + 秘isDataStolen() + " " + (s == "" ? "UNINITIALIZED" : s) + " unDisposedGraphicCount="
+ gCount + " data[0]=" + (data == null ? null : Integer.toHexString(data[0]));
}

@SuppressWarnings("unused")
Expand Down Expand Up @@ -179,7 +178,7 @@ public String getStateString() {
boolean b = raster.dataBuffer.theTrackable.getState() == sun.java2d.StateTrackable.State.UNTRACKABLE;
return b;
}

/**
*
* @return true if data are stolen, and the raster is active, not the canvas
Expand Down Expand Up @@ -557,6 +556,7 @@ public BufferedImage(int width, int height, int imageType) {
} else {
秘state = STATE_GRAPHICS | STATE_RASTER | STATE_HAVE_PIXELS8;
}
raster.秘setImage(this);
}
break;

Expand Down Expand Up @@ -1388,14 +1388,14 @@ public Graphics2D createGraphics() {
}

/**
* If data are stolen and we don't have raster, because createImage() or getImage()
* has been called, recreate the raster.
* If data are stolen and we don't have raster, because createImage() or
* getImage() has been called, recreate the raster.
*
* If we have a raster but no pixels, create the pixels.
*
* Then create the canvas.
*
*/
*/
@Override
public void flush() {
boolean isStolen = 秘isDataStolen();
Expand Down Expand Up @@ -2018,8 +2018,10 @@ public int getTransparency() {

HTML5Canvas canvas = (g == null ? null : /** @j2sNative g.canvas || */
null);
if (canvas == null)
if (canvas == null) {
canvas = (HTML5Canvas) DOMNode.createElement("canvas", null);
/** @j2sNative canvas.crossOrigin = "Anonymous"; */
}
int w = width;
int h = height;
byte[] data = HTML5Canvas.getDataBufferBytes(canvas, node, w, h);
Expand All @@ -2031,13 +2033,13 @@ public int getTransparency() {
case TYPE_INT_ARGB_PRE:// #3
case TYPE_INT_ARGB:
// convert canvas [r g b a r g b a ...] into [argb argb argb ...]
toIntARGB(data, (int[]) (秘pix = ((DataBufferInt) buf).data));
toIntARGB(data, (int[]) (秘pix = ((DataBufferInt) buf).data), imageType == TYPE_INT_RGB ? 0 : 0xFF000000);
// Jmol, for instance, uses a 4 * w * h buffer for antialiasing
if (((int[]) 秘pix).length != 秘wxh)
秘pix = null;
break;
case TYPE_4BYTE_HTML5:
data = ((DataBufferByte) buf).data;
((DataBufferByte) buf).data = data;
if (nBits != 32) {
秘pix = data;
haveHTML5Pixels = true;
Expand Down Expand Up @@ -2071,7 +2073,7 @@ public int getTransparency() {
break;
}
if (秘pix == null) {
toIntARGB(data, (int[]) (秘pix = new int[data.length >> 2]));
toIntARGB(data, (int[]) (秘pix = new int[data.length >> 2]), 0xFF000000);
}
秘state = STATE_GRAPHICS | STATE_RASTER;
秘state |= (haveHTML5Pixels ? STATE_HAVE_PIXELS8 : STATE_HAVE_PIXELS32);
Expand All @@ -2088,10 +2090,12 @@ public int getTransparency() {
* 0000
*
* @param ctxData HTML5 canvas.context.imageData.data
* @param iData int[] data buffer
* @param alpha alpha mask
* @return array of ARGB values
*
*/
private static void toIntARGB(byte[] ctxData, int[] iData) {
private static void toIntARGB(byte[] ctxData, int[] iData, int alpha) {
// red=imgData.data[0];
// green=imgData.data[1];
// blue=imgData.data[2];
Expand All @@ -2100,7 +2104,7 @@ private static void toIntARGB(byte[] ctxData, int[] iData) {
// convert canvas [r g b a r g b a ...] into [argb argb argb ...]
int n = ctxData.length >> 2;
for (int i = 0, j = 0; i < n;) {
int argb = (ctxData[j++] << 16) | (ctxData[j++] << 8) | ctxData[j++] | 0xFF000000;
int argb = (ctxData[j++] << 16) | (ctxData[j++] << 8) | ctxData[j++] | alpha;
iData[i++] = (ctxData[j++] == 0 ? 0 : argb);
}
}
Expand Down Expand Up @@ -2129,18 +2133,18 @@ private void toByte3BGR(byte[] ctxData, byte[] buf) {
}

/**
* This model involves two colors. red/blue for instance.
* The bits are packed into the raster bytes
* This model involves two colors. red/blue for instance. The bits are packed
* into the raster bytes
*
* @param ctxData
* @param buf
*/
private void toRaster(byte[] ctxData) {
ColorModel cm = getColorModel();
int[] iData = new int[ctxData.length >> 2];
for (int i = 0, pt = 0, n = ctxData.length; i < n; i+= 4)
iData[pt++] = cm.getDataElement((int[])(Object)ctxData, i);
raster.setDataElements(0, 0, width, height, iData);
for (int i = 0, pt = 0, n = ctxData.length; i < n; i += 4)
iData[pt++] = cm.getDataElement((int[]) (Object) ctxData, i);
raster.setDataElements(0, 0, width, height, iData);
}

private void toUShortGray(byte[] ctxData, short[] buf) {
Expand Down Expand Up @@ -2237,7 +2241,7 @@ private void toInt3BGR(byte[] ctxData, int[] buf) {
b = ((DataBufferByte) raster.getDataBuffer()).getData();
if (nbits == 32) {
int[] data = new int[n];
toIntARGB(b, data);
toIntARGB(b, data, 0xFF000000);
秘state |= STATE_HAVE_PIXELS32;
} else {
秘state |= STATE_HAVE_PIXELS8;
Expand Down Expand Up @@ -2306,7 +2310,7 @@ private void toInt3BGR(byte[] ctxData, int[] buf) {
}
if (nbits == 32) {
int[] data = new int[n];
toIntARGB((byte[]) (Object) p, data);
toIntARGB((byte[]) (Object) p, data, 0xFF000000);
秘state |= STATE_HAVE_PIXELS32;
} else {
秘state |= STATE_HAVE_PIXELS8;
Expand Down Expand Up @@ -2377,9 +2381,9 @@ private void toInt3BGR(byte[] ctxData, int[] buf) {
if (秘haveVideo())
return 秘imgNode;
DOMNode node = DOMNode.createElement("img", null);
node.setAttribute("width", 秘imgNode.getAttribute("width"));
node.setAttribute("height", 秘imgNode.getAttribute("height"));
node.setAttribute("src", 秘imgNode.getAttribute("src"));
node.setAttribute("width", 秘imgNode.getAttribute("width"));
node.setAttribute("height", 秘imgNode.getAttribute("height"));
node.setAttribute("src", 秘imgNode.getAttribute("src"));
return node;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public abstract class DataBuffer {
* Check only if NOT within an inner loop
*/
public void 秘checkImage() {
if (checkImageDepth == 0 & 秘image != null)
if (checkImageDepth == 0 && 秘image != null)
秘image.秘ensureRasterUpToDate();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public class Raster {
BufferedImage 秘image; // SwingJS -- necessary!

void 秘setImage(BufferedImage image) {
秘image = image;
秘image = dataBuffer.秘image = image;
}

/**
Expand Down
Loading