Class TextToImageSlicer

java.lang.Object
com.vuzix.ultralite.utils.scroll.TextToImageSlicer

public class TextToImageSlicer extends Object

Utility class to convert blocks of text to image slices to send to the SCROLL layout.

This class does not interact with the glasses in any way. This is a convenience class to manipulates local data to create content that is appropriate to send to the glasses via the SDK.

This is used internally by AutoScroller and TextToImageSlicer, and may also be used directly.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    TextToImageSlicer(String stringToSlice, int sliceHeight, int fontSize)
    Construct a slicer to convert a block of text to a series of image slices that can be sent to the SCROLL layout.
    TextToImageSlicer(String stringToSlice, int sliceHeight, int fontSize, int paddingPx)
    Construct a slicer to convert a block of text to a series of image slices that can be sent to the SCROLL layout.
    TextToImageSlicer(String stringToSlice, int sliceHeight, android.text.TextPaint textPaint, int paddingPx)
    Construct a slicer to convert a block of text to a series of image slices that can be sent to the SCROLL layout.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Find the first sliced line with a difference between two TextToImageSlicer objects
    Call this to get the next sequential line of text rendered to an image.
    int
    Determine the number of lines into which we have sliced the given text
    getSliceAt(int lineIndex)
    Call this to get a specific line of text rendered to an image.
    getStringAt(int lineIndex)
    Call this to get a specific line of text that will fit in a slice.
    You may loop calling getNextSlice() as long as hasMoreSlices() is true
    Call this to peek at the next sequential line of text that will be used if you call getNextSlice()

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TextToImageSlicer

      public TextToImageSlicer(String stringToSlice, int sliceHeight, int fontSize)
      Construct a slicer to convert a block of text to a series of image slices that can be sent to the SCROLL layout.
      Parameters:
      stringToSlice - String containing text to display
      sliceHeight - Height of each slice as configured in scrollLayoutConfig()
      fontSize - Point size of the font
    • TextToImageSlicer

      public TextToImageSlicer(String stringToSlice, int sliceHeight, int fontSize, int paddingPx)
      Construct a slicer to convert a block of text to a series of image slices that can be sent to the SCROLL layout.
      Parameters:
      stringToSlice - String containing text to display
      sliceHeight - Height of each slice as configured in scrollLayoutConfig()
      fontSize - Point size of the font
      paddingPx - Pixels on the device window to pad both left and right side
    • TextToImageSlicer

      public TextToImageSlicer(String stringToSlice, int sliceHeight, android.text.TextPaint textPaint, int paddingPx)
      Construct a slicer to convert a block of text to a series of image slices that can be sent to the SCROLL layout.
      Parameters:
      stringToSlice - String containing text to display
      sliceHeight - Height of each slice as configured in scrollLayoutConfig()
      textPaint - Defines the specific look of the text
      paddingPx - Pixels on the device window to pad both left and right side
  • Method Details

    • peekSliceText

      public String peekSliceText()
      Call this to peek at the next sequential line of text that will be used if you call getNextSlice()
      Returns:
      String containing one line of text that will be rendered to the next image slice
    • getNextSlice

      public LVGLImage getNextSlice()
      Call this to get the next sequential line of text rendered to an image. Continue until it returns null, or until hasMoreSlices() returns false. Each call to this method increments an internal iterator.
      Returns:
      LVGLImage containing a single line of text rendered to an image
    • getSliceAt

      public LVGLImage getSliceAt(int lineIndex)
      Call this to get a specific line of text rendered to an image.
      Parameters:
      lineIndex - zero-based index, up to ( getNumLines()-1 )
      Returns:
      LVGLImage containing a single line of text rendered to an image
    • getStringAt

      public String getStringAt(int lineIndex)
      Call this to get a specific line of text that will fit in a slice.
      Parameters:
      lineIndex - zero-based index, up to ( getNumLines()-1 )
      Returns:
      String of text
    • hasMoreSlices

      public Boolean hasMoreSlices()
      You may loop calling getNextSlice() as long as hasMoreSlices() is true
      Returns:
      - True if calling getNextSlice() will return a valid image
    • getNumLines

      public int getNumLines()
      Determine the number of lines into which we have sliced the given text
      Returns:
      number of lines of text after formatting to lines
    • firstDifferentIndexFrom

      public int firstDifferentIndexFrom(TextToImageSlicer that)
      Find the first sliced line with a difference between two TextToImageSlicer objects
      Parameters:
      that - TextToImageSlicer object against which to compare
      Returns:
      Valid zero-based index of the first line with a difference, or negative if both objects have the same content. Note, a non-negative index is guaranteed to be valid in at least one of the objects, but may be out of bounds in the other.