Ignore:
Timestamp:
01/07/09 13:25:13 (15 years ago)
Author:
ra33
Message:
 
Location:
trunk/src/org/expeditee/agents
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/agents/Format.java

    r376 r427  
    5050                // Check the position of the cursor and only format stuff inside the
    5151                // same box as the cursor
    52                 Collection<Text> itemsToFormat = FrameUtils.getCurrentTextItems();
    53 
    54                 // If the cursor is not inside a box...
    55                 if (itemsToFormat.size() < 1) {
    56                         // Add all the items that are in free space
    57                         itemsToFormat = start.getBodyTextItems(true);
    58                         // Remove all the enclosed items
    59                         Collection<Item> seen = new HashSet<Item>();
    60                         for (Item i : start.getVisibleItems()) {
    61                                 if (!seen.contains(i) && i.isEnclosed()) {
    62                                         seen.addAll(i.getEnclosingDots());
    63                                         itemsToFormat.removeAll(i.getEnclosedItems());
    64                                 }
    65                         }
    66                 }
     52                Collection<Text> itemsToFormat = getItemsToFormat(start);
    6753
    6854                ArrayList<Item> columnHeads = new ArrayList<Item>();
     
    197183        }
    198184
     185        /**
     186         * Gets all the items that need to be formatted. If the user clicks in
     187         * freeSpace these are all items not enclosed by a rectangle. If the user is
     188         * formatting the items in a rectangle this is all the items in the
     189         * rectangle.
     190         *
     191         * @param start
     192         */
     193        protected Collection<Text> getItemsToFormat(Frame start) {
     194                Collection<Text> itemsToFormat = FrameUtils.getCurrentTextItems();
     195
     196                // If the cursor is not inside a box...
     197                if (itemsToFormat.size() < 1) {
     198                        // Add all the items that are in free space
     199                        itemsToFormat = start.getBodyTextItems(true);
     200                        // Remove all the enclosed items
     201                        Collection<Item> seen = new HashSet<Item>();
     202                        for (Item i : start.getVisibleItems()) {
     203                                if (!seen.contains(i) && i.isEnclosed()) {
     204                                        seen.addAll(i.getEnclosingDots());
     205                                        itemsToFormat.removeAll(i.getEnclosedItems());
     206                                }
     207                        }
     208                }
     209                return itemsToFormat;
     210        }
     211
    199212}
Note: See TracChangeset for help on using the changeset viewer.