@@ -64,10 +64,6 @@ public abstract class Border {
64
64
*/
65
65
public static final Border NO_BORDER = null ;
66
66
67
- /**
68
- * Value used by discontinuous borders during the drawing process
69
- */
70
- private static final float CURV = 0.447f ;
71
67
/**
72
68
* The solid border.
73
69
*
@@ -129,6 +125,13 @@ public abstract class Border {
129
125
*/
130
126
public static final int DASHED_FIXED = 9 ;
131
127
128
+ private static final int ARC_RIGHT_DEGREE = 0 ;
129
+ private static final int ARC_TOP_DEGREE = 90 ;
130
+ private static final int ARC_LEFT_DEGREE = 180 ;
131
+ private static final int ARC_BOTTOM_DEGREE = 270 ;
132
+
133
+ private static final int ARC_QUARTER_CLOCKWISE_EXTENT = -90 ;
134
+
132
135
/**
133
136
* The color of the border.
134
137
*
@@ -487,34 +490,34 @@ protected float getDotsGap(double distance, float initialGap) {
487
490
* @param borderWidthAfter defines width of the border that is after the current one
488
491
*/
489
492
protected void drawDiscontinuousBorders (PdfCanvas canvas , Rectangle boundingRectangle , float [] horizontalRadii , float [] verticalRadii , Side defaultSide , float borderWidthBefore , float borderWidthAfter ) {
490
- float x1 = boundingRectangle .getX ();
491
- float y1 = boundingRectangle .getY ();
492
- float x2 = boundingRectangle .getRight ();
493
- float y2 = boundingRectangle .getTop ();
493
+ double x1 = boundingRectangle .getX ();
494
+ double y1 = boundingRectangle .getY ();
495
+ double x2 = boundingRectangle .getRight ();
496
+ double y2 = boundingRectangle .getTop ();
494
497
495
- float horizontalRadius1 = horizontalRadii [0 ];
496
- float horizontalRadius2 = horizontalRadii [1 ];
498
+ final double horizontalRadius1 = horizontalRadii [0 ];
499
+ final double horizontalRadius2 = horizontalRadii [1 ];
497
500
498
- float verticalRadius1 = verticalRadii [0 ];
499
- float verticalRadius2 = verticalRadii [1 ];
501
+ final double verticalRadius1 = verticalRadii [0 ];
502
+ final double verticalRadius2 = verticalRadii [1 ];
500
503
501
504
// Points (x0, y0) and (x3, y3) are used to produce Bezier curve
502
- float x0 = boundingRectangle .getX ();
503
- float y0 = boundingRectangle .getY ();
504
- float x3 = boundingRectangle .getRight ();
505
- float y3 = boundingRectangle .getTop ();
505
+ double x0 = boundingRectangle .getX ();
506
+ double y0 = boundingRectangle .getY ();
507
+ double x3 = boundingRectangle .getRight ();
508
+ double y3 = boundingRectangle .getTop ();
506
509
507
- float innerRadiusBefore ;
508
- float innerRadiusFirst ;
509
- float innerRadiusSecond ;
510
- float innerRadiusAfter ;
510
+ double innerRadiusBefore ;
511
+ double innerRadiusFirst ;
512
+ double innerRadiusSecond ;
513
+ double innerRadiusAfter ;
511
514
512
- float widthHalf = width / 2 ;
515
+ final double widthHalf = width / 2.0 ;
513
516
514
517
Point clipPoint1 ;
515
518
Point clipPoint2 ;
516
519
Point clipPoint ;
517
- Border .Side borderSide = getBorderSide (x1 , y1 , x2 , y2 , defaultSide );
520
+ final Border .Side borderSide = getBorderSide (( float ) x1 , ( float ) y1 , ( float ) x2 , ( float ) y2 , defaultSide );
518
521
switch (borderSide ) {
519
522
case TOP :
520
523
@@ -547,9 +550,12 @@ protected void drawDiscontinuousBorders(PdfCanvas canvas, Rectangle boundingRect
547
550
y2 += widthHalf ;
548
551
549
552
canvas
550
- .moveTo (x0 , y0 ).curveTo (x0 , y0 + innerRadiusFirst * CURV , x1 - innerRadiusBefore * CURV , y1 , x1 , y1 )
551
- .lineTo (x2 , y2 )
552
- .curveTo (x2 + innerRadiusAfter * CURV , y2 , x3 , y3 + innerRadiusSecond * CURV , x3 , y3 );
553
+ .arc (x0 , y0 - innerRadiusFirst ,
554
+ x1 + innerRadiusBefore , y1 ,
555
+ ARC_LEFT_DEGREE , ARC_QUARTER_CLOCKWISE_EXTENT )
556
+ .arcContinuous (x2 - innerRadiusAfter , y2 ,
557
+ x3 , y3 - innerRadiusSecond ,
558
+ ARC_TOP_DEGREE , ARC_QUARTER_CLOCKWISE_EXTENT );
553
559
break ;
554
560
case RIGHT :
555
561
innerRadiusBefore = Math .max (0 , verticalRadius1 - borderWidthBefore );
@@ -580,10 +586,12 @@ protected void drawDiscontinuousBorders(PdfCanvas canvas, Rectangle boundingRect
580
586
y2 += innerRadiusAfter ;
581
587
582
588
canvas
583
- .moveTo (x0 , y0 ).curveTo (x0 + innerRadiusFirst * CURV , y0 , x1 , y1 + innerRadiusBefore * CURV , x1 , y1 )
584
- .lineTo (x2 , y2 )
585
- .curveTo (x2 , y2 - innerRadiusAfter * CURV , x3 + innerRadiusSecond * CURV , y3 , x3 , y3 );
586
-
589
+ .arc (x0 - innerRadiusFirst , y0 ,
590
+ x1 , y1 - innerRadiusBefore ,
591
+ ARC_TOP_DEGREE , ARC_QUARTER_CLOCKWISE_EXTENT )
592
+ .arcContinuous (x2 , y2 + innerRadiusAfter ,
593
+ x3 - innerRadiusSecond , y3 ,
594
+ ARC_RIGHT_DEGREE , ARC_QUARTER_CLOCKWISE_EXTENT );
587
595
break ;
588
596
case BOTTOM :
589
597
innerRadiusBefore = Math .max (0 , horizontalRadius1 - borderWidthBefore );
@@ -614,10 +622,12 @@ protected void drawDiscontinuousBorders(PdfCanvas canvas, Rectangle boundingRect
614
622
y2 -= widthHalf ;
615
623
616
624
canvas
617
- .moveTo (x0 , y0 ).curveTo (x0 , y0 - innerRadiusFirst * CURV , x1 + innerRadiusBefore * CURV , y1 , x1 , y1 )
618
- .lineTo (x2 , y2 )
619
- .curveTo (x2 - innerRadiusAfter * CURV , y2 , x3 , y3 - innerRadiusSecond * CURV , x3 , y3 );
620
-
625
+ .arc (x0 , y0 + innerRadiusFirst ,
626
+ x1 - innerRadiusBefore , y1 ,
627
+ ARC_RIGHT_DEGREE , ARC_QUARTER_CLOCKWISE_EXTENT )
628
+ .arcContinuous (x2 + innerRadiusAfter , y2 ,
629
+ x3 , y3 + innerRadiusSecond ,
630
+ ARC_BOTTOM_DEGREE , ARC_QUARTER_CLOCKWISE_EXTENT );
621
631
break ;
622
632
case LEFT :
623
633
innerRadiusBefore = Math .max (0 , verticalRadius1 - borderWidthBefore );
@@ -648,9 +658,12 @@ protected void drawDiscontinuousBorders(PdfCanvas canvas, Rectangle boundingRect
648
658
y2 -= innerRadiusAfter ;
649
659
650
660
canvas
651
- .moveTo (x0 , y0 ).curveTo (x0 - innerRadiusFirst * CURV , y0 , x1 , y1 - innerRadiusBefore * CURV , x1 , y1 )
652
- .lineTo (x2 , y2 )
653
- .curveTo (x2 , y2 + innerRadiusAfter * CURV , x3 - innerRadiusSecond * CURV , y3 , x3 , y3 );
661
+ .arc (x0 + innerRadiusFirst , y0 ,
662
+ x1 , y1 + innerRadiusBefore ,
663
+ ARC_BOTTOM_DEGREE , ARC_QUARTER_CLOCKWISE_EXTENT )
664
+ .arcContinuous (x2 , y2 - innerRadiusAfter ,
665
+ x3 + innerRadiusSecond , y3 ,
666
+ ARC_LEFT_DEGREE , ARC_QUARTER_CLOCKWISE_EXTENT );
654
667
break ;
655
668
default :
656
669
break ;
0 commit comments