public List getTextRuns(TextNode node, AttributedCharacterIterator aci) { List textRuns = node.getTextRuns(); if (textRuns != null) { return textRuns; } AttributedCharacterIterator[] chunkACIs = getTextChunkACIs(aci); textRuns = computeTextRuns(node, aci, chunkACIs); // cache the textRuns so don't need to recalculate node.setTextRuns(textRuns); return node.getTextRuns(); }
@Override protected Set getTextRunBoundaryAttributes() { Set textRunBoundaryAttributes = super.getTextRunBoundaryAttributes(); if (!textRunBoundaryAttributes.contains(BIDI_LEVEL)) { textRunBoundaryAttributes.add(BIDI_LEVEL); } return textRunBoundaryAttributes; }
/** * Paints the specified text node using the specified Graphics2D. * * @param node the text node to paint * @param g2d the Graphics2D to use */ public void paint(TextNode node, Graphics2D g2d) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return; List textRuns = getTextRuns(node, aci); // draw the underline and overline first, then the actual text // and finally the strikethrough paintDecorations(textRuns, g2d, TextSpanLayout.DECORATION_UNDERLINE); paintDecorations(textRuns, g2d, TextSpanLayout.DECORATION_OVERLINE); paintTextRuns(textRuns, g2d); paintDecorations (textRuns, g2d, TextSpanLayout.DECORATION_STRIKETHROUGH); }
chunkACIs [i] = createModifiedACIForFontMatching(chunkACIs[i]); chunkStart += (chunkACIs[i].getEndIndex() - chunkACIs[i].getBeginIndex()); chunk = getTextChunk(node, chunkACIs[currentChunk], chunkCharMaps != null ? chunkCharMaps[currentChunk] : null, perChunkRuns = reorderTextRuns(chunk, perChunkRuns); location = adjustChunkOffsets(location, perChunkRuns, chunk);
boolean isChunkStart = true; TextSpanLayout layout = null; Set textRunBoundaryAttributes = getTextRunBoundaryAttributes(); do { int start = aci.getRunStart(textRunBoundaryAttributes); layout = getTextLayoutFactory().createTextLayout (runaci, subCharMap, offset, frc);
List textRuns = getTextRuns(node, aci); Shape underline = getDecorationOutline (textRuns, TextSpanLayout.DECORATION_UNDERLINE); Shape strikeThrough = getDecorationOutline (textRuns, TextSpanLayout.DECORATION_STRIKETHROUGH); Shape overline = getDecorationOutline (textRuns, TextSpanLayout.DECORATION_OVERLINE);
List textRuns = getTextRuns(node, aci); Shape underline = getDecorationStrokeOutline (textRuns, TextSpanLayout.DECORATION_UNDERLINE); Shape strikeThrough = getDecorationStrokeOutline (textRuns, TextSpanLayout.DECORATION_STRIKETHROUGH); if (strikeThrough != null) { Shape overline = getDecorationStrokeOutline (textRuns, TextSpanLayout.DECORATION_OVERLINE); if (overline != null) {
@Override public List computeTextRuns(TextNode node, AttributedCharacterIterator nodeACI, AttributedCharacterIterator [] chunkACIs) { nodeACI.first(); int defaultBidiLevel = (((Integer) nodeACI.getAttribute(WRITING_MODE)).intValue() == WRITING_MODE_RTL) ? 1 : 0; for (int i = 0, n = chunkACIs.length; i < n; ++i) { chunkACIs[i] = new BidiAttributedCharacterIterator(chunkACIs[i], defaultBidiLevel); } return super.computeTextRuns(node, nodeACI, chunkACIs, null); }
@Override protected void paintTextRuns(@SuppressWarnings("rawtypes") List textRuns, Graphics2D g2d) { if (log.isTraceEnabled()) { log.trace("paintTextRuns: count = " + textRuns.size()); } if (!isSupported(g2d)) { super.paintTextRuns(textRuns, g2d); return; } for (Object textRun1 : textRuns) { TextRun textRun = (TextRun) textRun1; try { paintTextRun(textRun, g2d); } catch (IOException ioe) { //No other possibility than to use a RuntimeException throw new RuntimeException(ioe); } } }
/** * Sets the text painter of this text node. If the specified text * painter is null, this text node will use its default text * painter (StrokingTextPainter.getInstance()). * * @param textPainter the text painter to use */ public void setTextPainter(TextPainter textPainter) { if (textPainter == null) { this.textPainter = StrokingTextPainter.getInstance(); } else { this.textPainter = textPainter; } }
fonts.add(getFontFamilyResolver().getDefault().deriveFont(fontSize, aci)); char c = aci.setIndex(start+i); GVTFontFamily fontFamily; fontFamily = getFontFamilyResolver().getFamilyThatCanDisplay(c);
chunkACIs [i] = createModifiedACIForFontMatching(chunkACIs[i]); chunkStart += (chunkACIs[i].getEndIndex() - chunkACIs[i].getBeginIndex()); chunk = getTextChunk(node, chunkACIs[currentChunk], chunkCharMaps != null ? chunkCharMaps[currentChunk] : null, perChunkRuns = reorderTextRuns(chunk, perChunkRuns); location = adjustChunkOffsets(location, perChunkRuns, chunk);
boolean isChunkStart = true; TextSpanLayout layout = null; Set textRunBoundaryAttributes = getTextRunBoundaryAttributes(); do { int start = aci.getRunStart(textRunBoundaryAttributes); layout = getTextLayoutFactory().createTextLayout (runaci, subCharMap, offset, frc);
List textRuns = getTextRuns(node, aci); Shape underline = getDecorationOutline (textRuns, TextSpanLayout.DECORATION_UNDERLINE); Shape strikeThrough = getDecorationOutline (textRuns, TextSpanLayout.DECORATION_STRIKETHROUGH); Shape overline = getDecorationOutline (textRuns, TextSpanLayout.DECORATION_OVERLINE);
List textRuns = getTextRuns(node, aci); Shape underline = getDecorationStrokeOutline (textRuns, TextSpanLayout.DECORATION_UNDERLINE); Shape strikeThrough = getDecorationStrokeOutline (textRuns, TextSpanLayout.DECORATION_STRIKETHROUGH); if (strikeThrough != null) { Shape overline = getDecorationStrokeOutline (textRuns, TextSpanLayout.DECORATION_OVERLINE); if (overline != null) {
public List computeTextRuns(TextNode node, AttributedCharacterIterator aci, AttributedCharacterIterator [] chunkACIs) { int [][] chunkCharMaps = new int[chunkACIs.length][]; // reorder each chunk ACI for bidi text int chunkStart = aci.getBeginIndex(); for (int i = 0; i < chunkACIs.length; i++) { BidiAttributedCharacterIterator iter; iter = new BidiAttributedCharacterIterator (chunkACIs[i], fontRenderContext, chunkStart); chunkACIs [i] = iter; chunkCharMaps[i] = iter.getCharMap(); chunkStart += (chunkACIs[i].getEndIndex()- chunkACIs[i].getBeginIndex()); } return computeTextRuns(node, aci, chunkACIs, chunkCharMaps); }
/** * Sets the text painter of this text node. If the specified text * painter is null, this text node will use its default text * painter (StrokingTextPainter.getInstance()). * * @param textPainter the text painter to use */ public void setTextPainter(TextPainter textPainter) { if (textPainter == null) { this.textPainter = StrokingTextPainter.getInstance(); } else { this.textPainter = textPainter; } }
fonts.add(getFontFamilyResolver().getDefault().deriveFont(fontSize, aci)); char c = aci.setIndex(start+i); GVTFontFamily fontFamily; fontFamily = getFontFamilyResolver().getFamilyThatCanDisplay(c);
chunkACIs [i] = createModifiedACIForFontMatching(chunkACIs[i]); chunkStart += (chunkACIs[i].getEndIndex() - chunkACIs[i].getBeginIndex()); chunk = getTextChunk(node, chunkACIs[currentChunk], chunkCharMaps != null ? chunkCharMaps[currentChunk] : null, perChunkRuns = reorderTextRuns(chunk, perChunkRuns); location = adjustChunkOffsets(location, perChunkRuns, chunk);
/** * Paints the specified text node using the specified Graphics2D. * * @param node the text node to paint * @param g2d the Graphics2D to use */ public void paint(TextNode node, Graphics2D g2d) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return; List textRuns = getTextRuns(node, aci); // draw the underline and overline first, then the actual text // and finally the strikethrough paintDecorations(textRuns, g2d, TextSpanLayout.DECORATION_UNDERLINE); paintDecorations(textRuns, g2d, TextSpanLayout.DECORATION_OVERLINE); paintTextRuns(textRuns, g2d); paintDecorations (textRuns, g2d, TextSpanLayout.DECORATION_STRIKETHROUGH); }