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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/expeditee/items/Text.java

    r1143 r1190  
    420420        public Integer getWidth()
    421421        {
    422                 if (_maxWidth == null || _maxWidth <= 0) return null;
     422                if (_maxWidth == null || _maxWidth <= 0) {
     423                        return null;
     424                }
    423425               
    424426                return _maxWidth;
     
    435437        @Override
    436438        public Colour getHighlightColor() {
    437                 if (_highlightColour.equals(getPaintBackgroundColor()))
     439                if (_highlightColour.equals(getPaintBackgroundColor())) {
    438440                        return ALTERNATE_HIGHLIGHT;
     441                }
    439442                return _highlightColour;
    440443        }
     
    471474        public Justification getJustification()
    472475        {
    473                 if (_justification == null || _justification.equals(Justification.left)) return null;
     476                if (_justification == null || _justification.equals(Justification.left)) {
     477                        return null;
     478                }
    474479               
    475480                return _justification;
     
    487492         */
    488493        private int getJustOffset(TextLayout layout) {
    489                 if (getJustification() == Justification.center)
     494                if (getJustification() == Justification.center) {
    490495                        return (int) ((getAbsoluteWidth() - layout.getAdvance()) / 2);
    491                 else if (getJustification() == Justification.right)
     496                } else if (getJustification() == Justification.right) {
    492497                        return (int) (getAbsoluteWidth() - layout.getAdvance());
     498                }
    493499
    494500                return 0;
     
    524530
    525531        public void setTextList(List<String> text) {
    526                 if (text == null || text.size() <= 0)
     532                if (text == null || text.size() <= 0) {
    527533                        return;
     534                }
    528535
    529536                invalidateAll();
     
    535542                }
    536543
    537                 if (sb.length() > 0)
     544                if (sb.length() > 0) {
    538545                        sb.deleteCharAt(sb.length() - 1);
     546                }
    539547
    540548                setText(sb.toString());
     
    615623         */
    616624        public void appendLine(String text) {
    617                 if (text == null)
     625                if (text == null) {
    618626                        text = "";
    619 
    620                 if (_text.length() > 0)
     627                }
     628
     629                if (_text.length() > 0) {
    621630                        _text.append('\n');
     631                }
    622632
    623633                _text.append(text);
     
    638648
    639649        public boolean startsWith(String text, boolean ignoreCase) {
    640                 if (text == null || _text == null || _text.length() < 1)
     650                if (text == null || _text == null || _text.length() < 1) {
    641651                        return false;
    642 
    643                 if (ignoreCase)
     652                }
     653
     654                if (ignoreCase) {
    644655                        return _text.toString().toLowerCase().startsWith(text.toLowerCase());
    645                 else
     656                } else {
    646657                        return _text.indexOf(text) == 0;
     658                }
    647659        }
    648660
     
    658670         */
    659671        public Point insertChar(char ch, float mouseX, float mouseY) {
    660                 if (ch != '\t') /* && ch != '\n' */
     672                if (ch != '\t') {
    661673                        return insertText("" + ch, mouseX, mouseY);
     674                }
    662675
    663676                return insertText(" " + ch, mouseX, mouseY);
     
    670683        private char getNextBullet(char bullet) {
    671684                for (int i = 0; i < BULLETS.length - 1; i++) {
    672                         if (BULLETS[i] == bullet)
     685                        if (BULLETS[i] == bullet) {
    673686                                return BULLETS[i + 1];
     687                        }
    674688                }
    675689                return BULLETS[0];
     
    678692        private char getPreviousBullet(char bullet) {
    679693                for (int i = 1; i < BULLETS.length; i++) {
    680                         if (BULLETS[i] == bullet)
     694                        if (BULLETS[i] == bullet) {
    681695                                return BULLETS[i - 1];
     696                        }
    682697                }
    683698                return BULLETS[BULLETS.length - 1];
     
    702717        private Point getEdgePosition(int line, boolean start) {
    703718                // if there is no text yet, or the line is invalid
    704                 if (_text == null || _text.length() == 0 || line < 0 || line > _textLayouts.size() - 1)
     719                if (_text == null || _text.length() == 0 || line < 0 || line > _textLayouts.size() - 1) {
    705720                        return new Point(getX(), getY());
     721                }
    706722
    707723                TextLayout last = _textLayouts.get(line);
    708724                TextHitInfo hit;
    709                 if (start)
     725                if (start) {
    710726                        hit = last.getNextLeftHit(1);
    711                 else
     727                } else {
    712728                        hit = last.getNextRightHit(last.getCharacterCount() - 1);
     729                }
    713730
    714731                // move the cursor to the new location
     
    778795        {
    779796                if (_lastSelected != this) {
    780                         if (_lastSelected != null) _lastSelected.clearSelection();
     797                        if (_lastSelected != null) {
     798                                _lastSelected.clearSelection();
     799                        }
    781800                        _lastSelected = this;
    782801                }
     
    784803
    785804        public String copySelectedText() {
    786                 if (_selectionStart < 0 || _selectionEnd < 0)
     805                if (_selectionStart < 0 || _selectionEnd < 0) {
    787806                        return null;
    788                 else if (_selectionEnd > _text.length())
     807                } else if (_selectionEnd > _text.length()) {
    789808                        _selectionEnd = _text.length();
     809                }
    790810
    791811                return _text.substring(Math.min(_selectionStart, _selectionEnd), Math.max(_selectionStart, _selectionEnd));
     
    797817
    798818        public String replaceSelectedText(String newText) {
    799                 if (_selectionStart < 0 || _selectionEnd < 0)
     819                if (_selectionStart < 0 || _selectionEnd < 0) {
    800820                        return null;
    801 
    802                 invalidateAll();
    803 
    804                 if (_selectionEnd > _text.length())
     821                }
     822
     823                invalidateAll();
     824
     825                if (_selectionEnd > _text.length()) {
    805826                        _selectionEnd = _text.length();
     827                }
    806828
    807829                int left = Math.min(_selectionStart, _selectionEnd);
     
    838860
    839861        public int getSelectionSize() {
    840                 if (_selectionEnd < 0 || _selectionStart < 0)
     862                if (_selectionEnd < 0 || _selectionStart < 0) {
    841863                        return 0;
     864                }
    842865
    843866                // System.out.println(_selectionStart + ":" + _selectionEnd);
     
    873896
    874897                // check for empty string
    875                 if (text == null || text.length() == 0)
     898                if (text == null || text.length() == 0) {
    876899                        return new Point((int) mouseX, (int) mouseY);
     900                }
    877901
    878902                // if there is no text yet
     
    905929                        }
    906930
    907                         if (insertPos < 0)
     931                        if (insertPos < 0) {
    908932                                insertPos = insertionIndex;
     933                        }
    909934
    910935                        // if this is a backspace key
     
    914939                                } else if (insertPos > 0) {
    915940                                        deleteChar(insertPos - 1);
    916                                         if (insertionIndex > 0)
     941                                        if (insertionIndex > 0) {
    917942                                                insertionIndex--;
     943                                        }
    918944                                }
    919945                        // if this is a delete key
     
    931957                                        int index = 0;
    932958                                        for (index = 0; index < _text.length(); index++) {
    933                                                 if (!Character.isSpaceChar(_text.charAt(index)))
     959                                                if (!Character.isSpaceChar(_text.charAt(index))) {
    934960                                                        break;
     961                                                }
    935962                                        }
    936963                                        // Check if there is a space after the bullet
     
    944971                                                        deleteChar(0);
    945972                                                        insertionIndex--;
    946                                                 } else
     973                                                } else {
    947974                                                        break;
     975                                                }
    948976                                        }
    949977                                } else {
     
    951979                                        int index = 0;
    952980                                        for (index = 0; index < _text.length(); index++) {
    953                                                 if (!Character.isSpaceChar(_text.charAt(index)))
     981                                                if (!Character.isSpaceChar(_text.charAt(index))) {
    954982                                                        break;
     983                                                }
    955984                                        }
    956985                                        // Check if there is a space after the bullet
     
    9931022                        if (newLine == lineIndex) {
    9941023//                              System.err.println("newLine == lineIndex");
    995                                 if (insertionIndex > 0)
     1024                                if (insertionIndex > 0) {
    9961025                                        hit = current.getNextRightHit(insertionIndex - 1);
    997                                 else
     1026                                } else {
    9981027                                        hit = current.getNextLeftHit(1);
     1028                                }
    9991029                        } else if (newLine < lineIndex) {
    10001030                                hit = current.getNextRightHit(insertionIndex - 1);
     
    10851115                                // determine the line of text to check
    10861116                                line = getLinePosition(mouseY);
    1087                                 if (line < 0)
     1117                                if (line < 0) {
    10881118                                        line = _textLayouts.size() - 1;
     1119                                }
    10891120
    10901121                                // if the cursor is moving up or down, change the line
    1091                                 if (direction == UP)
     1122                                if (direction == UP) {
    10921123                                        line = Math.max(line - 1, 0);
    1093                                 else if (direction == DOWN)
     1124                                } else if (direction == DOWN) {
    10941125                                        line = Math.min(line + 1, _textLayouts.size() - 1);
     1126                                }
    10951127
    10961128                                hit = getCharPosition(line, mouseX);
     
    11041136
    11051137                                                        // Stop if at the start of the line
    1106                                                         if (hit.getInsertionIndex() == 0)
     1138                                                        if (hit.getInsertionIndex() == 0) {
    11071139                                                                break;
     1140                                                        }
    11081141                                                        // Keep going if the char to the left is a
    11091142                                                        // letterOrDigit
     
    11581191                }
    11591192               
    1160                 if (setSelection) setSelectionEnd(resultPos.getX(), resultPos.getY());
     1193                if (setSelection) {
     1194                        setSelectionEnd(resultPos.getX(), resultPos.getY());
     1195                }
    11611196               
    11621197                return resultPos;
     
    11741209         */
    11751210        public TextHitInfo getCharPosition(int line, float mouseX) {
    1176                 if (line < 0 || line >= _textLayouts.size())
     1211                if (line < 0 || line >= _textLayouts.size()) {
    11771212                        return null;
     1213                }
    11781214
    11791215                TextLayout layout = _textLayouts.get(line);
     
    12031239                        AxisAlignedBoxBounds bounds = text.getLogicalHighlightShape(0, text.getCharacterCount());
    12041240
    1205                         if (bounds.getWidth() < 1) bounds.getSize().width = 10;
     1241                        if (bounds.getWidth() < 1) {
     1242                                bounds.getSize().width = 10;
     1243                        }
    12061244
    12071245                        double x = bounds.getCentreX();
    12081246
    1209                         if (bounds.contains((int) x, (int) (mouseY - y)))
     1247                        if (bounds.contains((int) x, (int) (mouseY - y))) {
    12101248                                return _textLayouts.indexOf(text);
     1249                        }
    12111250
    12121251                        // check if the cursor is between lines
    1213                         if (mouseY - y < bounds.getMinY())
     1252                        if (mouseY - y < bounds.getMinY()) {
    12141253                                return Math.max(0, _textLayouts.indexOf(text) - 1);
     1254                        }
    12151255
    12161256                        y += getLineDrop(text);
     
    13781418         */
    13791419        public List<String> getTextList() {
    1380                 if (_text == null)
     1420                if (_text == null) {
    13811421                        return null;
     1422                }
    13821423                try {
    13831424                        List<String> list = new LinkedList<String>();
     
    13901431                        for (TextLayout layout : _textLayouts) {
    13911432                                String text = layout.getLine().replaceAll("\n", "");
    1392                                 if (!text.equals("")) list.add(text);
     1433                                if (!text.equals("")) {
     1434                                        list.add(text);
     1435                                }
    13931436                        }
    13941437
     
    14001443        }
    14011444
     1445        @Override
    14021446        public String getText() {
    14031447                return _text.toString();
     
    14101454         */
    14111455        public String getFirstLine() {
    1412                 if (_text == null || _text.length() == 0)
     1456                if (_text == null || _text.length() == 0) {
    14131457                        return null;
     1458                }
    14141459
    14151460                // start at the first non-newLine char
     
    14221467
    14231468                /* If there are no more newLines return the remaining text */
    1424                 if (nextNewLine < 0)
     1469                if (nextNewLine < 0) {
    14251470                        return _text.substring(index);
     1471                }
    14261472
    14271473                return _text.substring(index, nextNewLine);
     
    15631609                AxisAlignedBoxBounds outline = getBoundingBox();
    15641610               
    1565                 if (outline == null) return false;
     1611                if (outline == null) {
     1612                        return false;
     1613                }
    15661614
    15671615                // Check if its outside the top and left and bottom bounds
     
    15971645         * Updates the Polygon (rectangle) that surrounds this Text on the screen.
    15981646         */
     1647        @Override
    15991648        public AxisAlignedBoxBounds updateBounds()
    16001649        {
    16011650                // if there is no text, there is nothing to do
    1602                 if (_text == null) return null;
    1603 
    1604                 if (_textLayouts == null || _textLayouts.size() < 1) return null;
     1651                if (_text == null) {
     1652                        return null;
     1653                }
     1654
     1655                if (_textLayouts == null || _textLayouts.size() < 1) {
     1656                        return null;
     1657                }
    16051658
    16061659                int preChangeWidth = 0;
     
    16261679                        AxisAlignedBoxBounds bounds = layout.getLogicalHighlightShape(0, layout.getCharacterCount());
    16271680
    1628                         if (y < 0)
     1681                        if (y < 0) {
    16291682                                y = 0;
    1630                         else
     1683                        } else {
    16311684                                y += getLineDrop(layout);
    1632 
    1633                         maxX = Math.max(maxX, (int) bounds.getMaxX());
    1634                         minX = Math.min(minX, (int) bounds.getMinX());
     1685                        }
     1686
     1687                        maxX = Math.max(maxX, bounds.getMaxX());
     1688                        minX = Math.min(minX, bounds.getMinX());
    16351689                        maxY = Math.max(maxY, (int) (bounds.getMaxY() + y));
    16361690                        minY = Math.min(minY, (int) (bounds.getMinY() + y));
     
    16451699                }
    16461700
    1647                 AxisAlignedBoxBounds ret = new AxisAlignedBoxBounds(getX() + minX - getGravity(),
    1648                                                                                                                         getY() + minY - getGravity(),
    1649                                                                                                                         2 * getGravity() + maxX - minX,
    1650                                                                                                                         2 * getGravity() + maxY - minY);
     1701                final int xPos = getX() + minX - getGravity();
     1702                final int yPos = getY() + minY - getGravity();
     1703                final int width = 2 * getGravity() + maxX - minX;
     1704                final int height = 2 * getGravity() + maxY - minY;
     1705                AxisAlignedBoxBounds ret = new AxisAlignedBoxBounds(xPos, yPos, width, height);
    16511706               
    16521707                Dimension polySize = ret.getSize();
     
    16951750
    16961751                EcosystemManager.getTextLayoutManager().releaseLayouts(_textLayouts);
    1697                 if (_textLayouts != null) _textLayouts.clear();
     1752                if (_textLayouts != null) {
     1753                        _textLayouts.clear();
     1754                }
    16981755
    16991756                // Calculate the maximum allowable width of this line of text
     
    17211778                }
    17221779                }
     1780               
     1781                if (_text.toString().startsWith("Title")) {
     1782                        //System.err.println("TitleTemplate doing stuffs");
     1783                }
    17231784
    17241785                float width = Float.MAX_VALUE;
     
    17301791                        }
    17311792                }
    1732                
     1793                               
    17331794                _textLayouts = EcosystemManager.getTextLayoutManager().layoutString(_text.toString(),
    17341795                                                                                                                                        getPaintFont(),
     
    17401801                                                                                                                                        getJustification() == Justification.full);
    17411802
     1803                if (_textLayouts.size() > 1) {
     1804                        //System.err.println("Text::rebuild::" + _text.toString() + " is split up over " + _textLayouts.size() + " text layouts");
     1805                        //System.err.println(Arrays.toString(_text.toString().toCharArray()));
     1806                }
    17421807                invalidateBounds();
    17431808
     
    18071872                }
    18081873
    1809                 if (_selectionStart < 0)
     1874                if (_selectionStart < 0) {
    18101875                        _selectionStart = 0;
    1811 
    1812                 if (_selectionStart < 0 || _selectionEnd < 0)
     1876                }
     1877
     1878                if (_selectionStart < 0 || _selectionEnd < 0) {
    18131879                        return null;
     1880                }
    18141881
    18151882                int selectionLeft = Math.min(_selectionStart, _selectionEnd);
     
    18171884
    18181885                // if the selection is after this line, return null
    1819                 if (_textLayouts.get(line).getStartCharIndex() > selectionRight) return null;
     1886                if (_textLayouts.get(line).getStartCharIndex() > selectionRight) {
     1887                        return null;
     1888                }
    18201889
    18211890                // if the selection is before this line, return null
    1822                 if (_textLayouts.get(line).getEndCharIndex() < selectionLeft) return null;
     1891                if (_textLayouts.get(line).getEndCharIndex() < selectionLeft) {
     1892                        return null;
     1893                }
    18231894
    18241895                // Dont highlight a single char
     
    18411912        public void setSelectionColour(Colour colour)
    18421913        {
    1843                 if (colour == null) colour = RANGE_SELECT_COLOUR;
     1914                if (colour == null) {
     1915                        colour = RANGE_SELECT_COLOUR;
     1916                }
    18441917               
    18451918                _selectionColour = colour;
     
    18551928        public void paint()
    18561929        {
    1857                 if (!isVisible()) return;
     1930                if (!isVisible()) {
     1931                        return;
     1932                }
    18581933
    18591934                // if there is no text to paint, do nothing.
    1860                 if (_text == null || _text.length() == 0) return;
     1935                if (_text == null || _text.length() == 0) {
     1936                        return;
     1937                }
    18611938
    18621939                if (_autoWrap || ExperimentalFeatures.AutoWrap.get()) {
     
    19171994
    19181995                if (isHighlighted()) {
    1919                         Stroke highlightStroke = new Stroke((float) getHighlightThickness(), DEFAULT_CAP, DEFAULT_JOIN);
     1996                        Stroke highlightStroke = new Stroke(getHighlightThickness(), DEFAULT_CAP, DEFAULT_JOIN);
    19201997                        Fill fill;
    19211998                        if (HighlightMode.Enclosed.equals(getHighlightMode())) {
     
    20272104                // size *= UserSettings.ScaleFactor;
    20282105                // Dont want to have size set when duplicating a point which has size 0
    2029                 if (size < 0)
     2106                if (size < 0) {
    20302107                        return;
    2031 
    2032                 if (size < MINIMUM_FONT_SIZE)
     2108                }
     2109
     2110                if (size < MINIMUM_FONT_SIZE) {
    20332111                        size = MINIMUM_FONT_SIZE;
     2112                }
    20342113                Font currentFont = getPaintFont();
    20352114                currentFont.setSize((int) size);
     
    20462125                if (val) {
    20472126                        // if this is already an annotation, do nothing
    2048                         if (isAnnotation())
     2127                        if (isAnnotation()) {
    20492128                                return;
     2129                        }
    20502130                        if (!isLineEnd() && _text.length() > 0 && _text.charAt(0) == DEFAULT_BULLET) {
    20512131                                newPoint.set(insertText("\b", mouseX, mouseY, 1));
    2052                                 if (_text.length() > 0 && _text.charAt(0) == ' ')
     2132                                if (_text.length() > 0 && _text.charAt(0) == ' ') {
    20532133                                        newPoint.set(insertText("\b", newPoint.getX(), newPoint.getY(), 1));
     2134                                }
    20542135                        } else {
    20552136                                newPoint.set(insertText("@", mouseX, mouseY, 0));
     
    20572138                } else {
    20582139                        // if this is not an annotation, do nothing
    2059                         if (!isAnnotation())
     2140                        if (!isAnnotation()) {
    20602141                                return;
     2142                        }
    20612143                        if (!isLineEnd() && _text.charAt(0) == '@') {
    20622144                                newPoint.set(insertText("\b", mouseX, mouseY, 1));
     
    20982180        @Override
    20992181        public boolean isAnnotation() {
    2100                 if (_text != null && _text.length() > 0 && _text.charAt(0) == '@')
     2182                if (_text != null && _text.length() > 0 && _text.charAt(0) == '@') {
    21012183                        return true;
     2184                }
    21022185
    21032186                return false;
     
    21102193                        if (s.equals("@old") || s.equals("@ao") || s.equals("@itemtemplate") || s.equals("@parent")
    21112194                                        || s.equals("@next") || s.equals("@previous") || s.equals("@first") || s.equals("@i")
    2112                                         || s.equals("@iw") || s.equals("@f"))
     2195                                        || s.equals("@iw") || s.equals("@f")) {
    21132196                                return true;
     2197                        }
    21142198                }
    21152199
     
    21212205                if (merger.isLineEnd()) {
    21222206                        // Merging line ends onto non line end text is a no-op
    2123                         if (!isLineEnd())
     2207                        if (!isLineEnd()) {
    21242208                                return null;
    2125 
    2126                         if (merger instanceof Text)
     2209                        }
     2210
     2211                        if (merger instanceof Text) {
    21272212                                insertText(((Text) merger).getText(), mouseX, mouseY);
     2213                        }
    21282214
    21292215                        // Set the position by moving the cursor before calling this
     
    21402226                }
    21412227
    2142                 if (!(merger instanceof Text))
     2228                if (!(merger instanceof Text)) {
    21432229                        return merger;
     2230                }
    21442231
    21452232                Text merge = (Text) merger;
     
    21562243                                // TODO get this to return the merged item and attach it to the
    21572244                                // cursor only when the user presses the middle button.
    2158                         } else
     2245                        } else {
    21592246                                setLink(merge.getLink());
     2247                        }
    21602248                }
    21612249
     
    21682256         */
    21692257        public void resetTitlePosition() {
    2170                 setPosition(MARGIN_LEFT, MARGIN_LEFT + getBoundsHeight());
     2258                final int boundsHeight = getBoundsHeight();
     2259                setPosition(MARGIN_LEFT, MARGIN_LEFT + boundsHeight);
    21712260                Frame modelFrame = getParentOrCurrentFrame();
    21722261                if (modelFrame != null) {
     
    21992288        }
    22002289
     2290        @Override
    22012291        public String toString() {
    22022292                String message = "[" + getFirstLine() + "]" + FRAME_NAME_SEPARATOR;
    22032293
    2204                 if (getParent() != null)
     2294                if (getParent() != null) {
    22052295                        return message + getParent().getName();
     2296                }
    22062297                return message + getDateCreated();
    22072298        }
     
    22622353                clearSelection();
    22632354                setAlpha(0);
    2264                 if (isLineEnd())
     2355                if (isLineEnd()) {
    22652356                        DisplayController.setCursor(Item.DEFAULT_CURSOR);
     2357                }
    22662358
    22672359                String text = _text.toString().trim();
     
    22832375                        if (!_text.toString().contains(" ")) {
    22842376                                Integer width = getWidth();
    2285                                 if (width == null || width < 0)
     2377                                if (width == null || width < 0) {
    22862378                                        setWidth(Integer.MIN_VALUE + 1);
     2379                                }
    22872380                        } else if (frameWidth - getX() > ADJUST_WIDTH_THRESHOLD) {
    22882381                                justify(false);
     
    22942387        public void justify(boolean fixWidth, PolygonBounds enclosure) {
    22952388                // if autowrap is on, wrapping is done every time we draw
    2296                 if(ExperimentalFeatures.AutoWrap.get()) return;
     2389                if(ExperimentalFeatures.AutoWrap.get()) {
     2390                        return;
     2391                }
    22972392
    22982393                Integer width = DisplayController.getFramePaintArea().getWidth();
     
    23072402                }
    23082403
    2309                 if (getWidth() == null) setRightMargin(width, fixWidth);
     2404                if (getWidth() == null) {
     2405                        setRightMargin(width, fixWidth);
     2406                }
    23102407
    23112408                // Check for the annotation that restricts the width of text items on the frame
     
    23152412                                int oldWidth = getWidth();
    23162413                                int maxWidth = Integer.parseInt(widthString);
    2317                                 if (maxWidth < oldWidth)
     2414                                if (maxWidth < oldWidth) {
    23182415                                        setWidth(maxWidth);
     2416                                }
    23192417                        } catch (NumberFormatException nfe) {
    23202418                        }
     
    23252423        public void justify(boolean fixWidth) {
    23262424                // if autowrap is on, wrapping is done every time we draw
    2327                 if(ExperimentalFeatures.AutoWrap.get()) return;
     2425                if(ExperimentalFeatures.AutoWrap.get()) {
     2426                        return;
     2427                }
    23282428
    23292429                this.justify(fixWidth, FrameUtils.getEnlosingPolygon());
     
    23402440        @Override
    23412441        protected int getLinkYOffset() {
    2342                 if (_textLayouts.size() == 0)
     2442                if (_textLayouts.size() == 0) {
    23432443                        return 0;
     2444                }
    23442445                return Math.round(-(_textLayouts.get(0).getAscent() / 2));
    23452446        }
     
    23632464        public static boolean isBulletChar(char c) {
    23642465                for (int i = 0; i < BULLETS.length; i++) {
    2365                         if (BULLETS[i] == c)
     2466                        if (BULLETS[i] == c) {
    23662467                                return true;
     2468                        }
    23672469                }
    23682470                return c == '*' || c == '+' || c == '>' || c == '-' || c == 'o';
    23692471        }
    23702472
     2473        @Override
    23712474        public boolean hasOverlay() {
    2372                 if (!isAnnotation() || getLink() == null)
     2475                if (!isAnnotation() || getLink() == null) {
    23732476                        return false;
     2477                }
    23742478                String text = getText().toLowerCase();
    23752479                // TODO make it so can just check the _overlay variable
    23762480                // Mike can't remember the reason _overlay var can't be use! oops
    2377                 if (!text.startsWith("@"))
     2481                if (!text.startsWith("@")) {
    23782482                        return false;
     2483                }
    23792484                return text.startsWith("@o") || text.startsWith("@ao") || text.startsWith("@v") || text.startsWith("@av");
    23802485        }
     
    23962501        @Override
    23972502        public boolean calculate(String formula) {
    2398                 if (DisplayController.isXRayMode())
     2503                if (DisplayController.isXRayMode()) {
    23992504                        return false;
     2505                }
    24002506
    24012507                super.calculate(formula);
     
    24142520                Collection<Item> enclosed = getItemsInSameEnclosure();
    24152521                for (Item i : enclosed) {
    2416                         if (i == this)
     2522                        if (i == this) {
    24172523                                continue;
     2524                        }
    24182525                        if (i instanceof Text && !i.isAnnotation()) {
    24192526                                AttributeValuePair pair = i.getAttributeValuePair();
     
    24322539                                try {
    24332540                                        double value = pair.getDoubleValue();
    2434                                         if (value != Double.NaN)
     2541                                        if (value != Double.NaN) {
    24352542                                                myParser.addVariable("$" + nextVarNo++, value);
     2543                                        }
    24362544                                } catch (NumberFormatException nfe) {
    24372545                                        continue;
     
    25162624                }
    25172625
    2518                 if (sameEnclosure == null)
     2626                if (sameEnclosure == null) {
    25192627                        return new LinkedList<Item>();
     2628                }
    25202629
    25212630                return sameEnclosure;
     
    25262635         * item is modified
    25272636         */
     2637        @Override
    25282638        public boolean recalculateWhenChanged() {
    25292639                if (/*
    25302640                         * !isAnnotation() &&
    2531                          */(hasFormula() || isLineEnd()))
     2641                         */(hasFormula() || isLineEnd())) {
    25322642                        return true;
     2643                }
    25332644                try {
    25342645                        AttributeValuePair avp = getAttributeValuePair();
    25352646
    2536                         if (!avp.getDoubleValue().equals(Double.NaN))
     2647                        if (!avp.getDoubleValue().equals(Double.NaN)) {
    25372648                                return true;
     2649                        }
    25382650                } catch (Exception e) {
    25392651                        e.printStackTrace();
     
    26932805                                final AxisAlignedBoxBounds r = getPixelBounds(_textLayouts.get(i));
    26942806                                cumulativeHeight += _textLayouts.get(i).getDescent() + _textLayouts.get(i).getAscent();
    2695                                 if (r.getSize().width > maxWidth)
     2807                                if (r.getSize().width > maxWidth) {
    26962808                                        maxWidth = r.getSize().width;
     2809                                }
    26972810                        }
    26982811                }
     
    29113024                                // add the date to the text item
    29123025                                textItem.prependText(dateToAdd);
    2913                                 if (dateToAdd.length() == textItem.getLength())
     3026                                if (dateToAdd.length() == textItem.getLength()) {
    29143027                                        DisplayController.setCursorPosition(textItem.getParagraphEndPosition());
     3028                                }
    29153029                        } else if (append) {
    29163030                                textItem.appendText(dateToAdd);
    2917                                 if (dateToAdd.length() == textItem.getLength())
     3031                                if (dateToAdd.length() == textItem.getLength()) {
    29183032                                        DisplayController.setCursorPosition(textItem.getPosition());
     3033                                }
    29193034                        } else {
    29203035                                for (int i = 0; i < date1.length(); i++) {
Note: See TracChangeset for help on using the changeset viewer.