Ignore:
Timestamp:
05/30/08 10:14:43 (16 years ago)
Author:
ra33
Message:

Added some more unit tests
Did a bunch of refactoring
AND added a few new features... @b @v were the most significant

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/io/DefaultTreeWriter.java

    r46 r80  
    99import org.expeditee.gui.FrameIO;
    1010import org.expeditee.items.Item;
     11import org.expeditee.items.Text;
    1112
    1213public abstract class DefaultTreeWriter extends DefaultFrameWriter implements
     
    1516        // the list of frames currently being processed
    1617        private Stack<FrameCounter> _frames = new Stack<FrameCounter>();
     18
    1719        private int _frameCount = 0;
    18        
     20
    1921        public int getFrameCount() {
    2022                return _frameCount;
     
    2426                try {
    2527                        initialise(toWrite);
    26 
    2728                        outputTree(toWrite);
    2829
    29                         _running = false;
    30                         return finaliseTree();
    3130                } catch (IOException ioe) {
    3231                        _running = false;
    3332                        throw ioe;
     33                } catch (Exception e) {
     34                        e.printStackTrace();
    3435                }
     36                _running = false;
     37                return finaliseTree();
    3538        }
    3639
     
    6669                        return;
    6770
    68                 _frames.push(new FrameCounter(toWrite.getFrameName(), -1));
     71                _frames.push(new FrameCounter(toWrite.getName(), -1));
    6972
    7073                // process the entire tree of frames in depth-first order
    7174                while (_frames.size() > 0) {
    7275                        FrameCounter cur = _frames.pop();
     76
     77                        if (_stop)
     78                                return;
    7379
    7480                        Frame next = FrameIO.LoadFrame(cur.frame);
     
    8591                                this.resumeFrame(next);
    8692                        } else {
    87                                 FrameGraphics.OverwriteMessage("Writing: "
    88                                                 + next.getFrameName());
    89                                 _frameCount ++;
     93                                FrameGraphics.OverwriteMessage("Writing: " + next.getName());
     94                                _frameCount++;
    9095                                writeStartFrame(next);
    9196                        }
     
    102107                                // ignore annotation and framenames
    103108                                if (item.getID() >= 0) {
    104                                         if (item.getLink() != null && !item.isAnnotation()) {
     109                                        //Only follow the links of text items
     110                                        if (item instanceof Text && item.getLink() != null
     111                                                        && !item.isAnnotation()) {
    105112                                                cur.index = i;
    106113                                                _frames.push(cur);
     
    110117                                                this.writeStartLink(item);
    111118
    112                                                 Frame linked = FrameIO.LoadFrame(item.getAbsoluteLink());
     119                                                Frame linked = FrameIO
     120                                                                .LoadFrame(item.getAbsoluteLink());
    113121
    114122                                                // if the linked frame was found, then display it next
    115123                                                if (linked != null) {
    116                                                         FrameCounter fc = new FrameCounter(linked
    117                                                                         .getFrameName(), -1);
     124                                                        FrameCounter fc = new FrameCounter(
     125                                                                        linked.getName(), -1);
    118126                                                        if (!_frames.contains(fc)) {
    119127                                                                // remember what frame we are on before
     
    127135                                                        }
    128136                                                }
    129                                         } else if (item != next.getTitle())
     137                                                // Dont write out the title here because it is written
     138                                                // out earlier
     139                                        } else if (item != next.getTitleItem())
    130140                                                this.writeItem(item);
    131141                                }
     
    160170                        if (o instanceof FrameCounter)
    161171                                return (((FrameCounter) o).frame.equals(frame));// && fc.index
    162                                                                                                                                 // == index);
     172                        // == index);
    163173
    164174                        return false;
Note: See TracChangeset for help on using the changeset viewer.