Changeset 67 for trunk/src/org/expeditee/gui/FrameMouseActions.java
- Timestamp:
- 05/19/08 12:03:18 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/FrameMouseActions.java
r58 r67 1 1 package org.expeditee.gui; 2 2 3 import java.awt.Point; 3 4 import java.awt.event.ActionEvent; 4 5 import java.awt.event.ActionListener; … … 261 262 // pre-cache the frame if it is linked 262 263 if (on != null && on.getLink() != null && on.isLinkValid()) { 263 FrameIO.Precache(on.get Link());264 FrameIO.Precache(on.getAbsoluteLink()); 264 265 } 265 266 … … 739 740 .getPosition(), false); 740 741 pickup(newPoint); 741 ItemUtils.EnclosedCheck(toDisconnect.getCurrentFrame().getItems()); 742 ItemUtils.EnclosedCheck(toDisconnect 743 .getParentOrCurrentFrame().getItems()); 742 744 return; 743 745 } … … 913 915 914 916 if (toCopy.size() > 0) { 917 //Find the closest item to the mouse cursor 918 double currentX = DisplayIO.getMouseX(); 919 double currentY = DisplayIO.getMouseY(); 920 Item closest = null; 921 double shortestDistance = Double.MAX_VALUE; 922 for(int i = 0; i < toCopy.size(); i++) { 923 Item next = toCopy.get(i); 924 if (next instanceof Line) 925 continue; 926 double distance = Point.distance(currentX, currentY, next.getX(), next.getY()); 927 if (distance < shortestDistance) { 928 shortestDistance = distance; 929 closest = next; 930 } 931 } 932 //Move the cursor to closest item 933 DisplayIO.setCursorPosition(closest.getPosition()); 934 //Pickup copy of the stuff inside the rectange 915 935 pickup(copy(toCopy)); 936 //Remove the rectangle 916 937 DisplayIO.getCurrentFrame().removeAllItems( 917 938 d.getAllConnected()); 918 939 } else { 940 //Pick up a copy of the rectangle 919 941 pickup(copy(d.getAllConnected())); 920 942 } … … 1443 1465 setTdfcItem(linker); 1444 1466 1445 // Set the link for an @Parent annotation item if one is on the frame 1446 for (Item i : next.getItems()) { 1447 if ((i instanceof Text) && ItemUtils.isTag(i, ItemUtils.TAG_PARENT) 1448 && i.getLink() == null) 1449 i.setLink(DisplayIO.getCurrentFrame().getFrameName()); 1467 for (Text i : next.getBodyTextItems(true)) { 1468 // Set the link for @Parent annotation item if one 1469 if (ItemUtils.isTag(i, ItemUtils.TAG_PARENT) && i.getLink() == null) { 1470 Frame parent = linker.getParentOrCurrentFrame(); 1471 i.setLink(parent.getFrameName()); 1472 } else if (ItemUtils.isTag(i, ItemUtils.TAG_BACKUP)) { 1473 // Delink backup tag if it is on the frame 1474 i.setLink(null); 1475 } 1450 1476 } 1451 1477 … … 1594 1620 // reset the mouse cursor 1595 1621 updateCursor(); 1596 FrameGraphics.Repaint();1597 1598 1622 ItemUtils.EnclosedCheck(current.getItems()); 1599 1623 FrameGraphics.Repaint(); … … 1604 1628 1605 1629 private static void deleteItems(List<Item> itemList) { 1606 Frame current = DisplayIO.getCurrentFrame(); 1630 List<Frame> modifiedFrames = new LinkedList<Frame>(); 1631 // Get a list of all the modified frames 1632 for (Item i : itemList) { 1633 Frame parent = i.getParent(); 1634 if (parent != null) 1635 modifiedFrames.add(parent); 1636 } 1637 1607 1638 List<Item> toUndo = new LinkedList<Item>(); 1608 1639 List<Item> seen = new LinkedList<Item>(); 1609 1610 // Mike: Removed code that checked for rectangles and removed them1611 // completely!!1612 1640 1613 1641 // disconnect any connected items … … 1623 1651 toUndo.addAll(copy(i)); 1624 1652 } 1625 1626 1653 seen.add(i); 1627 1654 } 1628 1629 // Mike: What is the point of the code below 1630 // It causes problems when deleting three items off the cursor which 1631 // include a non dot or line item 1632 /* 1633 * // check for rectangle deletion if (itemList.size() == 3) { boolean 1634 * rectangle = false; Dot dot = null; // check that this is indeed a 1635 * rectangle for (Item check : itemList) { if (dot == null && check 1636 * instanceof Dot) dot = (Dot) check; else if (check != dot && 1637 * !dot.getLines().contains(check)) { rectangle = false; break; } else 1638 * rectangle = true; } // if this is a rectangle, remove the entire 1639 * rectangle if (rectangle) { // List<Item> copy = 1640 * copy(dot.getAllConnected()); 1641 * current.addAllToUndo(dot.getAllConnected()); 1642 * current.removeAllItems(dot.getAllConnected()); itemList.clear(); // 1643 * reset the mouse cursor updateCursor(); FrameGraphics.Repaint(); 1644 * return; } } 1645 */ 1646 1647 current.removeAllItems(itemList); 1648 current.addAllToUndo(itemList); 1655 for (Frame f : modifiedFrames) { 1656 f.removeAllItems(itemList); 1657 ItemUtils.EnclosedCheck(f.getItems()); 1658 } 1659 // TODO: How should undelete deal with undo when items are removed from 1660 // the current frame as well as the overlay frame 1661 DisplayIO.getCurrentFrame().addAllToUndo(itemList); 1649 1662 itemList.clear(); 1650 1663 } … … 1964 1977 1965 1978 FrameGraphics.Repaint(); 1966 ItemUtils.EnclosedCheck(toAnchor.get CurrentFrame().getItems());1979 ItemUtils.EnclosedCheck(toAnchor.getParentOrCurrentFrame().getItems()); 1967 1980 } 1968 1981
Note:
See TracChangeset
for help on using the changeset viewer.