Changeset 1379


Ignore:
Timestamp:
05/27/19 11:38:10 (5 years ago)
Author:
bln4
Message:

Reimplementation of the functionality that limits a text item to one line by reducing font size. The user must now specify inject a width property (eg Width: 300) and inject the property 'SingleLineOnly: true' to cause the functionality to happen. This new version of the functionality also now works with pasting large amounts of content rather than adding a single character at the time. Also, this new version dynamically returns to the larger font size as the length of the text item decreases.

Location:
trunk/src/org/expeditee
Files:
4 edited

Legend:

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

    r1377 r1379  
    322322                        _Attrib.put("Placeholder",                      Text.class.getMethod("getPlaceholder"),
    323323                                                                                                Text.class.getMethod("setPlaceholder", pString));
     324                        _Attrib.put("SingleLineOnly",           Text.class.getMethod("isSingleLineOnly"),
     325                                                                                                Text.class.getMethod("setSingleLineOnly", pBool));
    324326                       
    325327                        // Aliases for attribute setting
  • trunk/src/org/expeditee/io/DefaultFrameReader.java

    r1377 r1379  
    181181                       
    182182                        _ItemTagsExt.put("_ph", Text.class.getMethod("setPlaceholder", pString));
     183                        _ItemTagsExt.put("_sl", Text.class.getMethod("setSingleLineOnly", pBool));
    183184                } catch (Exception e) {
    184185                        e.printStackTrace();
  • trunk/src/org/expeditee/io/DefaultFrameWriter.java

    r1377 r1379  
    155155                       
    156156                        _ItemTagsExt.put("_ph", Text.class.getMethod("getPlaceholder"));
     157                        _ItemTagsExt.put("_sl", Text.class.getMethod("isSingleLineOnly"));
    157158                } catch (Exception e) {
    158159                        e.printStackTrace();
  • trunk/src/org/expeditee/items/Text.java

    r1377 r1379  
    139139
    140140        private Integer _minWidth = -Integer.MAX_VALUE;
     141       
     142        private boolean _singleLine = false;
    141143       
    142144        private Justification _justification = Justification.left;
     
    18171819                Font paintFont = getPaintFont();
    18181820                if (this._text != null && this._text.length() > 0) {
    1819                         this._textLayouts =
     1821                        List<TextLayout> proposedTextLayout =
    18201822                                        EcosystemManager.getTextLayoutManager().layoutString(
    18211823                                                _text.toString(),
     
    18271829                                                getJustification() == Justification.full
    18281830                                        );
     1831                        if (proposedTextLayout.size() > 1 && isSingleLineOnly()) {
     1832                                paintFont = paintFont.clone();
     1833                               
     1834                                while(proposedTextLayout.size() > 1) {
     1835                                        paintFont.setSize(paintFont.getSize() - 1);
     1836                                        proposedTextLayout =
     1837                                                EcosystemManager.getTextLayoutManager().layoutString(
     1838                                                        _text.toString(),
     1839                                                        paintFont,
     1840                                                        new Point(getX(), getY()), lines != null ? lines.toArray(new org.expeditee.core.Line[1]) : null,
     1841                                                        (int) width,
     1842                                                        (int) getSpacing(),
     1843                                                        true,
     1844                                                        getJustification() == Justification.full
     1845                                                );
     1846                                }
     1847                        }
     1848                        this._textLayouts = proposedTextLayout;
    18291849                       
    18301850                        if (this.getMask() != null) {
     
    31543174                }
    31553175        }
     3176
     3177        public boolean isSingleLineOnly() {
     3178                return _singleLine;
     3179        }
     3180
     3181        public void setSingleLineOnly(boolean _singleLine) {
     3182                this._singleLine = _singleLine;
     3183        }
    31563184}
Note: See TracChangeset for help on using the changeset viewer.