package com.epson.cameracopy.printlayout;

import android.content.Context;
import android.graphics.Point;
import android.graphics.PointF;
import com.epson.cameracopy.printlayout.ManuscriptSize;

/* compiled from: ManuscriptSize */
class CustomManuscriptSize implements ManuscriptSize.ManuscriptTypeAdapter {
    private DocumentSizeInfo mDocumentSizeInfo;
    private double mHeight;
    private int mScale;
    private double mWidth;

    public boolean displayLength() {
        return true;
    }

    public CustomManuscriptSize(DocumentSizeInfo documentSizeInfo) {
        this.mDocumentSizeInfo = documentSizeInfo;
        this.mWidth = documentSizeInfo.getWidth();
        this.mHeight = documentSizeInfo.getHeight();
        this.mScale = documentSizeInfo.getScaleId();
    }

    public Point getBasePixelSize(int i) {
        return new Point(lengthToPixel(this.mWidth, i), lengthToPixel(this.mHeight, i));
    }

    public String getSizeName(Context context) {
        return this.mDocumentSizeInfo.getDocSizeName(context);
    }

    public int getUnitType(Context context) {
        return this.mDocumentSizeInfo.getScaleId() == 2 ? 2 : 1;
    }

    public PointF getCustomDocumentSize(Context context) {
        return new PointF((float) this.mWidth, (float) this.mHeight);
    }

    protected int lengthToPixel(double d, int i) {
        switch (this.mDocumentSizeInfo.getScaleId()) {
            case 1:
                return (int) (((d * ((double) i)) / 25.4d) + 0.5d);
            case 2:
                return (int) ((d * ((double) i)) + 0.5d);
            default:
                return 0;
        }
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        CustomManuscriptSize customManuscriptSize = (CustomManuscriptSize) obj;
        DocumentSizeInfo documentSizeInfo = this.mDocumentSizeInfo;
        if (documentSizeInfo == null) {
            if (customManuscriptSize.mDocumentSizeInfo != null) {
                return false;
            }
        } else if (!documentSizeInfo.equals(customManuscriptSize.mDocumentSizeInfo)) {
            return false;
        }
        return Double.doubleToLongBits(this.mHeight) == Double.doubleToLongBits(customManuscriptSize.mHeight) && this.mScale == customManuscriptSize.mScale && Double.doubleToLongBits(this.mWidth) == Double.doubleToLongBits(customManuscriptSize.mWidth);
    }
}
