package epson.print.phlayout; import android.graphics.Point; import android.graphics.Rect; import android.graphics.RectF; import android.support.annotation.NonNull; import epson.common.Info_paper; import epson.print.EPImage; class CdLayoutPosition implements ILayoutPosition { private int layout = 2; private int layoutMulti = 0; private int mBottomMargin = 0; private boolean mIsPaperLandScape = false; private int mLeftMargin = 0; private int mPaperHeight = 0; private int mPaperWidth = 0; private AltRect mPreviewPrintArea = new AltRect(); private int mRightMargin = 0; private int mTopMargin = 0; CdLayoutPosition() { } public int getLayoutId() { return this.layout; } public int getLeftMargin() { return this.mLeftMargin; } public int getRightMargin() { return this.mRightMargin; } public int getTopMargin() { return this.mTopMargin; } public int getBottomMargin() { return this.mBottomMargin; } public RectF getPreviewImageCircumscribedTargetSize() { return this.mPreviewPrintArea.getRectF(); } public boolean isPreviewImageSizeValid() { return this.mPreviewPrintArea.right - this.mPreviewPrintArea.left > 0 && this.mPreviewPrintArea.bottom - this.mPreviewPrintArea.top > 0; } public void setPaperLandscape(boolean z) { this.mIsPaperLandScape = z; } public boolean getIsPaperLandscape() { return this.mIsPaperLandScape; } public Rect getPreviewPaperRect() { return this.mPreviewPrintArea.getRect(); } /* access modifiers changed from: package-private */ @VisibleForTesting public AltRect getPreviewPaperAltRect() { return this.mPreviewPrintArea; } /* access modifiers changed from: package-private */ @VisibleForTesting public void setPaperAndImageSize_forTest(int i, int i2, int i3, int i4) { this.mPaperWidth = i; this.mPaperHeight = i2; } public void setLayoutId(int i, int i2) { this.layout = i; this.layoutMulti = i2; } public void copyPreviewPrintAreaFromEpImage(@NonNull EPImage ePImage) { this.mIsPaperLandScape = ePImage.isPaperLandScape; this.mPreviewPrintArea.left = ePImage.previewPaperRectLeft; this.mPreviewPrintArea.top = ePImage.previewPaperRectTop; this.mPreviewPrintArea.right = ePImage.previewPaperRectRight; this.mPreviewPrintArea.bottom = ePImage.previewPaperRectBottom; } public void copyPreviewPrintAreaToEpImage(EPImage ePImage) { ePImage.isPaperLandScape = this.mIsPaperLandScape; ePImage.previewPaperRectLeft = this.mPreviewPrintArea.left; ePImage.previewPaperRectTop = this.mPreviewPrintArea.top; ePImage.previewPaperRectRight = this.mPreviewPrintArea.right; ePImage.previewPaperRectBottom = this.mPreviewPrintArea.bottom; } public void setPaperAndCalcPreviewPosition(Info_paper info_paper, int i, int i2, Point point) { setPaperSizeFromPaperInfo(info_paper); if (this.mPaperWidth <= 0 || this.mPaperHeight <= 0) { this.mPaperWidth = 2892; this.mPaperHeight = 4125; } calculateLayoutSizeCdDvd(i, i2, point); } /* access modifiers changed from: package-private */ @VisibleForTesting public void calculateLayoutSizeCdDvd(int i, int i2, @NonNull Point point) { int i3 = i2 > i ? (int) (((double) i) * 0.800000011920929d) : (int) (((double) i2) * 0.800000011920929d); AltRect altRect = this.mPreviewPrintArea; altRect.left = (i - i3) / 2; altRect.top = (i2 - i3) / 2; altRect.right = altRect.left + i3; AltRect altRect2 = this.mPreviewPrintArea; altRect2.bottom = altRect2.top + i3; point.x = ((this.mPreviewPrintArea.right - this.mPreviewPrintArea.left) / 2) + this.mPreviewPrintArea.left; point.y = ((this.mPreviewPrintArea.bottom - this.mPreviewPrintArea.top) / 2) + this.mPreviewPrintArea.top; float width = ((float) this.mPreviewPrintArea.width()) / ((float) this.mPaperWidth); this.mTopMargin = (int) (((float) this.mTopMargin) * width); this.mLeftMargin = (int) (((float) this.mLeftMargin) * width); this.mRightMargin = (int) (((float) this.mRightMargin) * width); this.mBottomMargin = (int) (((float) this.mBottomMargin) * width); if (this.mIsPaperLandScape) { int i4 = this.mTopMargin; this.mTopMargin = this.mRightMargin; this.mRightMargin = this.mBottomMargin; this.mBottomMargin = this.mLeftMargin; this.mLeftMargin = i4; } } /* access modifiers changed from: package-private */ @VisibleForTesting public void setPaperSizeFromPaperInfo(Info_paper info_paper) { this.mPaperWidth = info_paper.getPaper_width(); this.mPaperHeight = info_paper.getPaper_height(); this.mLeftMargin = info_paper.getLeftMargin_border(); this.mTopMargin = info_paper.getTopMargin_border(); this.mRightMargin = info_paper.getRightMargin_border(); this.mBottomMargin = info_paper.getBottomMargin_border(); } }