package com.iqser.red.service.persistence.service.v1.api.shared.model.analysislog.entitylog;

import java.awt.geom.Rectangle2D;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.FieldDefaults;

@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
public class Position {

    float[] rectangle; // x, y, w, h
    int pageNumber;


    public Position(float x, float y, float w, float h, int pageNumber) {

        this.rectangle = new float[]{x, y, w, h};
        this.pageNumber = pageNumber;
    }


    public Position(Rectangle2D rectangle2D, int pageNumber) {

        this.rectangle = new float[]{(float) rectangle2D.getX(), (float) rectangle2D.getY(), (float) rectangle2D.getWidth(), (float) rectangle2D.getHeight()};
        this.pageNumber = pageNumber;
    }


    public Rectangle2D toRectangle2D() {

        return new Rectangle2D.Float(x(), y(), w(), h());
    }


    public float x() {

        return rectangle[0];
    }


    public float y() {

        return rectangle[1];
    }


    public float w() {

        return rectangle[2];
    }


    public float h() {

        return rectangle[3];
    }

}
