@@ -556,59 +556,63 @@ protected boolean clipBorderArea(DrawContext drawContext, Rectangle outerBorderB
556
556
}
557
557
if (0 != radius ) {
558
558
float top = outerBorderBox .getTop (), right = outerBorderBox .getRight (), bottom = outerBorderBox .getBottom (), left = outerBorderBox .getLeft ();
559
-
559
+ float verticalRadius = Math .min (outerBorderBox .getHeight () / 2 , radius );
560
+ float horizontalRadius = Math .min (outerBorderBox .getWidth () / 2 , radius );
560
561
// radius border bbox
561
- float x1 = right - radius , y1 = top - radius ,
562
- x2 = right - radius , y2 = bottom + radius ,
563
- x3 = left + radius , y3 = bottom + radius ,
564
- x4 = left + radius , y4 = top - radius ;
562
+ float x1 = right - horizontalRadius , y1 = top - verticalRadius ,
563
+ x2 = right - horizontalRadius , y2 = bottom + verticalRadius ,
564
+ x3 = left + horizontalRadius , y3 = bottom + verticalRadius ,
565
+ x4 = left + horizontalRadius , y4 = top - verticalRadius ;
565
566
566
567
PdfCanvas canvas = drawContext .getCanvas ();
567
568
canvas .saveState ();
568
569
569
-
570
+ // right top corner
570
571
canvas
571
572
.moveTo (left , top )
572
573
.lineTo (x1 , top )
573
- .curveTo (x1 + radius * curv , top , right , y1 + radius * curv , right , y1 )
574
+ .curveTo (x1 + horizontalRadius * curv , top , right , y1 + verticalRadius * curv , right , y1 )
574
575
.lineTo (right , bottom )
575
576
.lineTo (left , bottom )
576
577
.lineTo (left , top );
577
578
canvas .clip ().newPath ();
578
579
580
+ // right bottom corner
579
581
canvas
580
582
.moveTo (right , top )
581
583
.lineTo (right , y2 )
582
- .curveTo (right , y2 - radius * curv , x2 + radius * curv , bottom , x2 , bottom )
584
+ .curveTo (right , y2 - verticalRadius * curv , x2 + horizontalRadius * curv , bottom , x2 , bottom )
583
585
.lineTo (left , bottom )
584
586
.lineTo (left , top )
585
587
.lineTo (right , top );
586
588
canvas .clip ().newPath ();
587
589
590
+ // left bottom corner
588
591
canvas
589
592
.moveTo (right , bottom )
590
593
.lineTo (x3 , bottom )
591
- .curveTo (x3 - radius * curv , bottom , left , y3 - radius * curv , left , y3 )
594
+ .curveTo (x3 - horizontalRadius * curv , bottom , left , y3 - verticalRadius * curv , left , y3 )
592
595
.lineTo (left , top )
593
596
.lineTo (right , top )
594
597
.lineTo (right , bottom );
595
598
canvas .clip ().newPath ();
596
599
600
+ // left top corner
597
601
canvas
598
602
.moveTo (left , bottom )
599
603
.lineTo (left , y4 )
600
- .curveTo (left , y4 + radius * curv , x4 - radius * curv , top , x4 , top )
604
+ .curveTo (left , y4 + verticalRadius * curv , x4 - horizontalRadius * curv , top , x4 , top )
601
605
.lineTo (right , top )
602
606
.lineTo (right , bottom )
603
607
.lineTo (left , bottom );
604
608
canvas .clip ().newPath ();
605
609
606
610
Border [] borders = getBorders ();
607
611
608
- float radiusTop = radius , radiusRight = radius , radiusBottom = radius , radiusLeft = radius ;
609
- float deltaTop = 0 , deltaRight = 0 , deltaBottom = 0 , deltaLeft = 0 ;
612
+ float radiusTop = verticalRadius , radiusRight = horizontalRadius , radiusBottom = verticalRadius , radiusLeft = horizontalRadius ;
613
+ float topBorderWidth = 0 , rightBorderWidth = 0 , bottomBorderWidth = 0 , leftBorderWidth = 0 ;
610
614
if (borders [0 ] != null ) {
611
- deltaTop = borders [0 ].getWidth ();
615
+ topBorderWidth = borders [0 ].getWidth ();
612
616
top = top - borders [0 ].getWidth ();
613
617
if (y1 > top ) {
614
618
y1 = top ;
@@ -617,7 +621,7 @@ protected boolean clipBorderArea(DrawContext drawContext, Rectangle outerBorderB
617
621
radiusTop = Math .max (0 , radiusTop - borders [0 ].getWidth ());
618
622
}
619
623
if (borders [1 ] != null ) {
620
- deltaRight = borders [1 ].getWidth ();
624
+ rightBorderWidth = borders [1 ].getWidth ();
621
625
622
626
right = right - borders [1 ].getWidth ();
623
627
if (x1 > right ) {
@@ -627,7 +631,7 @@ protected boolean clipBorderArea(DrawContext drawContext, Rectangle outerBorderB
627
631
radiusRight = Math .max (0 , radiusRight - borders [1 ].getWidth ());
628
632
}
629
633
if (borders [2 ] != null ) {
630
- deltaBottom = borders [2 ].getWidth ();
634
+ bottomBorderWidth = borders [2 ].getWidth ();
631
635
632
636
bottom = bottom + borders [2 ].getWidth ();
633
637
if (x3 < left ) {
@@ -638,7 +642,7 @@ protected boolean clipBorderArea(DrawContext drawContext, Rectangle outerBorderB
638
642
radiusBottom = Math .max (0 , radiusBottom - borders [2 ].getWidth ());
639
643
}
640
644
if (borders [3 ] != null ) {
641
- deltaLeft = borders [3 ].getWidth ();
645
+ leftBorderWidth = borders [3 ].getWidth ();
642
646
643
647
left = left + borders [3 ].getWidth ();
644
648
radiusLeft = Math .max (0 , radiusLeft - borders [3 ].getWidth ());
@@ -647,57 +651,61 @@ protected boolean clipBorderArea(DrawContext drawContext, Rectangle outerBorderB
647
651
canvas
648
652
.moveTo (x1 , top )
649
653
.curveTo (x1 + Math .min (radiusTop , radiusRight ) * curv , top , right , y1 + Math .min (radiusTop , radiusRight ) * curv , right , y1 )
650
- .lineTo (x4 , y1 )
651
- .lineTo (x4 , top )
654
+ .lineTo (right , y2 )
655
+ .lineTo (x3 , y2 )
656
+ .lineTo (x3 , top )
652
657
.lineTo (x1 , top )
653
- .lineTo (x1 , top + deltaTop )
654
- .lineTo (left - deltaLeft , top + deltaTop )
655
- .lineTo (left - deltaLeft , bottom - deltaBottom )
656
- .lineTo (right + deltaRight , bottom - deltaBottom )
657
- .lineTo (right + deltaRight , top + deltaTop )
658
- .lineTo (x1 , top + deltaTop );
658
+ .lineTo (x1 , top + topBorderWidth )
659
+ .lineTo (left - leftBorderWidth , top + topBorderWidth )
660
+ .lineTo (left - leftBorderWidth , bottom - bottomBorderWidth )
661
+ .lineTo (right + rightBorderWidth , bottom - bottomBorderWidth )
662
+ .lineTo (right + rightBorderWidth , top + topBorderWidth )
663
+ .lineTo (x1 , top + topBorderWidth );
659
664
canvas .clip ().newPath ();
660
665
661
666
canvas
662
667
.moveTo (right , y2 )
663
668
.curveTo (right , y2 - Math .min (radiusRight , radiusBottom ) * curv , x2 + Math .min (radiusRight , radiusBottom ) * curv , bottom , x2 , bottom )
664
- .lineTo (x2 , y1 )
665
- .lineTo (right , y1 )
669
+ .lineTo (x3 , bottom )
670
+ .lineTo (x3 , y4 )
671
+ .lineTo (right , y4 )
666
672
.lineTo (right , y2 )
667
- .lineTo (right + deltaRight , y2 )
668
- .lineTo (right + deltaRight , top + deltaTop )
669
- .lineTo (left - deltaLeft , top + deltaTop )
670
- .lineTo (left - deltaLeft , bottom - deltaBottom )
671
- .lineTo (right + deltaRight , bottom - deltaBottom )
672
- .lineTo (right + deltaRight , y2 );
673
+ .lineTo (right + rightBorderWidth , y2 )
674
+ .lineTo (right + rightBorderWidth , top + topBorderWidth )
675
+ .lineTo (left - leftBorderWidth , top + topBorderWidth )
676
+ .lineTo (left - leftBorderWidth , bottom - bottomBorderWidth )
677
+ .lineTo (right + rightBorderWidth , bottom - bottomBorderWidth )
678
+ .lineTo (right + rightBorderWidth , y2 );
673
679
canvas .clip ().newPath ();
674
680
675
681
canvas
676
682
.moveTo (x3 , bottom )
677
683
.curveTo (x3 - Math .min (radiusBottom , radiusLeft ) * curv , bottom , left , y3 - Math .min (radiusBottom , radiusLeft ) * curv , left , y3 )
678
- .lineTo (x2 , y3 )
679
- .lineTo (x2 , bottom )
684
+ .lineTo (left , y4 )
685
+ .lineTo (x1 , y4 )
686
+ .lineTo (x1 , bottom )
680
687
.lineTo (x3 , bottom )
681
- .lineTo (x3 , bottom - deltaBottom )
682
- .lineTo (right + deltaRight , bottom - deltaBottom )
683
- .lineTo (right + deltaRight , top + deltaTop )
684
- .lineTo (left - deltaLeft , top + deltaTop )
685
- .lineTo (left - deltaLeft , bottom - deltaBottom )
686
- .lineTo (x3 , bottom - deltaBottom );
688
+ .lineTo (x3 , bottom - bottomBorderWidth )
689
+ .lineTo (right + rightBorderWidth , bottom - bottomBorderWidth )
690
+ .lineTo (right + rightBorderWidth , top + topBorderWidth )
691
+ .lineTo (left - leftBorderWidth , top + topBorderWidth )
692
+ .lineTo (left - leftBorderWidth , bottom - bottomBorderWidth )
693
+ .lineTo (x3 , bottom - bottomBorderWidth );
687
694
canvas .clip ().newPath ();
688
695
689
696
canvas
690
697
.moveTo (left , y4 )
691
698
.curveTo (left , y4 + Math .min (radiusLeft , radiusTop ) * curv , x4 - Math .min (radiusLeft , radiusTop ) * curv , top , x4 , top )
692
- .lineTo (x4 , y3 )
693
- .lineTo (left , y3 )
699
+ .lineTo (x1 , top )
700
+ .lineTo (x1 , y2 )
701
+ .lineTo (left , y2 )
694
702
.lineTo (left , y4 )
695
- .lineTo (left - deltaLeft , y4 )
696
- .lineTo (left - deltaLeft , bottom - deltaBottom )
697
- .lineTo (right + deltaRight , bottom - deltaBottom )
698
- .lineTo (right + deltaRight , top + deltaTop )
699
- .lineTo (left - deltaLeft , top + deltaTop )
700
- .lineTo (left - deltaLeft , y4 );
703
+ .lineTo (left - leftBorderWidth , y4 )
704
+ .lineTo (left - leftBorderWidth , bottom - bottomBorderWidth )
705
+ .lineTo (right + rightBorderWidth , bottom - bottomBorderWidth )
706
+ .lineTo (right + rightBorderWidth , top + topBorderWidth )
707
+ .lineTo (left - leftBorderWidth , top + topBorderWidth )
708
+ .lineTo (left - leftBorderWidth , y4 );
701
709
canvas .clip ().newPath ();
702
710
703
711
}
0 commit comments