- Timestamp:
- 04/08/19 15:59:17 (5 years ago)
- Location:
- trunk/src/org/expeditee
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gui/AttributeUtils.java
r1227 r1296 315 315 _Attrib.put("Mask", Text.class.getMethod("getMask"), 316 316 Text.class.getMethod("setMask", pIntO)); 317 _Attrib.put("Placeholder", Text.class.getMethod("getPlaceholder"), 318 Text.class.getMethod("setPlaceholder", pString)); 317 319 318 320 // Aliases for attribute setting -
trunk/src/org/expeditee/io/DefaultFrameReader.java
r1242 r1296 161 161 _ItemTags.put('O', Text.class.getMethod("setMask", pIntO)); 162 162 163 _ItemTags.put('=', Text.class.getMethod("setPlaceholder", pString)); 164 163 165 // Lines and constraints are created differently 164 166 _ItemTags.put('L', Line.class.getMethod("setStartItem", pItem)); -
trunk/src/org/expeditee/io/DefaultFrameWriter.java
r1274 r1296 149 149 _ItemTags.put('^', Item.class.getMethod("getMagnetizedItemTop")); 150 150 _ItemTags.put('_', Item.class.getMethod("getMagnetizedItemBottom")); 151 152 _ItemTags.put('=', Text.class.getMethod("getPlaceholder")); 151 153 } catch (Exception e) { 152 154 e.printStackTrace(); -
trunk/src/org/expeditee/items/Text.java
r1258 r1296 176 176 // text is broken up into lines 177 177 protected StringBuffer _text = new StringBuffer(); 178 179 // place holder text to use if _text is empty. 180 protected StringBuffer _placeholder = new StringBuffer(); 178 181 179 182 private List<TextLayout> _textLayouts = new LinkedList<TextLayout>(); 180 183 private List<TextLayout> _maskTextLayouts = new LinkedList<TextLayout>(); 184 private List<TextLayout> _placeholderTextLayouts = new LinkedList<TextLayout>(); 181 185 182 186 // The font to display this text in … … 1753 1757 1754 1758 // if there is no text, there is nothing to do 1755 if ( _text == null || _text.length() == 0) {1759 if ((_text == null || _text.length() == 0 ) && getPlaceholder() == null) { 1756 1760 // Frame parent = getParent(); 1757 1761 // if(parent != null) … … 1767 1771 if (_maskTextLayouts != null) { 1768 1772 _maskTextLayouts.clear(); 1773 } 1774 EcosystemManager.getTextLayoutManager().releaseLayouts(_placeholderTextLayouts); 1775 if (_placeholderTextLayouts != null) { 1776 _placeholderTextLayouts.clear(); 1769 1777 } 1770 1778 … … 1807 1815 } 1808 1816 1809 this._textLayouts = 1810 EcosystemManager.getTextLayoutManager().layoutString( 1811 _text.toString(), 1812 getPaintFont(), 1813 new Point(getX(), getY()), lines != null ? lines.toArray(new org.expeditee.core.Line[1]) : null, 1814 (int) width, 1815 (int) getSpacing(), 1816 true, 1817 getJustification() == Justification.full 1818 ); 1819 if (this.getMask() != null) { 1820 final Stream<Character> maskStream = _text.toString().chars().mapToObj(c -> (char) this.getMask().intValue()); 1821 final StringBuilder sb = new StringBuilder(); 1822 maskStream.forEach(c -> sb.append(c)); 1823 this._maskTextLayouts = 1824 EcosystemManager.getTextLayoutManager().layoutString( 1825 sb.toString(), 1826 getPaintFont(), 1827 new Point(getX(), getY()), lines != null ? lines.toArray(new org.expeditee.core.Line[1]) : null, 1828 (int) width, 1829 (int) getSpacing(), 1830 true, 1831 getJustification() == Justification.full 1832 ); 1833 } 1834 1817 Font paintFont = getPaintFont(); 1818 if (this._text != null && this._text.length() > 0) { 1819 this._textLayouts = 1820 EcosystemManager.getTextLayoutManager().layoutString( 1821 _text.toString(), 1822 paintFont, 1823 new Point(getX(), getY()), lines != null ? lines.toArray(new org.expeditee.core.Line[1]) : null, 1824 (int) width, 1825 (int) getSpacing(), 1826 true, 1827 getJustification() == Justification.full 1828 ); 1829 1830 if (this.getMask() != null) { 1831 final Stream<Character> maskStream = _text.toString().chars().mapToObj(c -> (char) this.getMask().intValue()); 1832 final StringBuilder sb = new StringBuilder(); 1833 maskStream.forEach(c -> sb.append(c)); 1834 this._maskTextLayouts = 1835 EcosystemManager.getTextLayoutManager().layoutString( 1836 sb.toString(), 1837 paintFont, 1838 new Point(getX(), getY()), lines != null ? lines.toArray(new org.expeditee.core.Line[1]) : null, 1839 (int) width, 1840 (int) getSpacing(), 1841 true, 1842 getJustification() == Justification.full 1843 ); 1844 } 1845 } 1846 if (this.getPlaceholder() != null) { 1847 this._placeholderTextLayouts = 1848 EcosystemManager.getTextLayoutManager().layoutString( 1849 getPlaceholder(), 1850 paintFont, 1851 new Point(getX(), getY()), lines != null ? lines.toArray(new org.expeditee.core.Line[1]) : null, 1852 (int) width, 1853 (int) getSpacing(), 1854 true, 1855 getJustification() == Justification.full 1856 ); 1857 } 1835 1858 invalidateBounds(); 1836 1859 } … … 1941 1964 return; 1942 1965 } 1943 1944 // if there is no text to paint, do nothing. 1945 if (_text == null) { 1946 return; 1947 } 1966 1967 boolean hasContent = !(_text == null || (_text.length() == 0 && getMinWidth() == null)); 1968 boolean hasPlaceholderContent = getPlaceholder() != null; 1969 1948 1970 1949 1971 // if the text to paint is empty string and there is no min width, do nothing. 1950 if ( (_text.length() == 0 && getMinWidth() == null)) {1972 if (!hasContent && !hasPlaceholderContent) { 1951 1973 return; 1952 1974 } … … 2025 2047 paintColour = new Colour(paintColour); 2026 2048 paintColour.setAlpha(Colour.FromComponent255(_alpha)); 2027 2049 } 2050 if (getTextLayouts() == _placeholderTextLayouts) { 2051 paintColour = paintColour.clone(); 2052 paintColour.setAlpha(Colour.FromComponent255(60)); 2028 2053 } 2029 2054 … … 3108 3133 _mask = c; 3109 3134 } 3135 3136 public String getPlaceholder() { 3137 if (_placeholder == null || _placeholder.length() == 0) { 3138 return null; 3139 } 3140 return _placeholder.toString(); 3141 } 3142 3143 public void setPlaceholder(String _placeholder) { 3144 this._placeholder = new StringBuffer(_placeholder); 3145 } 3110 3146 3111 3147 protected List<TextLayout> getTextLayouts() { 3112 if (this.getMask() != null) { 3148 if (this.getPlaceholder() != null && (this._text == null || this._text.length() == 0)) { 3149 return _placeholderTextLayouts; 3150 } else if (this.getMask() != null) { 3113 3151 return _maskTextLayouts; 3114 3152 } else {
Note:
See TracChangeset
for help on using the changeset viewer.