@@ -717,21 +717,45 @@ private LineChunk parsingRectangleFromLines(int i) {
717717 Vertex .areCloseVertexes (line2 .getEnd (), line3 .getStart ()) &&
718718 Vertex .areCloseVertexes (line3 .getEnd (), line4 .getStart ()) &&
719719 Vertex .areCloseVertexes (line4 .getEnd (), line1 .getStart ())) {
720- if (line1 .isHorizontalLine () && line2 .isVerticalLine () &&
721- line3 .isHorizontalLine () && line4 .isVerticalLine ()) {
720+ if (isHorizontalLine (line1 , line2 , line3 , line4 )) {
722721 LineChunk line = new LineChunk (pageNumber , line2 .getCenterX (), line2 .getCenterY (),
723722 line4 .getCenterX (), line4 .getCenterY (), Math .abs (line1 .getCenterY () - line3 .getCenterY ()));
724723 return transformLineChunk (line , line .getWidth (), LineChunk .BUTT_CAP_STYLE );
725- } else if (line1 .isVerticalLine () && line2 .isHorizontalLine () &&
726- line3 .isVerticalLine () && line4 .isHorizontalLine ()) {
724+ }
725+ if (isVerticalLine (line1 , line2 , line3 , line4 )) {
726+ LineChunk line = new LineChunk (pageNumber , line2 .getCenterX (), line2 .getCenterY (),
727+ line4 .getCenterX (), line4 .getCenterY (), Math .abs (line1 .getCenterX () - line3 .getCenterX ()));
728+ return transformLineChunk (line , line .getWidth (), LineChunk .BUTT_CAP_STYLE );
729+ }
730+ if (isHorizontalLine (line2 , line1 , line4 , line3 )) {
727731 LineChunk line = new LineChunk (pageNumber , line1 .getCenterX (), line1 .getCenterY (),
728732 line3 .getCenterX (), line3 .getCenterY (), Math .abs (line2 .getCenterY () - line4 .getCenterY ()));
729733 return transformLineChunk (line , line .getWidth (), LineChunk .BUTT_CAP_STYLE );
730734 }
735+ if (isVerticalLine (line2 , line1 , line4 , line3 )) {
736+ LineChunk line = new LineChunk (pageNumber , line1 .getCenterX (), line1 .getCenterY (),
737+ line3 .getCenterX (), line3 .getCenterY (), Math .abs (line2 .getCenterX () - line4 .getCenterX ()));
738+ return transformLineChunk (line , line .getWidth (), LineChunk .BUTT_CAP_STYLE );
739+ }
731740 }
732741 }
733742 return null ;
734743 }
744+
745+ private static boolean isHorizontalLine (LineChunk line1 , LineChunk line2 , LineChunk line3 , LineChunk line4 ) {
746+ return line1 .isHorizontalLine () && (line2 .isVerticalLine () ||
747+ Vertex .areCloseVertexes (line2 .getEnd (), line2 .getStart ())) &&
748+ line3 .isHorizontalLine () && (line4 .isVerticalLine () ||
749+ Vertex .areCloseVertexes (line4 .getEnd (), line4 .getStart ()));
750+ }
751+
752+ private static boolean isVerticalLine (LineChunk line1 , LineChunk line2 , LineChunk line3 , LineChunk line4 ) {
753+ return line1 .isVerticalLine () && (line2 .isHorizontalLine () ||
754+ Vertex .areCloseVertexes (line2 .getEnd (), line2 .getStart ())) &&
755+ line3 .isVerticalLine () && (line4 .isHorizontalLine () ||
756+ Vertex .areCloseVertexes (line4 .getEnd (), line4 .getStart ()));
757+ }
758+
735759
736760 private Double getValueOfLastNumber (List <COSBase > arguments ) {
737761 if (!arguments .isEmpty ()) {
0 commit comments