Changeset 58


Ignore:
Timestamp:
05/16/08 11:17:55 (16 years ago)
Author:
ra33
Message:

Items that are completely off the screen to the left or above are no longer saved in the file

Location:
trunk/src/org/expeditee
Files:
5 edited

Legend:

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

    r48 r58  
    1010import org.expeditee.gui.FrameUtils;
    1111import org.expeditee.items.Item;
     12import org.expeditee.items.Text;
    1213
    1314/**
     
    3839                        e.printStackTrace();
    3940                }
    40 
    4141        }
    4242
     
    4646
    4747                ArrayList<ArrayList<Item>> columns = new ArrayList<ArrayList<Item>>();
    48                 for (int j = 0; j < start.getItems().size(); j++) {
    49                         Item i = start.getItems().get(j);
    5048
    51                         if (j > 0 && start.isNormalTextItem(i)) {
    52                                 int col = findColumn(columnHeads, i);
    53                                 // if this is the head of a new column
    54                                 if (col < 0) {
    55                                         columnHeads.add(i);
    56                                         columns.add(new ArrayList<Item>());
    57                                         // otherwise the column for this item has already been
    58                                         // found set the column to be the one we just added...
    59                                         col = columns.size() - 1;
    60                                 } else
    61                                         columns.get(col).add(i);
    62                         }
     49                for (Text t : start.getBodyTextItems(true)) {
     50                        int col = findColumn(columnHeads, t);
     51                        // if this is the head of a new column
     52                        if (col < 0) {
     53                                columnHeads.add(t);
     54                                columns.add(new ArrayList<Item>());
     55                                // otherwise the column for this item has already been
     56                                // found set the column to be the one we just added...
     57                                col = columns.size() - 1;
     58                        } else
     59                                columns.get(col).add(t);
    6360                }
    6461
     
    165162        @Override
    166163        protected void finalise(Frame start) {
    167                  if(_success) overwriteMessage("Formating complete.");
     164                if (_success)
     165                        overwriteMessage("Formating complete.");
    168166        }
    169167
  • trunk/src/org/expeditee/gui/DisplayIO.java

    r55 r58  
    6161         * The title to display in the Title bar.
    6262         */
    63         public static final String TITLE = "Exp15May2008A";
     63        public static final String TITLE = "Exp16May2008A";
    6464
    6565        private DisplayIO() {
  • trunk/src/org/expeditee/gui/FrameMouseActions.java

    r50 r58  
    13121312         */
    13131313        private static boolean rubberBanding() {
    1314                 if (Frame.FreeItems.size() < 2) {
     1314                if (Frame.FreeItems.size() != 2) {
    13151315                        return false;
    13161316                }
  • trunk/src/org/expeditee/io/ExpWriter.java

    r50 r58  
    11package org.expeditee.io;
    22
     3import java.awt.Rectangle;
    34import java.io.File;
    45import java.io.FileWriter;
     
    215216                _stringWriter.append(toWrite);
    216217        }
    217 
     218       
    218219        // writes the given Item out to the file
    219220        // This method is not used to write out LINE items
     
    221222                if (_writer == null)
    222223                        return;
     224
     225                // Dont save the item if it is off the screen
     226                if (item.offScreen()) {
     227                        System.out.println("item offscreen!");
     228                        return;
     229                }
    223230
    224231                // Pictures are saved as the corresponding text items that created them
     
    228235                        item = ((WidgetCorner) item).getWidgetSource().getSource();
    229236
    230                 if (item.getLines().size() > 0)
     237                if (item.isLineEnd())
    231238                        writePoint(item);
    232239                else if (!(item instanceof Line))
  • trunk/src/org/expeditee/items/Item.java

    r55 r58  
    15521552                }
    15531553        }
     1554       
     1555        /**
     1556         * Checks if this item is off the left or top of the screen
     1557         * @return
     1558         */
     1559        public boolean offScreen() {
     1560                Rectangle itemRect = getArea().getBounds();
     1561                //Check that the bottom right corner of this item is on the screen
     1562                if (itemRect.x + itemRect.width >= 0 && itemRect.y + itemRect.height >= 0)
     1563                        return false;
     1564                //Check if all the items it is connected to are offscreen
     1565                for(Item i: getAllConnected()){
     1566                        Rectangle iRect = i.getArea().getBounds();
     1567                        //Check that the bottom right corner of this item is on the screen
     1568                        if (iRect.x + iRect.width >= 0 && iRect.y + iRect.height >= 0) {
     1569                                return false;
     1570                        }
     1571                }
     1572                return true;
     1573        }
    15541574}
Note: See TracChangeset for help on using the changeset viewer.