Changeset 960 for trunk/src/org/expeditee
- Timestamp:
- 09/01/15 11:06:36 (9 years ago)
- 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 27 27 if(BoxLogic.boxCollision(item)) { 28 28 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."); 34 34 } else { 35 35 MagneticConstraints.Log(this.getClass(), new Item[]{item}, -
trunk/src/org/expeditee/items/MagneticConstraint/Utilities/BoxLogic.java
r954 r960 37 37 38 38 public static boolean boxCollision(final Item item) { 39 if(item.getParent() == null) return false; 39 40 final List<org.expeditee.items.Line> verticalLines = BoxLogic 40 41 .getVerticalLines(item.getParent()); … … 44 45 final int bottomPos = Math.max(canditate.getStartItem().getY(), 45 46 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 48 50 .getStartItem().getX() 49 && item .getX() < canditate.getStartItem().getX()) {51 && itemHitBox.getX() < canditate.getStartItem().getX()) { 50 52 return true; 51 53 } … … 54 56 return false; 55 57 } 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 // } 56 67 57 68 public static void resolveCollision(final Item item, final MagneticConstraintAction remagnet) { -
trunk/src/org/expeditee/items/MagneticConstraint/Utilities/Line.java
r954 r960 57 57 58 58 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()); 62 66 return rect; 63 67 } -
trunk/src/org/expeditee/items/MagneticConstraint/Utilities/Paragraph.java
r934 r960 58 58 //4b. No; then we simply need to calculate the position of the next line and return that. 59 59 final Rectangle boundingBox = splitAt.getBoundingBox(); 60 return new Point((int)boundingBox.getX(), (int)boundingBox.getM inY() + lineHeight);60 return new Point((int)boundingBox.getX(), (int)boundingBox.getMaxY() + lineHeight); 61 61 } 62 62 //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. … … 69 69 70 70 private static int getLineHeight(final Line line) { 71 return (int) (line.get(0).get BoundsHeight() * 1.2);71 return (int) (line.get(0).getArea().getBounds().getHeight() * 1.2); 72 72 } 73 73
Note:
See TracChangeset
for help on using the changeset viewer.