Skip to content

Commit 4925844

Browse files
committed
new tests; minor fixes
j2sApplet fix allows file:/ for code and document paths j2sClazz fix for Array.newInstance(Integer.TYPE, 1, 2, 3);
1 parent b83b53d commit 4925844

File tree

14 files changed

+109
-69
lines changed

14 files changed

+109
-69
lines changed
-1.76 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200625205024
1+
20200630071831
-1.76 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20200625205024
1+
20200630071831
-1.76 KB
Binary file not shown.

sources/net.sf.j2s.java.core/src/swingjs/plaf/JSButtonUI.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public DOMNode updateDOMNode() {
9393
allowPaintedBackground = false;
9494
setDoPropagate();
9595
domNode = enableNode = buttonNode = newDOMObject("button", id + "_dom", "type", "button", "style", "padding:0");
96+
//DOMNode.setStyles(domNode, "outline", "none");
9697
//DOMNode.setStyles(domNode,"transform","translateY(0.5px)translateX(0.5px)");
9798
addClass(domNode, "j2sbutton");
9899
setFocusable();

sources/net.sf.j2s.java.core/src/test/Test_Applet_1.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import javax.swing.JLabel;
1818
import javax.swing.JPanel;
1919
import javax.swing.JScrollBar;
20+
import javax.swing.SwingUtilities;
2021
import javax.swing.border.LineBorder;
2122

2223
/**

sources/net.sf.j2s.java.core/src/test/Test_Array.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class Test_Array extends Test_ {
3131
static Object iType3_ = Array.newInstance(int[].class, 3);
3232
static Object iType3 = Array.newInstance(Integer.TYPE, 3);
3333
static Object iType123_ = Array.newInstance(Integer.TYPE, 1, 2, 3);
34+
static Object fType123_ = Array.newInstance(Float.TYPE, 1, 2, 3);
3435
static Object i3def = new int[] { 3, 4, 5 };
3536
static Object i3 = new int[3];
3637
static Object i3_ = new int[3][];

sources/net.sf.j2s.java.core/src/test/Test_Image.java

Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.awt.Color;
44
import java.awt.Graphics;
5+
import java.awt.GraphicsEnvironment;
56
import java.awt.Image;
67
import java.awt.Toolkit;
78
import java.awt.color.ColorSpace;
@@ -178,78 +179,79 @@ private static void testWrite() {
178179
}
179180

180181
private static void testGray() {
181-
BufferedImage image = new BufferedImage(100,100, BufferedImage.TYPE_USHORT_GRAY);
182-
ColorModel cm = image.getColorModel();
183-
184-
// Tests stolen buffer, though it is not used.
185-
186-
short[] bwData = ((DataBufferUShort) image.getRaster().getDataBuffer()).getData();
187-
ColorSpace x = image.getColorModel().getColorSpace();
188-
System.out.println(cm instanceof PackedColorModel);
189-
System.out.println(cm instanceof ColorModel);
190-
System.out.println(cm instanceof ComponentColorModel);
191-
192-
PixelConverter pc = PixelConverter.UshortGray.instance;
193-
int rgb, p;
194-
195-
rgb = 0xFFFFFF00;
196-
image.setRGB(0, 0, rgb);
197-
p = image.getRGB(0, 0);
198-
System.out.println(p + " " + Integer.toHexString(rgb));
199-
rgb = pc.pixelToRgb(p, null);
200-
System.out.println(p + " " + Integer.toHexString(rgb));
201-
202-
rgb = 0xFFFF0000;
203-
p = pc.rgbToPixel(rgb, null);
204-
System.out.println(p + " " + Integer.toHexString(rgb));
205-
rgb = pc.pixelToRgb(p, null);
206-
System.out.println(p + " " + Integer.toHexString(rgb));
207-
208-
rgb = 0xFF00FF00;
209-
p = pc.rgbToPixel(rgb, null);
210-
System.out.println(p + " " + Integer.toHexString(rgb));
211-
rgb = pc.pixelToRgb(p, null);
212-
System.out.println(p + " " + Integer.toHexString(rgb));
213-
214-
rgb = 0xFF0000FF;
215-
p = pc.rgbToPixel(rgb, null);
216-
System.out.println(p + " " + Integer.toHexString(rgb));
217-
rgb = pc.pixelToRgb(p, null);
218-
System.out.println(p + " " + Integer.toHexString(rgb));
219-
220-
rgb = 0xFFFF0000;
221-
p = pc.rgbToPixel(rgb, null);
222-
System.out.println(p + " " + Integer.toHexString(rgb));
223-
rgb = pc.pixelToRgb(p, null);
224-
System.out.println(p + " " + Integer.toHexString(rgb));
225-
226-
227-
rgb = 0xFF4c4c4c;
228-
p = pc.rgbToPixel(rgb, null);
229-
System.out.println(p + " " + Integer.toHexString(rgb));
230-
rgb = pc.pixelToRgb(p, null);
231-
System.out.println(p + " " + Integer.toHexString(rgb));
232-
182+
BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_USHORT_GRAY);
183+
ColorModel cm = image.getColorModel();
184+
185+
// Tests stolen buffer, though it is not used.
186+
187+
short[] bwData = ((DataBufferUShort) image.getRaster().getDataBuffer()).getData();
188+
ColorSpace x = image.getColorModel().getColorSpace();
189+
System.out.println(cm instanceof PackedColorModel);
190+
System.out.println(cm instanceof ColorModel);
191+
System.out.println(cm instanceof ComponentColorModel);
192+
193+
PixelConverter pc = PixelConverter.UshortGray.instance;
194+
int rgb, p;
195+
196+
rgb = 0xFFFFFF00;
197+
image.setRGB(0, 0, rgb);
198+
p = image.getRGB(0, 0);
199+
System.out.println(p + " " + Integer.toHexString(rgb));
200+
rgb = pc.pixelToRgb(p, null);
201+
System.out.println(p + " " + Integer.toHexString(rgb));
202+
203+
rgb = 0xFFFF0000;
204+
p = pc.rgbToPixel(rgb, null);
205+
System.out.println(p + " " + Integer.toHexString(rgb));
206+
rgb = pc.pixelToRgb(p, null);
207+
System.out.println(p + " " + Integer.toHexString(rgb));
208+
209+
rgb = 0xFF00FF00;
210+
p = pc.rgbToPixel(rgb, null);
211+
System.out.println(p + " " + Integer.toHexString(rgb));
212+
rgb = pc.pixelToRgb(p, null);
213+
System.out.println(p + " " + Integer.toHexString(rgb));
214+
215+
rgb = 0xFF0000FF;
216+
p = pc.rgbToPixel(rgb, null);
217+
System.out.println(p + " " + Integer.toHexString(rgb));
218+
rgb = pc.pixelToRgb(p, null);
219+
System.out.println(p + " " + Integer.toHexString(rgb));
220+
221+
rgb = 0xFFFF0000;
222+
p = pc.rgbToPixel(rgb, null);
223+
System.out.println(p + " " + Integer.toHexString(rgb));
224+
rgb = pc.pixelToRgb(p, null);
225+
System.out.println(p + " " + Integer.toHexString(rgb));
226+
227+
rgb = 0xFF4c4c4c;
228+
p = pc.rgbToPixel(rgb, null);
229+
System.out.println(p + " " + Integer.toHexString(rgb));
230+
rgb = pc.pixelToRgb(p, null);
231+
System.out.println(p + " " + Integer.toHexString(rgb));
233232

234233
int[] pixels = new int[10000];
235-
for (int i = 0; i < 10000; i++) {
236-
int pixel = (int) ((i % 100)* 2.55);
237-
pixels[i] = ((((((0xff << 8) | pixel) << 8) | pixel) << 8) | pixel); // ((i % 100)*0xFFFFFF/100) | 0xFF000000;//Math.random() * 0xFFFFFF);
234+
for (int i = 0; i < 10000; i++) {
235+
int pixel = (int) ((i % 100) * 2.55);
236+
pixels[i] = ((((((0xff << 8) | pixel) << 8) | pixel) << 8) | pixel); // ((i % 100)*0xFFFFFF/100) |
237+
// 0xFF000000;//Math.random() *
238+
// 0xFFFFFF);
238239
}
239-
image.setRGB(0, 0, 100, 100, pixels, 0, 100);
240+
image.setRGB(0, 0, 100, 100, pixels, 0, 100);
240241

241242
// test to send color to a gray-scale image
242243
Graphics g = image.getGraphics();
243244
g.setColor(Color.green);
244245
System.out.println(Integer.toHexString(g.getColor().getRGB()));
245246
g.fillRect(25, 25, 50, 50);
246247
showImage(image);
247-
248-
JFrame f = new JFrame();
249-
f.add(new JLabel(new ImageIcon(image)));
250-
f.pack();
251-
f.show();
252-
}
248+
if (!GraphicsEnvironment.isHeadless()) {
249+
JFrame f = new JFrame();
250+
f.add(new JLabel(new ImageIcon(image)));
251+
f.pack();
252+
f.show();
253+
}
254+
}
253255

254256
private static void testPacked() {
255257

sources/net.sf.j2s.java.core/src/test/Test_Label.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ Container getVisualPaneContent() {
195195

196196
ImageIcon icon1 = new ImageIcon("test/zoom.gif");
197197
// either <br> or <br/> is fine.
198-
JLabel l = new JLabel("<html>this is<br/>a<br> test</html>", null, SwingConstants.LEADING);
198+
JLabel l = new JLabel("<html>this is<br/>a<br> t<sub>e</sub>st</html>", null, SwingConstants.LEADING);
199199
l.setBounds(300,300,20,20);
200200
add(l);
201201
//

0 commit comments

Comments
 (0)