Ignore:
Timestamp:
05/01/08 17:02:40 (16 years ago)
Author:
ra33
Message:

Added Interactive Widget Items

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/Frame.java

    r7 r10  
    88import java.awt.image.VolatileImage;
    99import java.util.ArrayList;
     10import java.util.Collection;
    1011import java.util.Collections;
    1112import java.util.LinkedList;
     
    1617import org.expeditee.io.Logger;
    1718import org.expeditee.items.Dot;
     19import org.expeditee.items.InteractiveWidget;
    1820import org.expeditee.items.Item;
    1921import org.expeditee.items.ItemUtils;
    2022import org.expeditee.items.Line;
    2123import org.expeditee.items.Text;
     24import org.expeditee.items.WidgetCorner;
    2225
    2326/**
     
    8689
    8790        public static List<Item> FreeItems = new ArrayList<Item>();
     91       
     92        // for drawing purposes
     93        private List<InteractiveWidget> _iWidgets = new ArrayList<InteractiveWidget>();
    8894
    8995        private int _lineCount = 0;
     
    140146                                i.setID(++_lineCount);
    141147        }
     148       
     149        /**
     150         *
     151         * @return The interactive widgets that are currently ancored in this frame.
     152         * Hence it exlcudes free-widgets.
     153         */
     154        public List<InteractiveWidget> getInteractiveWidgets() {
     155                return Collections.unmodifiableList(this._iWidgets);
     156                // return       this._iWidgets; // faster
     157        }
    142158
    143159        /**
     
    163179                _change = value;
    164180
    165                 if (_change) {
     181                if (_change){
    166182                        setBufferValid(false);
    167183                        _saved = false;
     
    186202                        _sorted = true;
    187203                }
    188 
     204               
    189205                List<Item> visibleItems = new ArrayList<Item>();
    190 
    191                 for (Item i : _body) {
     206               
     207                for(Item i: _body) {
    192208                        if (i.isVisible())
    193209                                visibleItems.add(i);
    194210                }
    195 
     211               
    196212                return visibleItems;
    197213        }
     
    214230                }
    215231
    216                 return bodyTextItems;
    217 
     232                return bodyTextItems;           
    218233        }
    219234
     
    289304                        if (autoBulletText.length() > 0)
    290305                                frameTitle.stripFirstWord();
     306                }
     307                //TODO Widgets... check this out
     308                // Brook: Cannot figure what is going on above... widget  annot titles should be stripped always
     309                if (ItemUtils.isTag(frameTitle, ItemUtils.GetTag(ItemUtils.TAG_IWIDGET))) {
     310                        frameTitle.stripFirstWord();
    291311                }
    292312
     
    452472                if (_frameName != null) {
    453473                        id = _frameName.getID();
    454                 } else {
     474                } else{
    455475                        id = -1 * getNextItemID();
    456476                }
     
    575595                if (item != null) {
    576596                        if (_body.contains(item)) {
    577                                 // System.out.println("Item (" + item.getClass().getSimpleName()
    578                                 // + ") with ID " + item.getID() + " already in body.");
     597                                //System.out.println("Item (" + item.getClass().getSimpleName()
     598                                //              + ") with ID " + item.getID() + " already in body.");
    579599                                return;
    580600                        }
     
    582602                        if (item instanceof Line)
    583603                                _lineCount++;
    584 
     604                       
    585605                        _itemCount = Math.max(_itemCount, item.getID());
    586606
     
    591611
    592612                        item.setMaxSize(FrameGraphics.getMaxFrameSize());
     613                        //add widget items to the list of widgets
     614                        if (item instanceof WidgetCorner) {
     615                                InteractiveWidget iw = ((WidgetCorner)item).getWidgetSource();
     616                                if (!this._iWidgets.contains(iw)) { // A set would have been best
     617                                        _iWidgets.add(iw);
     618                                }
     619                        }
     620                       
     621                        item.onAddedToFrame();
     622
    593623                        change();
    594624                }
     
    608638        }
    609639
    610         public void addAllItems(List<Item> toAdd) {
     640        public void addAllItems(Collection<Item> toAdd) {
    611641                for (Item i : toAdd)
    612642                        addItem(i);
    613643        }
    614644
    615         public void removeAllItems(List<Item> toRemove) {
     645        public void removeAllItems(Collection<Item> toRemove) {
    616646                for (Item i : toRemove)
    617647                        removeItem(i);
     
    621651                if (_body.remove(item))
    622652                        change();
     653               
     654                //Remove widgets from the widget list
     655                if (item != null) {
     656                        item.onRemovedFromFrame();
     657                        if (item instanceof WidgetCorner) {
     658                                _iWidgets.remove(((WidgetCorner)item).getWidgetSource());
     659                        }
     660                }
     661               
    623662        }
    624663
     
    951990                List<Item> copies = ItemUtils.CopyItems(toMergeWith.getItems());
    952991                copies.remove(toMergeWith.getFrameNameItem());
    953 
     992               
    954993                for (Item i : copies) {
    955994                        if (i.getID() >= 0) {
Note: See TracChangeset for help on using the changeset viewer.