@@ -1033,6 +1033,47 @@ public Rectangle getInnerAreaBBox() {
1033
1033
return rect ;
1034
1034
}
1035
1035
1036
+ /**
1037
+ * Applies margins of the renderer on the given rectangle
1038
+ *
1039
+ * @param rect a rectangle margins will be applied on.
1040
+ * @param reverse indicates whether margins will be applied
1041
+ * inside (in case of false) or outside (in case of true) the rectangle.
1042
+ * @return a {@link Rectangle border box} of the renderer
1043
+ * @see #getMargins
1044
+ */
1045
+ public Rectangle applyMargins (Rectangle rect , boolean reverse ) {
1046
+ return this .applyMargins (rect , getMargins (), reverse );
1047
+ }
1048
+
1049
+ /**
1050
+ * Applies the border box of the renderer on the given rectangle
1051
+ * If the border of a certain side is null, the side will remain as it was.
1052
+ *
1053
+ * @param rect a rectangle the border box will be applied on.
1054
+ * @param reverse indicates whether the border box will be applied
1055
+ * inside (in case of false) or outside (in case of false) the rectangle.
1056
+ * @return a {@link Rectangle border box} of the renderer
1057
+ * @see #getBorders
1058
+ */
1059
+ public Rectangle applyBorderBox (Rectangle rect , boolean reverse ) {
1060
+ Border [] borders = getBorders ();
1061
+ return applyBorderBox (rect , borders , reverse );
1062
+ }
1063
+
1064
+ /**
1065
+ * Applies paddings of the renderer on the given rectangle
1066
+ *
1067
+ * @param rect a rectangle paddings will be applied on.
1068
+ * @param reverse indicates whether paddings will be applied
1069
+ * inside (in case of false) or outside (in case of false) the rectangle.
1070
+ * @return a {@link Rectangle border box} of the renderer
1071
+ * @see #getPaddings
1072
+ */
1073
+ public Rectangle applyPaddings (Rectangle rect , boolean reverse ) {
1074
+ return applyPaddings (rect , getPaddings (), reverse );
1075
+ }
1076
+
1036
1077
public boolean isFirstOnRootArea () {
1037
1078
return isFirstOnRootArea (false );
1038
1079
}
@@ -1043,24 +1084,24 @@ protected void applyDestinationsAndAnnotation(DrawContext drawContext) {
1043
1084
applyLinkAnnotation (drawContext .getDocument ());
1044
1085
}
1045
1086
1046
- static boolean isBorderBoxSizing (IRenderer renderer ) {
1087
+ protected static boolean isBorderBoxSizing (IRenderer renderer ) {
1047
1088
BoxSizingPropertyValue boxSizing = renderer .<BoxSizingPropertyValue >getProperty (Property .BOX_SIZING );
1048
1089
return boxSizing != null && boxSizing .equals (BoxSizingPropertyValue .BORDER_BOX );
1049
1090
}
1050
1091
1051
- boolean isOverflowProperty (OverflowPropertyValue equalsTo , int overflowProperty ) {
1092
+ protected boolean isOverflowProperty (OverflowPropertyValue equalsTo , int overflowProperty ) {
1052
1093
return isOverflowProperty (equalsTo , this .<OverflowPropertyValue >getProperty (overflowProperty ));
1053
1094
}
1054
1095
1055
- static boolean isOverflowProperty (OverflowPropertyValue equalsTo , IRenderer renderer , int overflowProperty ) {
1096
+ protected static boolean isOverflowProperty (OverflowPropertyValue equalsTo , IRenderer renderer , int overflowProperty ) {
1056
1097
return isOverflowProperty (equalsTo , renderer .<OverflowPropertyValue >getProperty (overflowProperty ));
1057
1098
}
1058
1099
1059
- static boolean isOverflowProperty (OverflowPropertyValue equalsTo , OverflowPropertyValue rendererOverflowProperty ) {
1100
+ protected static boolean isOverflowProperty (OverflowPropertyValue equalsTo , OverflowPropertyValue rendererOverflowProperty ) {
1060
1101
return equalsTo .equals (rendererOverflowProperty ) || equalsTo .equals (OverflowPropertyValue .FIT ) && rendererOverflowProperty == null ;
1061
1102
}
1062
1103
1063
- static boolean isOverflowFit (OverflowPropertyValue rendererOverflowProperty ) {
1104
+ protected static boolean isOverflowFit (OverflowPropertyValue rendererOverflowProperty ) {
1064
1105
return rendererOverflowProperty == null || OverflowPropertyValue .FIT .equals (rendererOverflowProperty );
1065
1106
}
1066
1107
@@ -1188,7 +1229,7 @@ protected Float retrieveMinWidth(float parentBoxWidth) {
1188
1229
*
1189
1230
* @param updatedWidthValue element's new fixed content box width.
1190
1231
*/
1191
- void updateWidth (UnitValue updatedWidthValue ) {
1232
+ protected void updateWidth (UnitValue updatedWidthValue ) {
1192
1233
if (updatedWidthValue .isPointValue () && isBorderBoxSizing (this )) {
1193
1234
updatedWidthValue .setValue (updatedWidthValue .getValue () + calculatePaddingBorderWidth (this ));
1194
1235
}
@@ -1287,7 +1328,7 @@ private float[] calculateRadii(BorderRadius[] radii, Rectangle area, boolean hor
1287
1328
*
1288
1329
* @param updatedHeight element's new fixed content box height, shall be not null.
1289
1330
*/
1290
- void updateHeight (UnitValue updatedHeight ) {
1331
+ protected void updateHeight (UnitValue updatedHeight ) {
1291
1332
if (isBorderBoxSizing (this ) && updatedHeight .isPointValue ()) {
1292
1333
updatedHeight .setValue (updatedHeight .getValue () + calculatePaddingBorderHeight (this ));
1293
1334
@@ -1343,8 +1384,7 @@ protected Float retrieveMaxHeight() {
1343
1384
*
1344
1385
* @param updatedMaxHeight element's new content box max-height, shall be not null.
1345
1386
*/
1346
-
1347
- void updateMaxHeight (UnitValue updatedMaxHeight ) {
1387
+ protected void updateMaxHeight (UnitValue updatedMaxHeight ) {
1348
1388
if (isBorderBoxSizing (this ) && updatedMaxHeight .isPointValue ()) {
1349
1389
updatedMaxHeight .setValue (updatedMaxHeight .getValue () + calculatePaddingBorderHeight (this ));
1350
1390
@@ -1393,7 +1433,7 @@ protected Float retrieveMinHeight() {
1393
1433
*
1394
1434
* @param updatedMinHeight element's new content box min-height, shall be not null.
1395
1435
*/
1396
- void updateMinHeight (UnitValue updatedMinHeight ) {
1436
+ protected void updateMinHeight (UnitValue updatedMinHeight ) {
1397
1437
if (isBorderBoxSizing (this ) && updatedMinHeight .isPointValue ()) {
1398
1438
updatedMinHeight .setValue (updatedMinHeight .getValue () + calculatePaddingBorderHeight (this ));
1399
1439
}
@@ -1448,9 +1488,7 @@ protected Float getFirstYLineRecursively() {
1448
1488
}
1449
1489
1450
1490
protected Float getLastYLineRecursively () {
1451
- if (isOverflowProperty (OverflowPropertyValue .HIDDEN , Property .OVERFLOW_X )
1452
- || isOverflowProperty (OverflowPropertyValue .HIDDEN , Property .OVERFLOW_Y )) {
1453
- // TODO may be this logic should also be based on BlockFormattingContextUtil?
1491
+ if (!allowLastYLineRecursiveExtraction ()) {
1454
1492
return null ;
1455
1493
}
1456
1494
for (int i = childRenderers .size () - 1 ; i >= 0 ; i --) {
@@ -1465,17 +1503,9 @@ protected Float getLastYLineRecursively() {
1465
1503
return null ;
1466
1504
}
1467
1505
1468
- /**
1469
- * Applies margins of the renderer on the given rectangle
1470
- *
1471
- * @param rect a rectangle margins will be applied on.
1472
- * @param reverse indicates whether margins will be applied
1473
- * inside (in case of false) or outside (in case of true) the rectangle.
1474
- * @return a {@link Rectangle border box} of the renderer
1475
- * @see #getMargins
1476
- */
1477
- protected Rectangle applyMargins (Rectangle rect , boolean reverse ) {
1478
- return this .applyMargins (rect , getMargins (), reverse );
1506
+ protected boolean allowLastYLineRecursiveExtraction () {
1507
+ return !isOverflowProperty (OverflowPropertyValue .HIDDEN , Property .OVERFLOW_X )
1508
+ && !isOverflowProperty (OverflowPropertyValue .HIDDEN , Property .OVERFLOW_Y );
1479
1509
}
1480
1510
1481
1511
/**
@@ -1525,19 +1555,6 @@ protected UnitValue[] getPaddings() {
1525
1555
return getPaddings (this );
1526
1556
}
1527
1557
1528
- /**
1529
- * Applies paddings of the renderer on the given rectangle
1530
- *
1531
- * @param rect a rectangle paddings will be applied on.
1532
- * @param reverse indicates whether paddings will be applied
1533
- * inside (in case of false) or outside (in case of false) the rectangle.
1534
- * @return a {@link Rectangle border box} of the renderer
1535
- * @see #getPaddings
1536
- */
1537
- protected Rectangle applyPaddings (Rectangle rect , boolean reverse ) {
1538
- return applyPaddings (rect , getPaddings (), reverse );
1539
- }
1540
-
1541
1558
/**
1542
1559
* Applies given paddings on the given rectangle
1543
1560
*
@@ -1567,21 +1584,6 @@ protected Rectangle applyPaddings(Rectangle rect, UnitValue[] paddings, boolean
1567
1584
return rect .applyMargins (paddings [0 ].getValue (), paddings [1 ].getValue (), paddings [2 ].getValue (), paddings [3 ].getValue (), reverse );
1568
1585
}
1569
1586
1570
- /**
1571
- * Applies the border box of the renderer on the given rectangle
1572
- * If the border of a certain side is null, the side will remain as it was.
1573
- *
1574
- * @param rect a rectangle the border box will be applied on.
1575
- * @param reverse indicates whether the border box will be applied
1576
- * inside (in case of false) or outside (in case of false) the rectangle.
1577
- * @return a {@link Rectangle border box} of the renderer
1578
- * @see #getBorders
1579
- */
1580
- protected Rectangle applyBorderBox (Rectangle rect , boolean reverse ) {
1581
- Border [] borders = getBorders ();
1582
- return applyBorderBox (rect , borders , reverse );
1583
- }
1584
-
1585
1587
/**
1586
1588
* Applies the given border box (borders) on the given rectangle
1587
1589
*
0 commit comments