AltRect.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package epson.print.phlayout;
  2. import android.graphics.Rect;
  3. import android.graphics.RectF;
  4. public class AltRect {
  5. int bottom;
  6. int left;
  7. int right;
  8. int top;
  9. public AltRect() {
  10. }
  11. public AltRect(int i, int i2, int i3, int i4) {
  12. this.left = i;
  13. this.top = i2;
  14. this.right = i3;
  15. this.bottom = i4;
  16. }
  17. AltRect(AltRect altRect) {
  18. this.left = altRect.left;
  19. }
  20. private int width() {
  21. return this.right - this.left;
  22. }
  23. private int height() {
  24. return this.bottom - this.top;
  25. }
  26. private int centerX() {
  27. return (this.left + this.right) >> 1;
  28. }
  29. private int centerY() {
  30. return (this.top + this.bottom) >> 1;
  31. }
  32. public Rect getRect() {
  33. return new Rect(this.left, this.top, this.right, this.bottom);
  34. }
  35. public RectF getRectF() {
  36. return new RectF((float) this.left, (float) this.top, (float) this.right, (float) this.bottom);
  37. }
  38. public boolean equals(Object obj) {
  39. if (this == obj) {
  40. return true;
  41. }
  42. if (obj == null || getClass() != obj.getClass()) {
  43. return false;
  44. }
  45. AltRect altRect = (AltRect) obj;
  46. if (this.left == altRect.left && this.top == altRect.top && this.right == altRect.right && this.bottom == altRect.bottom) {
  47. return true;
  48. }
  49. return false;
  50. }
  51. public int hashCode() {
  52. return (((((this.left * 31) + this.top) * 31) + this.right) * 31) + this.bottom;
  53. }
  54. public String toString() {
  55. StringBuilder sb = new StringBuilder(32);
  56. sb.append("AltRect(");
  57. sb.append(this.left);
  58. sb.append(PreferencesConstants.COOKIE_DELIMITER);
  59. sb.append(this.top);
  60. sb.append(PreferencesConstants.COOKIE_DELIMITER);
  61. sb.append(this.right);
  62. sb.append(PreferencesConstants.COOKIE_DELIMITER);
  63. sb.append(this.bottom);
  64. sb.append(")");
  65. return sb.toString();
  66. }
  67. }