package com.knecon.fforesight.service.layoutparser.processor.services;

import java.awt.geom.Rectangle2D;

import com.knecon.fforesight.service.layoutparser.processor.model.LineInformation;
import com.knecon.fforesight.service.layoutparser.processor.utils.RectangleTransformations;

import lombok.experimental.UtilityClass;

@UtilityClass
public class MainBodyTextFrameExtractionService {

    private static final double TEXT_FRAME_PAD_WIDTH = 0.0;
    private static final double TEXT_FRAME_PAD_HEIGHT = 0.02;


    public Rectangle2D calculateMainBodyTextFrame(LineInformation lineInformation) {

        Rectangle2D mainBodyTextFrame = lineInformation.getLineBBox().stream()
                .collect(RectangleTransformations.collectBBox());

        return RectangleTransformations.pad(mainBodyTextFrame, mainBodyTextFrame.getWidth() * TEXT_FRAME_PAD_WIDTH, mainBodyTextFrame.getHeight() * TEXT_FRAME_PAD_HEIGHT);
    }

}
