Ignore:
Timestamp:
05/16/08 10:25:28 (16 years ago)
Author:
ra33
Message:

A whole day of big changes.
Adding the ability to have Text at the end of Lines.
Also a lot of refactoring to improve the quality of code relating to constraints and lines

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/ItemUtils.java

    r26 r50  
    450450                                        for (Constraint c : consts) {
    451451                                                if (c.contains(line.getEndItem())) {
    452                                                         if (c.getConstraintType() == Constraint.VERTICAL) {
     452                                                        if (c.getType() == Constraint.VERTICAL) {
    453453                                                                vConst.add(line.getStartItem());
    454454                                                                vConst.add(line.getEndItem());
     
    659659                _seen.clear();
    660660
    661                 // get all dots on the Frame
    662                 List<Dot> dots = new ArrayList<Dot>(0);
     661                // get all lineEnds on the Frame
     662                List<Item> lineEnds = new ArrayList<Item>(0);
    663663                for (Item i : items) {
    664                         if (i instanceof Dot) {
    665                                 Dot d = (Dot) i;
    666                                 d.setEnclosedList(null);
    667 
    668                                 if (d.getLines().size() == 2)
    669                                         dots.add(d);
    670                         }
    671                 }
    672 
    673                 // if there are no dots on the Frame, then there can't be an enclosure
    674                 if (dots.size() == 0)
     664                        if (i.isLineEnd()) {
     665                                i.setEnclosedList(null);
     666
     667                                if (i.getLines().size() == 2)
     668                                        lineEnds.add(i);
     669                        }
     670                }
     671
     672                // if there are no line endpoints on the Frame, then there can't be an enclosure
     673                if (lineEnds.size() == 0)
    675674                        return;
    676675
    677676                //TODO optimise this code!!
    678                 // iterate through all the dots
    679                 for (Dot searchFor : dots) {
     677                // iterate through all the lineEnds
     678                for (Item searchFor : lineEnds) {
    680679                        _seen.clear();
    681680
     
    683682                                _seen.add(l);
    684683                                if (traverse(searchFor, l.getOppositeEnd(searchFor))) {
    685                                         _path.add((Dot) l.getOppositeEnd(searchFor));
    686 
    687                                         for (Dot d : _path)
    688                                                 d.setEnclosedList(_path);
    689 
    690                                         _path = new ArrayList<Dot>(0);
     684                                        _path.add(l.getOppositeEnd(searchFor));
     685
     686                                        for (Item i : _path)
     687                                                i.setEnclosedList(_path);
     688
     689                                        _path = new ArrayList<Item>(0);
    691690
    692691                                        break;
     
    699698        private static List<Line> _seen = new ArrayList<Line>();
    700699
    701         private static List<Dot> _path = new ArrayList<Dot>();
    702 
    703         private static boolean traverse(Dot toFind, Item searchFrom) {
     700        private static List<Item> _path = new ArrayList<Item>();
     701
     702        private static boolean traverse(Item toFind, Item searchFrom) {
    704703                if (toFind == null || searchFrom == null
    705                                 || !(searchFrom instanceof Dot))
     704                                || !searchFrom.isLineEnd())
    706705                        return false;
    707706
     
    716715                                _seen.add(l);
    717716                                if (traverse(toFind, l.getOppositeEnd(searchFrom))) {
    718                                         _path.add((Dot) l.getOppositeEnd(searchFrom));
     717                                        _path.add(l.getOppositeEnd(searchFrom));
    719718                                        return true;
    720719                                }
Note: See TracChangeset for help on using the changeset viewer.