123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- package epson.print.phlayout;
- import android.content.Context;
- 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;
- public class BorderedLayoutPosition implements ILayoutPosition {
- private int layout = 2;
- private int layoutMulti = 0;
- private int m3mmHeight = 0;
- private int m3mmWidth = 0;
- private int mBottomMargin = 0;
- private boolean mIsPaperLandScape = false;
- private int mLeftMargin = 0;
- private AltRect mPreview3mmEffectivePrintPosition = new AltRect();
- private int[] mPreviewMargin = new int[4];
- private int mRightMargin = 0;
- private int mTopMargin = 0;
- /* access modifiers changed from: package-private */
- @VisibleForTesting
- public AltRect getPreviewPaperAltRect() {
- return null;
- }
- public Rect getPreviewPaperRect() {
- return null;
- }
- public int getLayoutId() {
- return this.layout;
- }
- public int getLeftMargin() {
- return this.mPreviewMargin[0];
- }
- public int getRightMargin() {
- return this.mPreviewMargin[2];
- }
- public int getTopMargin() {
- return this.mPreviewMargin[1];
- }
- public int getBottomMargin() {
- return this.mPreviewMargin[3];
- }
- public int[] getPrintSize(Context context, int i, int i2) {
- setLayoutId(2, i2);
- setPaperSizeFromPaperInfo(Info_paper.getInfoPaper(context, i));
- return new int[]{this.m3mmWidth, this.m3mmHeight};
- }
- public RectF getPreviewImageCircumscribedTargetSize() {
- return this.mPreview3mmEffectivePrintPosition.getRectF();
- }
- public boolean isPreviewImageSizeValid() {
- return this.mPreview3mmEffectivePrintPosition.right - this.mPreview3mmEffectivePrintPosition.left > 0 && this.mPreview3mmEffectivePrintPosition.bottom - this.mPreview3mmEffectivePrintPosition.top > 0;
- }
- public void setPaperLandscape(boolean z) {
- this.mIsPaperLandScape = z;
- }
- public boolean getIsPaperLandscape() {
- return this.mIsPaperLandScape;
- }
- /* access modifiers changed from: package-private */
- @VisibleForTesting
- public void setPaperAndImageSize_forTest(int i, int i2, int i3, int i4) {
- this.m3mmWidth = i3;
- this.m3mmHeight = i4;
- }
- public void setLayoutId(int i, int i2) {
- this.layout = i;
- this.layoutMulti = i2;
- }
- public void setPaperAndCalcPreviewPosition(Info_paper info_paper, int i, int i2, Point point) {
- int i3 = this.layout;
- setPaperSizeFromPaperInfo(info_paper);
- if (this.m3mmWidth <= 0 || this.m3mmHeight <= 0) {
- this.m3mmWidth = 2892;
- this.m3mmHeight = 4125;
- }
- calculateLayoutSizeBordered(i, i2, point);
- }
- /* access modifiers changed from: package-private */
- @VisibleForTesting
- public void calculateLayoutSizeBordered(int i, int i2, Point point) {
- int i3;
- int i4;
- if ((!this.mIsPaperLandScape || this.m3mmWidth > this.m3mmHeight) && (this.mIsPaperLandScape || this.m3mmWidth <= this.m3mmHeight)) {
- i3 = (int) (((double) i2) * 0.800000011920929d);
- int i5 = this.m3mmWidth;
- int i6 = this.m3mmHeight;
- int i7 = (int) (((float) (i3 * i5)) / ((float) i6));
- int i8 = (int) (((double) i) * 0.800000011920929d);
- if (i7 > i8) {
- i3 = (int) (((float) (i6 * i8)) / ((float) i5));
- i4 = i8;
- } else {
- i4 = i7;
- }
- } else {
- i4 = (int) (((double) i) * 0.800000011920929d);
- int i9 = this.m3mmWidth;
- int i10 = this.m3mmHeight;
- i3 = (int) (((float) (i4 * i9)) / ((float) i10));
- int i11 = (int) (((double) i2) * 0.800000011920929d);
- if (i3 > i11) {
- i4 = (int) (((float) (i10 * i11)) / ((float) i9));
- i3 = i11;
- }
- }
- AltRect altRect = this.mPreview3mmEffectivePrintPosition;
- altRect.left = (i - i4) / 2;
- altRect.top = (i2 - i3) / 2;
- altRect.right = altRect.left + i4;
- AltRect altRect2 = this.mPreview3mmEffectivePrintPosition;
- altRect2.bottom = altRect2.top + i3;
- point.x = ((this.mPreview3mmEffectivePrintPosition.right - this.mPreview3mmEffectivePrintPosition.left) / 2) + this.mPreview3mmEffectivePrintPosition.left;
- point.y = ((this.mPreview3mmEffectivePrintPosition.bottom - this.mPreview3mmEffectivePrintPosition.top) / 2) + this.mPreview3mmEffectivePrintPosition.top;
- float width = ((float) this.mPreview3mmEffectivePrintPosition.width()) / ((float) this.m3mmWidth);
- int[] iArr = this.mPreviewMargin;
- iArr[0] = (int) (((float) this.mLeftMargin) * width);
- iArr[1] = (int) (((float) this.mTopMargin) * width);
- iArr[2] = (int) (((float) this.mRightMargin) * width);
- iArr[3] = (int) (((float) this.mBottomMargin) * width);
- if (this.mIsPaperLandScape) {
- int i12 = iArr[1];
- iArr[1] = iArr[2];
- iArr[2] = iArr[3];
- iArr[3] = iArr[0];
- iArr[0] = i12;
- }
- }
- /* access modifiers changed from: package-private */
- @VisibleForTesting
- public void setPaperSizeFromPaperInfo(Info_paper info_paper) {
- if (this.layout == 2) {
- this.m3mmWidth = info_paper.getPaper_width_boder();
- this.m3mmHeight = info_paper.getPaper_height_boder();
- this.mLeftMargin = info_paper.getLeftMargin_border();
- this.mTopMargin = info_paper.getTopMargin_border();
- this.mRightMargin = info_paper.getRightMargin_border();
- this.mBottomMargin = info_paper.getBottomMargin_border();
- int i = this.layoutMulti;
- if (i == 65536) {
- Rect printingArea_2in1 = info_paper.getPrintingArea_2in1();
- this.m3mmWidth = printingArea_2in1.width();
- this.m3mmHeight = printingArea_2in1.height();
- } else if (i == 131072 || i == 262144) {
- Rect printingArea_4in1 = info_paper.getPrintingArea_4in1();
- this.m3mmWidth = printingArea_4in1.width();
- this.m3mmHeight = printingArea_4in1.height();
- }
- } else {
- throw new RuntimeException();
- }
- }
- public void copyPreviewPrintAreaFromEpImage(@NonNull EPImage ePImage) {
- this.mIsPaperLandScape = ePImage.isPaperLandScape;
- this.mPreview3mmEffectivePrintPosition.left = ePImage.previewPaperRectLeft;
- this.mPreview3mmEffectivePrintPosition.top = ePImage.previewPaperRectTop;
- this.mPreview3mmEffectivePrintPosition.right = ePImage.previewPaperRectRight;
- this.mPreview3mmEffectivePrintPosition.bottom = ePImage.previewPaperRectBottom;
- }
- public void copyPreviewPrintAreaToEpImage(EPImage ePImage) {
- ePImage.isPaperLandScape = this.mIsPaperLandScape;
- ePImage.previewPaperRectLeft = this.mPreview3mmEffectivePrintPosition.left;
- ePImage.previewPaperRectTop = this.mPreview3mmEffectivePrintPosition.top;
- ePImage.previewPaperRectRight = this.mPreview3mmEffectivePrintPosition.right;
- ePImage.previewPaperRectBottom = this.mPreview3mmEffectivePrintPosition.bottom;
- }
- }
|