Skip to content

Commit d193cdb

Browse files
authored
Merge pull request #79 from BobHanson/master
JScrollBar, Math.IEEEremainder
2 parents dbdc32e + 5058da3 commit d193cdb

24 files changed

+505
-98
lines changed
1.57 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180913053826
1+
20180915215829
1.57 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20180913053826
1+
20180915215829
1.57 KB
Binary file not shown.

sources/net.sf.j2s.java.core/doc/Differences.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Notes
22
=====
3+
updated 9/15/19 -- adds integer 1/0 == 0
34
updated 7/24/18 -- most classes replaced with https://github.com/frohoff/jdk8u-jdk
45
updated 6/28/18 -- arrays do not inherit Object
56
updated 2/26/18
@@ -174,7 +175,6 @@ JTabbedPane (in development, NEM)
174175
MINOR ISSUES--required some rewriting/refactoring by Bob and Udo
175176
================================================================
176177

177-
java.util.BitSet is implemented using 16-bit integers, not 32
178178
Thread.currentThread() == dispatchThread
179179

180180

@@ -214,6 +214,7 @@ no format internationalization
214214
no winding rules
215215
text-related field implementation
216216
Formatter/Regex limitations
217+
integer 1/0 == 0
217218

218219
========================================================================
219220

@@ -1133,6 +1134,9 @@ Matcher.start(groupID) is not supported.
11331134

11341135
java.util.Formatter will function correctly for all standard %... patterns.
11351136

1137+
integer 1/0 == 0
1138+
----------------
11361139

1140+
1/0 in Java throws java.lang.ArithmeticException: / by zero but in JavaScript is just 0.
11371141

11381142

sources/net.sf.j2s.java.core/src/java/awt/Container.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,8 @@ public void paint(Graphics g) {
18231823
}
18241824

18251825
public void paintContainer(Graphics g) {
1826+
1827+
// !NOT! -- 9/15/18
18261828
// SwingJS: split off here so that
18271829
// the new JComponent-subclassed Window can
18281830
// hit this one directly instead of JComponent.paint()
@@ -2693,7 +2695,7 @@ public void addNotify() {
26932695
public void setDispatcher() {
26942696
if (dispatcher != null)
26952697
return;
2696-
System.err.println("LWD dispatch for "+ this);
2698+
//System.err.println("LWD dispatch for "+ this);
26972699
dispatcher = new LightweightDispatcher(this);
26982700
}
26992701
/**

sources/net.sf.j2s.java.core/src/javax/swing/BoxLayout.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.awt.Dimension;
3939
import java.awt.Insets;
4040
import java.awt.LayoutManager2;
41+
import java.io.PrintStream;
4142

4243
/**
4344
* A layout manager that allows multiple components to be laid out either
@@ -169,6 +170,9 @@ public class BoxLayout implements LayoutManager2 {
169170
*/
170171
public static final int PAGE_AXIS = 3;
171172

173+
public BoxLayout(Container target, int axis, PrintStream dbg) {
174+
this(target, axis);
175+
}
172176
/**
173177
* Creates a layout manager that will lay out components along the
174178
* given axis.

sources/net.sf.j2s.java.core/src/javax/swing/RepaintManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ private void paintDirtyRegions1(
870870
if (g != null) {
871871
// SwingJS not clipping, for performance g.setClip(rect.x, rect.y, rect.width, rect.height);
872872
try {
873-
((Container) dirtyComponent).paintContainer(g); // SwingJS
873+
((Container) dirtyComponent).paint(g); // SwingJS was paintContainer, but that bypasses user's paint(g)?? 9/15/18
874874
} finally {
875875
g.dispose();
876876
}

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

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ public JSGraphics2D(Object canvas) { // this must be Object, because we are
8686
hints = new RenderingHints(new Hashtable());
8787
this.canvas = (HTML5Canvas) canvas;
8888
ctx = this.canvas.getContext("2d");
89+
// reduce antialiasing, thank you,
90+
// http://www.rgraph.net/docs/howto-get-crisp-lines-with-no- antialias.html
91+
if (!isShifted)
92+
ctx.translate(-0.5, -0.5);
93+
isShifted = true;
8994
transform = new AffineTransform();
9095
setStroke(new BasicStroke());
9196
/**
@@ -184,14 +189,6 @@ private double toRad(double a) {
184189
public void background(Color bgcolor) {
185190
backgroundColor = bgcolor;
186191
if (bgcolor == null) {
187-
/*
188-
*
189-
* reduce antialiasing, thank you,
190-
* http://www.rgraph.net/docs/howto-get-crisp-lines-with-no- antialias.html
191-
*/
192-
if (!isShifted)
193-
ctx.translate(-0.5, -0.5);
194-
isShifted = true;
195192
return;
196193
}
197194
clearRect(0, 0, width, height);
@@ -244,7 +241,15 @@ public void fillRect(int x, int y, int width, int height) {
244241
if (width <= 0 || height <= 0)
245242
return;
246243
backgroundPainted = true;
244+
ctx.translate(0.5, 0.5);
247245
ctx.fillRect(x, y, width, height);
246+
ctx.translate(-0.5, -0.5);
247+
//
248+
// if (width == 1)
249+
// drawLine(x, y, x, y + height);
250+
// else if (height == 1)
251+
// drawLine(x, y, x + width, y);
252+
// else
248253
}
249254

250255
public void draw3DRect(int x, int y, int width, int height, boolean raised) {
@@ -702,10 +707,14 @@ public Shape getClip() {
702707
}
703708

704709
public void drawString(String s, int x, int y) {
705-
ctx.fillText(s, x, y);
710+
fillText(s, x, y);
706711
}
707712

708713
public void drawString(String str, float x, float y) {
714+
fillText(str, x, y);
715+
}
716+
717+
private void fillText(String str, float x, float y) {
709718
ctx.fillText(str, x, y);
710719
}
711720

0 commit comments

Comments
 (0)