Class TextUtils


  • public class TextUtils
    extends java.lang.Object
    Utility class to provide common operations on strings not supported by the base java API.
    Since:
    2.0.0
    Author:
    chris.gross@us.ibm.com, Mirko Paturzo , gongguangyong@live.cn Mirko modified the pivot calculation for improve short text provider performance. The pivot number is calculate starting from the size of the cell provided
    • Method Summary

      All Methods Static Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static java.lang.String getShortStr​(org.eclipse.swt.graphics.GC gc, java.lang.String t, int width)
      Shortens a supplied string so that it fits within the area specified by the width argument.
      static java.lang.String getShortString​(org.eclipse.swt.graphics.GC gc, java.lang.String t, int width)
      Deprecated.
      when text is large, performance is poor, possible occur OOM exception.
      static java.lang.String getShortText​(org.eclipse.swt.graphics.GC gc, java.lang.String t, int width)
      Deprecated.
      when text is large, performance is poor, possible occur OOM exception.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getShortText

        @Deprecated
        public static java.lang.String getShortText​(org.eclipse.swt.graphics.GC gc,
                                                    java.lang.String t,
                                                    int width)
        Deprecated.
        when text is large, performance is poor, possible occur OOM exception. suggest use getShortStr(GC, String, int)
        Shortens a supplied string so that it fits within the area specified by the width argument. Strings that have been shorted have an "..." attached to the end of the string. The width is computed using the GC.textExtent(String).
        Parameters:
        gc - GC used to perform calculation.
        t - text to modify.
        width - Pixels to display.
        Returns:
        shortened string that fits in area specified.
      • getShortString

        @Deprecated
        public static java.lang.String getShortString​(org.eclipse.swt.graphics.GC gc,
                                                      java.lang.String t,
                                                      int width)
        Deprecated.
        when text is large, performance is poor, possible occur OOM exception. suggest use getShortStr(GC, String, int)
        Shortens a supplied string so that it fits within the area specified by the width argument. Strings that have been shorted have an "..." attached to the end of the string. The width is computed using the GC.stringExtent(String).
        Parameters:
        gc - GC used to perform calculation.
        t - text to modify.
        width - Pixels to display.
        Returns:
        shortened string that fits in area specified.
      • getShortStr

        public static java.lang.String getShortStr​(org.eclipse.swt.graphics.GC gc,
                                                   java.lang.String t,
                                                   int width)
        Shortens a supplied string so that it fits within the area specified by the width argument. Strings that have been shorted have an "..." attached to the end of the string. The width is computed using the GC.getCharWidth(char).
        Parameters:
        gc - GC used to perform calculation.
        t - text to modify.
        width - Pixels to display.
        Returns:
        shortened string that fits in area specified.