AltRect.java 1.8 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. left = i;
  13. top = i2;
  14. right = i3;
  15. bottom = i4;
  16. }
  17. AltRect(AltRect altRect) {
  18. left = altRect.left;
  19. }
  20. private int width() {
  21. return right - left;
  22. }
  23. private int height() {
  24. return bottom - top;
  25. }
  26. private int centerX() {
  27. return (left + right) >> 1;
  28. }
  29. private int centerY() {
  30. return (top + bottom) >> 1;
  31. }
  32. public Rect getRect() {
  33. return new Rect(left, top, right, bottom);
  34. }
  35. public RectF getRectF() {
  36. return new RectF((float) left, (float) top, (float) right, (float) 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 (left == altRect.left && top == altRect.top && right == altRect.right && bottom == altRect.bottom) {
  47. return true;
  48. }
  49. return false;
  50. }
  51. public int hashCode() {
  52. return (((((left * 31) + top) * 31) + right) * 31) + bottom;
  53. }
  54. public String toString() {
  55. StringBuilder sb = new StringBuilder(32);
  56. sb.append("AltRect(");
  57. sb.append(left);
  58. sb.append(PreferencesConstants.COOKIE_DELIMITER);
  59. sb.append(top);
  60. sb.append(PreferencesConstants.COOKIE_DELIMITER);
  61. sb.append(right);
  62. sb.append(PreferencesConstants.COOKIE_DELIMITER);
  63. sb.append(bottom);
  64. sb.append(")");
  65. return sb.toString();
  66. }
  67. }