Changeset 427 for trunk/src/org/expeditee/items/ItemUtils.java
- Timestamp:
- 01/07/09 13:25:13 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/ItemUtils.java
r407 r427 27 27 import org.expeditee.items.widgets.WidgetEdge; 28 28 29 30 29 //Static methods that provide functions for the objects\ 31 30 //mostly to transform values (string -> color etc). … … 76 75 77 76 public static final int TAG_VECTOR = 19; 78 77 79 78 public static final int TAG_ACTIVE_VECTOR = 21; 80 79 … … 457 456 458 457 for (Item i : toCopy) { 459 // Dont copy parts of a vector460 if (!i.hasPermission(Permission.copy))458 // Dont copy parts of a vector 459 if (!i.hasPermission(Permission.copy)) 461 460 continue; 462 461 463 462 // BROOK 464 463 if (i instanceof WidgetCorner) { // dont add these … … 587 586 588 587 } 589 590 // Make sure filled rectangles are shown filled on vector overlays591 if (v != null)588 589 // Make sure filled rectangles are shown filled on vector overlays 590 if (v != null) 592 591 EnclosedCheck(copies); 593 592 … … 654 653 copy.removeAllConstraints(); 655 654 656 for (Line l: origEnd.getLines()){655 for (Line l : origEnd.getLines()) { 657 656 l.invalidateAll(); 658 657 } 659 658 660 659 // create a new line 661 660 Frame currentFrame = DisplayIO.getCurrentFrame(); … … 867 866 868 867 /** 869 * Determines if an item is visible from a the current frame(s). 870 * If the item is free then it is considered visible. 871 * @param i The item to check 868 * Determines if an item is visible from a the current frame(s). If the item 869 * is free then it is considered visible. 870 * 871 * @param i 872 * The item to check 872 873 * @return True if visible/free from given frame. 873 874 */ … … 879 880 return true; 880 881 } 881 } else 882 } else { 882 883 return isVisible(DisplayIO.getCurrentFrame(), i); 883 884 } … … 885 886 886 887 /** 887 * Determines if an item is visible from a given frame. 888 * If the item is free then it is considered visible. 889 * 890 * @param fromFrame The frame to check from. 891 * @param i The item to check 888 * Determines if an item is visible from a given frame. If the item is free 889 * then it is considered visible. 890 * 891 * @param fromFrame 892 * The frame to check from. 893 * @param i 894 * The item to check 892 895 * @return True if visible/free from given frame. 893 896 */ 894 897 public static boolean isVisible(Frame fromFrame, Item i) { 895 if (fromFrame == null) return false; 898 if (fromFrame == null) 899 return false; 900 901 Frame parent = i.getParent(); 902 903 if (parent == fromFrame) 904 return true; 896 905 897 Frame parent = i.getParent(); 898 899 if (parent == fromFrame) return true; 900 901 else if (parent == null) return FreeItems.getInstance().contains(i); 902 906 else if (parent == null) 907 return FreeItems.getInstance().contains(i) 908 || FreeItems.getCursor().contains(i); 909 903 910 return fromFrame.getAllItems().contains(i) && i.isVisible(); 904 911 } 905 912 906 913 public static Rectangle expandRectangle(Rectangle r, int n) { 907 return new Rectangle(r.x - (n >> 1), r.y - (n >> 1), 908 r. width + n, r.height + n);909 } 910 914 return new Rectangle(r.x - (n >> 1), r.y - (n >> 1), r.width + n, 915 r.height + n); 916 } 917 911 918 /* 912 919 * FrameMouseActions while (!copies.isEmpty()) { Iterator<Item> iterator = … … 943 950 item.setPermission(permission); 944 951 945 // TODO encapsulate this somewhere inside of circle class!946 //if(item instanceof Circle){947 //scaleItem(v, ((Circle)item).getCenter());948 //}949 950 if (!(item instanceof Line)) { 952 // TODO encapsulate this somewhere inside of circle class! 953 // if(item instanceof Circle){ 954 // scaleItem(v, ((Circle)item).getCenter()); 955 // } 956 957 if (!(item instanceof Line)) { 951 958 if (item.getColor() == null) { 952 959 item.setColor(defaultForeground); … … 963 970 item.setActionMark(false); 964 971 } 965 972 966 973 item.scale(scale, originX, originY); 967 974 } 968 975 969 976 } 970 977 971 978 /** 972 979 * Extracts widgets from an item list. 973 980 * 974 981 * @param items 975 * Items to extract from. Must not be null. 976 * 977 * @return 978 * List of (unique)widgets in items. Never null. 982 * Items to extract from. Must not be null. 983 * 984 * @return List of (unique)widgets in items. Never null. 979 985 */ 980 986 public static List<InteractiveWidget> extractWidgets(List<Item> items) { 981 assert (items != null);982 987 assert (items != null); 988 983 989 List<InteractiveWidget> iWidgets = new LinkedList<InteractiveWidget>(); 984 990 985 991 for (Item i : items) { 986 992 if (i instanceof WidgetEdge) { 987 WidgetEdge we = (WidgetEdge) i;993 WidgetEdge we = (WidgetEdge) i; 988 994 if (!iWidgets.contains(we.getWidgetSource())) 989 995 iWidgets.add(we.getWidgetSource()); 990 996 } else if (i instanceof WidgetCorner) { 991 WidgetCorner wc = (WidgetCorner) i;997 WidgetCorner wc = (WidgetCorner) i; 992 998 if (!iWidgets.contains(wc.getWidgetSource())) 993 999 iWidgets.add(wc.getWidgetSource()); 994 1000 } 995 1001 } 996 1002 997 1003 return iWidgets; 998 1004 } 999 1005 1000 1006 }
Note:
See TracChangeset
for help on using the changeset viewer.