1 29 30 package nextapp.echo2.app; 31 32 42 public class SplitPane extends Component 43 implements Pane, PaneContainer { 44 45 52 public static final int ORIENTATION_HORIZONTAL_LEADING_TRAILING = 1; 53 54 61 public static final int ORIENTATION_HORIZONTAL_TRAILING_LEADING = 2; 62 63 68 public static final int ORIENTATION_HORIZONTAL_LEFT_RIGHT = 3; 69 70 75 public static final int ORIENTATION_HORIZONTAL_RIGHT_LEFT = 4; 76 77 82 public static final int ORIENTATION_VERTICAL_TOP_BOTTOM = 5; 83 84 89 public static final int ORIENTATION_VERTICAL_BOTTOM_TOP = 6; 90 91 94 public static final int ORIENTATION_HORIZONTAL = ORIENTATION_HORIZONTAL_LEADING_TRAILING; 95 96 99 public static final int ORIENTATION_VERTICAL = ORIENTATION_VERTICAL_TOP_BOTTOM; 100 101 public static final String PROPERTY_ORIENTATION = "orientation"; 102 public static final String PROPERTY_RESIZABLE = "resizable"; 103 public static final String PROPERTY_SEPARATOR_COLOR = "separatorColor"; 104 public static final String PROPERTY_SEPARATOR_HEIGHT = "separatorHeight"; 105 public static final String PROPERTY_SEPARATOR_HORIZONTAL_IMAGE = "separatorHorizontalImage"; 106 public static final String PROPERTY_SEPARATOR_POSITION = "separatorPosition"; 107 public static final String PROPERTY_SEPARATOR_WIDTH = "separatorWidth"; 108 public static final String PROPERTY_SEPARATOR_VERTICAL_IMAGE = "separatorVerticalImage"; 109 110 114 public SplitPane() { 115 super(); 116 } 117 118 134 public SplitPane(int orientation) { 135 super(); 136 setOrientation(orientation); 137 } 138 139 158 public SplitPane(int orientation, Extent separatorPosition) { 159 super(); 160 setOrientation(orientation); 161 if (separatorPosition != null) { 162 setSeparatorPosition(separatorPosition); 163 } 164 } 165 166 182 public int getOrientation() { 183 Integer orientation = (Integer ) getProperty(PROPERTY_ORIENTATION); 184 return orientation == null ? ORIENTATION_VERTICAL : orientation.intValue(); 185 } 186 187 192 public Color getSeparatorColor() { 193 return (Color) getProperty(PROPERTY_SEPARATOR_COLOR); 194 } 195 196 204 public Extent getSeparatorHeight() { 205 return (Extent) getProperty(PROPERTY_SEPARATOR_HEIGHT); 206 } 207 208 214 public FillImage getSeparatorHorizontalImage() { 215 return (FillImage) getProperty(PROPERTY_SEPARATOR_HORIZONTAL_IMAGE); 216 } 217 218 225 public Extent getSeparatorPosition() { 226 return (Extent) getProperty(PROPERTY_SEPARATOR_POSITION); 227 } 228 229 235 public FillImage getSeparatorVerticalImage() { 236 return (FillImage) getProperty(PROPERTY_SEPARATOR_VERTICAL_IMAGE); 237 } 238 239 247 public Extent getSeparatorWidth() { 248 return (Extent) getProperty(PROPERTY_SEPARATOR_WIDTH); 249 } 250 251 256 public boolean isResizable() { 257 Boolean value = (Boolean ) getProperty(PROPERTY_RESIZABLE); 258 return value == null ? false : value.booleanValue(); 259 } 260 261 266 public boolean isValidChild(Component component) { 267 return getComponentCount() <= 1; 268 } 269 270 273 public boolean isValidParent(Component parent) { 274 return parent instanceof PaneContainer; 275 } 276 277 280 public void processInput(String inputName, Object inputValue) { 281 if (PROPERTY_SEPARATOR_POSITION.equals(inputName)) { 282 setSeparatorPosition((Extent) inputValue); 283 } 284 } 285 286 302 public void setOrientation(int newValue) { 303 setProperty(PROPERTY_ORIENTATION, new Integer (newValue)); 304 } 305 306 313 public void setResizable(boolean newValue) { 314 setProperty(PROPERTY_RESIZABLE, new Boolean (newValue)); 315 } 316 317 322 public void setSeparatorColor(Color newValue) { 323 setProperty(PROPERTY_SEPARATOR_COLOR, newValue); 324 } 325 326 334 public void setSeparatorHeight(Extent newValue) { 335 Extent.validate(newValue, Extent.PX); 336 setProperty(PROPERTY_SEPARATOR_HEIGHT, newValue); 337 } 338 339 345 public void setSeparatorHorizontalImage(FillImage newValue) { 346 setProperty(PROPERTY_SEPARATOR_HORIZONTAL_IMAGE, newValue); 347 } 348 349 356 public void setSeparatorPosition(Extent newValue) { 357 Extent.validate(newValue, Extent.PX); 358 if (newValue != null && newValue.getValue() < 0) { 359 throw new IllegalArgumentException ("Extent value may not be negative."); 360 } 361 setProperty(PROPERTY_SEPARATOR_POSITION, newValue); 362 } 363 364 370 public void setSeparatorVerticalImage(FillImage newValue) { 371 setProperty(PROPERTY_SEPARATOR_VERTICAL_IMAGE, newValue); 372 } 373 374 382 public void setSeparatorWidth(Extent newValue) { 383 Extent.validate(newValue, Extent.PX); 384 setProperty(PROPERTY_SEPARATOR_WIDTH, newValue); 385 } 386 } 387 | Popular Tags |