Changeset 1181 for trunk/src/org/expeditee/gui
- Timestamp:
- 10/02/18 10:24:16 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/Frame.java
r1144 r1181 36 36 import org.expeditee.core.bounds.PolygonBounds; 37 37 import org.expeditee.gio.gesture.StandardGestureActions; 38 import org.expeditee.gio.input.KBMInputEvent.Key; 38 39 import org.expeditee.gio.input.StandardInputEventListeners; 39 import org.expeditee.gio.input.KBMInputEvent.Key;40 40 import org.expeditee.io.Conversion; 41 41 import org.expeditee.items.Constraint; … … 192 192 _dotTemplate.setFillColor(ColorUtils.getNextColor(_dotTemplate.getFillColor(), TemplateSettings.FillColorWheel.get(), null)); 193 193 _dotTemplate.setColor(ColorUtils.getNextColor(_dotTemplate.getColor(), TemplateSettings.ColorWheel.get(), null)); 194 if (_dotTemplate.getColor() == null || _dotTemplate.getColor().equals(Colour.WHITE)) resetDot(); 194 if (_dotTemplate.getColor() == null || _dotTemplate.getColor().equals(Colour.WHITE)) { 195 resetDot(); 196 } 195 197 } 196 198 … … 207 209 public boolean isBufferValid() 208 210 { 209 if (_buffer == null) return false; 211 if (_buffer == null) { 212 return false; 213 } 210 214 211 215 return _validBuffer; … … 253 257 { 254 258 // virtual frames are never saved 255 if (_number == VIRTUAL_FRAME_NUMBER) return false; 259 if (_number == VIRTUAL_FRAME_NUMBER) { 260 return false; 261 } 256 262 257 263 return _change; … … 266 272 public void setChanged(boolean value) 267 273 { 268 if (_change == value) return; 274 if (_change == value) { 275 return; 276 } 269 277 270 278 _change = value; … … 285 293 public void notifyObservers(boolean bRecalculate) 286 294 { 287 if (bRecalculate) recalculate(); 295 if (bRecalculate) { 296 recalculate(); 297 } 288 298 // Notify the frame listeners that the frame has changed 289 299 /* … … 297 307 298 308 for (FrameObserver fl : observersCopy) { 299 if (fl.isVisible()) fl.update(); 309 if (fl.isVisible()) { 310 fl.update(); 311 } 300 312 } 301 313 } … … 331 343 332 344 for (Item i : _body) { 333 if (i == null) continue; 345 if (i == null) { 346 continue; 347 } 334 348 335 349 if (i.isVisible() || (!visible && !i.isDeleted())) { … … 354 368 public boolean containsItem(Item i) 355 369 { 356 if (i == null) throw new NullPointerException("i"); 370 if (i == null) { 371 throw new NullPointerException("i"); 372 } 357 373 358 374 return _body.contains(i); … … 392 408 for (Item i : getItems(true)) { 393 409 // only add up normal body text items 394 if (!i.isAnnotation()) items.add(i); 410 if (!i.isAnnotation()) { 411 items.add(i); 412 } 395 413 } 396 414 … … 417 435 418 436 if (it instanceof Text && !it.isAnnotation()) { 419 return (Item)it;437 return it; 420 438 } 421 439 } … … 450 468 public void setTitle(String title) 451 469 { 452 if (title == null || title.equals("")) return; 470 if (title == null || title.equals("")) { 471 return; 472 } 453 473 454 474 boolean oldchange = _change; … … 481 501 // If the @ symbol is followed by numbering or a bullet remove that too 482 502 String autoBulletText = StandardGestureActions.getAutoBullet(title); 483 if (autoBulletText.length() > 0) 503 if (autoBulletText.length() > 0) { 484 504 frameTitle.stripFirstWord(); 505 } 485 506 } 486 507 // TODO Widgets... check this out … … 513 534 { 514 535 Text title = getTitleItem(); 515 if (title == null) return getName(); 536 if (title == null) { 537 return getName(); 538 } 516 539 517 540 return title.getFirstLine(); … … 659 682 assert (number >= 0); 660 683 661 if (_number == number) return; 684 if (_number == number) { 685 return; 686 } 662 687 663 688 _number = number; … … 714 739 _permissionPair = new PermissionPair(permission); 715 740 716 if (_body.size() > 0) refreshItemPermissions(permission.getPermission(_owner)); 741 if (_body.size() > 0) { 742 refreshItemPermissions(permission.getPermission(_owner)); 743 } 717 744 } 718 745 … … 811 838 public void addItem(Item item, boolean recalculate) 812 839 { 813 if (item == null || item.equals(_frameName) || _body.contains(item)) return; 840 if (item == null || item.equals(_frameName) || _body.contains(item)) { 841 return; 842 } 814 843 815 844 // When an annotation item is anchored the annotation list must be … … 819 848 } 820 849 821 if (item instanceof Line) _lineCount++; 850 if (item instanceof Line) { 851 _lineCount++; 852 } 822 853 823 854 _itemCount = Math.max(_itemCount, item.getID()); … … 914 945 for (Item i : toAdd) { 915 946 // If an annotation is being deleted clear the annotation list 916 if (i.isAnnotation()) i.getParentOrCurrentFrame().clearAnnotations(); 947 if (i.isAnnotation()) { 948 i.getParentOrCurrentFrame().clearAnnotations(); 949 } 917 950 // TODO Improve efficiency when addAll is called 918 951 addItem(i); … … 924 957 for (Item i : toRemove) { 925 958 // If an annotation is being deleted clear the annotation list 926 if (i.isAnnotation()) i.getParentOrCurrentFrame().clearAnnotations(); 959 if (i.isAnnotation()) { 960 i.getParentOrCurrentFrame().clearAnnotations(); 961 } 927 962 removeItem(i); 928 963 } … … 937 972 { 938 973 // If an annotation is being deleted clear the annotation list 939 if (item.isAnnotation()) item.getParentOrCurrentFrame().clearAnnotations(); 974 if (item.isAnnotation()) { 975 item.getParentOrCurrentFrame().clearAnnotations(); 976 } 940 977 941 978 if (_body.remove(item)) { … … 966 1003 private void addToUndo(Collection<Item> items, History.Type type) 967 1004 { 968 if (items.size() < 1) return; 1005 if (items.size() < 1) { 1006 return; 1007 } 969 1008 970 1009 _undo.push(new History(items, type)); … … 986 1025 boolean bRecalculate = false; 987 1026 988 if (_undo.size() <= 0) return; 1027 if (_undo.size() <= 0) { 1028 return; 1029 } 989 1030 990 1031 History undo = _undo.pop(); … … 1044 1085 boolean bRecalculate = false; 1045 1086 1046 if (_redo.size() <= 0) return; 1087 if (_redo.size() <= 0) { 1088 return; 1089 } 1047 1090 1048 1091 History redo = _redo.pop(); … … 1134 1177 public UserAppliedPermission getUserAppliedPermission(UserAppliedPermission defaultPermission) 1135 1178 { 1136 if (_permissionPair == null) return defaultPermission; 1179 if (_permissionPair == null) { 1180 return defaultPermission; 1181 } 1137 1182 1138 1183 return _permissionPair.getPermission(_owner); … … 1224 1269 } 1225 1270 1271 @Override 1226 1272 public String toString() 1227 1273 { … … 1253 1299 1254 1300 int ind = toCheck.indexOf(current); 1255 if (ind == -1) return null; 1301 if (ind == -1) { 1302 return null; 1303 } 1256 1304 1257 1305 // loop through all items above this one, return the first match 1258 1306 for (int i = ind - 1; i >= 0; i--) { 1259 1307 Text check = toCheck.get(i); 1260 if (FrameUtils.inSameColumn(check, current)) return check; 1308 if (FrameUtils.inSameColumn(check, current)) { 1309 return check; 1310 } 1261 1311 } 1262 1312 … … 1274 1324 { 1275 1325 // Check that this item is on the current frame 1276 if (!_body.contains(from)) return null; 1326 if (!_body.contains(from)) { 1327 return null; 1328 } 1277 1329 1278 1330 if (from == null) { … … 1280 1332 } 1281 1333 1282 if (from == null) return null; 1334 if (from == null) { 1335 return null; 1336 } 1283 1337 1284 1338 // Get the enclosedItems … … 1304 1358 1305 1359 // If its the title index will be 0 1306 if (index < 0) index = 0; 1360 if (index < 0) { 1361 index = 0; 1362 } 1307 1363 1308 1364 for (int i = index; i < toCheck.size(); i++) { 1309 1365 Text item = toCheck.get(i); 1310 if (FrameUtils.inSameColumn(from, item)) column.add(item); 1366 if (FrameUtils.inSameColumn(from, item)) { 1367 column.add(item); 1368 } 1311 1369 } 1312 1370 } … … 1328 1386 { 1329 1387 // make sure we dont add this frame as an overlay of itself 1330 if (toAdd.Frame == this) return false; 1388 if (toAdd.Frame == this) { 1389 return false; 1390 } 1331 1391 1332 1392 _vectors.add(toAdd); … … 1338 1398 1339 1399 HighlightMode mode = toAdd.Source.getHighlightMode(); 1340 if (mode != HighlightMode.None) mode = HighlightMode.Connected; 1400 if (mode != HighlightMode.None) { 1401 mode = HighlightMode.Connected; 1402 } 1341 1403 1342 1404 Colour highlightColor = toAdd.Source.getHighlightColor(); … … 1352 1414 // Get the right most x and bottom most y pos 1353 1415 int itemRight = i.getX() + i.getBoundsWidth(); 1354 if (itemRight > maxX) maxX = itemRight; 1416 if (itemRight > maxX) { 1417 maxX = itemRight; 1418 } 1355 1419 1356 1420 int itemBottom = i.getY() + i.getBoundsHeight(); 1357 if (itemBottom > maxY) maxY = itemBottom; 1421 if (itemBottom > maxY) { 1422 maxY = itemBottom; 1423 } 1358 1424 } 1359 1425 … … 1387 1453 private boolean getVectorsDeep(List<Vector> vectors, Frame vector, List<Frame> seenVectors) 1388 1454 { 1389 if (seenVectors.contains(vector)) return false; 1455 if (seenVectors.contains(vector)) { 1456 return false; 1457 } 1390 1458 1391 1459 seenVectors.add(vector); … … 1411 1479 private boolean getOverlaysDeep(List<Overlay> overlays, List<Frame> seenOverlays) 1412 1480 { 1413 if (seenOverlays.contains(this)) return false; 1481 if (seenOverlays.contains(this)) { 1482 return false; 1483 } 1414 1484 1415 1485 seenOverlays.add(this); … … 1438 1508 List<Widget> widgets = new LinkedList<Widget>(); 1439 1509 1440 for (Overlay o : getOverlaysDeep()) widgets.addAll(o.Frame.getInteractiveWidgets()); 1510 for (Overlay o : getOverlaysDeep()) { 1511 widgets.addAll(o.Frame.getInteractiveWidgets()); 1512 } 1441 1513 1442 1514 return widgets; … … 1453 1525 public Overlay getOverlayOwner(Item item) 1454 1526 { 1455 if (item == null) throw new NullPointerException("item"); 1527 if (item == null) { 1528 throw new NullPointerException("item"); 1529 } 1456 1530 1457 1531 for (Overlay l : getOverlays()) { 1458 if (item.getParent() == l.Frame) return l; 1532 if (item.getParent() == l.Frame) { 1533 return l; 1534 } 1459 1535 } 1460 1536 … … 1462 1538 // the vector frame 1463 1539 for (Vector v : getVectors()) { 1464 if (item.getParent() == v.Frame) return v; 1540 if (item.getParent() == v.Frame) { 1541 return v; 1542 } 1465 1543 } 1466 1544 … … 1482 1560 protected boolean removeVector(Vector toRemove) 1483 1561 { 1484 if (!_vectors.remove(toRemove)) return false; 1562 if (!_vectors.remove(toRemove)) { 1563 return false; 1564 } 1485 1565 1486 1566 for (Item i : toRemove.Frame.getVectorItems()) { … … 1550 1630 { 1551 1631 // make sure we dont add this frame as an overlay of itself 1552 if (toAdd.Frame == this) return false; 1632 if (toAdd.Frame == this) { 1633 return false; 1634 } 1553 1635 1554 1636 // Dont add the overlay if there is already one for this frame 1555 if (_overlays.values().contains(toAdd.Frame)) return false; 1637 if (_overlays.values().contains(toAdd.Frame)) { 1638 return false; 1639 } 1556 1640 1557 1641 // Add the overlay to the map of overlays on this frame … … 1560 1644 // Add all the overlays from the overlay frame to this frame 1561 1645 // TODO: Can this cause a recursion loop? If A and B are overlays of each other? cts16 1562 for (Overlay o : toAdd.Frame.getOverlays()) addOverlay(o); 1646 for (Overlay o : toAdd.Frame.getOverlays()) { 1647 addOverlay(o); 1648 } 1563 1649 1564 1650 // Add all the vectors from the overlay frame to this frame 1565 for (Vector v : toAdd.Frame.getVectors()) addVector(v); 1651 for (Vector v : toAdd.Frame.getVectors()) { 1652 addVector(v); 1653 } 1566 1654 1567 1655 // Now add the items for this overlay … … 1599 1687 private void merge(Frame toMergeWith) 1600 1688 { 1601 if (toMergeWith == null) return; 1689 if (toMergeWith == null) { 1690 return; 1691 } 1602 1692 1603 1693 List<Item> copies = ItemUtils.CopyItems(toMergeWith.getItems()); … … 1658 1748 if (keepAnnotations) { 1659 1749 for (Item i : _body) { 1660 if (i.isAnnotation()) newBody.add(i); 1750 if (i.isAnnotation()) { 1751 newBody.add(i); 1752 } 1661 1753 } 1662 1754 } … … 1667 1759 change(); 1668 1760 1669 if (!keepAnnotations && _annotations != null) _annotations.clear(); 1761 if (!keepAnnotations && _annotations != null) { 1762 _annotations.clear(); 1763 } 1670 1764 } 1671 1765 … … 1732 1826 Item template = getTemplate(_dotTemplate, ItemUtils.TAG_DOT_TEMPLATE); 1733 1827 float thickness = template.getThickness(); 1734 if (thickness > 0) dot.setThickness(template.getThickness()); 1735 if (template.getLinePattern() != null) dot.setLinePattern(template.getLinePattern()); 1828 if (thickness > 0) { 1829 dot.setThickness(template.getThickness()); 1830 } 1831 if (template.getLinePattern() != null) { 1832 dot.setLinePattern(template.getLinePattern()); 1833 } 1736 1834 dot.setColor(template.getColor()); 1737 1835 dot.setFillColor(template.getFillColor()); … … 1754 1852 1755 1853 if (t == null) { 1756 if (defaultTemplate == null) return null; 1854 if (defaultTemplate == null) { 1855 return null; 1856 } 1757 1857 1758 1858 t = defaultTemplate; … … 1932 2032 for (int i = 0; i < items.size(); i++) { 1933 2033 Item it = items.get(i); 1934 if (isNormalTextItem(it)) itemsFound++; 2034 if (isNormalTextItem(it)) { 2035 itemsFound++; 2036 } 1935 2037 if (itemsFound > index) { 1936 2038 DisplayController.setCursorPosition(((Text) it).getParagraphEndPosition().getX(), it.getY()); … … 1964 2066 t.setText(""); 1965 2067 1966 if (t.getText().equals("")) DisplayController.getCurrentFrame().removeItem(t); 2068 if (t.getText().equals("")) { 2069 DisplayController.getCurrentFrame().removeItem(t); 2070 } 1967 2071 1968 2072 if (!FreeItems.hasItemsAttachedToCursor()) { … … 2021 2125 public void refreshItemPermissions(UserAppliedPermission maxPermission) 2022 2126 { 2023 if(_frameName == null) return; 2127 if(_frameName == null) { 2128 return; 2129 } 2024 2130 2025 2131 UserAppliedPermission permission = UserAppliedPermission.min(maxPermission, getUserAppliedPermission()); … … 2057 2163 { 2058 2164 Text title = getTitleItem(); 2059 if (title == null) return false; 2165 if (title == null) { 2166 return false; 2167 } 2060 2168 String action = title.getFirstAction(); 2061 if (action == null) return false; 2169 if (action == null) { 2170 return false; 2171 } 2062 2172 action = action.toLowerCase(); 2063 2173 return action.startsWith(Simple.RUN_FRAME_ACTION) || action.startsWith(Simple.DEBUG_FRAME_ACTION); … … 2100 2210 { 2101 2211 Text backupTag = _annotations.get("old"); 2102 if (backupTag == null) return null; 2212 if (backupTag == null) { 2213 return null; 2214 } 2103 2215 2104 2216 // TODO want another way to deal with updating of annotations items … … 2114 2226 // Now return the name of the backed up frame 2115 2227 String link = backupTag.getAbsoluteLink(); 2116 if (link == null || link.equalsIgnoreCase(getName())) return null; 2228 if (link == null || link.equalsIgnoreCase(getName())) { 2229 return null; 2230 } 2117 2231 2118 2232 Frame backup = FrameIO.LoadFrame(link); … … 2197 2311 public boolean hasAnnotation(String annotation) 2198 2312 { 2199 if (_annotations == null) refreshAnnotationList(); 2313 if (_annotations == null) { 2314 refreshAnnotationList(); 2315 } 2200 2316 2201 2317 return _annotations.containsKey(annotation.toLowerCase()); … … 2212 2328 public String getAnnotationValue(String annotation) 2213 2329 { 2214 if (_annotations == null) refreshAnnotationList(); 2330 if (_annotations == null) { 2331 refreshAnnotationList(); 2332 } 2215 2333 2216 2334 Text text = _annotations.get(annotation.toLowerCase()); 2217 if (text == null) return null; 2335 if (text == null) { 2336 return null; 2337 } 2218 2338 2219 2339 String[] tokens = text.getProcessedText(); 2220 2340 2221 if (tokens != null && tokens.length > 1) return tokens[1]; 2341 if (tokens != null && tokens.length > 1) { 2342 return tokens[1]; 2343 } 2222 2344 2223 2345 return null; … … 2276 2398 2277 2399 for (Item i : _body) { 2278 if (i == null || i.dontSave()) continue; 2400 if (i == null || i.dontSave()) { 2401 continue; 2402 } 2279 2403 2280 2404 // Ensure only one of the WidgetCorners represent a single widget 2281 2405 if (i instanceof WidgetCorner) { 2282 2406 Widget iw = ((WidgetCorner) i).getWidgetSource(); 2283 if (seenWidgets.contains(iw)) continue; 2407 if (seenWidgets.contains(iw)) { 2408 continue; 2409 } 2284 2410 seenWidgets.add(iw); 2285 2411 toSave.add(iw.getSource()); … … 2354 2480 public Text getAnnotation(String annotation) 2355 2481 { 2356 if (_annotations == null) refreshAnnotationList(); 2482 if (_annotations == null) { 2483 refreshAnnotationList(); 2484 } 2357 2485 2358 2486 return _annotations.get(annotation.toLowerCase()); … … 2486 2614 * every time this method is called 2487 2615 */ 2488 if (_interactableItems.size() > 0) return _interactableItems; 2616 if (_interactableItems.size() > 0) { 2617 return _interactableItems; 2618 } 2489 2619 2490 2620 for (Item i : _body) { 2491 if (i == null) continue; 2621 if (i == null) { 2622 continue; 2623 } 2492 2624 if (i.isVisible()) { 2493 2625 _interactableItems.add(i); … … 2527 2659 } 2528 2660 2661 @Override 2529 2662 public String toString() 2530 2663 {
Note:
See TracChangeset
for help on using the changeset viewer.