Changeset 1415 for trunk/src/org/expeditee/gui/FrameUtils.java
- Timestamp:
- 07/24/19 11:23:45 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/FrameUtils.java
r1407 r1415 60 60 import org.expeditee.core.bounds.AxisAlignedBoxBounds; 61 61 import org.expeditee.core.bounds.PolygonBounds; 62 import org.expeditee.encryption.items.surrogates.Label; 62 63 import org.expeditee.gio.EcosystemManager; 63 64 import org.expeditee.gio.gesture.StandardGestureActions; … … 384 385 } 385 386 386 for (Item i : current.get Items()) {387 for (Item i : current.getSortedItems()) { 387 388 i.setHighlightMode(Item.HighlightMode.None); 388 389 i.setHighlightColorToDefault(); … … 642 643 * @return True if the image was created successfully, false otherwise 643 644 */ 644 private static boolean createPicture(Frame frame, Text txt ) {645 private static boolean createPicture(Frame frame, Text txt, ItemsList items) { 645 646 // attempt to create the picture 646 647 Picture pic = ItemUtils.CreatePicture(txt); … … 659 660 return false; 660 661 } 661 frame.addItem(pic );662 frame.addItem(pic, true, items); 662 663 663 664 return true; 665 } 666 667 private static boolean createPictureInBody(Frame frame, Text txt) { 668 return createPicture(frame, txt, frame.getBody()); 664 669 } 665 670 … … 678 683 * @author Brook Novak 679 684 */ 680 private static boolean createWidget(Frame frame, Text txt ) {685 private static boolean createWidget(Frame frame, Text txt, ItemsList list) { 681 686 682 687 if (frame == null) { … … 713 718 } 714 719 715 frame.removeItem(txt );716 717 frame.addAllItems(iw.getItems() );720 frame.removeItem(txt, true, list); 721 722 frame.addAllItems(iw.getItems(), list); 718 723 719 724 return true; 725 } 726 727 private static boolean createWidgetInBody(Frame frame, Text txt) { 728 return createWidget(frame, txt, frame.getBody()); 720 729 } 721 730 … … 857 866 return dirsToAdd; 858 867 } 859 860 public static void Parse(Frame toParse) { 861 Parse(toParse, false); 862 } 863 864 /** 865 * Checks for any special Annotation items and updates the display as necessary. 866 * Special Items: Images, overlays, sort. 867 * 868 */ 869 public static void Parse(Frame toParse, boolean firstParse) { 870 Parse(toParse, firstParse, false); 871 } 872 873 /** 874 * 875 * @param toParse 876 * @param firstParse 877 * @param ignoreAnnotations 878 * used to prevent infinate loops such as when performing TDFC with 879 * an ao tag linked to a frame with an frameImage of a frame which 880 * also has an ao tag on it. 881 */ 882 public static void Parse(Frame toParse, boolean firstParse, boolean ignoreAnnotations) { 883 // TODO check why we are getting toParse == null... when profile frame 884 // is being created and change the lines below 885 if (toParse == null) { 886 return; 887 } 888 889 if (firstParse) { 890 ItemUtils.EnclosedCheck(toParse.getItems()); 891 } 892 893 List<Item> items = toParse.getItems(); 894 868 869 private static void transformOutOfPlaceItems(Frame toParse, ItemsList toTransform) { 870 // Get all items from toTransform that have not been marked as deleted. 871 List<Item> items = toParse.getItems(false, toTransform); 872 895 873 // if XRayMode is on, replace pictures with their underlying text 896 874 if (DisplayController.isXRayMode()) { … … 901 879 for (Item i : items) { 902 880 if (i instanceof XRayable) { 903 toParse.removeItem(i );881 toParse.removeItem(i, true, toTransform); 904 882 // Show the items 905 883 for (Item item : ((XRayable) i).getConnected()) { … … 908 886 } 909 887 } else if (i instanceof WidgetCorner) { 910 toParse.removeItem(i );888 toParse.removeItem(i, true, toTransform); 911 889 } else if (i instanceof WidgetEdge) { 912 toParse.removeItem(i );890 toParse.removeItem(i, true, toTransform); 913 891 } else if (i.hasFormula()) { 914 892 i.setText(i.getFormula()); … … 920 898 921 899 for (Widget iw : widgets) { 922 toParse.addItem(iw.getSource()); 923 } 924 } 925 926 // Text title = null; 927 // Text template = UserSettingsTemplate.copy(); 928 929 List<Overlay> overlays = new ArrayList<Overlay>(); 930 List<Vector> vectors = new ArrayList<Vector>(); 900 toParse.addItem(iw.getSource(), true, toTransform); 901 } 902 } 903 931 904 932 905 // disable reading of cached overlays if in twinframes mode … … 935 908 } 936 909 937 // DotType pointtype = DotType.square;938 // boolean filledPoints = true;939 940 UserAppliedPermission permission = toParse.getUserAppliedPermission();941 910 toParse.clearAnnotations(); 942 911 943 912 // check for any new overlay items 944 for (Item i : toParse.getItems()) { 913 items = toParse.getItems(false, toTransform); 914 for (Item i : items) { 945 915 try { 946 // reset overlay permission947 i.setOverlayPermission(null);948 // i.setPermission(permission);949 916 if (i instanceof WidgetCorner) { 950 917 // TODO improve efficiency so it only updates once... using … … 952 919 i.update(); 953 920 } else if (i instanceof Text) { 921 if (!DisplayController.isXRayMode() && i.isAnnotation()) { 922 if (ItemUtils.startsWithTag(i, ItemUtils.TAG_IMAGE, true)) { 923 if (!i.hasEnclosures()) { 924 createPicture(toParse, (Text) i, toTransform); 925 } 926 // check for frame images 927 } else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_FRAME_IMAGE) && i.getLink() != null 928 && !i.getAbsoluteLink().equalsIgnoreCase(toParse.getName())) { 929 XRayable image = null; 930 if (i.hasEnclosures()) { 931 // i.setHidden(true); 932 // image = 933 // i.getEnclosures().iterator().next(); 934 // image.refresh(); 935 } else { 936 image = new FrameImage((Text) i, null); 937 } 938 // TODO Add the image when creating new 939 // FrameImage 940 toParse.addItem(image, true, toTransform); 941 } else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_BITMAP_IMAGE) && i.getLink() != null 942 && !i.getAbsoluteLink().equalsIgnoreCase(toParse.getName())) { 943 XRayable image = null; 944 if (i.hasEnclosures()) { 945 // image = 946 // i.getEnclosures().iterator().next(); 947 // image.refresh(); 948 // i.setHidden(true); 949 } else { 950 // If a new bitmap is created for a 951 // frame which already has a bitmap dont 952 // recreate the bitmap 953 image = new FrameBitmap((Text) i, null); 954 } 955 toParse.addItem(image, true, toTransform); 956 } else if (ItemUtils.startsWithTag(i, "@c")) { 957 // Can only have a @c 958 if (!i.hasEnclosures() && i.getLines().size() == 1) { 959 Circle circle = new Circle((Text) i); 960 toParse.addItem(circle, true, toTransform); 961 } 962 // Check for JSItem 963 } else if (ItemUtils.startsWithTag(i, "@js")) { 964 JSItem jsItem = new JSItem((Text) i); 965 toParse.addItem(jsItem, true, toTransform); 966 // Check for interactive widgets 967 } else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_IWIDGET)) { 968 createWidget(toParse, (Text) i, toTransform); 969 } 970 971 // TODO decide exactly what to do here!! 972 toParse.addAnnotation((Text) i); 973 } else if (!DisplayController.isXRayMode() && i.hasFormula()) { 974 i.calculate(i.getFormula()); 975 } 976 } 977 } catch (Exception e) { 978 Logger.Log(e); 979 e.printStackTrace(); 980 System.err 981 .println("**** Have temporarily supressed MessageBay call, as resulted in infinite recursion"); 982 // MessageBay.warningMessage("Exception occured when loading " + 983 // i.getClass().getSimpleName() + "(ID: " 984 // + i.getID() + ") " + e.getMessage() != null ? e.getMessage() : ""); 985 } 986 } 987 988 /* 989 * for (Item i : items) { if (i instanceof Dot) { ((Dot) 990 * i).setPointType(pointtype); ((Dot) i).useFilledPoints(filledPoints); } } 991 */ 992 993 if (DisplayController.isTwinFramesOn()) { 994 FrameIO.ResumeCache(); 995 } 996 997 998 } 999 1000 private static void generatingSupportingItems(Frame toParse, 1001 ItemsList toBuildOff, boolean ignoreAnnotations) { 1002 // Get all items from toBuildOff that have not been marked as deleted. 1003 List<Item> items = toParse.getItems(false, toBuildOff); 1004 1005 List<Overlay> overlays = new ArrayList<Overlay>(); 1006 List<Vector> vectors = new ArrayList<Vector>(); 1007 1008 // disable reading of cached overlays if in twinframes mode 1009 if (DisplayController.isTwinFramesOn()) { 1010 FrameIO.SuspendCache(); 1011 } 1012 1013 UserAppliedPermission permission = toParse.getUserAppliedPermission(); 1014 // check for any new overlay items 1015 for (Item i : items) { 1016 try { 1017 // reset overlay permission 1018 i.setOverlayPermission(null); 1019 if (i instanceof Text) { 954 1020 if (i.isAnnotation()) { 955 if (ItemUtils.startsWithTag(i, ItemUtils.TAG_POINTTYPE)) { 956 Text txt = (Text) i; 957 String line = txt.getFirstLine(); 958 line = ItemUtils.StripTag(line, ItemUtils.GetTag(ItemUtils.TAG_POINTTYPE)); 959 960 if (line != null) { 961 line = line.toLowerCase(); 962 if (line.indexOf(" ") > 0) { 963 String fill = line.substring(line.indexOf(" ") + 1); 964 if (fill.startsWith("nofill")) { 965 // filledPoints = false; 966 } else { 967 // filledPoints = true; 968 } 969 } 970 971 if (line.startsWith("circle")) { 972 // pointtype = DotType.circle; 973 } else { 974 // pointtype = DotType.square; 975 } 976 } 977 } // check for new VECTOR items 978 else if (!DisplayController.isXRayMode() && ItemUtils.startsWithTag(i, ItemUtils.TAG_VECTOR) 1021 if (!DisplayController.isXRayMode() && ItemUtils.startsWithTag(i, ItemUtils.TAG_VECTOR) 979 1022 && i.getLink() != null) { 980 1023 if (!i.getAbsoluteLink().equals(toParse.getName())) { … … 1047 1090 } 1048 1091 } 1049 // check for Images and widgets 1050 else { 1051 if (!DisplayController.isXRayMode()) { 1052 if (ItemUtils.startsWithTag(i, ItemUtils.TAG_IMAGE, true)) { 1053 if (!i.hasEnclosures()) { 1054 createPicture(toParse, (Text) i); 1055 } 1056 // check for frame images 1057 } else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_FRAME_IMAGE) && i.getLink() != null 1058 && !i.getAbsoluteLink().equalsIgnoreCase(toParse.getName())) { 1059 XRayable image = null; 1060 if (i.hasEnclosures()) { 1061 // i.setHidden(true); 1062 // image = 1063 // i.getEnclosures().iterator().next(); 1064 // image.refresh(); 1065 } else { 1066 image = new FrameImage((Text) i, null); 1067 } 1068 // TODO Add the image when creating new 1069 // FrameImage 1070 toParse.addItem(image); 1071 } else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_BITMAP_IMAGE) && i.getLink() != null 1072 && !i.getAbsoluteLink().equalsIgnoreCase(toParse.getName())) { 1073 XRayable image = null; 1074 if (i.hasEnclosures()) { 1075 // image = 1076 // i.getEnclosures().iterator().next(); 1077 // image.refresh(); 1078 // i.setHidden(true); 1079 } else { 1080 // If a new bitmap is created for a 1081 // frame which already has a bitmap dont 1082 // recreate the bitmap 1083 image = new FrameBitmap((Text) i, null); 1084 } 1085 toParse.addItem(image); 1086 } else if (ItemUtils.startsWithTag(i, "@c")) { 1087 // Can only have a @c 1088 if (!i.hasEnclosures() && i.getLines().size() == 1) { 1089 toParse.addItem(new Circle((Text) i)); 1090 } 1091 // Check for JSItem 1092 } else if (ItemUtils.startsWithTag(i, "@js")) { 1093 toParse.addItem(new JSItem((Text) i)); 1094 // Check for interactive widgets 1095 } else if (ItemUtils.startsWithTag(i, ItemUtils.TAG_IWIDGET)) { 1096 createWidget(toParse, (Text) i); 1097 } 1098 } 1099 // TODO decide exactly what to do here!! 1100 toParse.addAnnotation((Text) i); 1101 } 1102 } else if (!DisplayController.isXRayMode() && i.hasFormula()) { 1103 i.calculate(i.getFormula()); 1092 1104 1093 } 1105 1094 } … … 1118 1107 */ 1119 1108 1120 FrameIO.ResumeCache(); 1109 if (DisplayController.isTwinFramesOn()) { 1110 FrameIO.ResumeCache(); 1111 } 1121 1112 1122 1113 toParse.clearOverlays(); … … 1124 1115 toParse.addAllOverlays(overlays); 1125 1116 toParse.addAllVectors(vectors); 1126 1117 } 1118 1119 public static void Parse(Frame toParse) { 1120 Parse(toParse, false); 1121 } 1122 1123 /** 1124 * Checks for any special Annotation items and updates the display as necessary. 1125 * Special Items: Images, overlays, sort. 1126 * 1127 */ 1128 public static void Parse(Frame toParse, boolean firstParse) { 1129 Parse(toParse, firstParse, false); 1130 } 1131 1132 /** 1133 * 1134 * @param toParse 1135 * @param firstParse 1136 * @param ignoreAnnotations 1137 * used to prevent infinate loops such as when performing TDFC with 1138 * an ao tag linked to a frame with an frameImage of a frame which 1139 * also has an ao tag on it. 1140 */ 1141 public static void Parse(Frame toParse, boolean firstParse, boolean ignoreAnnotations) { 1142 List<String> accessList = Label.getAccessibleLabelsNames(new ItemsList(toParse.getPrimaryBody())); 1143 1144 ItemsList primaries = toParse.getPrimaryBody(); 1145 ItemsList surrogates = toParse.getSurrogateBody(); 1146 1147 transformOutOfPlaceItems(toParse, primaries); 1148 transformOutOfPlaceItems(toParse, surrogates); 1149 1150 toParse.getInteractableItems().clear(); 1151 List<Item> newBody = parseFromPrimary(primaries, accessList); 1152 toParse.getBody().clear(); 1153 toParse.getBody().addAll(newBody); 1154 generatingSupportingItems(toParse, toParse.getBody(), ignoreAnnotations); 1155 1156 if (firstParse) { 1157 ItemUtils.EnclosedCheck(toParse.getSortedItems()); 1158 } 1159 } 1160 1161 private static List<Item> parseFromPrimary(ItemsList primaryBody, List<String> access) { 1162 List<Item> parsedBody = new ArrayList<Item>(); 1163 1164 for (Item item: primaryBody) { 1165 String encryptionLabel = item.getEncryptionLabel(); 1166 if (encryptionLabel == null || encryptionLabel.isEmpty()) { 1167 parsedBody.add(item); 1168 } else if (access.contains(encryptionLabel)) { 1169 parsedBody.add(item); 1170 } else { 1171 parsedBody.addAll(item.getSurrogates()); 1172 } 1173 } 1174 1175 return parsedBody; 1127 1176 } 1128 1177 … … 1225 1274 if (LastEdited.contains(x, y) && !FreeItems.getInstance().contains(LastEdited) 1226 1275 && LastEdited.getParent() == DisplayController.getCurrentFrame() 1227 && LastEdited.getParent().get Items().contains(LastEdited)) {1276 && LastEdited.getParent().getSortedItems().contains(LastEdited)) { 1228 1277 LastEdited.setOverlayPermission(UserAppliedPermission.full); 1229 1278 return LastEdited; … … 1412 1461 return null; 1413 1462 } 1414 List<Item> items = current.get Items();1463 List<Item> items = current.getSortedItems(); 1415 1464 1416 1465 // Remove all items that are connected to freeItems … … 1572 1621 MessageBay.suppressMessages(true); 1573 1622 int lastNumber = FrameIO.getLastNumber(defaultFrame.getFramesetName()); 1574 for (int i = 1; i <= lastNumber; i++) { 1623 for (int i = 1; i <= lastNumber; i++) { 1575 1624 // Load in next default, if it doesn't exist continue loop. 1576 1625 defaultFrame = FrameIO.LoadFrame(defaultFrame.getFramesetName() + i); … … 1670 1719 Frame indexFrame = FrameIO.LoadFrame(framesetName + '1'); 1671 1720 // Look through the folder for help index pages 1672 if (indexFrame != null && ItemUtils.FindTag(indexFrame.get Items(), "@HelpIndex") != null) {1721 if (indexFrame != null && ItemUtils.FindTag(indexFrame.getSortedItems(), "@HelpIndex") != null) { 1673 1722 // yPos += spacing; 1674 1723 yPos += 30;
Note:
See TracChangeset
for help on using the changeset viewer.