package com.iqser.red.service.persistence.management.v1.processor.migration.migrations.model.reducetext;

import com.dslplatform.json.JsonAttribute;
import com.fasterxml.jackson.annotation.JsonAlias;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RedTextPosition {

    // Same values
    private String textMatrix;
    private String unicode;

    // New
    @JsonProperty
    private float[] position;

    // Moved to position
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private float XDirAdj;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private float YDirAdj;
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @JsonAttribute
    private float heightDir;
    @JsonAttribute
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private float widthDirAdj;

    // Moved To TextPositionSequence
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @JsonAttribute
    private float pageHeight;
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @JsonAttribute
    private float pageWidth;
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @JsonAttribute
    private float dir;
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @JsonAttribute
    private int rotation;

    // Removed values
    @JsonIgnore
    private float y;
    @JsonIgnore
    private float width;


    @JsonAttribute()
    public float[] getPosition() {

        var pos = new float[4];

        pos[0] = XDirAdj;
        pos[1] = YDirAdj;
        pos[2] = widthDirAdj;
        pos[3] = heightDir;

        return pos;
    }


    @JsonIgnore
    public float getXDirAdj() {return this.XDirAdj;}


    @JsonAlias("xdirAdj")
    @JsonAttribute(alternativeNames = {"xdirAdj"})
    @JsonProperty
    public void setXDirAdj(float XDirAdj) {

        this.XDirAdj = XDirAdj;
    }


    @JsonIgnore
    public float getYDirAdj() {return this.YDirAdj;}


    @JsonAlias("ydirAdj")
    @JsonAttribute(alternativeNames = {"ydirAdj"})
    @JsonProperty
    public void setYDirAdj(float YDirAdj) {this.YDirAdj = YDirAdj;}


    @JsonIgnore
    public float getWidthDirAdj() {return this.widthDirAdj;}


    @JsonIgnore
    public float getHeightDir() {return this.heightDir;}


    @JsonIgnore
    public float getPageHeight() {return this.pageHeight;}


    @JsonIgnore
    public float getPageWidth() {return this.pageWidth;}


    @JsonIgnore
    public int getRotation() {return this.rotation;}


    @JsonIgnore
    public float getDir() {return this.dir;}

}
