1 19 20 package org.netbeans.editor.view.spi; 21 22 import java.io.Serializable ; 23 24 39 40 public final class ViewInsets implements Serializable { 41 42 public static final ViewInsets ZERO_INSETS = new ViewInsets(0, 0, 0, 0); 43 44 private float top; 45 46 private float left; 47 48 private float bottom; 49 50 private float right; 51 52 60 public ViewInsets(float top, float left, float bottom, float right) { 61 this.top = top; 62 this.left = left; 63 this.bottom = bottom; 64 this.right = right; 65 } 66 67 public float getTop() { 68 return top; 69 } 70 71 public float getLeft() { 72 return left; 73 } 74 75 public float getBottom() { 76 return bottom; 77 } 78 79 public float getRight() { 80 return right; 81 } 82 83 public float getLeftRight() { 84 return left + right; 85 } 86 87 public float getTopBottom() { 88 return top + bottom; 89 } 90 91 99 public boolean equals(Object obj) { 100 if (obj instanceof ViewInsets) { 101 ViewInsets insets = (ViewInsets)obj; 102 return ((top == insets.top) && (left == insets.left) && 103 (bottom == insets.bottom) && (right == insets.right)); 104 } 105 return false; 106 } 107 108 113 public int hashCode() { 114 float sum1 = left + bottom; 115 float sum2 = right + top; 116 float val1 = sum1 * (sum1 + 1)/2 + left; 117 float val2 = sum2 * (sum2 + 1)/2 + top; 118 int sum3 = (int)(val1 + val2); 119 return sum3 * (sum3 + 1)/2 + (int)val2; 120 } 121 122 131 public String toString() { 132 return getClass().getName() 133 + "[top=" + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]"; } 136 137 } 138 | Popular Tags |