Java 8 LineBreakMeasurer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 LineBreakMeasurer class.

This code example shows how to use the following methods:getPosition, nextLayout, setPosition
 
  protected TextLayout postProcess(final int start,
                                   final TextLayout textLayout,
                                   final LineBreakMeasurer lineBreakMeasurer)
  { 
    int end = lineBreakMeasurer.getPosition();
    final TextLayout layout = performWordBreak(start, textLayout, lineBreakMeasurer, end);
    return super.postProcess(start, layout, lineBreakMeasurer);
  } 
 
  private TextLayout performWordBreak(final int start,
                                      final TextLayout textLayout,
                                      final LineBreakMeasurer lineBreakMeasurer, final int end)
  { 
    final TextLayout layout;
    if (wordInstance.isBoundary(end) != false)
    { 
      return textLayout;
    } 
 

6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:nextLayout
 
  private static TextLayout getNextLayout(TextModel model, LineBreakMeasurer breaker, int returnCharIndex, ArrayList<Integer> newLineCharIndices)
  { 
    TextLayout layout;
    if(thereAreMoreReturnCharacters(returnCharIndex, newLineCharIndices))
      layout = breaker.nextLayout(model.getContainer().getWidth(), newLineCharIndices.get(returnCharIndex) + 1, false);
    else 
      layout = breaker.nextLayout(model.getContainer().getWidth());
    return layout;
  } 
 
  private static boolean isTheVeryLastCharANewLineChar(String text)
  { 
    return text.endsWith("\n") || text.endsWith("\r\n");
  } 
 
  private static boolean thereAreMoreReturnCharacters(int returnCharIndex, ArrayList<Integer> newLineCharIndices)
  { 
    return newLineCharIndices != null && returnCharIndex < newLineCharIndices.size();
  } 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getPosition, nextLayout
  } 
 
  public LineBreakIteratorState next() 
  { 
    // For each line produced by the LinebreakMeasurer 
    int start = lineBreakMeasurer.getPosition();
    // float is the worst option to have accurate layouts. So we have to 'adjust' for rounding errors 
    // and hope that no one notices .. 
    TextLayout textLayout = lineBreakMeasurer.nextLayout(wrappingWidth + 0.5f, ci.getEndIndex(), false);
    textLayout = postProcess(start, textLayout, lineBreakMeasurer);
    int end = lineBreakMeasurer.getPosition();
 
    // check if the text must be justified 
 
    return new LineBreakIteratorState(textLayout, start, end);
  } 
 
  protected TextLayout postProcess(final int start,
                                   final TextLayout textLayout,
                                   final LineBreakMeasurer lineBreakMeasurer)
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getPosition, nextLayout
            } else { 
                y += ascent * lineHeight;
            } 
            float layoutWidth = width == 0 ? Float.MAX_VALUE : (float) width;
 
            TextLayout layout = currentMeasurer.nextLayout(layoutWidth);
            if (width == 0) {
                layoutWidth = layout.getAdvance();
                if (align == Align.RIGHT) {
                    x = -layoutWidth;
                } else if (align == Align.CENTER) {
                    x = -layoutWidth / 2.0F;
                } 
            } else if (align == Align.RIGHT) {
                x = (float) (width - layout.getAdvance());
            } else if (align == Align.CENTER) {
                x = (float) ((width - layout.getAdvance()) / 2.0F);
            } else if (align == Align.JUSTIFY) {
                // Don't justify the last line. 
                if (currentMeasurer.getPosition() < currentText.length()) {

4
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 LineBreakMeasurer Methods: