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.
- Since:
- 1.4.0
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Detailed results of comparing two slice objects -
Constructor Summary
ConstructorDescriptionCreate a deep copy of the TextToImageSlicerTextToImageSlicer
(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 TypeMethodDescriptioncompareTo
(TextToImageSlicer that) Compare one TextToImageSlicer to another for detailed resultsvoid
discardLeadingLines
(int numberToDiscard) Discard the leading lines of textint
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()void
replaceLineFrom
(TextToImageSlicer that, int indexToCopy) Replace a line in the current sliced text with a line from another textToImageSlicertoString()
Return the string currently being sliced, useful for debuggingvoid
truncateToLine
(int numLinesNeeded) Truncate this sliced text to a given number of lines.
-
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- Since:
- 1.4.0
-
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- Since:
- 1.4.0
-
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- Since:
- 1.4.0
-
TextToImageSlicer
Create a deep copy of the TextToImageSlicer- Parameters:
from
- TextToImageSlicer to copy- Since:
- 1.7.0
-
-
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
- Since:
- 1.4.0
-
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
- Since:
- 1.4.0
-
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
- Since:
- 1.4.0
-
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
- Since:
- 1.4.0
-
hasMoreSlices
You may loop calling getNextSlice() as long as hasMoreSlices() is true- Returns:
- - True if calling getNextSlice() will return a valid image
- Since:
- 1.4.0
-
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
- Since:
- 1.4.0
-
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.
- Since:
- 1.4.0
-
toString
Return the string currently being sliced, useful for debugging -
compareTo
Compare one TextToImageSlicer to another for detailed results- Parameters:
that
- TextToImageSlicer object against which to compare this object- Returns:
- SliceComparison object containing deatils about the simliarities and differences
- Since:
- 1.7.0
-
discardLeadingLines
public void discardLeadingLines(int numberToDiscard) Discard the leading lines of text- Parameters:
numberToDiscard
- Number of lines to discard from the beginning- Since:
- 1.7.0
-
truncateToLine
public void truncateToLine(int numLinesNeeded) Truncate this sliced text to a given number of lines. Discard the remaining lines from the end. This may be useful when scrolling a subset of the text and adding it to the screen over time.- Parameters:
numLinesNeeded
- Number of lines to retain from the current sliced text- Since:
- 1.7.0
-
replaceLineFrom
Replace a line in the current sliced text with a line from another textToImageSlicer- Parameters:
that
- TextToImageSlicer from which we will copy the line of textindexToCopy
- Zero-based index identifying the line to copy- Since:
- 1.7.0
-