Changeset 663


Ignore:
Timestamp:
01/08/14 10:01:57 (10 years ago)
Author:
jts21
Message:

Improve default text rebuilding behaviour (shouldn't impact performance at all, since it just reschedules rebuilding to happen before the item is painted next, which will be after other items have loaded, so the text can wrap correctly around them).
Also made text items automatically rebuild on frame load.
Could possibly further improve performance in some cases by replacing all calls to rebuild() with the deferred rebuild, which should speed up loading (since it would only have to rebuild once instead of rebuilding every time it changes a property).

File:
1 edited

Legend:

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

    r659 r663  
    131131        // text is broken up into lines
    132132        private StringBuffer _text = new StringBuffer();
     133        private boolean _rebuildText = false;
    133134
    134135        private List<TextLayout> _textLayouts = new LinkedList<TextLayout>();
     
    206207
    207208                _maxWidth = width;
    208                 rebuild(true);
     209                // delay rebuilding until the next time we redraw
     210                // this makes sure other items will have loaded, so we will be able to rebuild correctly
     211                _rebuildText = true;
     212                // rebuild(true);
    209213                invalidateAll();
    210214        }
     
    403407
    404408                _text.append(text);
     409               
     410                // rebuild at next redraw
     411                // this makes sure the text item draws correctly upon loading a frame,
     412                // and also keeps this method efficient
     413                _rebuildText = true;
    405414        }
    406415
     
    16601669               
    16611670                        rebuild(true);
    1662                 } else if (_textLayouts.size() < 1) {
     1671                } else if (_rebuildText || _textLayouts.size() < 1) {
     1672                        clipFrameMargin();
    16631673                        rebuild(true);
    1664                         // System.out.println("Error: " + _text);
     1674                        _rebuildText = false;
    16651675                        // return;
    16661676                }
     
    21002110                String text = _text.toString().trim();
    21012111
     2112                clipFrameMargin();
     2113
     2114                // Show the overlay stuff immediately if this is an overlay item
     2115                if (hasLink() && (text.startsWith("@ao") || text.startsWith("@o"))) {
     2116                        FrameKeyboardActions.Refresh();
     2117                }
     2118        }
     2119       
     2120        private void clipFrameMargin() {
    21022121                if (!hasFixedWidth()) {
    21032122                        int frameWidth = FrameGraphics.getMaxFrameSize().width;
     
    21062125                         * the screen
    21072126                         */
    2108                         if (!text.contains(" ")) {
     2127                        if (!_text.toString().contains(" ")) {
    21092128                                Integer width = getWidth();
    21102129                                if (width == null || width < 0)
     
    21142133                                // setRightMargin(frameWidth, false);
    21152134                        }
    2116                 }
    2117 
    2118                 // Show the overlay stuff immediately if this is an overlay item
    2119                 if (hasLink() && (text.startsWith("@ao") || text.startsWith("@o"))) {
    2120                         FrameKeyboardActions.Refresh();
    21212135                }
    21222136        }
Note: See TracChangeset for help on using the changeset viewer.