Skip to content

Commit 11c7752

Browse files
authored
Merge pull request #44 from BobHanson/master
JSGraphics2D, swingjs2.js update
2 parents a653b97 + 6f70e23 commit 11c7752

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
110 Bytes
Binary file not shown.

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ private void doCirc(int left, int top, int diameter, boolean fill) {
157157

158158
private void doArc(double x, double y, double width, double height, double startAngle,
159159
double arcAngle, boolean fill) {
160+
if (width < 0 || height < 0)
161+
return;
160162
// boolean doClose = (arcAngle - startAngle == 360);
161163
ctx.save();
162164
{
@@ -230,6 +232,8 @@ private void doPoly(int[] axPoints, int[] ayPoints, int nPoints,
230232

231233

232234
public void drawRect(int x, int y, int width, int height) {
235+
if (width <= 0 || height <= 0)
236+
return;
233237
ctx.beginPath();
234238
ctx.rect(x, y, width, height);
235239
ctx.stroke();
@@ -245,11 +249,15 @@ public void fillPolygon(int[] axPoints, int[] ayPoints, int nPoints) {
245249

246250

247251
public void fillRect(int x, int y, int width, int height) {
252+
if (width <= 0 || height <= 0)
253+
return;
248254
backgroundPainted = true;
249255
ctx.fillRect(x, y, width, height);
250256
}
251257

252258
public void fill3DRect(int x, int y, int width, int height, boolean raised) {
259+
if (width <= 0 || height <= 0)
260+
return;
253261
Paint p = getPaint();
254262
Color c = getColor();
255263
Color brighter = c.brighter();
@@ -374,6 +382,8 @@ public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
374382

375383
public boolean drawImage(Image img, int x, int y, int width, int height,
376384
ImageObserver observer) {
385+
if (width <= 0 || height <= 0)
386+
return true;
377387
backgroundPainted = true;
378388
if (img != null) {
379389
DOMNode imgNode = getImageNode(img);
@@ -406,6 +416,8 @@ public boolean drawImage(Image img, int x, int y, Color bgcolor,
406416

407417
public boolean drawImage(Image img, int x, int y, int width, int height,
408418
Color bgcolor, ImageObserver observer) {
419+
if (width <= 0 || height <= 0)
420+
return false;
409421
backgroundPainted = true;
410422
JSUtil.notImplemented(null);
411423
return drawImage(img, x, y, width, height, observer);

0 commit comments

Comments
 (0)