private void appendStyleRun(Styler style, int offset) { StyleRun lastRun = getLastRun(); if (lastRun != null && lastRun.offset == offset) { lastRun.style = style; return; } if (lastRun == null && style != null || lastRun != null && isDifferentStyle(style, lastRun.style)) { getStyleRuns().add(new StyleRun(offset, style)); } }
/** * Returns an array of {@link StyleRange} resulting from applying all * associated stylers for this string builder. * * @return an array of all {@link StyleRange} resulting from applying the * stored stylers to this string. */ public StyleRange[] getStyleRanges() { if (hasRuns()) { ArrayList<StyleRange> res = new ArrayList<>(); List<StyleRun> styleRuns = getStyleRuns(); int offset = 0; Styler style = null; for (int i = 0; i < styleRuns.size(); i++) { StyleRun curr = styleRuns.get(i); if (isDifferentStyle(curr.style, style)) { if (curr.offset > offset && style != null) { res.add(createStyleRange(offset, curr.offset, style)); } offset = curr.offset; style = curr.style; } } if (fBuffer.length() > offset && style != null) { res.add(createStyleRange(offset, fBuffer.length(), style)); } return res.toArray(new StyleRange[res.size()]); } return EMPTY; }
/** * Returns an array of {@link StyleRange} resulting from applying all * associated stylers for this string builder. * * @return an array of all {@link StyleRange} resulting from applying the * stored stylers to this string. */ public StyleRange[] getStyleRanges() { if (hasRuns()) { ArrayList res = new ArrayList(); List styleRuns = getStyleRuns(); int offset = 0; Styler style = null; for (int i = 0; i < styleRuns.size(); i++) { StyleRun curr = (StyleRun) styleRuns.get(i); if (isDifferentStyle(curr.style, style)) { if (curr.offset > offset && style != null) { res.add(createStyleRange(offset, curr.offset, style)); } offset = curr.offset; style = curr.style; } } if (fBuffer.length() > offset && style != null) { res.add(createStyleRange(offset, fBuffer.length(), style)); } return (StyleRange[]) res.toArray(new StyleRange[res.size()]); } return EMPTY; }
private void appendStyleRun(Styler style, int offset) { StyleRun lastRun = getLastRun(); if (lastRun != null && lastRun.offset == offset) { lastRun.style = style; return; } if (lastRun == null && style != null || lastRun != null && isDifferentStyle(style, lastRun.style)) { getStyleRuns().add(new StyleRun(offset, style)); } }
if (isDifferentStyle(prevStyle, styler) || (startRun == 0 && styler != null)) { fStyleRuns.add(startRun, new StyleRun(offset, styler));
if (isDifferentStyle(prevStyle, styler) || (startRun == 0 && styler != null)) { fStyleRuns.add(startRun, new StyleRun(offset, styler));