Skip to content

Commit 739ea06

Browse files
committed
SwingJS-site.zip; JSmouse.java
1 parent 8ca18fb commit 739ea06

File tree

11 files changed

+60
-32
lines changed

11 files changed

+60
-32
lines changed
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20240814095418
1+
20241104091759
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20240814095418
1+
20241104091759
Binary file not shown.

sources/net.sf.j2s.java.core/src/javajs/util/CifDataParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,8 @@ public String skipLoop(boolean doReport) throws Exception {
424424
while ((str = (String) getNextDataToken()) != null) {
425425
if (ret == null)
426426
continue;
427-
ret.append(str).append(" ");
427+
if (str.charAt(0) != 0)
428+
ret.append(str).append(" ");
428429
if ((++m % n) == 0)
429430
ret.append("\n");
430431
}

sources/net.sf.j2s.java.core/src/javajs/util/MeasureD.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public static double computeAngleABC(T3d pointA, T3d pointB, T3d pointC, boolean
4747
}
4848

4949
public static double computeTorsion(T3d p1, T3d p2, T3d p3, T3d p4, boolean asDegrees) {
50-
50+
if (p1.distanceSquared(p2) < 1e-10)
51+
return 0;
5152
double ijx = p1.x - p2.x;
5253
double ijy = p1.y - p2.y;
5354
double ijz = p1.z - p2.z;

sources/net.sf.j2s.java.core/src/swingjs/JSMouse.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ private void entry(long time, int x, int y, int id) {
206206
* @param modifiers
207207
* @param clickCount
208208
*/
209-
private void clicked(long time, int x, int y, int modifiers, int clickCount) {
209+
public void clicked(long time, int x, int y, int modifiers, int clickCount) {
210210
// clearKeyBuffer();
211211
// clickedCount is not reliable on some platforms
212212
// so we will just deal with it ourselves
@@ -404,10 +404,10 @@ private static void processMouseEvent(Object jqevent, Component source, int id,
404404
boolean popupTrigger = isPopupTrigger(id, modifiers, JSToolkit.isWin);
405405
MouseEvent e;
406406
if (id == MouseEvent.MOUSE_WHEEL) {
407-
e = new MouseWheelEvent(source, id, time, modifiers, x, y, x, y, count, popupTrigger,
407+
e = new MouseWheelEvent(source, id, time, modifiers, x, y, count, popupTrigger,
408408
MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, dy);
409409
} else {
410-
e = new MouseEvent(source, id, time, modifiers, x, y, x, y, count, popupTrigger, button);
410+
e = new MouseEvent(source, id, time, modifiers, x, y, count, popupTrigger, button);
411411
}
412412
byte[] bdata = new byte[0];
413413
e.setBData(bdata);

sources/net.sf.j2s.java.core/src/swingjs/JSMouse2.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,29 @@ public JSMouse2 set(JSMouse mouse) {
5757
*
5858
*/
5959
public void processTwoPointGesture(float[][][] touches) {
60-
61-
if (touches[0].length < 2)
62-
return;
6360
float[][] t1 = touches[0];
6461
float[][] t2 = touches[1];
62+
int nt = t1.length;
63+
if (nt < 2)
64+
return;
65+
boolean isClick = (nt > t2.length);
6566
float[] t1first = t1[0];
66-
float[] t1last = t1[t2.length - 1];
6767
float x1first = t1first[0];
68-
float x1last = t1last[0];
69-
float dx1 = x1last - x1first;
7068
float y1first = t1first[1];
69+
70+
if (isClick) {
71+
mouse.clicked(System.currentTimeMillis(), (int) x1first, (int) y1first, 0, 2);
72+
return;
73+
}
74+
float[] t1last = t1[nt - 1];
75+
float x1last = t1last[0];
7176
float y1last = t1last[1];
77+
float dx1 = x1last - x1first;
7278
float dy1 = y1last - y1first;
7379
V3 v1 = V3.new3(dx1, dy1, 0);
7480
float d1 = v1.length();
7581
float[] t2first = t2[0];
76-
float[] t2last = t2[t2.length - 1];
82+
float[] t2last = t2[nt - 1];
7783
float x2first = t2first[0];
7884
float x2last = t2last[0];
7985
float dx2 = x2last - x2first;

sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// j2sApplet.js BH = Bob Hanson hansonr@stolaf.edu
22

3+
// BH 2024.10.03 adds two-finger tap as "click"; reinstates touch gestures lost when we went to pointerup 2023.11.01
34
// BH 2023.12.14 fixes resizing into application (making it smaller)
45
// BH 2023.12.13 fixes RIGHT-DRAG and SHIFT-LEFT-DRAG modifier
56
// BH 2023.12.07 fixes mouseUp on body causing (ignorable) error
@@ -1729,11 +1730,13 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
17291730
J2S._haveMouse;
17301731
J2S._firstTouch; // three-position switch: undefined, true, false
17311732

1732-
J2S.$bind('body', 'pointerdown pointermove mousedown mousemove mouseup', function(ev) {
1733+
J2S.$bind('body', //'pointerdown pointermove
1734+
'mousedown mousemove mouseup', function(ev) {
17331735
J2S._haveMouse = true;
17341736
});
17351737

1736-
J2S.$bind('body', 'pointerup mouseup touchend', function(ev) {
1738+
J2S.$bind('body', //'pointerup
1739+
'mouseup touchend', function(ev) {
17371740
mouseUp(null, ev);
17381741
return true;
17391742
});
@@ -1797,13 +1800,16 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
17971800
// otherwise, if J2S._firstTouch is undefined (!!x != x), set J2S._firstTouch
17981801
// and ignore future touch events (through the first touchend):
17991802

1800-
if (ev.type == "pointerdown" || ev.type == "mousedown") {// BHTEst
1803+
if (//ev.type == "pointerdown" ||
1804+
ev.type == "mousedown") {// BHTEst
18011805
J2S._haveMouse = true;
18021806
} else {
18031807
if (J2S._haveMouse) return;
18041808
if (!!J2S._firstTouch != J2S._firstTouch) {
1805-
J2S._firstTouch = true;
1806-
return;
1809+
// q - why did we do this?
1810+
// J2S._firstTouch = true;
1811+
// return;
1812+
J2S._firstTouch = false;
18071813
}
18081814
}
18091815

@@ -2061,7 +2067,8 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
20612067
J2S.$bind(who, (J2S._haveMouse ? 'mousedown pointerdown' : 'pointerdown mousedown touchstart'),
20622068
function(ev) { return mouseDown(who, ev) });
20632069

2064-
J2S.$bind(who, (J2S._haveMouse ? 'mouseup pointerup' : 'pointerup mouseup touchend'),
2070+
J2S.$bind(who, (J2S._haveMouse ? 'mouseup pointerup' : // 'pointerup
2071+
'mouseup touchend'),
20652072
function(ev) { return mouseUp(who, ev) });
20662073

20672074
J2S.$bind(who, 'pointerenter mouseenter', function(ev) { return mouseEnter(who, ev) });
@@ -2255,21 +2262,24 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
22552262
J2S._touching = false;
22562263
break;
22572264
}
2258-
if (!oe.touches || oe.touches.length != 2)
2265+
if (!oe.touches || oe.touches.length != (ev.type == "touchend" ? 1 : 2))
22592266
return false;
2267+
var n = 0;
22602268
switch (ev.type) {
22612269
case "touchstart":
22622270
who._touches = [ [], [] ];
22632271
break;
2272+
case "touchend":
22642273
case "touchmove":
22652274
var offsets = J2S.$offset(who.id);
22662275
var t0 = who._touches[0];
22672276
var t1 = who._touches[1];
22682277
t0.push([ oe.touches[0].pageX - offsets.left,
22692278
oe.touches[0].pageY - offsets.top ]);
2270-
t1.push([ oe.touches[1].pageX - offsets.left,
2279+
if (ev.type != "touchend")
2280+
t1.push([ oe.touches[1].pageX - offsets.left,
22712281
oe.touches[1].pageY - offsets.top ]);
2272-
var n = t0.length;
2282+
n = t0.length;
22732283
if (n > 3) {
22742284
t0.shift();
22752285
t1.shift();

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10686,6 +10686,7 @@ return jQuery;
1068610686
})(jQuery,document,"click mousemove mouseup touchmove touchend", "outjsmol");
1068710687
// j2sApplet.js BH = Bob Hanson hansonr@stolaf.edu
1068810688

10689+
// BH 2024.10.03 adds two-finger tap as "click"; reinstates touch gestures lost when we went to pointerup 2023.11.01
1068910690
// BH 2023.12.14 fixes resizing into application (making it smaller)
1069010691
// BH 2023.12.13 fixes RIGHT-DRAG and SHIFT-LEFT-DRAG modifier
1069110692
// BH 2023.12.07 fixes mouseUp on body causing (ignorable) error
@@ -12415,11 +12416,13 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1241512416
J2S._haveMouse;
1241612417
J2S._firstTouch; // three-position switch: undefined, true, false
1241712418

12418-
J2S.$bind('body', 'pointerdown pointermove mousedown mousemove mouseup', function(ev) {
12419+
J2S.$bind('body', //'pointerdown pointermove
12420+
'mousedown mousemove mouseup', function(ev) {
1241912421
J2S._haveMouse = true;
1242012422
});
1242112423

12422-
J2S.$bind('body', 'pointerup mouseup touchend', function(ev) {
12424+
J2S.$bind('body', //'pointerup
12425+
'mouseup touchend', function(ev) {
1242312426
mouseUp(null, ev);
1242412427
return true;
1242512428
});
@@ -12483,13 +12486,16 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1248312486
// otherwise, if J2S._firstTouch is undefined (!!x != x), set J2S._firstTouch
1248412487
// and ignore future touch events (through the first touchend):
1248512488

12486-
if (ev.type == "pointerdown" || ev.type == "mousedown") {// BHTEst
12489+
if (//ev.type == "pointerdown" ||
12490+
ev.type == "mousedown") {// BHTEst
1248712491
J2S._haveMouse = true;
1248812492
} else {
1248912493
if (J2S._haveMouse) return;
1249012494
if (!!J2S._firstTouch != J2S._firstTouch) {
12491-
J2S._firstTouch = true;
12492-
return;
12495+
// q - why did we do this?
12496+
// J2S._firstTouch = true;
12497+
// return;
12498+
J2S._firstTouch = false;
1249312499
}
1249412500
}
1249512501

@@ -12747,7 +12753,8 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1274712753
J2S.$bind(who, (J2S._haveMouse ? 'mousedown pointerdown' : 'pointerdown mousedown touchstart'),
1274812754
function(ev) { return mouseDown(who, ev) });
1274912755

12750-
J2S.$bind(who, (J2S._haveMouse ? 'mouseup pointerup' : 'pointerup mouseup touchend'),
12756+
J2S.$bind(who, (J2S._haveMouse ? 'mouseup pointerup' : // 'pointerup
12757+
'mouseup touchend'),
1275112758
function(ev) { return mouseUp(who, ev) });
1275212759

1275312760
J2S.$bind(who, 'pointerenter mouseenter', function(ev) { return mouseEnter(who, ev) });
@@ -12941,21 +12948,24 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1294112948
J2S._touching = false;
1294212949
break;
1294312950
}
12944-
if (!oe.touches || oe.touches.length != 2)
12951+
if (!oe.touches || oe.touches.length != (ev.type == "touchend" ? 1 : 2))
1294512952
return false;
12953+
var n = 0;
1294612954
switch (ev.type) {
1294712955
case "touchstart":
1294812956
who._touches = [ [], [] ];
1294912957
break;
12958+
case "touchend":
1295012959
case "touchmove":
1295112960
var offsets = J2S.$offset(who.id);
1295212961
var t0 = who._touches[0];
1295312962
var t1 = who._touches[1];
1295412963
t0.push([ oe.touches[0].pageX - offsets.left,
1295512964
oe.touches[0].pageY - offsets.top ]);
12956-
t1.push([ oe.touches[1].pageX - offsets.left,
12965+
if (ev.type != "touchend")
12966+
t1.push([ oe.touches[1].pageX - offsets.left,
1295712967
oe.touches[1].pageY - offsets.top ]);
12958-
var n = t0.length;
12968+
n = t0.length;
1295912969
if (n > 3) {
1296012970
t0.shift();
1296112971
t1.shift();

0 commit comments

Comments
 (0)