1 7 package javax.swing.text; 8 9 import java.io.Serializable ; 10 11 28 public class TabStop implements Serializable { 29 30 31 public static final int ALIGN_LEFT = 0; 32 34 public static final int ALIGN_RIGHT = 1; 35 38 public static final int ALIGN_CENTER = 2; 39 43 public static final int ALIGN_DECIMAL = 4; 44 public static final int ALIGN_BAR = 5; 45 46 50 51 public static final int LEAD_NONE = 0; 52 public static final int LEAD_DOTS = 1; 53 public static final int LEAD_HYPHENS = 2; 54 public static final int LEAD_UNDERLINE = 3; 55 public static final int LEAD_THICKLINE = 4; 56 public static final int LEAD_EQUALS = 5; 57 58 59 private int alignment; 60 61 private float position; 62 private int leader; 63 64 68 public TabStop(float pos) { 69 this(pos, ALIGN_LEFT, LEAD_NONE); 70 } 71 72 76 public TabStop(float pos, int align, int leader) { 77 alignment = align; 78 this.leader = leader; 79 position = pos; 80 } 81 82 86 public float getPosition() { 87 return position; 88 } 89 90 94 public int getAlignment() { 95 return alignment; 96 } 97 98 102 public int getLeader() { 103 return leader; 104 } 105 106 110 public boolean equals(Object other) 111 { 112 if (other == this) { 113 return true; 114 } 115 if (other instanceof TabStop ) { 116 TabStop o = (TabStop )other; 117 return ( (alignment == o.alignment) && 118 (leader == o.leader) && 119 (position == o.position) ); 120 } 121 return false; 122 } 123 124 130 public int hashCode() { 131 return alignment ^ leader ^ Math.round(position); 132 } 133 134 135 public String toString() { 136 String buf; 137 switch(alignment) { 138 default: 139 case ALIGN_LEFT: 140 buf = ""; 141 break; 142 case ALIGN_RIGHT: 143 buf = "right "; 144 break; 145 case ALIGN_CENTER: 146 buf = "center "; 147 break; 148 case ALIGN_DECIMAL: 149 buf = "decimal "; 150 break; 151 case ALIGN_BAR: 152 buf = "bar "; 153 break; 154 } 155 buf = buf + "tab @" + String.valueOf(position); 156 if (leader != LEAD_NONE) 157 buf = buf + " (w/leaders)"; 158 return buf; 159 } 160 } 161 162 | Popular Tags |