Ignore:
Timestamp:
10/02/18 10:24:16 (6 years ago)
Author:
bln4
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/gui/Frame.java

    r1144 r1181  
    3636import org.expeditee.core.bounds.PolygonBounds;
    3737import org.expeditee.gio.gesture.StandardGestureActions;
     38import org.expeditee.gio.input.KBMInputEvent.Key;
    3839import org.expeditee.gio.input.StandardInputEventListeners;
    39 import org.expeditee.gio.input.KBMInputEvent.Key;
    4040import org.expeditee.io.Conversion;
    4141import org.expeditee.items.Constraint;
     
    192192                _dotTemplate.setFillColor(ColorUtils.getNextColor(_dotTemplate.getFillColor(), TemplateSettings.FillColorWheel.get(), null));
    193193                _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                }
    195197        }
    196198
     
    207209        public boolean isBufferValid()
    208210        {
    209                 if (_buffer == null) return false;
     211                if (_buffer == null) {
     212                        return false;
     213                }
    210214
    211215                return _validBuffer;
     
    253257        {
    254258                // virtual frames are never saved
    255                 if (_number == VIRTUAL_FRAME_NUMBER) return false;
     259                if (_number == VIRTUAL_FRAME_NUMBER) {
     260                        return false;
     261                }
    256262
    257263                return _change;
     
    266272        public void setChanged(boolean value)
    267273        {
    268                 if (_change == value) return;
     274                if (_change == value) {
     275                        return;
     276                }
    269277
    270278                _change = value;
     
    285293        public void notifyObservers(boolean bRecalculate)
    286294        {
    287                 if (bRecalculate) recalculate();
     295                if (bRecalculate) {
     296                        recalculate();
     297                }
    288298                // Notify the frame listeners that the frame has changed
    289299                /*
     
    297307
    298308                for (FrameObserver fl : observersCopy) {
    299                         if (fl.isVisible()) fl.update();
     309                        if (fl.isVisible()) {
     310                                fl.update();
     311                        }
    300312                }
    301313        }
     
    331343
    332344                for (Item i : _body) {
    333                         if (i == null) continue;
     345                        if (i == null) {
     346                                continue;
     347                        }
    334348                       
    335349                        if (i.isVisible() || (!visible && !i.isDeleted())) {
     
    354368        public boolean containsItem(Item i)
    355369        {
    356                 if (i == null) throw new NullPointerException("i");
     370                if (i == null) {
     371                        throw new NullPointerException("i");
     372                }
    357373               
    358374                return _body.contains(i);
     
    392408                for (Item i : getItems(true)) {
    393409                        // only add up normal body text items
    394                         if (!i.isAnnotation()) items.add(i);
     410                        if (!i.isAnnotation()) {
     411                                items.add(i);
     412                        }
    395413                }
    396414               
     
    417435
    418436                        if (it instanceof Text && !it.isAnnotation()) {
    419                                 return (Item) it;
     437                                return it;
    420438                        }
    421439                }
     
    450468        public void setTitle(String title)
    451469        {
    452                 if (title == null || title.equals("")) return;
     470                if (title == null || title.equals("")) {
     471                        return;
     472                }
    453473
    454474                boolean oldchange = _change;
     
    481501                        // If the @ symbol is followed by numbering or a bullet remove that too
    482502                        String autoBulletText = StandardGestureActions.getAutoBullet(title);
    483                         if (autoBulletText.length() > 0)
     503                        if (autoBulletText.length() > 0) {
    484504                                frameTitle.stripFirstWord();
     505                        }
    485506                }
    486507                // TODO Widgets... check this out
     
    513534        {
    514535                Text title = getTitleItem();
    515                 if (title == null) return getName();
     536                if (title == null) {
     537                        return getName();
     538                }
    516539
    517540                return title.getFirstLine();
     
    659682                assert (number >= 0);
    660683
    661                 if (_number == number) return;
     684                if (_number == number) {
     685                        return;
     686                }
    662687
    663688                _number = number;
     
    714739                _permissionPair = new PermissionPair(permission);
    715740
    716                 if (_body.size() > 0) refreshItemPermissions(permission.getPermission(_owner));
     741                if (_body.size() > 0) {
     742                        refreshItemPermissions(permission.getPermission(_owner));
     743                }
    717744        }
    718745
     
    811838        public void addItem(Item item, boolean recalculate)
    812839        {
    813                 if (item == null || item.equals(_frameName) || _body.contains(item)) return;
     840                if (item == null || item.equals(_frameName) || _body.contains(item)) {
     841                        return;
     842                }
    814843
    815844                // When an annotation item is anchored the annotation list must be
     
    819848                }
    820849
    821                 if (item instanceof Line) _lineCount++;
     850                if (item instanceof Line) {
     851                        _lineCount++;
     852                }
    822853
    823854                _itemCount = Math.max(_itemCount, item.getID());
     
    914945                for (Item i : toAdd) {
    915946                        // 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                        }
    917950                        // TODO Improve efficiency when addAll is called
    918951                        addItem(i);
     
    924957                for (Item i : toRemove) {
    925958                        // 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                        }
    927962                        removeItem(i);
    928963                }
     
    937972        {
    938973                // 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                }
    940977
    941978                if (_body.remove(item)) {
     
    9661003        private void addToUndo(Collection<Item> items, History.Type type)
    9671004        {
    968                 if (items.size() < 1) return;
     1005                if (items.size() < 1) {
     1006                        return;
     1007                }
    9691008
    9701009                _undo.push(new History(items, type));
     
    9861025                boolean bRecalculate = false;
    9871026
    988                 if (_undo.size() <= 0) return;
     1027                if (_undo.size() <= 0) {
     1028                        return;
     1029                }
    9891030
    9901031                History undo = _undo.pop();
     
    10441085                boolean bRecalculate = false;
    10451086
    1046                 if (_redo.size() <= 0) return;
     1087                if (_redo.size() <= 0) {
     1088                        return;
     1089                }
    10471090
    10481091                History redo = _redo.pop();
     
    11341177        public UserAppliedPermission getUserAppliedPermission(UserAppliedPermission defaultPermission)
    11351178        {
    1136                 if (_permissionPair == null) return defaultPermission;
     1179                if (_permissionPair == null) {
     1180                        return defaultPermission;
     1181                }
    11371182
    11381183                return _permissionPair.getPermission(_owner);
     
    12241269        }
    12251270
     1271        @Override
    12261272        public String toString()
    12271273        {
     
    12531299
    12541300                int ind = toCheck.indexOf(current);
    1255                 if (ind == -1) return null;
     1301                if (ind == -1) {
     1302                        return null;
     1303                }
    12561304
    12571305                // loop through all items above this one, return the first match
    12581306                for (int i = ind - 1; i >= 0; i--) {
    12591307                        Text check = toCheck.get(i);
    1260                         if (FrameUtils.inSameColumn(check, current)) return check;
     1308                        if (FrameUtils.inSameColumn(check, current)) {
     1309                                return check;
     1310                        }
    12611311                }
    12621312
     
    12741324        {
    12751325                // 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                }
    12771329
    12781330                if (from == null) {
     
    12801332                }
    12811333
    1282                 if (from == null) return null;
     1334                if (from == null) {
     1335                        return null;
     1336                }
    12831337
    12841338                // Get the enclosedItems
     
    13041358
    13051359                        // If its the title index will be 0
    1306                         if (index < 0) index = 0;
     1360                        if (index < 0) {
     1361                                index = 0;
     1362                        }
    13071363
    13081364                        for (int i = index; i < toCheck.size(); i++) {
    13091365                                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                                }
    13111369                        }
    13121370                }
     
    13281386        {
    13291387                // 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                }
    13311391               
    13321392                _vectors.add(toAdd);
     
    13381398               
    13391399                HighlightMode mode = toAdd.Source.getHighlightMode();
    1340                 if (mode != HighlightMode.None) mode = HighlightMode.Connected;
     1400                if (mode != HighlightMode.None) {
     1401                        mode = HighlightMode.Connected;
     1402                }
    13411403               
    13421404                Colour highlightColor = toAdd.Source.getHighlightColor();
     
    13521414                        // Get the right most x and bottom most y pos
    13531415                        int itemRight = i.getX() + i.getBoundsWidth();
    1354                         if (itemRight > maxX) maxX = itemRight;
     1416                        if (itemRight > maxX) {
     1417                                maxX = itemRight;
     1418                        }
    13551419                       
    13561420                        int itemBottom = i.getY() + i.getBoundsHeight();
    1357                         if (itemBottom > maxY) maxY = itemBottom;
     1421                        if (itemBottom > maxY) {
     1422                                maxY = itemBottom;
     1423                        }
    13581424                }
    13591425               
     
    13871453        private boolean getVectorsDeep(List<Vector> vectors, Frame vector, List<Frame> seenVectors)
    13881454        {
    1389                 if (seenVectors.contains(vector)) return false;
     1455                if (seenVectors.contains(vector)) {
     1456                        return false;
     1457                }
    13901458
    13911459                seenVectors.add(vector);
     
    14111479        private boolean getOverlaysDeep(List<Overlay> overlays, List<Frame> seenOverlays)
    14121480        {
    1413                 if (seenOverlays.contains(this)) return false;
     1481                if (seenOverlays.contains(this)) {
     1482                        return false;
     1483                }
    14141484               
    14151485                seenOverlays.add(this);
     
    14381508                List<Widget> widgets = new LinkedList<Widget>();
    14391509               
    1440                 for (Overlay o : getOverlaysDeep()) widgets.addAll(o.Frame.getInteractiveWidgets());
     1510                for (Overlay o : getOverlaysDeep()) {
     1511                        widgets.addAll(o.Frame.getInteractiveWidgets());
     1512                }
    14411513               
    14421514                return widgets;
     
    14531525        public Overlay getOverlayOwner(Item item)
    14541526        {
    1455                 if (item == null) throw new NullPointerException("item");
     1527                if (item == null) {
     1528                        throw new NullPointerException("item");
     1529                }
    14561530
    14571531                for (Overlay l : getOverlays()) {
    1458                         if (item.getParent() == l.Frame) return l;
     1532                        if (item.getParent() == l.Frame) {
     1533                                return l;
     1534                        }
    14591535                }
    14601536
     
    14621538                // the vector frame
    14631539                for (Vector v : getVectors()) {
    1464                         if (item.getParent() == v.Frame) return v;
     1540                        if (item.getParent() == v.Frame) {
     1541                                return v;
     1542                        }
    14651543                }
    14661544
     
    14821560        protected boolean removeVector(Vector toRemove)
    14831561        {
    1484                 if (!_vectors.remove(toRemove)) return false;
     1562                if (!_vectors.remove(toRemove)) {
     1563                        return false;
     1564                }
    14851565               
    14861566                for (Item i : toRemove.Frame.getVectorItems()) {
     
    15501630        {
    15511631                // 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                }
    15531635               
    15541636                // 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                }
    15561640               
    15571641                // Add the overlay to the map of overlays on this frame
     
    15601644                // Add all the overlays from the overlay frame to this frame
    15611645                // 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                }
    15631649
    15641650                // 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                }
    15661654
    15671655                // Now add the items for this overlay
     
    15991687        private void merge(Frame toMergeWith)
    16001688        {
    1601                 if (toMergeWith == null) return;
     1689                if (toMergeWith == null) {
     1690                        return;
     1691                }
    16021692
    16031693                List<Item> copies = ItemUtils.CopyItems(toMergeWith.getItems());
     
    16581748                if (keepAnnotations) {
    16591749                        for (Item i : _body) {
    1660                                 if (i.isAnnotation()) newBody.add(i);
     1750                                if (i.isAnnotation()) {
     1751                                        newBody.add(i);
     1752                                }
    16611753                        }
    16621754                }
     
    16671759                change();
    16681760
    1669                 if (!keepAnnotations && _annotations != null) _annotations.clear();
     1761                if (!keepAnnotations && _annotations != null) {
     1762                        _annotations.clear();
     1763                }
    16701764        }
    16711765
     
    17321826                Item template = getTemplate(_dotTemplate, ItemUtils.TAG_DOT_TEMPLATE);
    17331827                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                }
    17361834                dot.setColor(template.getColor());
    17371835                dot.setFillColor(template.getFillColor());
     
    17541852
    17551853                if (t == null) {
    1756                         if (defaultTemplate == null) return null;
     1854                        if (defaultTemplate == null) {
     1855                                return null;
     1856                        }
    17571857                       
    17581858                        t = defaultTemplate;
     
    19322032                for (int i = 0; i < items.size(); i++) {
    19332033                        Item it = items.get(i);
    1934                         if (isNormalTextItem(it)) itemsFound++;
     2034                        if (isNormalTextItem(it)) {
     2035                                itemsFound++;
     2036                        }
    19352037                        if (itemsFound > index) {
    19362038                                DisplayController.setCursorPosition(((Text) it).getParagraphEndPosition().getX(), it.getY());
     
    19642066                                        t.setText("");
    19652067
    1966                                         if (t.getText().equals("")) DisplayController.getCurrentFrame().removeItem(t);
     2068                                        if (t.getText().equals("")) {
     2069                                                DisplayController.getCurrentFrame().removeItem(t);
     2070                                        }
    19672071                                       
    19682072                                        if (!FreeItems.hasItemsAttachedToCursor()) {
     
    20212125        public void refreshItemPermissions(UserAppliedPermission maxPermission)
    20222126        {
    2023                 if(_frameName == null) return;
     2127                if(_frameName == null) {
     2128                        return;
     2129                }
    20242130               
    20252131                UserAppliedPermission permission = UserAppliedPermission.min(maxPermission, getUserAppliedPermission());
     
    20572163        {
    20582164                Text title = getTitleItem();
    2059                 if (title == null) return false;
     2165                if (title == null) {
     2166                        return false;
     2167                }
    20602168                String action = title.getFirstAction();
    2061                 if (action == null) return false;
     2169                if (action == null) {
     2170                        return false;
     2171                }
    20622172                action = action.toLowerCase();
    20632173                return action.startsWith(Simple.RUN_FRAME_ACTION) || action.startsWith(Simple.DEBUG_FRAME_ACTION);
     
    21002210        {
    21012211                Text backupTag = _annotations.get("old");
    2102                 if (backupTag == null) return null;
     2212                if (backupTag == null) {
     2213                        return null;
     2214                }
    21032215               
    21042216                // TODO want another way to deal with updating of annotations items
     
    21142226                // Now return the name of the backed up frame
    21152227                String link = backupTag.getAbsoluteLink();
    2116                 if (link == null || link.equalsIgnoreCase(getName())) return null;
     2228                if (link == null || link.equalsIgnoreCase(getName())) {
     2229                        return null;
     2230                }
    21172231
    21182232                Frame backup = FrameIO.LoadFrame(link);
     
    21972311        public boolean hasAnnotation(String annotation)
    21982312        {
    2199                 if (_annotations == null) refreshAnnotationList();
     2313                if (_annotations == null) {
     2314                        refreshAnnotationList();
     2315                }
    22002316               
    22012317                return _annotations.containsKey(annotation.toLowerCase());
     
    22122328        public String getAnnotationValue(String annotation)
    22132329        {
    2214                 if (_annotations == null) refreshAnnotationList();
     2330                if (_annotations == null) {
     2331                        refreshAnnotationList();
     2332                }
    22152333
    22162334                Text text = _annotations.get(annotation.toLowerCase());
    2217                 if (text == null) return null;
     2335                if (text == null) {
     2336                        return null;
     2337                }
    22182338
    22192339                String[] tokens = text.getProcessedText();
    22202340               
    2221                 if (tokens != null && tokens.length > 1) return tokens[1];
     2341                if (tokens != null && tokens.length > 1) {
     2342                        return tokens[1];
     2343                }
    22222344               
    22232345                return null;
     
    22762398
    22772399                for (Item i : _body) {
    2278                         if (i == null || i.dontSave()) continue;
     2400                        if (i == null || i.dontSave()) {
     2401                                continue;
     2402                        }
    22792403
    22802404                        // Ensure only one of the WidgetCorners represent a single widget
    22812405                        if (i instanceof WidgetCorner) {
    22822406                                Widget iw = ((WidgetCorner) i).getWidgetSource();
    2283                                 if (seenWidgets.contains(iw)) continue;
     2407                                if (seenWidgets.contains(iw)) {
     2408                                        continue;
     2409                                }
    22842410                                seenWidgets.add(iw);
    22852411                                toSave.add(iw.getSource());
     
    23542480        public Text getAnnotation(String annotation)
    23552481        {
    2356                 if (_annotations == null) refreshAnnotationList();
     2482                if (_annotations == null) {
     2483                        refreshAnnotationList();
     2484                }
    23572485
    23582486                return _annotations.get(annotation.toLowerCase());
     
    24862614                 * every time this method is called
    24872615                 */
    2488                 if (_interactableItems.size() > 0) return _interactableItems;
     2616                if (_interactableItems.size() > 0) {
     2617                        return _interactableItems;
     2618                }
    24892619
    24902620                for (Item i : _body) {
    2491                         if (i == null) continue;
     2621                        if (i == null) {
     2622                                continue;
     2623                        }
    24922624                        if (i.isVisible()) {
    24932625                                _interactableItems.add(i);
     
    25272659                }
    25282660               
     2661                @Override
    25292662                public String toString()
    25302663                {
Note: See TracChangeset for help on using the changeset viewer.