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(); }
public void setSelection(Mark begin, Mark end) { TextNode node = begin.getTextNode(); if (node != end.getTextNode()) { throw new Error("Markers not from same TextNode"); } node.setSelection(begin, end); selectionNode = node; selectionNodeRoot = node.getRoot(); Object selection = getSelection(); Shape shape = node.getHighlightShape(); dispatchSelectionEvent(new SelectionEvent (selection, SelectionEvent.SELECTION_DONE, shape)); }
/** * Create a text element bridge. * * This set the text painter on the node if the text is simple. * @param ctx the bridge context * @param e the svg element * @return the text graphics node created by the super class */ public GraphicsNode createGraphicsNode(BridgeContext ctx, Element e) { GraphicsNode node = super.createGraphicsNode(ctx, e); if (node != null) { //Set our own text painter ((TextNode)node).setTextPainter(textPainter); } return node; }
/** * Sets the location of this text node. * * @param newLocation the new location of this text node */ public void setLocation(Point2D newLocation){ fireGraphicsNodeChangeStarted(); invalidateGeometryCache(); this.location = newLocation; fireGraphicsNodeChangeCompleted(); }
/** * Retrieve the list of layout for the * text node. */ protected List getTextRuns(TextNode node){ //System.out.println(node.getTextRuns()); if ( node.getTextRuns() == null ){ //TODO : need to work out a solution //to compute the text runs node.getPrimitiveBounds(); } //System.out.println(node.getTextRuns()); return node.getTextRuns(); }
/** * Selects the first glyph in the text node. */ public Mark selectFirst(TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; TextHit textHit = new TextHit(aci.getBeginIndex(), false); return new BasicTextPainter.BasicMark(node, textHit); }
String text = textNode.getText(); String pattern = search.getText(); if (!caseSensitive.isSelected()) { textNode.getAttributedCharacterIterator(); aci.first(); for (int i=0; i < end; ++i) { aci.next(); Mark startMark = textNode.getMarkerForChar(aci.getIndex(), true); Mark endMark = textNode.getMarkerForChar(aci.getIndex(), false); svgCanvas.select(startMark, endMark); Shape s = textNode.getHighlightShape(); AffineTransform at; if (highlightCenterZoomButton.isSelected()) {
List list = tn.getTextRuns(); if (list == null) return elems;
List list = tn.getTextRuns(); if (list == null) return false; AffineTransform at = tn.getGlobalTransform(); at.preConcatenate(ati); tnRect = tn.getBounds(); tnRect = at.createTransformedShape(tnRect).getBounds2D(); if (!rect.intersects(tnRect)) return false;
protected void rebuildACI() { if (hasNewACI) return; TextNode textNode = getTextNode(); if (textNode.getAttributedCharacterIterator() == null) return; TextPaintInfo pi, oldPI; if ( cssProceedElement == e ){ pi = new TextPaintInfo(); setBaseTextPaintInfo(pi, e, node, ctx); setDecorationTextPaintInfo(pi, e); oldPI = (TextPaintInfo)elemTPI.get(e); } else { //if a child CSS property has changed, then //retrieve the parent text decoration //and only update the section of the AtrtibutedString of //the child TextPaintInfo parentPI; parentPI = getParentTextPaintInfo(cssProceedElement); pi = getTextPaintInfo(cssProceedElement, textNode, parentPI, ctx); oldPI = (TextPaintInfo)elemTPI.get(cssProceedElement); } if (oldPI == null) return; textNode.swapTextPaintInfo(pi, oldPI); if (usingComplexSVGFont) // Force Complex SVG fonts to be recreated textNode.setAttributedCharacterIterator (textNode.getAttributedCharacterIterator()); }
node.setTextPainter(ctx.getTextPainter()); hints = CSSUtilities.convertTextRendering (e, hints); if (hints != null) node.setRenderingHints(hints); node.setLocation(getLocation(ctx, e));
/** * Returns true if the specified Point2D is inside the boundary of this * node, false otherwise. * * @param p the specified Point2D in the user space */ public boolean contains(Point2D p) { // <!> FIXME: should put this code in TextPaint somewhere, // as pointer-events support - same problem with pointer-events // and ShapeNode if (!super.contains(p)) { return false; } List list = getTextRuns(); // place coords in text node coordinate system for (int i = 0 ; i < list.size(); i++) { StrokingTextPainter.TextRun run = (StrokingTextPainter.TextRun)list.get(i); TextSpanLayout layout = run.getLayout(); float x = (float)p.getX(); float y = (float)p.getY(); TextHit textHit = layout.hitTestChar(x, y); if (textHit != null && contains(p, layout.getBounds2D())) { return true; } } return false; }
/** * Select an ensemble of characters for that element. * * TODO : report the selection to the selection * manager in JSVGComponent. */ protected void selectSubString(Element element, int charnum, int nchars) { TextNode textNode = getTextNode(); AttributedCharacterIterator aci; aci = textNode.getAttributedCharacterIterator(); if (aci == null) return; int firstChar = getElementStartIndex(element); if ( firstChar == -1 ) return; List list = getTextRuns(textNode); int lastChar = getElementEndIndex(element); CharacterInformation firstInfo, lastInfo; firstInfo = getCharacterInformation(list, firstChar,charnum,aci); lastInfo = getCharacterInformation(list, firstChar,charnum+nchars-1,aci); Mark firstMark, lastMark; firstMark = textNode.getMarkerForChar(firstInfo.characterIndex,true); if ( lastInfo != null && lastInfo.characterIndex <= lastChar ){ lastMark = textNode.getMarkerForChar(lastInfo.characterIndex,false); } else{ lastMark = textNode.getMarkerForChar(lastChar,false); } ctx.getUserAgent().setTextSelection(firstMark,lastMark); }
/** * Paints the specified attributed character iterator using the * specified Graphics2D and context and font context. * * @param node the TextNode to paint * @param g2d the Graphics2D to use */ public void paint(TextNode node, Graphics2D g2d) { if (isSupportedGraphics2D(g2d)) { new TextRunPainter().paintTextRuns(node.getTextRuns(), g2d, node.getLocation()); } proxyTextPainter.paint(node, g2d); }
int currentChunk = 0; Point2D location = node.getLocation(); do {
/** * Creates the GraphicsNode depending on the GraphicsNodeBridge * implementation. */ protected GraphicsNode instantiateGraphicsNode() { return new TextNode(); }
/** * Sets the location of this text node. * * @param newLocation the new location of this text node */ public void setLocation(Point2D newLocation){ fireGraphicsNodeChangeStarted(); invalidateGeometryCache(); this.location = newLocation; fireGraphicsNodeChangeCompleted(); }
/** * Selects the first glyph in the text node. */ public Mark selectFirst(TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; TextHit textHit = new TextHit(aci.getBeginIndex(), false); return new BasicTextPainter.BasicMark(node, textHit); }
String text = textNode.getText(); String pattern = search.getText(); if (!caseSensitive.isSelected()) { textNode.getAttributedCharacterIterator(); aci.first(); for (int i=0; i < end; ++i) { aci.next(); Mark startMark = textNode.getMarkerForChar(aci.getIndex(), true); Mark endMark = textNode.getMarkerForChar(aci.getIndex(), false); svgCanvas.select(startMark, endMark); Shape s = textNode.getHighlightShape(); AffineTransform at; if (highlightCenterZoomButton.isSelected()) {
List list = tn.getTextRuns(); if (list == null) return elems;