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) {
        mDocumentSizeInfo = documentSizeInfo;
        mWidth = documentSizeInfo.getWidth();
        mHeight = documentSizeInfo.getHeight();
        mScale = documentSizeInfo.getScaleId();
    }

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

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

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

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

    protected int lengthToPixel(double d, int i) {
        switch (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 = mDocumentSizeInfo;
        if (documentSizeInfo == null) {
            if (customManuscriptSize.mDocumentSizeInfo != null) {
                return false;
            }
        } else if (!documentSizeInfo.equals(customManuscriptSize.mDocumentSizeInfo)) {
            return false;
        }
        return Double.doubleToLongBits(mHeight) == Double.doubleToLongBits(customManuscriptSize.mHeight) && mScale == customManuscriptSize.mScale && Double.doubleToLongBits(mWidth) == Double.doubleToLongBits(customManuscriptSize.mWidth);
    }
}
