@@ -44,6 +44,7 @@ This file is part of the iText (R) project.
44
44
package com .itextpdf .layout .border ;
45
45
46
46
import com .itextpdf .kernel .color .Color ;
47
+ import com .itextpdf .kernel .geom .Point ;
47
48
import com .itextpdf .kernel .pdf .canvas .PdfCanvas ;
48
49
49
50
/**
@@ -157,6 +158,7 @@ public void draw(PdfCanvas canvas, float x1, float y1, float x2, float y2, float
157
158
adjustedGap -= width ;
158
159
}
159
160
161
+ // Points (x0, y0) and (x3, y3) are used to produce Bezier curve
160
162
float x0 = x1 , y0 = y1 ,
161
163
x3 = x2 , y3 = y2 ;
162
164
@@ -173,7 +175,7 @@ public void draw(PdfCanvas canvas, float x1, float y1, float x2, float y2, float
173
175
transparentColor .applyStrokeTransparency (canvas );
174
176
canvas .setLineDash (width , adjustedGap , width + adjustedGap / 2 );
175
177
176
-
178
+ Point clipPoint1 , clipPoint2 , clipPoint ;
177
179
Border .Side borderSide = getBorderSide (x1 , y1 , x2 , y2 );
178
180
switch (borderSide ) {
179
181
case TOP :
@@ -183,6 +185,16 @@ public void draw(PdfCanvas canvas, float x1, float y1, float x2, float y2, float
183
185
x3 += borderWidthAfter / 2 ;
184
186
y3 -= innerRadius ;
185
187
188
+ clipPoint1 = getIntersectionPoint (new Point (x1 - borderWidthBefore , y1 + width ), new Point (x1 , y1 ), new Point (x0 , y0 ), new Point (x0 + 10 , y0 ));
189
+ clipPoint2 = getIntersectionPoint (new Point (x2 + borderWidthAfter , y2 + width ), new Point (x2 , y2 ), new Point (x3 , y3 ), new Point (x3 - 10 , y3 ));
190
+ if (clipPoint1 .x > clipPoint2 .x ) {
191
+ clipPoint = getIntersectionPoint (new Point (x1 - borderWidthBefore , y1 + width ), clipPoint1 , clipPoint2 , new Point (x2 + borderWidthAfter , y2 + width ));
192
+ canvas .moveTo (x1 - borderWidthBefore , y1 + width ).lineTo (clipPoint .x , clipPoint .y ).lineTo (x2 + borderWidthAfter , y2 + width ).lineTo (x1 - borderWidthBefore , y1 + width );
193
+ } else {
194
+ canvas .moveTo (x1 - borderWidthBefore , y1 + width ).lineTo (clipPoint1 .x , clipPoint1 .y ).lineTo (clipPoint2 .x , clipPoint2 .y ).lineTo (x2 + borderWidthAfter , y2 + width ).lineTo (x1 - borderWidthBefore , y1 + width );
195
+ }
196
+ canvas .clip ().newPath ();
197
+
186
198
x1 += innerRadiusBefore ;
187
199
y1 += widthHalf ;
188
200
@@ -193,16 +205,24 @@ public void draw(PdfCanvas canvas, float x1, float y1, float x2, float y2, float
193
205
.moveTo (x0 , y0 ).curveTo (x0 , y0 + innerRadius * curv , x1 - innerRadiusBefore * curv , y1 , x1 , y1 )
194
206
.lineTo (x2 , y2 )
195
207
.curveTo (x2 + innerRadiusAfter * curv , y2 , x3 , y3 + innerRadius * curv , x3 , y3 );
196
-
197
208
break ;
198
209
case RIGHT :
199
-
200
210
x0 -= innerRadius ;
201
211
y0 += borderWidthBefore / 2 ;
202
212
203
213
x3 -= innerRadius ;
204
214
y3 -= borderWidthAfter ;
205
215
216
+ clipPoint1 = getIntersectionPoint (new Point (x1 + width , y1 + borderWidthBefore ), new Point (x1 , y1 ), new Point (x0 , y0 ), new Point (x0 , y0 - 10 ));
217
+ clipPoint2 = getIntersectionPoint (new Point (x2 + width , y2 - borderWidthAfter ), new Point (x2 , y2 ), new Point (x3 , y3 ), new Point (x3 , y3 - 10 ));
218
+ if (clipPoint1 .y < clipPoint2 .y ) {
219
+ clipPoint = getIntersectionPoint (new Point (x1 + width , y1 + borderWidthBefore ), clipPoint1 , clipPoint2 , new Point (x2 + width , y2 - borderWidthAfter ));
220
+ canvas .moveTo (x1 + width , y1 + borderWidthBefore ).lineTo (clipPoint .x , clipPoint .y ).lineTo (x2 + width , y2 - borderWidthAfter ).lineTo (x1 + width , y1 + borderWidthBefore ).clip ().newPath ();
221
+ } else {
222
+ canvas .moveTo (x1 + width , y1 + borderWidthBefore ).lineTo (clipPoint1 .x , clipPoint1 .y ).lineTo (clipPoint2 .x , clipPoint2 .y ).lineTo (x2 + width , y2 - borderWidthAfter ).lineTo (x1 + width , y1 + borderWidthBefore ).clip ().newPath ();
223
+ }
224
+ canvas .clip ().newPath ();
225
+
206
226
x1 += widthHalf ;
207
227
y1 -= innerRadiusBefore ;
208
228
@@ -222,6 +242,16 @@ public void draw(PdfCanvas canvas, float x1, float y1, float x2, float y2, float
222
242
x3 -= borderWidthAfter / 2 ;
223
243
y3 += innerRadius ;
224
244
245
+ clipPoint1 = getIntersectionPoint (new Point (x1 + borderWidthBefore , y1 - width ), new Point (x1 , y1 ), new Point (x0 , y0 ), new Point (x0 - 10 , y0 ));
246
+ clipPoint2 = getIntersectionPoint (new Point (x2 - borderWidthAfter , y2 - width ), new Point (x2 , y2 ), new Point (x3 , y3 ), new Point (x3 + 10 , y3 ));
247
+ if (clipPoint1 .x < clipPoint2 .x ) {
248
+ clipPoint = getIntersectionPoint (new Point (x1 + borderWidthBefore , y1 - width ), clipPoint1 , clipPoint2 , new Point (x2 - borderWidthAfter , y2 - width ));
249
+ canvas .moveTo (x1 + borderWidthBefore , y1 - width ).lineTo (clipPoint .x , clipPoint .y ).lineTo (x2 - borderWidthAfter , y2 - width ).lineTo (x1 + borderWidthBefore , y1 - width );
250
+ } else {
251
+ canvas .moveTo (x1 + borderWidthBefore , y1 - width ).lineTo (clipPoint1 .x , clipPoint1 .y ).lineTo (clipPoint2 .x , clipPoint2 .y ).lineTo (x2 - borderWidthAfter , y2 - width ).lineTo (x1 + borderWidthBefore , y1 - width );
252
+ }
253
+ canvas .clip ().newPath ();
254
+
225
255
x1 -= innerRadiusBefore ;
226
256
y1 -= widthHalf ;
227
257
@@ -239,7 +269,17 @@ public void draw(PdfCanvas canvas, float x1, float y1, float x2, float y2, float
239
269
y0 -= borderWidthBefore / 2 ;
240
270
241
271
x3 += innerRadius ;
242
- y3 -= borderWidthAfter ;
272
+ y3 += borderWidthAfter ;
273
+
274
+ clipPoint1 = getIntersectionPoint (new Point (x1 - width , y1 - borderWidthBefore ), new Point (x1 , y1 ), new Point (x0 , y0 ), new Point (x0 , y0 + 10 ));
275
+ clipPoint2 = getIntersectionPoint (new Point (x2 - width , y2 + borderWidthAfter ), new Point (x2 , y2 ), new Point (x3 , y3 ), new Point (x3 , y3 + 10 ));
276
+ if (clipPoint1 .y > clipPoint2 .y ) {
277
+ clipPoint = getIntersectionPoint (new Point (x1 - width , y1 - borderWidthBefore ), clipPoint1 , clipPoint2 , new Point (x2 - width , y2 + borderWidthAfter ));
278
+ canvas .moveTo (x1 - width , y1 - borderWidthBefore ).lineTo (clipPoint .x , clipPoint .y ).lineTo (x2 - width , y2 + borderWidthAfter ).lineTo (x1 - width , y1 - borderWidthBefore );
279
+ } else {
280
+ canvas .moveTo (x1 - width , y1 - borderWidthBefore ).lineTo (clipPoint1 .x , clipPoint1 .y ).lineTo (clipPoint2 .x , clipPoint2 .y ).lineTo (x2 - width , y2 + borderWidthAfter ).lineTo (x1 - width , y1 - borderWidthBefore );
281
+ }
282
+ canvas .clip ().newPath ();
243
283
244
284
x1 -= widthHalf ;
245
285
y1 += innerRadiusBefore ;
@@ -253,7 +293,8 @@ public void draw(PdfCanvas canvas, float x1, float y1, float x2, float y2, float
253
293
.curveTo (x2 , y2 + innerRadiusAfter * curv , x3 - innerRadius * curv , y3 , x3 , y3 );
254
294
break ;
255
295
}
256
- canvas .stroke ()
296
+ canvas
297
+ .stroke ()
257
298
.restoreState ();
258
299
}
259
300
0 commit comments