Changeset 77
- Timestamp:
- 05/26/08 08:17:18 (16 years ago)
- Location:
- trunk/src/org/expeditee/items
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/InteractiveWidget.java
r76 r77 28 28 public abstract class InteractiveWidget { 29 29 30 protected JComponent _ component;30 protected JComponent _swingComponent; 31 31 32 32 /** A widget is comprised of dots and lines that basically form a rectangle */ … … 38 38 * GUIDE: l1 d1-------d2 | | l4 | X | 12 | | d4-------d3 13 39 39 */ 40 private List<Item> _ items; // used for quickly returning item list40 private List<Item> _expediteeItems; // used for quickly returning item list 41 41 42 42 // Widget size restrictions … … 51 51 // The Expeditee item that is used for saving widget state in expiditee 52 52 // world 53 private Text _ source;53 private Text _textRepresentation; 54 54 55 55 // A flag for signifying whether the swing components are ready to paint. … … 346 346 "source's parent is null, InteractiveWidget's must be created from Text items with non-null parents"); 347 347 348 _ component = component;349 _ source= source;348 _swingComponent = component; 349 _textRepresentation = source; 350 350 351 351 _minWidth = minWidth; … … 367 367 int height = (_minHeight < 0) ? 10 : _minHeight; 368 368 369 Frame idAllocator = _ source.getParent();369 Frame idAllocator = _textRepresentation.getParent(); 370 370 371 371 // create WidgetCorners … … 382 382 _l4 = new WidgetEdge(_d4, _d1, idAllocator.getNextItemID()); 383 383 384 _items = new ArrayList<Item>(8); // Note: order important 385 _items.add(_d1); 386 _items.add(_d2); 387 _items.add(_d3); 388 _items.add(_d4); 389 _items.add(_l1); 390 _items.add(_l2); 391 _items.add(_l3); 392 _items.add(_l4); 393 } 394 395 /** 396 * This is for consistancy and to make the code clearer. 397 * 398 * @return the corner chosen to listen for events from. 399 */ 400 private WidgetCorner getEventCorner() { 401 return _d4; 384 _expediteeItems = new ArrayList<Item>(8); // Note: order important 385 _expediteeItems.add(_d1); 386 _expediteeItems.add(_d2); 387 _expediteeItems.add(_d3); 388 _expediteeItems.add(_d4); 389 _expediteeItems.add(_l1); 390 _expediteeItems.add(_l2); 391 _expediteeItems.add(_l3); 392 _expediteeItems.add(_l4); 402 393 } 403 394 … … 408 399 throws InteractiveWidgetNotAvailableException { 409 400 410 Text t = _ source.copy();401 Text t = _textRepresentation.copy(); 411 402 String clonedAnnotation = getAnnotationString(true); 412 _ source.setText(clonedAnnotation);403 _textRepresentation.setText(clonedAnnotation); 413 404 return InteractiveWidget.CreateWidget(t); 414 405 } … … 431 422 432 423 // Set the new text 433 _ source.setText(newAnnotation);434 435 return _ source;424 _textRepresentation.setText(newAnnotation); 425 426 return _textRepresentation; 436 427 } 437 428 … … 672 663 int newTextX = getX(); 673 664 int newTextY = getY(); 674 if (_ source.getX() != newTextX || _source.getY() != newTextY)675 _ source.setPosition(newTextX, newTextY);665 if (_textRepresentation.getX() != newTextX || _textRepresentation.getY() != newTextY) 666 _textRepresentation.setPosition(newTextX, newTextY); 676 667 677 668 _settingPositionFlag = false; … … 703 694 */ 704 695 public List<Item> getItems() { 705 return Collections.unmodifiableList(_ items);696 return Collections.unmodifiableList(_expediteeItems); 706 697 } 707 698 708 699 public JComponent getComponant() { 709 return _ component;700 return _swingComponent; 710 701 } 711 702 … … 716 707 case ItemParentStateChangedEvent.EVENT_TYPE_REMOVED_VIA_OVERLAY: 717 708 case ItemParentStateChangedEvent.EVENT_TYPE_HIDDEN: 718 if (_ component.getParent() != null) {719 _ component.getParent().remove(_component);709 if (_swingComponent.getParent() != null) { 710 _swingComponent.getParent().remove(_swingComponent); 720 711 } 721 712 break; … … 725 716 case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN: 726 717 case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN_VIA_OVERLAY: 727 if (_ component.getParent() == null) {718 if (_swingComponent.getParent() == null) { 728 719 addJComponantToFrame(e); 729 720 } … … 741 732 } 742 733 743 if (_ component.getParent() == null) {734 if (_swingComponent.getParent() == null) { 744 735 745 736 if (Browser._theBrowser != null) { … … 754 745 || e.getEventType() == ItemParentStateChangedEvent.EVENT_TYPE_SHOWN_VIA_OVERLAY 755 746 || e.getSource() == DisplayIO.getCurrentFrame()) { 756 Browser._theBrowser.getContentPane().add(_ component);757 layout(_ component);747 Browser._theBrowser.getContentPane().add(_swingComponent); 748 layout(_swingComponent); 758 749 } 759 750 … … 835 826 public void onBoundsChanged() { 836 827 837 _ component.setBounds(getX(), getY(), getWidth(), getHeight());828 _swingComponent.setBounds(getX(), getY(), getWidth(), getHeight()); 838 829 839 830 } … … 847 838 848 839 if (!_isReadyToPaint) { 849 layout(_ component);850 } 851 852 Point loc = _ component.getLocation();840 layout(_swingComponent); 841 } 842 843 Point loc = _swingComponent.getLocation(); 853 844 g.translate(loc.x, loc.y - 1); 854 _ component.paint(g);845 _swingComponent.paint(g); 855 846 g.translate(-loc.x, -(loc.y - 1)); 856 847 … … 869 860 */ 870 861 void paint(Graphics g, WidgetCorner notifier) { 871 if (_ component.getParent() == null) {862 if (_swingComponent.getParent() == null) { 872 863 // Note that frames with @f may want to paint the widgets so do not 873 864 // paint over the widget interface in these cases: must only -
trunk/src/org/expeditee/items/SampleWidget1.java
r28 r77 11 11 public SampleWidget1(Text source, String[] args) { 12 12 super(source, new JComboBox(testItems), 200, 200, 50, 50); 13 _combo = (JComboBox)super._ component;13 _combo = (JComboBox)super._swingComponent; 14 14 15 15 // Set state -
trunk/src/org/expeditee/items/SampleWidget2.java
r28 r77 19 19 super(source, new JSplitPane(JSplitPane.VERTICAL_SPLIT), 60, -1, 40, -1); 20 20 21 JSplitPane sp = (JSplitPane)super._ component;21 JSplitPane sp = (JSplitPane)super._swingComponent; 22 22 23 23 JPanel p = new JPanel(new FlowLayout()); … … 68 68 try { 69 69 int div = Integer.parseInt(args[2]); 70 ((JSplitPane)super._ component).setDividerLocation(div);70 ((JSplitPane)super._swingComponent).setDividerLocation(div); 71 71 } catch (NumberFormatException e) {} 72 72 … … 82 82 Integer.toString(_combo.getSelectedIndex()), 83 83 _text.getText(), 84 Integer.toString(((JSplitPane)super._ component).getDividerLocation())84 Integer.toString(((JSplitPane)super._swingComponent).getDividerLocation()) 85 85 }; 86 86 }
Note:
See TracChangeset
for help on using the changeset viewer.