Changeset 970 for trunk/src/org/expeditee
- Timestamp:
- 10/27/15 12:11:12 (9 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/io/flowlayout/XGroupItem.java
r969 r970 410 410 } 411 411 } 412 412 413 protected boolean daisyChainContainsLoop(final XGroupItem toplevel_xgroup, final Item exitingDot, Collection<XGroupItem> groupsSeen) { 414 final Item start_item = exitingDot; 415 final Item end_item = start_item.getLines().get(0).getEndItem(); 416 final XGroupItem xgroup = innermostXGroup(end_item,toplevel_xgroup.getGroupedItemList()); 417 418 if(groupsSeen.contains(xgroup)) return true; 419 420 groupsSeen.add(xgroup); 421 422 for(final Item i : xgroup.remaining_item_list) { 423 final List<Line> lines = i.getLines(); 424 if(lines.size() == 1 && lines.get(0).getStartItem() == i) { 425 return daisyChainContainsLoop(toplevel_xgroup, i, groupsSeen); 426 } 427 } 428 429 return false; 430 } 413 431 414 432 protected void repositionOutOfFlowGroupsFollowLine(XGroupItem toplevel_xgroup, Item remaining_item, Collection<XGroupItem> out_of_flow) … … 419 437 // See if the arrow-head falls inside an XGroup area 420 438 // => Ignore endings that are in the same XGroupItem as the line started in 421 422 439 List<Line> used_in_lines = remaining_item.getLines(); 423 440 if (used_in_lines.size()==1) { … … 452 469 453 470 if (xgroup_item != this) { 454 455 if(out_of_flow.contains(xgroup_item)) { 456 final Collection<Item> remaining_dots = new ArrayList<Item>(xgroup_item.remaining_item_list); 457 boolean hasExit = false; 458 for(final Item i : remaining_dots) { 459 final List<Line> lines = i.getLines(); 460 if(lines.size() == 1 && lines.get(0).getStartItem() == i) { 461 hasExit = true; 462 break; 463 } 471 472 if(out_of_flow.contains(xgroup_item) && daisyChainContainsLoop(toplevel_xgroup, start_item, new ArrayList<XGroupItem>())) { 473 System.err.println("#Found infinite loop; not following."); 474 continue; 475 } 476 477 478 479 if(!out_of_flow.contains(xgroup_item)) { 480 for (Item remaining_item_deeper: xgroup_item.getRemainingItemList()) { 481 xgroup_item.repositionOutOfFlowGroupsFollowLine(toplevel_xgroup,remaining_item_deeper,out_of_flow); 464 482 } 465 if(hasExit) continue;466 483 } 467 468 out_of_flow.add(xgroup_item); 469 470 for (Item remaining_item_deeper: xgroup_item.getRemainingItemList()) { 471 xgroup_item.repositionOutOfFlowGroupsFollowLine(toplevel_xgroup,remaining_item_deeper,out_of_flow); 472 } 473 484 485 out_of_flow.add(xgroup_item); 474 486 475 487 … … 535 547 repositionOutOfFlowGroupsRecursive(toplevel_xgroup,out_of_flow); 536 548 537 List<XGroupItem >toplevel_grouped_item_list = toplevel_xgroup.getGroupedItemList();549 // List<XGroupItem >toplevel_grouped_item_list = toplevel_xgroup.getGroupedItemList(); 538 550 539 551 // **** … … 622 634 List<Text> raw_text_item_list, List<XGroupItem> grouped_item_list, List<Item> remaining_item_list) 623 635 { 636 final List<Item> origonal_item_list = new ArrayList<Item>(item_list); 624 637 // raw_text_items_list => all the non-enclosed text items 625 638 // grouped_items_list => list of all enclosures containing text items … … 760 773 if (area_polygon.isPerimeterPoint(enclosed_item.getPosition())) { 761 774 enclosed_item_list.remove(i); 762 } 775 //Don't include items the user hasn't asked us to. 776 } 777 //Only include items the user has asked to to include. 778 else if(!origonal_item_list.contains(enclosed_item)) enclosed_item_list.remove(i); 763 779 else { 764 780 i++; -
trunk/src/org/expeditee/items/MagneticConstraint/Actions/RepelTextAction.java
r966 r970 3 3 import java.awt.Point; 4 4 5 import org.expeditee.gui.Browser; 5 6 import org.expeditee.gui.FrameUtils; 6 7 import org.expeditee.items.Item; 8 import org.expeditee.items.Text; 7 9 import org.expeditee.items.MagneticConstraint.MagneticConstraintActionWithArguments; 8 10 import org.expeditee.items.MagneticConstraint.MagneticConstraints; … … 42 44 return false; 43 45 } else { 46 final int charDistance = Browser._theBrowser.getFontMetrics(((Text)item).getFont()).stringWidth("X"); 44 47 final Line tokensToMove = Line.getLineFromToken(item); 45 System.err.println("#Repeling tokens: " + tokensToMove);46 48 tokensToMove.removeFirst(); 49 boolean afterGap = false; 50 for(int i = 1; i < tokensToMove.size();) { 51 if(afterGap) tokensToMove.remove(i); 52 else if((tokensToMove.get(i).getX() - charDistance) > (tokensToMove.get(i - 1).getX() + tokensToMove.get(i - 1).getBoundsWidth())) { 53 afterGap = true; 54 tokensToMove.remove(i); 55 } else i++; 56 } 47 57 tokensToMove.deltaX(args[0].intValue()); 48 58 for(final Item token : tokensToMove) {
Note:
See TracChangeset
for help on using the changeset viewer.