Changeset 1190 for trunk/src/org/expeditee/items/Text.java
- Timestamp:
- 10/31/18 10:24:23 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/Text.java
r1143 r1190 420 420 public Integer getWidth() 421 421 { 422 if (_maxWidth == null || _maxWidth <= 0) return null; 422 if (_maxWidth == null || _maxWidth <= 0) { 423 return null; 424 } 423 425 424 426 return _maxWidth; … … 435 437 @Override 436 438 public Colour getHighlightColor() { 437 if (_highlightColour.equals(getPaintBackgroundColor())) 439 if (_highlightColour.equals(getPaintBackgroundColor())) { 438 440 return ALTERNATE_HIGHLIGHT; 441 } 439 442 return _highlightColour; 440 443 } … … 471 474 public Justification getJustification() 472 475 { 473 if (_justification == null || _justification.equals(Justification.left)) return null; 476 if (_justification == null || _justification.equals(Justification.left)) { 477 return null; 478 } 474 479 475 480 return _justification; … … 487 492 */ 488 493 private int getJustOffset(TextLayout layout) { 489 if (getJustification() == Justification.center) 494 if (getJustification() == Justification.center) { 490 495 return (int) ((getAbsoluteWidth() - layout.getAdvance()) / 2); 491 else if (getJustification() == Justification.right)496 } else if (getJustification() == Justification.right) { 492 497 return (int) (getAbsoluteWidth() - layout.getAdvance()); 498 } 493 499 494 500 return 0; … … 524 530 525 531 public void setTextList(List<String> text) { 526 if (text == null || text.size() <= 0) 532 if (text == null || text.size() <= 0) { 527 533 return; 534 } 528 535 529 536 invalidateAll(); … … 535 542 } 536 543 537 if (sb.length() > 0) 544 if (sb.length() > 0) { 538 545 sb.deleteCharAt(sb.length() - 1); 546 } 539 547 540 548 setText(sb.toString()); … … 615 623 */ 616 624 public void appendLine(String text) { 617 if (text == null) 625 if (text == null) { 618 626 text = ""; 619 620 if (_text.length() > 0) 627 } 628 629 if (_text.length() > 0) { 621 630 _text.append('\n'); 631 } 622 632 623 633 _text.append(text); … … 638 648 639 649 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) { 641 651 return false; 642 643 if (ignoreCase) 652 } 653 654 if (ignoreCase) { 644 655 return _text.toString().toLowerCase().startsWith(text.toLowerCase()); 645 else656 } else { 646 657 return _text.indexOf(text) == 0; 658 } 647 659 } 648 660 … … 658 670 */ 659 671 public Point insertChar(char ch, float mouseX, float mouseY) { 660 if (ch != '\t') /* && ch != '\n' */672 if (ch != '\t') { 661 673 return insertText("" + ch, mouseX, mouseY); 674 } 662 675 663 676 return insertText(" " + ch, mouseX, mouseY); … … 670 683 private char getNextBullet(char bullet) { 671 684 for (int i = 0; i < BULLETS.length - 1; i++) { 672 if (BULLETS[i] == bullet) 685 if (BULLETS[i] == bullet) { 673 686 return BULLETS[i + 1]; 687 } 674 688 } 675 689 return BULLETS[0]; … … 678 692 private char getPreviousBullet(char bullet) { 679 693 for (int i = 1; i < BULLETS.length; i++) { 680 if (BULLETS[i] == bullet) 694 if (BULLETS[i] == bullet) { 681 695 return BULLETS[i - 1]; 696 } 682 697 } 683 698 return BULLETS[BULLETS.length - 1]; … … 702 717 private Point getEdgePosition(int line, boolean start) { 703 718 // 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) { 705 720 return new Point(getX(), getY()); 721 } 706 722 707 723 TextLayout last = _textLayouts.get(line); 708 724 TextHitInfo hit; 709 if (start) 725 if (start) { 710 726 hit = last.getNextLeftHit(1); 711 else727 } else { 712 728 hit = last.getNextRightHit(last.getCharacterCount() - 1); 729 } 713 730 714 731 // move the cursor to the new location … … 778 795 { 779 796 if (_lastSelected != this) { 780 if (_lastSelected != null) _lastSelected.clearSelection(); 797 if (_lastSelected != null) { 798 _lastSelected.clearSelection(); 799 } 781 800 _lastSelected = this; 782 801 } … … 784 803 785 804 public String copySelectedText() { 786 if (_selectionStart < 0 || _selectionEnd < 0) 805 if (_selectionStart < 0 || _selectionEnd < 0) { 787 806 return null; 788 else if (_selectionEnd > _text.length())807 } else if (_selectionEnd > _text.length()) { 789 808 _selectionEnd = _text.length(); 809 } 790 810 791 811 return _text.substring(Math.min(_selectionStart, _selectionEnd), Math.max(_selectionStart, _selectionEnd)); … … 797 817 798 818 public String replaceSelectedText(String newText) { 799 if (_selectionStart < 0 || _selectionEnd < 0) 819 if (_selectionStart < 0 || _selectionEnd < 0) { 800 820 return null; 801 802 invalidateAll(); 803 804 if (_selectionEnd > _text.length()) 821 } 822 823 invalidateAll(); 824 825 if (_selectionEnd > _text.length()) { 805 826 _selectionEnd = _text.length(); 827 } 806 828 807 829 int left = Math.min(_selectionStart, _selectionEnd); … … 838 860 839 861 public int getSelectionSize() { 840 if (_selectionEnd < 0 || _selectionStart < 0) 862 if (_selectionEnd < 0 || _selectionStart < 0) { 841 863 return 0; 864 } 842 865 843 866 // System.out.println(_selectionStart + ":" + _selectionEnd); … … 873 896 874 897 // check for empty string 875 if (text == null || text.length() == 0) 898 if (text == null || text.length() == 0) { 876 899 return new Point((int) mouseX, (int) mouseY); 900 } 877 901 878 902 // if there is no text yet … … 905 929 } 906 930 907 if (insertPos < 0) 931 if (insertPos < 0) { 908 932 insertPos = insertionIndex; 933 } 909 934 910 935 // if this is a backspace key … … 914 939 } else if (insertPos > 0) { 915 940 deleteChar(insertPos - 1); 916 if (insertionIndex > 0) 941 if (insertionIndex > 0) { 917 942 insertionIndex--; 943 } 918 944 } 919 945 // if this is a delete key … … 931 957 int index = 0; 932 958 for (index = 0; index < _text.length(); index++) { 933 if (!Character.isSpaceChar(_text.charAt(index))) 959 if (!Character.isSpaceChar(_text.charAt(index))) { 934 960 break; 961 } 935 962 } 936 963 // Check if there is a space after the bullet … … 944 971 deleteChar(0); 945 972 insertionIndex--; 946 } else 973 } else { 947 974 break; 975 } 948 976 } 949 977 } else { … … 951 979 int index = 0; 952 980 for (index = 0; index < _text.length(); index++) { 953 if (!Character.isSpaceChar(_text.charAt(index))) 981 if (!Character.isSpaceChar(_text.charAt(index))) { 954 982 break; 983 } 955 984 } 956 985 // Check if there is a space after the bullet … … 993 1022 if (newLine == lineIndex) { 994 1023 // System.err.println("newLine == lineIndex"); 995 if (insertionIndex > 0) 1024 if (insertionIndex > 0) { 996 1025 hit = current.getNextRightHit(insertionIndex - 1); 997 else1026 } else { 998 1027 hit = current.getNextLeftHit(1); 1028 } 999 1029 } else if (newLine < lineIndex) { 1000 1030 hit = current.getNextRightHit(insertionIndex - 1); … … 1085 1115 // determine the line of text to check 1086 1116 line = getLinePosition(mouseY); 1087 if (line < 0) 1117 if (line < 0) { 1088 1118 line = _textLayouts.size() - 1; 1119 } 1089 1120 1090 1121 // if the cursor is moving up or down, change the line 1091 if (direction == UP) 1122 if (direction == UP) { 1092 1123 line = Math.max(line - 1, 0); 1093 else if (direction == DOWN)1124 } else if (direction == DOWN) { 1094 1125 line = Math.min(line + 1, _textLayouts.size() - 1); 1126 } 1095 1127 1096 1128 hit = getCharPosition(line, mouseX); … … 1104 1136 1105 1137 // Stop if at the start of the line 1106 if (hit.getInsertionIndex() == 0) 1138 if (hit.getInsertionIndex() == 0) { 1107 1139 break; 1140 } 1108 1141 // Keep going if the char to the left is a 1109 1142 // letterOrDigit … … 1158 1191 } 1159 1192 1160 if (setSelection) setSelectionEnd(resultPos.getX(), resultPos.getY()); 1193 if (setSelection) { 1194 setSelectionEnd(resultPos.getX(), resultPos.getY()); 1195 } 1161 1196 1162 1197 return resultPos; … … 1174 1209 */ 1175 1210 public TextHitInfo getCharPosition(int line, float mouseX) { 1176 if (line < 0 || line >= _textLayouts.size()) 1211 if (line < 0 || line >= _textLayouts.size()) { 1177 1212 return null; 1213 } 1178 1214 1179 1215 TextLayout layout = _textLayouts.get(line); … … 1203 1239 AxisAlignedBoxBounds bounds = text.getLogicalHighlightShape(0, text.getCharacterCount()); 1204 1240 1205 if (bounds.getWidth() < 1) bounds.getSize().width = 10; 1241 if (bounds.getWidth() < 1) { 1242 bounds.getSize().width = 10; 1243 } 1206 1244 1207 1245 double x = bounds.getCentreX(); 1208 1246 1209 if (bounds.contains((int) x, (int) (mouseY - y))) 1247 if (bounds.contains((int) x, (int) (mouseY - y))) { 1210 1248 return _textLayouts.indexOf(text); 1249 } 1211 1250 1212 1251 // check if the cursor is between lines 1213 if (mouseY - y < bounds.getMinY()) 1252 if (mouseY - y < bounds.getMinY()) { 1214 1253 return Math.max(0, _textLayouts.indexOf(text) - 1); 1254 } 1215 1255 1216 1256 y += getLineDrop(text); … … 1378 1418 */ 1379 1419 public List<String> getTextList() { 1380 if (_text == null) 1420 if (_text == null) { 1381 1421 return null; 1422 } 1382 1423 try { 1383 1424 List<String> list = new LinkedList<String>(); … … 1390 1431 for (TextLayout layout : _textLayouts) { 1391 1432 String text = layout.getLine().replaceAll("\n", ""); 1392 if (!text.equals("")) list.add(text); 1433 if (!text.equals("")) { 1434 list.add(text); 1435 } 1393 1436 } 1394 1437 … … 1400 1443 } 1401 1444 1445 @Override 1402 1446 public String getText() { 1403 1447 return _text.toString(); … … 1410 1454 */ 1411 1455 public String getFirstLine() { 1412 if (_text == null || _text.length() == 0) 1456 if (_text == null || _text.length() == 0) { 1413 1457 return null; 1458 } 1414 1459 1415 1460 // start at the first non-newLine char … … 1422 1467 1423 1468 /* If there are no more newLines return the remaining text */ 1424 if (nextNewLine < 0) 1469 if (nextNewLine < 0) { 1425 1470 return _text.substring(index); 1471 } 1426 1472 1427 1473 return _text.substring(index, nextNewLine); … … 1563 1609 AxisAlignedBoxBounds outline = getBoundingBox(); 1564 1610 1565 if (outline == null) return false; 1611 if (outline == null) { 1612 return false; 1613 } 1566 1614 1567 1615 // Check if its outside the top and left and bottom bounds … … 1597 1645 * Updates the Polygon (rectangle) that surrounds this Text on the screen. 1598 1646 */ 1647 @Override 1599 1648 public AxisAlignedBoxBounds updateBounds() 1600 1649 { 1601 1650 // 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 } 1605 1658 1606 1659 int preChangeWidth = 0; … … 1626 1679 AxisAlignedBoxBounds bounds = layout.getLogicalHighlightShape(0, layout.getCharacterCount()); 1627 1680 1628 if (y < 0) 1681 if (y < 0) { 1629 1682 y = 0; 1630 else1683 } else { 1631 1684 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()); 1635 1689 maxY = Math.max(maxY, (int) (bounds.getMaxY() + y)); 1636 1690 minY = Math.min(minY, (int) (bounds.getMinY() + y)); … … 1645 1699 } 1646 1700 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); 1651 1706 1652 1707 Dimension polySize = ret.getSize(); … … 1695 1750 1696 1751 EcosystemManager.getTextLayoutManager().releaseLayouts(_textLayouts); 1697 if (_textLayouts != null) _textLayouts.clear(); 1752 if (_textLayouts != null) { 1753 _textLayouts.clear(); 1754 } 1698 1755 1699 1756 // Calculate the maximum allowable width of this line of text … … 1721 1778 } 1722 1779 } 1780 1781 if (_text.toString().startsWith("Title")) { 1782 //System.err.println("TitleTemplate doing stuffs"); 1783 } 1723 1784 1724 1785 float width = Float.MAX_VALUE; … … 1730 1791 } 1731 1792 } 1732 1793 1733 1794 _textLayouts = EcosystemManager.getTextLayoutManager().layoutString(_text.toString(), 1734 1795 getPaintFont(), … … 1740 1801 getJustification() == Justification.full); 1741 1802 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 } 1742 1807 invalidateBounds(); 1743 1808 … … 1807 1872 } 1808 1873 1809 if (_selectionStart < 0) 1874 if (_selectionStart < 0) { 1810 1875 _selectionStart = 0; 1811 1812 if (_selectionStart < 0 || _selectionEnd < 0) 1876 } 1877 1878 if (_selectionStart < 0 || _selectionEnd < 0) { 1813 1879 return null; 1880 } 1814 1881 1815 1882 int selectionLeft = Math.min(_selectionStart, _selectionEnd); … … 1817 1884 1818 1885 // 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 } 1820 1889 1821 1890 // 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 } 1823 1894 1824 1895 // Dont highlight a single char … … 1841 1912 public void setSelectionColour(Colour colour) 1842 1913 { 1843 if (colour == null) colour = RANGE_SELECT_COLOUR; 1914 if (colour == null) { 1915 colour = RANGE_SELECT_COLOUR; 1916 } 1844 1917 1845 1918 _selectionColour = colour; … … 1855 1928 public void paint() 1856 1929 { 1857 if (!isVisible()) return; 1930 if (!isVisible()) { 1931 return; 1932 } 1858 1933 1859 1934 // 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 } 1861 1938 1862 1939 if (_autoWrap || ExperimentalFeatures.AutoWrap.get()) { … … 1917 1994 1918 1995 if (isHighlighted()) { 1919 Stroke highlightStroke = new Stroke( (float)getHighlightThickness(), DEFAULT_CAP, DEFAULT_JOIN);1996 Stroke highlightStroke = new Stroke(getHighlightThickness(), DEFAULT_CAP, DEFAULT_JOIN); 1920 1997 Fill fill; 1921 1998 if (HighlightMode.Enclosed.equals(getHighlightMode())) { … … 2027 2104 // size *= UserSettings.ScaleFactor; 2028 2105 // Dont want to have size set when duplicating a point which has size 0 2029 if (size < 0) 2106 if (size < 0) { 2030 2107 return; 2031 2032 if (size < MINIMUM_FONT_SIZE) 2108 } 2109 2110 if (size < MINIMUM_FONT_SIZE) { 2033 2111 size = MINIMUM_FONT_SIZE; 2112 } 2034 2113 Font currentFont = getPaintFont(); 2035 2114 currentFont.setSize((int) size); … … 2046 2125 if (val) { 2047 2126 // if this is already an annotation, do nothing 2048 if (isAnnotation()) 2127 if (isAnnotation()) { 2049 2128 return; 2129 } 2050 2130 if (!isLineEnd() && _text.length() > 0 && _text.charAt(0) == DEFAULT_BULLET) { 2051 2131 newPoint.set(insertText("\b", mouseX, mouseY, 1)); 2052 if (_text.length() > 0 && _text.charAt(0) == ' ') 2132 if (_text.length() > 0 && _text.charAt(0) == ' ') { 2053 2133 newPoint.set(insertText("\b", newPoint.getX(), newPoint.getY(), 1)); 2134 } 2054 2135 } else { 2055 2136 newPoint.set(insertText("@", mouseX, mouseY, 0)); … … 2057 2138 } else { 2058 2139 // if this is not an annotation, do nothing 2059 if (!isAnnotation()) 2140 if (!isAnnotation()) { 2060 2141 return; 2142 } 2061 2143 if (!isLineEnd() && _text.charAt(0) == '@') { 2062 2144 newPoint.set(insertText("\b", mouseX, mouseY, 1)); … … 2098 2180 @Override 2099 2181 public boolean isAnnotation() { 2100 if (_text != null && _text.length() > 0 && _text.charAt(0) == '@') 2182 if (_text != null && _text.length() > 0 && _text.charAt(0) == '@') { 2101 2183 return true; 2184 } 2102 2185 2103 2186 return false; … … 2110 2193 if (s.equals("@old") || s.equals("@ao") || s.equals("@itemtemplate") || s.equals("@parent") 2111 2194 || 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")) { 2113 2196 return true; 2197 } 2114 2198 } 2115 2199 … … 2121 2205 if (merger.isLineEnd()) { 2122 2206 // Merging line ends onto non line end text is a no-op 2123 if (!isLineEnd()) 2207 if (!isLineEnd()) { 2124 2208 return null; 2125 2126 if (merger instanceof Text) 2209 } 2210 2211 if (merger instanceof Text) { 2127 2212 insertText(((Text) merger).getText(), mouseX, mouseY); 2213 } 2128 2214 2129 2215 // Set the position by moving the cursor before calling this … … 2140 2226 } 2141 2227 2142 if (!(merger instanceof Text)) 2228 if (!(merger instanceof Text)) { 2143 2229 return merger; 2230 } 2144 2231 2145 2232 Text merge = (Text) merger; … … 2156 2243 // TODO get this to return the merged item and attach it to the 2157 2244 // cursor only when the user presses the middle button. 2158 } else 2245 } else { 2159 2246 setLink(merge.getLink()); 2247 } 2160 2248 } 2161 2249 … … 2168 2256 */ 2169 2257 public void resetTitlePosition() { 2170 setPosition(MARGIN_LEFT, MARGIN_LEFT + getBoundsHeight()); 2258 final int boundsHeight = getBoundsHeight(); 2259 setPosition(MARGIN_LEFT, MARGIN_LEFT + boundsHeight); 2171 2260 Frame modelFrame = getParentOrCurrentFrame(); 2172 2261 if (modelFrame != null) { … … 2199 2288 } 2200 2289 2290 @Override 2201 2291 public String toString() { 2202 2292 String message = "[" + getFirstLine() + "]" + FRAME_NAME_SEPARATOR; 2203 2293 2204 if (getParent() != null) 2294 if (getParent() != null) { 2205 2295 return message + getParent().getName(); 2296 } 2206 2297 return message + getDateCreated(); 2207 2298 } … … 2262 2353 clearSelection(); 2263 2354 setAlpha(0); 2264 if (isLineEnd()) 2355 if (isLineEnd()) { 2265 2356 DisplayController.setCursor(Item.DEFAULT_CURSOR); 2357 } 2266 2358 2267 2359 String text = _text.toString().trim(); … … 2283 2375 if (!_text.toString().contains(" ")) { 2284 2376 Integer width = getWidth(); 2285 if (width == null || width < 0) 2377 if (width == null || width < 0) { 2286 2378 setWidth(Integer.MIN_VALUE + 1); 2379 } 2287 2380 } else if (frameWidth - getX() > ADJUST_WIDTH_THRESHOLD) { 2288 2381 justify(false); … … 2294 2387 public void justify(boolean fixWidth, PolygonBounds enclosure) { 2295 2388 // 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 } 2297 2392 2298 2393 Integer width = DisplayController.getFramePaintArea().getWidth(); … … 2307 2402 } 2308 2403 2309 if (getWidth() == null) setRightMargin(width, fixWidth); 2404 if (getWidth() == null) { 2405 setRightMargin(width, fixWidth); 2406 } 2310 2407 2311 2408 // Check for the annotation that restricts the width of text items on the frame … … 2315 2412 int oldWidth = getWidth(); 2316 2413 int maxWidth = Integer.parseInt(widthString); 2317 if (maxWidth < oldWidth) 2414 if (maxWidth < oldWidth) { 2318 2415 setWidth(maxWidth); 2416 } 2319 2417 } catch (NumberFormatException nfe) { 2320 2418 } … … 2325 2423 public void justify(boolean fixWidth) { 2326 2424 // 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 } 2328 2428 2329 2429 this.justify(fixWidth, FrameUtils.getEnlosingPolygon()); … … 2340 2440 @Override 2341 2441 protected int getLinkYOffset() { 2342 if (_textLayouts.size() == 0) 2442 if (_textLayouts.size() == 0) { 2343 2443 return 0; 2444 } 2344 2445 return Math.round(-(_textLayouts.get(0).getAscent() / 2)); 2345 2446 } … … 2363 2464 public static boolean isBulletChar(char c) { 2364 2465 for (int i = 0; i < BULLETS.length; i++) { 2365 if (BULLETS[i] == c) 2466 if (BULLETS[i] == c) { 2366 2467 return true; 2468 } 2367 2469 } 2368 2470 return c == '*' || c == '+' || c == '>' || c == '-' || c == 'o'; 2369 2471 } 2370 2472 2473 @Override 2371 2474 public boolean hasOverlay() { 2372 if (!isAnnotation() || getLink() == null) 2475 if (!isAnnotation() || getLink() == null) { 2373 2476 return false; 2477 } 2374 2478 String text = getText().toLowerCase(); 2375 2479 // TODO make it so can just check the _overlay variable 2376 2480 // Mike can't remember the reason _overlay var can't be use! oops 2377 if (!text.startsWith("@")) 2481 if (!text.startsWith("@")) { 2378 2482 return false; 2483 } 2379 2484 return text.startsWith("@o") || text.startsWith("@ao") || text.startsWith("@v") || text.startsWith("@av"); 2380 2485 } … … 2396 2501 @Override 2397 2502 public boolean calculate(String formula) { 2398 if (DisplayController.isXRayMode()) 2503 if (DisplayController.isXRayMode()) { 2399 2504 return false; 2505 } 2400 2506 2401 2507 super.calculate(formula); … … 2414 2520 Collection<Item> enclosed = getItemsInSameEnclosure(); 2415 2521 for (Item i : enclosed) { 2416 if (i == this) 2522 if (i == this) { 2417 2523 continue; 2524 } 2418 2525 if (i instanceof Text && !i.isAnnotation()) { 2419 2526 AttributeValuePair pair = i.getAttributeValuePair(); … … 2432 2539 try { 2433 2540 double value = pair.getDoubleValue(); 2434 if (value != Double.NaN) 2541 if (value != Double.NaN) { 2435 2542 myParser.addVariable("$" + nextVarNo++, value); 2543 } 2436 2544 } catch (NumberFormatException nfe) { 2437 2545 continue; … … 2516 2624 } 2517 2625 2518 if (sameEnclosure == null) 2626 if (sameEnclosure == null) { 2519 2627 return new LinkedList<Item>(); 2628 } 2520 2629 2521 2630 return sameEnclosure; … … 2526 2635 * item is modified 2527 2636 */ 2637 @Override 2528 2638 public boolean recalculateWhenChanged() { 2529 2639 if (/* 2530 2640 * !isAnnotation() && 2531 */(hasFormula() || isLineEnd())) 2641 */(hasFormula() || isLineEnd())) { 2532 2642 return true; 2643 } 2533 2644 try { 2534 2645 AttributeValuePair avp = getAttributeValuePair(); 2535 2646 2536 if (!avp.getDoubleValue().equals(Double.NaN)) 2647 if (!avp.getDoubleValue().equals(Double.NaN)) { 2537 2648 return true; 2649 } 2538 2650 } catch (Exception e) { 2539 2651 e.printStackTrace(); … … 2693 2805 final AxisAlignedBoxBounds r = getPixelBounds(_textLayouts.get(i)); 2694 2806 cumulativeHeight += _textLayouts.get(i).getDescent() + _textLayouts.get(i).getAscent(); 2695 if (r.getSize().width > maxWidth) 2807 if (r.getSize().width > maxWidth) { 2696 2808 maxWidth = r.getSize().width; 2809 } 2697 2810 } 2698 2811 } … … 2911 3024 // add the date to the text item 2912 3025 textItem.prependText(dateToAdd); 2913 if (dateToAdd.length() == textItem.getLength()) 3026 if (dateToAdd.length() == textItem.getLength()) { 2914 3027 DisplayController.setCursorPosition(textItem.getParagraphEndPosition()); 3028 } 2915 3029 } else if (append) { 2916 3030 textItem.appendText(dateToAdd); 2917 if (dateToAdd.length() == textItem.getLength()) 3031 if (dateToAdd.length() == textItem.getLength()) { 2918 3032 DisplayController.setCursorPosition(textItem.getPosition()); 3033 } 2919 3034 } else { 2920 3035 for (int i = 0; i < date1.length(); i++) {
Note:
See TracChangeset
for help on using the changeset viewer.