1 29 30 package nextapp.echo2.app; 31 32 44 public class Grid extends Component { 45 46 public static final int DEFAULT_SIZE = 2; 47 48 53 public static final int ORIENTATION_HORIZONTAL = 0; 54 55 59 public static final int ORIENTATION_VERTICAL = 1; 60 61 public static final String PROPERTY_BORDER = "border"; 62 public static final String PROPERTY_COLUMN_WIDTH = "columnWidth"; 63 public static final String PROPERTY_HEIGHT = "height"; 64 public static final String PROPERTY_INSETS = "insets"; 65 public static final String PROPERTY_ORIENTATION = "orientation"; 66 public static final String PROPERTY_ROW_HEIGHT = "rowHeight"; 67 public static final String PROPERTY_SIZE = "size"; 68 public static final String PROPERTY_WIDTH = "width"; 69 70 74 public Grid() { 75 super(); 76 } 77 78 85 public Grid(int size) { 86 super(); 87 setSize(size); 88 } 89 90 95 public Border getBorder() { 96 return (Border) getProperty(PROPERTY_BORDER); 97 } 98 99 107 public Extent getColumnWidth(int columnIndex) { 108 return (Extent) getIndexedProperty(PROPERTY_COLUMN_WIDTH, columnIndex); 109 } 110 111 118 public Extent getHeight() { 119 return (Extent) getProperty(PROPERTY_HEIGHT); 120 } 121 122 129 public Insets getInsets() { 130 return (Insets) getProperty(PROPERTY_INSETS); 131 } 132 133 152 public int getOrientation() { 153 Integer orientationValue = (Integer ) getProperty(PROPERTY_ORIENTATION); 154 return orientationValue == null ? ORIENTATION_HORIZONTAL : orientationValue.intValue(); 155 } 156 157 165 public Extent getRowHeight(int rowIndex) { 166 return (Extent) getIndexedProperty(PROPERTY_ROW_HEIGHT, rowIndex); 167 } 168 169 180 public int getSize() { 181 Integer sizeValue = (Integer ) getProperty(PROPERTY_SIZE); 182 if (sizeValue == null) { 183 return DEFAULT_SIZE; 184 } else { 185 return sizeValue.intValue(); 186 } 187 } 188 189 196 public Extent getWidth() { 197 return (Extent) getProperty(PROPERTY_WIDTH); 198 } 199 200 205 public void setBorder(Border newValue) { 206 setProperty(PROPERTY_BORDER, newValue); 207 } 208 209 217 public void setColumnWidth(int columnIndex, Extent newValue) { 218 setIndexedProperty(PROPERTY_COLUMN_WIDTH, columnIndex, newValue); 219 } 220 221 228 public void setHeight(Extent newValue) { 229 setProperty(PROPERTY_HEIGHT, newValue); 230 } 231 232 239 public void setInsets(Insets newValue) { 240 setProperty(PROPERTY_INSETS, newValue); 241 } 242 243 261 public void setOrientation(int newValue) { 262 setProperty(PROPERTY_ORIENTATION, new Integer (newValue)); 263 } 264 265 273 public void setRowHeight(int rowIndex, Extent newValue) { 274 setIndexedProperty(PROPERTY_ROW_HEIGHT, rowIndex, newValue); 275 } 276 277 289 public void setSize(int newValue) { 290 setProperty(PROPERTY_SIZE, new Integer (newValue)); 291 } 292 293 300 public void setWidth(Extent newValue) { 301 setProperty(PROPERTY_WIDTH, newValue); 302 } 303 } 304 | Popular Tags |