aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorPo Lu2023-07-08 21:49:21 +0800
committerPo Lu2023-07-08 21:49:21 +0800
commita36207574ac436fd8871639388cc6400069bb9bb (patch)
tree4d9cb662104eeb5013ef8a8af5c1d8c22ccfa052 /java
parentc843f3e23b48dcf65e72db0eefa6a5a74c815ff6 (diff)
downloademacs-a36207574ac436fd8871639388cc6400069bb9bb.tar.gz
emacs-a36207574ac436fd8871639388cc6400069bb9bb.zip
Fix EmacsDrawLine again
* java/org/gnu/emacs/EmacsDrawLine.java (perform): Symmetrically adjust coordinates to cover the last pixel. Then, fill the left most pixel of the line.
Diffstat (limited to 'java')
-rw-r--r--java/org/gnu/emacs/EmacsDrawLine.java33
1 files changed, 24 insertions, 9 deletions
diff --git a/java/org/gnu/emacs/EmacsDrawLine.java b/java/org/gnu/emacs/EmacsDrawLine.java
index 3f5067c0bdd..d367ccff9c4 100644
--- a/java/org/gnu/emacs/EmacsDrawLine.java
+++ b/java/org/gnu/emacs/EmacsDrawLine.java
@@ -32,30 +32,45 @@ public final class EmacsDrawLine
32 Rect rect; 32 Rect rect;
33 Canvas canvas; 33 Canvas canvas;
34 Paint paint; 34 Paint paint;
35 int x0, x1, y0, y1;
35 36
36 /* TODO implement stippling. */ 37 /* TODO implement stippling. */
37 if (gc.fill_style == EmacsGC.GC_FILL_OPAQUE_STIPPLED) 38 if (gc.fill_style == EmacsGC.GC_FILL_OPAQUE_STIPPLED)
38 return; 39 return;
39 40
41 /* Calculate the leftmost and rightmost points. */
42
43 x0 = Math.min (x, x2 + 1);
44 x1 = Math.max (x, x2 + 1);
45 y0 = Math.min (y, y2 + 1);
46 y1 = Math.max (y, y2 + 1);
47
48 /* And the clip rectangle. */
49
40 paint = gc.gcPaint; 50 paint = gc.gcPaint;
41 rect = new Rect (Math.min (x, x2 + 1), 51 rect = new Rect (x0, y0, x1, y1);
42 Math.min (y, y2 + 1),
43 Math.max (x2 + 1, x),
44 Math.max (y2 + 1, y));
45 canvas = drawable.lockCanvas (gc); 52 canvas = drawable.lockCanvas (gc);
46 53
47 if (canvas == null) 54 if (canvas == null)
48 return; 55 return;
49 56
50 paint.setStyle (Paint.Style.STROKE); 57 paint.setStyle (Paint.Style.FILL);
51 58
52 /* Since drawLine has PostScript style behavior, adjust the 59 /* Since drawLine has PostScript style behavior, adjust the
53 coordinates appropriately. */ 60 coordinates appropriately.
61
62 The left most pixel of a straight line is always partially
63 filled. Patch it in manually. */
54 64
55 if (gc.clip_mask == null) 65 if (gc.clip_mask == null)
56 canvas.drawLine ((float) x, (float) y + 0.5f, 66 {
57 (float) x2 + 0.5f, (float) y2 + 0.5f, 67 canvas.drawLine ((float) x + 0.5f, (float) y + 0.5f,
58 paint); 68 (float) x2 + 0.5f, (float) y2 + 0.5f,
69 paint);
70
71 if (x2 > x)
72 canvas.drawRect (new Rect (x, y, x + 1, y + 1), paint);
73 }
59 74
60 /* DrawLine with clip mask not implemented; it is not used by 75 /* DrawLine with clip mask not implemented; it is not used by
61 Emacs. */ 76 Emacs. */