Changeset 1200 for trunk/src/org/expeditee/items
- Timestamp:
- 11/28/18 16:16:29 (6 years ago)
- Location:
- trunk/src/org/expeditee/items
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/items/Item.java
r1190 r1200 50 50 import org.expeditee.gui.DisplayController; 51 51 import org.expeditee.gui.Frame; 52 import org.expeditee.gui.FrameGraphics;53 52 import org.expeditee.gui.FrameIO; 54 53 import org.expeditee.gui.FrameUtils; … … 59 58 import org.expeditee.io.Conversion; 60 59 import org.expeditee.settings.UserSettings; 60 import org.expeditee.settings.legacy.LegacyFeatures; 61 61 import org.expeditee.simple.Context; 62 62 import org.expeditee.stats.AgentStats; … … 275 275 276 276 private List<String> _data = null; 277 277 278 278 private String _formula = null; 279 279 … … 309 309 310 310 protected boolean _filled = true; 311 312 // NGIKM Attributes 313 private List<String> _ngikmLabels = new ArrayList<String>(); 314 private List<String> _ngikmKeys = new ArrayList<String>(); 311 315 312 316 /** Just calls source.duplicateOnto(dest). */ … … 380 384 381 385 dest._visible = this._visible; 386 387 dest._ngikmKeys = new ArrayList<String>(this._ngikmKeys); 388 dest._ngikmLabels = new ArrayList<String>(this._ngikmLabels); 382 389 383 390 Frame parent = DisplayController.getCurrentFrame(); … … 494 501 { 495 502 _permissionPair = permissionPair; 503 if (_permissionPair.getPermission(_owner) == UserAppliedPermission.denied) { 504 this.getParent().moveItemToBodyHiddenDueToPermission(this); 505 } 496 506 } 497 507 … … 1155 1165 return getWidth(); 1156 1166 } 1167 1168 public Integer getMinWidthToSave() { 1169 return getMinWidth(); 1170 } 1157 1171 1158 1172 public Integer getWidth() 1159 1173 { 1174 return null; 1175 } 1176 1177 public Integer getMinWidth() { 1160 1178 return null; 1161 1179 } … … 1458 1476 1459 1477 for (String s : getAction()) { 1460 Object returnValue = Actions.PerformActionCatchErrors(sourceFrame, 1461 sourceItem, s); 1478 Object returnValue; 1479 if (LegacyFeatures.UseLegacyActionArgumentMapping.get()) { 1480 returnValue = Actions.LegacyPerformActionCatchErrors(sourceFrame, sourceItem, s); 1481 } else { 1482 returnValue = Actions.PerformActionCatchErrors(sourceFrame, sourceItem, s, this); 1483 } 1484 1462 1485 if (returnValue != null) { 1463 1486 FreeItems.getInstance().clear(); … … 2254 2277 throw new UnsupportedOperationException("Item type does not support width attribute!"); 2255 2278 } 2279 2280 public void setMinWidth(final Integer width) throws UnsupportedOperationException { 2281 throw new UnsupportedOperationException("Item type does not support minwidth attribute."); 2282 } 2256 2283 2257 2284 public void setRightMargin(int i, boolean fixWidth) … … 2283 2310 */ 2284 2311 public void setY(float newY) { 2312 if (newY == 265) { 2313 System.err.println("Item::setY::setting y to 265"); 2314 } 2285 2315 setPosition(getX(), newY); 2286 2316 } -
trunk/src/org/expeditee/items/PermissionPair.java
r1193 r1200 35 35 if (permissionCode.length() != 0) { 36 36 37 if (permissionCode.length() == 1 ) {37 if (permissionCode.length() == 1 || (permissionCode.length() == 2 && permissionCode.startsWith("-"))) { 38 38 // replicate it to cover ifOwner/ifNotOwner 39 39 permissionCode += permissionCode; … … 50 50 ownerPermission = UserAppliedPermission.getPermission(ownerPermissionCode, defaultPermission); 51 51 notOwnerPermission = UserAppliedPermission.getPermission(notOwnerPermissionCode, defaultPermission); 52 //ownerPermission = UserAppliedPermission.getPermission(permissionCode.substring(0, 1),53 // defaultPermission);54 //notOwnerPermission = UserAppliedPermission.getPermission(permissionCode.substring(1, 2),55 // defaultPermission);56 52 } 57 53 } -
trunk/src/org/expeditee/items/Text.java
r1190 r1200 136 136 */ 137 137 private Integer _maxWidth = -Integer.MAX_VALUE; 138 139 private Integer _minWidth = -Integer.MAX_VALUE; 138 140 139 141 private Justification _justification = Justification.left; … … 172 174 173 175 // text is broken up into lines 174 pr ivateStringBuffer _text = new StringBuffer();175 176 pr ivateList<TextLayout> _textLayouts = new LinkedList<TextLayout>();176 protected StringBuffer _text = new StringBuffer(); 177 178 protected List<TextLayout> _textLayouts = new LinkedList<TextLayout>(); 177 179 178 180 // The font to display this text in 179 181 private Font _font; 182 183 // The optional mask character to us in place of the text's content. 184 private Integer _mask = null; 180 185 181 186 protected static void InitFontFamily(File fontFamilyDir) … … 373 378 374 379 /** 375 <<<<<<< .mine376 * Sets the maximum width of this Text item when justification is used.377 * passing in 0 or -1 means there is no maximum width378 ||||||| .r1094379 * Sets the maximum width of this Text item when justifcation is used.380 * passing in 0 or -1 means there is no maximum width381 =======382 * Sets the maximum width of this Text item when justifcation is used. passing383 * in 0 or -1 means there is no maximum width384 >>>>>>> .r1100385 *386 380 * @param width 387 381 * The maximum width of this item when justification is applied to … … 399 393 400 394 _maxWidth = width; 395 rebuild(true); 396 invalidateAll(); 397 } 398 399 @Override 400 public void setMinWidth(final Integer width) { 401 invalidateAll(); 402 403 if (width == null) { 404 setJustification(Justification.left); 405 setRightMargin(DisplayController.getFramePaintArea().getWidth(), false); 406 return; 407 } 408 409 _minWidth = width; 401 410 rebuild(true); 402 411 invalidateAll(); … … 433 442 434 443 return Math.abs(_maxWidth); 444 } 445 446 public Integer getMinWidth() { 447 if (_minWidth == null || _minWidth <= 0) { 448 return null; 449 } 450 return _minWidth; 451 } 452 453 public Integer getAbsoluteMinWidth() { 454 if (_minWidth == null) { 455 return Integer.MAX_VALUE; 456 } 457 return Math.abs(_minWidth); 435 458 } 436 459 … … 1035 1058 lineIndex = newLine; 1036 1059 } 1037 1038 // move the cursor to the new location1039 float[] caret = current.getCaretInfo(hit);1040 float y = getLineDrop(current) * lineIndex;1041 y = getY() + y + caret[1];1042 1043 float x = getX() + caret[0] + getJustOffset(current);1044 x = Math.min(x, (getX() - Item.MARGIN_RIGHT - (2 * getGravity()) + getBoundsWidth()));1045 1046 invalidateAll();1047 1060 1048 // System.err.println("Mouse location: " + mouseX + "," + mouseY); 1049 // System.err.println("Caret location: " + caret[0] + "," + caret[1]); 1050 1051 // System.err.println(text); 1052 // System.err.println("X delta: " + (x - getX())); 1053 final Point newCursor = new Point(Math.round(x), Math.round(y)); 1054 // System.err.println("Moving cursor to: " + newCursor); 1055 return newCursor; 1061 if (this.getMask() != null) { 1062 // If we are working with a mask than the positioning of the mouse is simplified. (as character length is constant) 1063 String content = ""; 1064 for (int i = 0; i < this._text.length(); i++) { 1065 content += (char) this.getMask().intValue(); 1066 } 1067 final TextLayout fakeLayout = TextLayout.getManager().layoutStringSimple(content, this.getFont()); 1068 //final TextHitInfo fakeHitInfo = fakeLayout.getNextRightHit(hit.getCharIndex()); 1069 final float[] fakeCaretInfo = fakeLayout.getCaretInfo(hit); 1070 1071 float y = getLineDrop(current) * lineIndex; 1072 y = getY() + y + fakeCaretInfo[1]; 1073 float x = getX() + fakeCaretInfo[0] + getJustOffset(current); 1074 x = Math.min(x, (getX() - Item.MARGIN_RIGHT - (2 * getGravity()) + getBoundsWidth())); 1075 1076 return new Point(Math.round(x), Math.round(y)); 1077 } else { 1078 // If we have no mask then.... 1079 // move the cursor to the new location 1080 float[] caret = current.getCaretInfo(hit); 1081 float y = getLineDrop(current) * lineIndex; 1082 y = getY() + y + caret[1]; 1083 1084 float x = getX() + caret[0] + getJustOffset(current); 1085 x = Math.min(x, (getX() - Item.MARGIN_RIGHT - (2 * getGravity()) + getBoundsWidth())); 1086 1087 invalidateAll(); 1088 1089 final Point newCursor = new Point(Math.round(x), Math.round(y)); 1090 return newCursor; 1091 } 1056 1092 } 1057 1093 … … 1503 1539 * The distance to advance in the y-direction before the next line. 1504 1540 */ 1505 pr ivatefloat getLineDrop(TextLayout layout)1541 protected float getLineDrop(TextLayout layout) 1506 1542 { 1507 1543 if (getSpacing() < 0) { … … 1620 1656 return false; 1621 1657 } 1658 1659 if (this.getMinWidth() != null && outline.contains(mouseX, mouseY)) { 1660 return true; 1661 } 1622 1662 1623 1663 for (TextLayout text : _textLayouts) { … … 1628 1668 // gravity of right 1629 1669 int justOffset = getJustOffset(text); 1630 1670 1631 1671 if (mouseY - textY > textOutline.getMinY() && 1632 1672 mouseY - textY < textOutline.getMinY() + textOutline.getHeight() && … … 1653 1693 } 1654 1694 1655 if (_textLayouts == null || _textLayouts.size() < 1) { 1695 // if there is no text layouts and the text has no min width, do nothing 1696 if (_textLayouts == null || (_textLayouts.size() < 1 && this.getMinWidth() == null)) { 1656 1697 return null; 1657 } 1698 } 1658 1699 1659 1700 int preChangeWidth = 0; … … 1669 1710 1670 1711 float y = -1; 1712 1713 if (this.getMinWidth() != null && _textLayouts.size() == 0 && this.getFont() != null) { 1714 final TextLayout fakeLayout = TextLayout.getManager().layoutStringSimple("p", this.getFont()); 1715 final int xPos = getX() - getGravity(); 1716 final int yPos = getY() - getGravity() - (int) fakeLayout.getAscent(); 1717 final int width = 2 * getGravity() + this.getMinWidth(); 1718 final int height = 2 * getGravity() + EcosystemManager.getGraphicsManager().getFontHeight(getFont()); 1719 TextLayout.getManager().releaseLayout(fakeLayout); 1720 return new AxisAlignedBoxBounds(xPos, yPos, width, height); 1721 } 1671 1722 1672 1723 // Fix concurrency error in ScaleFrameset … … 1676 1727 } 1677 1728 1678 for (TextLayout layout : tmpTextLayouts) { 1729 for (int index = 0; index < tmpTextLayouts.size(); index++) { 1730 final TextLayout layout = tmpTextLayouts.get(index); 1679 1731 AxisAlignedBoxBounds bounds = layout.getLogicalHighlightShape(0, layout.getCharacterCount()); 1680 1732 1681 1733 if (y < 0) { 1682 1734 y = 0; 1683 } else { 1735 } else { 1684 1736 y += getLineDrop(layout); 1685 1737 } 1686 1687 maxX = Math.max(maxX, bounds.getMaxX()); 1738 1739 int minWidth = getAbsoluteMinWidth(); 1740 1688 1741 minX = Math.min(minX, bounds.getMinX()); 1742 maxX = minWidth < Integer.MAX_VALUE 1743 ? Math.max(minX + minWidth, bounds.getMaxX()) 1744 : Math.max(maxX, bounds.getMaxX()); 1745 minY = Math.min(minY, (int) (bounds.getMinY() + y)); 1689 1746 maxY = Math.max(maxY, (int) (bounds.getMaxY() + y)); 1690 minY = Math.min(minY, (int) (bounds.getMinY() + y));1691 1747 } 1692 1748 … … 1805 1861 //System.err.println(Arrays.toString(_text.toString().toCharArray())); 1806 1862 } 1863 1807 1864 invalidateBounds(); 1808 1809 1865 } 1810 1866 … … 1933 1989 1934 1990 // if there is no text to paint, do nothing. 1935 if (_text == null || _text.length() == 0) { 1991 if (_text == null) { 1992 return; 1993 } 1994 1995 // if the text to paint is empty string and there is no min width, do nothing. 1996 if ((_text.length() == 0 && getMinWidth() == null)) { 1936 1997 return; 1937 1998 } … … 2001 2062 fill = null; 2002 2063 } 2003 // System.err.println("Top left: " + getBoundingBox().getTopLeft() + ", " + "Bottom right: " + getBoundingBox().getBottomRight());2004 2064 g.drawRectangle(bounds, 0.0, fill, getPaintHighlightColor(), highlightStroke, null); 2005 2065 } … … 2032 2092 } 2033 2093 2094 if (layout.getCharacterCount() == 0) { continue; } 2034 2095 int ldx = 1 + getX() + getJustOffset(layout); // Layout draw x 2035 2036 g.drawTextLayout(layout, new Point(ldx, (int) y), paintColour); 2096 if (_mask == null) { 2097 g.drawTextLayout(layout, new Point(ldx, (int) y), paintColour); 2098 } else { 2099 String mask = ""; 2100 for(int o = 0; o < layout.getCharacterCount(); o++) { mask += (char) getMask().intValue(); } 2101 g.drawString(mask, new Point(ldx, (int) y), layout.getFont(), paintColour); 2102 } 2037 2103 2038 2104 y += getLineDrop(layout); 2039 2105 } 2040 2106 } 2041 2107 2042 2108 paintLink(); 2043 2109 } … … 2076 2142 copy.setWidth(getWidthToSave()); 2077 2143 copy.setFont(getFont().clone()); 2144 copy.setMinWidth(getMinWidthToSave()); 2145 copy.setMask(_mask); 2078 2146 if (hasFormula()) { 2079 2147 copy.calculate(getFormula()); … … 2168 2236 2169 2237 if (_text.length() == 0) { 2238 if (this.getMinWidth() != null) { 2239 // final TextLayout base = _textLayouts.get(0); 2240 // _textLayouts.set(0, TextLayout.get(" ", base.getFont(), 0, 1)); 2241 _textLayouts.clear(); 2242 } 2170 2243 if (this.isLineEnd()) { 2171 2244 // Remove and replace with a dot … … 2496 2569 String text = getText(); 2497 2570 assert (text != null); 2498 return text.trim().length() == 0 || super.dontSave();2571 return super.dontSave() || (text.trim().length() == 0 && this.getMinWidth() == null); 2499 2572 } 2500 2573 … … 2713 2786 @Override 2714 2787 public void setAnchorTop(Integer anchor) { 2715 if (!isLineEnd()) { 2788 if (!isLineEnd()) { 2716 2789 super.setAnchorTop(anchor); 2717 2790 if (anchor != null) { 2718 setY(anchor + _textLayouts.get(0).getAscent()); 2791 if (!_textLayouts.isEmpty()) { 2792 final float ascent = _textLayouts.get(0).getAscent(); 2793 setY(anchor + ascent); 2794 } else if (this.getFont() != null) { 2795 // p could be any character 2796 final TextLayout fakeLayout = TextLayout.getManager().layoutStringSimple("p", this.getFont()); 2797 final float ascent = fakeLayout.getAscent(); 2798 EcosystemManager.getTextLayoutManager().releaseLayout(fakeLayout); 2799 setY(anchor + ascent); 2800 } 2719 2801 } 2720 2802 return; … … 2740 2822 super.setAnchorBottom(anchor); 2741 2823 if (anchor != null) { 2742 setY(DisplayController.getFramePaintArea().getHeight() - (anchor + this.getBoundsHeight() - _textLayouts.get(0).getAscent() - _textLayouts.get(0).getDescent())); 2824 if (!_textLayouts.isEmpty()) { 2825 final float ascent = _textLayouts.get(0).getAscent(); 2826 final float descent = _textLayouts.get(0).getDescent(); 2827 setY(DisplayController.getFramePaintArea().getHeight() - (anchor + this.getBoundsHeight() - ascent - descent)); 2828 } else if (this.getFont() != null) { 2829 // p could be any character 2830 final TextLayout fakeLayout = TextLayout.getManager().layoutStringSimple("p", this.getFont()); 2831 final float ascent = fakeLayout.getAscent(); 2832 final float descent = fakeLayout.getDescent(); 2833 setY(DisplayController.getFramePaintArea().getHeight() - (anchor + this.getBoundsHeight() - ascent - descent)); 2834 } 2835 2743 2836 } 2744 2837 return; … … 3055 3148 DisplayController.setCursorPosition(newText.getParagraphEndPosition()); 3056 3149 } 3057 3058 } 3150 } 3151 3152 public Integer getMask() { 3153 if (_mask == null) { return null; } 3154 else { return _mask; } 3155 } 3156 3157 public void setMask(final Integer c) { _mask = c; } 3059 3158 }
Note:
See TracChangeset
for help on using the changeset viewer.