Package com.vuzix.ultralite.utils.scroll
Class TextToImageSlicer
java.lang.Object
com.vuzix.ultralite.utils.scroll.TextToImageSlicer
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
ConstructorDescriptionTextToImageSlicer
(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 TypeMethodDescriptionint
Find the first sliced line with a difference between two TextToImageSlicer objectsCall 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 textgetSliceAt
(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 trueCall this to peek at the next sequential line of text that will be used if you call getNextSlice()
-
Constructor Details
-
TextToImageSlicer
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 displaysliceHeight
- Height of each slice as configured in scrollLayoutConfig()fontSize
- Point size of the font
-
TextToImageSlicer
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 displaysliceHeight
- Height of each slice as configured in scrollLayoutConfig()fontSize
- Point size of the fontpaddingPx
- 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 displaysliceHeight
- Height of each slice as configured in scrollLayoutConfig()textPaint
- Defines the specific look of the textpaddingPx
- Pixels on the device window to pad both left and right side
-
-
Method Details
-
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
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
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
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
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
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.
-