Changeset 960


Ignore:
Timestamp:
09/01/15 11:06:36 (9 years ago)
Author:
bln4
Message:
 
Location:
trunk/src/org/expeditee/items/MagneticConstraint
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/MagneticConstraint/Actions/RepelTextAction.java

    r934 r960  
    2727                        if(BoxLogic.boxCollision(item)) {
    2828                                callback(null);
    29                                 BoxLogic.resolveCollision(item, this);
    30                                 callback(null);
    31                                 MagneticConstraints.Log(this.getClass(), new Item[]{item},
    32                                                 Line.getLineContainingToken(item).toArray(new Item[]{}),
    33                                                 "No item found to right to repel.  Collision occured.");
     29//                              BoxLogic.resolveCollision(item, this);
     30//                              callback(null);
     31//                              MagneticConstraints.Log(this.getClass(), new Item[]{item},
     32//                                              Line.getLineContainingToken(item).toArray(new Item[]{}),
     33//                                              "No item found to right to repel.  Collision occured.");
    3434                        } else {
    3535                                MagneticConstraints.Log(this.getClass(), new Item[]{item},
  • trunk/src/org/expeditee/items/MagneticConstraint/Utilities/BoxLogic.java

    r954 r960  
    3737       
    3838        public static boolean boxCollision(final Item item) {
     39                if(item.getParent() == null) return false;
    3940                final List<org.expeditee.items.Line> verticalLines = BoxLogic
    4041                                .getVerticalLines(item.getParent());
     
    4445                        final int bottomPos = Math.max(canditate.getStartItem().getY(),
    4546                                        canditate.getEndItem().getY());
    46                         if (topPos < item.getY() && bottomPos > item.getY()) {
    47                                 if (item.getX() + item.getBoundsWidth() > canditate
     47                        final Rectangle itemHitBox = item.getArea().getBounds();
     48                        if (topPos < itemHitBox.getY() && bottomPos > itemHitBox.getY()) {
     49                                if (itemHitBox.getX() + itemHitBox.getWidth() > canditate
    4850                                                .getStartItem().getX()
    49                                                 && item.getX() < canditate.getStartItem().getX()) {
     51                                                && itemHitBox.getX() < canditate.getStartItem().getX()) {
    5052                                        return true;
    5153                                }
     
    5456                return false;
    5557        }
     58       
     59//      private static boolean lineShadowsItem(final org.expeditee.items.Line line, final Item item) {
     60//              final int topPos = Math.min(line.getStartItem().getY(),
     61//                              line.getEndItem().getY());
     62//              final int bottomPos = Math.max(line.getStartItem().getY(),
     63//                              line.getEndItem().getY());
     64//              final Rectangle itemHitBox = item.getArea().getBounds();
     65//              return topPos < itemHitBox.
     66//      }
    5667
    5768        public static void resolveCollision(final Item item, final MagneticConstraintAction remagnet) {
  • trunk/src/org/expeditee/items/MagneticConstraint/Utilities/Line.java

    r954 r960  
    5757       
    5858        public Rectangle getBoundingBox() {
    59                 final Rectangle rect = new Rectangle(this.getFirst().getX(), this.getFirst().getY(), this.getFirst().getBoundsWidth(), this.getFirst().getBoundsHeight());
    60                 for(final Item token : this)
    61                         rect.add(new Rectangle(token.getX(), token.getY(), token.getBoundsWidth(), token.getBoundsHeight()));
     59//              final Rectangle rect = new Rectangle(this.getFirst().getX(), this.getFirst().getY(), this.getFirst().getBoundsWidth(), this.getFirst().getBoundsHeight());
     60//              for(final Item token : this)
     61//                      rect.add(new Rectangle(token.getX(), token.getY(), token.getBoundsWidth(), token.getBoundsHeight()));
     62//              return rect;
     63                final Rectangle rect = this.getFirst().getArea().getBounds();
     64                for(final Item token : this)
     65                        rect.add(token.getArea().getBounds());
    6266                return rect;
    6367        }
  • trunk/src/org/expeditee/items/MagneticConstraint/Utilities/Paragraph.java

    r934 r960  
    5858                        //4b. No; then we simply need to calculate the position of the next line and return that.
    5959                        final Rectangle boundingBox = splitAt.getBoundingBox();
    60                         return new Point((int)boundingBox.getX(), (int)boundingBox.getMinY() + lineHeight);
     60                        return new Point((int)boundingBox.getX(), (int)boundingBox.getMaxY() + lineHeight);
    6161                }
    6262                //NB at this point we know that there are lines below our 'splitAt' line in the same paragraph so they need to be moved down.
     
    6969       
    7070        private static int getLineHeight(final Line line) {
    71                 return (int) (line.get(0).getBoundsHeight() * 1.2);
     71                return (int) (line.get(0).getArea().getBounds().getHeight() * 1.2);
    7272        }
    7373       
Note: See TracChangeset for help on using the changeset viewer.