CdLayoutPosition.java 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. package epson.print.phlayout;
  2. import android.graphics.Point;
  3. import android.graphics.Rect;
  4. import android.graphics.RectF;
  5. import android.support.annotation.NonNull;
  6. import epson.common.Info_paper;
  7. import epson.print.EPImage;
  8. class CdLayoutPosition implements ILayoutPosition {
  9. private int layout = 2;
  10. private int layoutMulti = 0;
  11. private int mBottomMargin = 0;
  12. private boolean mIsPaperLandScape = false;
  13. private int mLeftMargin = 0;
  14. private int mPaperHeight = 0;
  15. private int mPaperWidth = 0;
  16. private AltRect mPreviewPrintArea = new AltRect();
  17. private int mRightMargin = 0;
  18. private int mTopMargin = 0;
  19. CdLayoutPosition() {
  20. }
  21. public int getLayoutId() {
  22. return this.layout;
  23. }
  24. public int getLeftMargin() {
  25. return this.mLeftMargin;
  26. }
  27. public int getRightMargin() {
  28. return this.mRightMargin;
  29. }
  30. public int getTopMargin() {
  31. return this.mTopMargin;
  32. }
  33. public int getBottomMargin() {
  34. return this.mBottomMargin;
  35. }
  36. public RectF getPreviewImageCircumscribedTargetSize() {
  37. return this.mPreviewPrintArea.getRectF();
  38. }
  39. public boolean isPreviewImageSizeValid() {
  40. return this.mPreviewPrintArea.right - this.mPreviewPrintArea.left > 0 && this.mPreviewPrintArea.bottom - this.mPreviewPrintArea.top > 0;
  41. }
  42. public void setPaperLandscape(boolean z) {
  43. this.mIsPaperLandScape = z;
  44. }
  45. public boolean getIsPaperLandscape() {
  46. return this.mIsPaperLandScape;
  47. }
  48. public Rect getPreviewPaperRect() {
  49. return this.mPreviewPrintArea.getRect();
  50. }
  51. /* access modifiers changed from: package-private */
  52. @VisibleForTesting
  53. public AltRect getPreviewPaperAltRect() {
  54. return this.mPreviewPrintArea;
  55. }
  56. /* access modifiers changed from: package-private */
  57. @VisibleForTesting
  58. public void setPaperAndImageSize_forTest(int i, int i2, int i3, int i4) {
  59. this.mPaperWidth = i;
  60. this.mPaperHeight = i2;
  61. }
  62. public void setLayoutId(int i, int i2) {
  63. this.layout = i;
  64. this.layoutMulti = i2;
  65. }
  66. public void copyPreviewPrintAreaFromEpImage(@NonNull EPImage ePImage) {
  67. this.mIsPaperLandScape = ePImage.isPaperLandScape;
  68. this.mPreviewPrintArea.left = ePImage.previewPaperRectLeft;
  69. this.mPreviewPrintArea.top = ePImage.previewPaperRectTop;
  70. this.mPreviewPrintArea.right = ePImage.previewPaperRectRight;
  71. this.mPreviewPrintArea.bottom = ePImage.previewPaperRectBottom;
  72. }
  73. public void copyPreviewPrintAreaToEpImage(EPImage ePImage) {
  74. ePImage.isPaperLandScape = this.mIsPaperLandScape;
  75. ePImage.previewPaperRectLeft = this.mPreviewPrintArea.left;
  76. ePImage.previewPaperRectTop = this.mPreviewPrintArea.top;
  77. ePImage.previewPaperRectRight = this.mPreviewPrintArea.right;
  78. ePImage.previewPaperRectBottom = this.mPreviewPrintArea.bottom;
  79. }
  80. public void setPaperAndCalcPreviewPosition(Info_paper info_paper, int i, int i2, Point point) {
  81. setPaperSizeFromPaperInfo(info_paper);
  82. if (this.mPaperWidth <= 0 || this.mPaperHeight <= 0) {
  83. this.mPaperWidth = 2892;
  84. this.mPaperHeight = 4125;
  85. }
  86. calculateLayoutSizeCdDvd(i, i2, point);
  87. }
  88. /* access modifiers changed from: package-private */
  89. @VisibleForTesting
  90. public void calculateLayoutSizeCdDvd(int i, int i2, @NonNull Point point) {
  91. int i3 = i2 > i ? (int) (((double) i) * 0.800000011920929d) : (int) (((double) i2) * 0.800000011920929d);
  92. AltRect altRect = this.mPreviewPrintArea;
  93. altRect.left = (i - i3) / 2;
  94. altRect.top = (i2 - i3) / 2;
  95. altRect.right = altRect.left + i3;
  96. AltRect altRect2 = this.mPreviewPrintArea;
  97. altRect2.bottom = altRect2.top + i3;
  98. point.x = ((this.mPreviewPrintArea.right - this.mPreviewPrintArea.left) / 2) + this.mPreviewPrintArea.left;
  99. point.y = ((this.mPreviewPrintArea.bottom - this.mPreviewPrintArea.top) / 2) + this.mPreviewPrintArea.top;
  100. float width = ((float) this.mPreviewPrintArea.width()) / ((float) this.mPaperWidth);
  101. this.mTopMargin = (int) (((float) this.mTopMargin) * width);
  102. this.mLeftMargin = (int) (((float) this.mLeftMargin) * width);
  103. this.mRightMargin = (int) (((float) this.mRightMargin) * width);
  104. this.mBottomMargin = (int) (((float) this.mBottomMargin) * width);
  105. if (this.mIsPaperLandScape) {
  106. int i4 = this.mTopMargin;
  107. this.mTopMargin = this.mRightMargin;
  108. this.mRightMargin = this.mBottomMargin;
  109. this.mBottomMargin = this.mLeftMargin;
  110. this.mLeftMargin = i4;
  111. }
  112. }
  113. /* access modifiers changed from: package-private */
  114. @VisibleForTesting
  115. public void setPaperSizeFromPaperInfo(Info_paper info_paper) {
  116. this.mPaperWidth = info_paper.getPaper_width();
  117. this.mPaperHeight = info_paper.getPaper_height();
  118. this.mLeftMargin = info_paper.getLeftMargin_border();
  119. this.mTopMargin = info_paper.getTopMargin_border();
  120. this.mRightMargin = info_paper.getRightMargin_border();
  121. this.mBottomMargin = info_paper.getBottomMargin_border();
  122. }
  123. }