/** * Invoked when an MutationEvent of type 'DOMSubtree' is fired. */ public void handleDOMSubtreeModifiedEvent(MutationEvent evt) { //an operation occured onto the children of the //text element, check if the layout was discarded if (laidoutText == null) { computeLaidoutText(ctx, e, getTextNode()); } }
/** * Invoked when an MutationEvent of type 'DOMSubtree' is fired. */ public void handleDOMSubtreeModifiedEvent(MutationEvent evt) { //an operation occured onto the children of the //text element, check if the layout was discarded if (laidoutText == null) { computeLaidoutText(ctx, e, getTextNode()); } }
/** * Invoked when an MutationEvent of type 'DOMSubtree' is fired. */ public void handleDOMSubtreeModifiedEvent(MutationEvent evt) { //an operation occured onto the children of the //text element, check if the layout was discarded if (laidoutText == null) { computeLaidoutText(ctx, e, getTextNode()); } }
/** * Invoked when the animated value of an animatable attribute has * changed on a 'tref' element. */ public void handleAnimatedAttributeChanged (AnimatedLiveAttributeValue alav) { if (alav.getNamespaceURI() == null) { String ln = alav.getLocalName(); if (ln.equals(SVG_X_ATTRIBUTE) || ln.equals(SVG_Y_ATTRIBUTE) || ln.equals(SVG_DX_ATTRIBUTE) || ln.equals(SVG_DY_ATTRIBUTE) || ln.equals(SVG_ROTATE_ATTRIBUTE) || ln.equals(SVG_TEXT_LENGTH_ATTRIBUTE) || ln.equals(SVG_LENGTH_ADJUST_ATTRIBUTE)) { // Recompute the layout of the text node. textBridge.computeLaidoutText(ctx, textBridge.e, textBridge.getTextNode()); return; } } super.handleAnimatedAttributeChanged(alav); } }
/** * Invoked when the animated value of an animatable attribute has changed. */ public void handleAnimatedAttributeChanged (AnimatedLiveAttributeValue alav) { if (alav.getNamespaceURI() == null) { String ln = alav.getLocalName(); if (ln.equals(SVG_X_ATTRIBUTE) || ln.equals(SVG_Y_ATTRIBUTE) || ln.equals(SVG_DX_ATTRIBUTE) || ln.equals(SVG_DY_ATTRIBUTE) || ln.equals(SVG_ROTATE_ATTRIBUTE) || ln.equals(SVG_TEXT_LENGTH_ATTRIBUTE) || ln.equals(SVG_LENGTH_ADJUST_ATTRIBUTE)) { char c = ln.charAt(0); if (c == 'x' || c == 'y') { getTextNode().setLocation(getLocation(ctx, e)); } computeLaidoutText(ctx, e, getTextNode()); return; } } super.handleAnimatedAttributeChanged(alav); }
/** * Invoked when the animated value of an animatable attribute has * changed on a 'tref' element. */ public void handleAnimatedAttributeChanged (AnimatedLiveAttributeValue alav) { if (alav.getNamespaceURI() == null) { String ln = alav.getLocalName(); if (ln.equals(SVG_X_ATTRIBUTE) || ln.equals(SVG_Y_ATTRIBUTE) || ln.equals(SVG_DX_ATTRIBUTE) || ln.equals(SVG_DY_ATTRIBUTE) || ln.equals(SVG_ROTATE_ATTRIBUTE) || ln.equals(SVG_TEXT_LENGTH_ATTRIBUTE) || ln.equals(SVG_LENGTH_ADJUST_ATTRIBUTE)) { // Recompute the layout of the text node. textBridge.computeLaidoutText(ctx, textBridge.e, textBridge.getTextNode()); return; } } super.handleAnimatedAttributeChanged(alav); } }
/** * Invoked when the animated value of an animatable attribute has * changed on a 'tspan' element. */ public void handleAnimatedAttributeChanged (AnimatedLiveAttributeValue alav) { if (alav.getNamespaceURI() == null) { String ln = alav.getLocalName(); if (ln.equals(SVG_X_ATTRIBUTE) || ln.equals(SVG_Y_ATTRIBUTE) || ln.equals(SVG_DX_ATTRIBUTE) || ln.equals(SVG_DY_ATTRIBUTE) || ln.equals(SVG_ROTATE_ATTRIBUTE) || ln.equals(SVG_TEXT_LENGTH_ATTRIBUTE) || ln.equals(SVG_LENGTH_ADJUST_ATTRIBUTE)) { // Recompute the layout of the text node. textBridge.computeLaidoutText(ctx, textBridge.e, textBridge.getTextNode()); return; } } super.handleAnimatedAttributeChanged(alav); } }
/** * Invoked when the animated value of an animatable attribute has * changed on a 'tref' element. */ public void handleAnimatedAttributeChanged (AnimatedLiveAttributeValue alav) { if (alav.getNamespaceURI() == null) { String ln = alav.getLocalName(); if (ln.equals(SVG_X_ATTRIBUTE) || ln.equals(SVG_Y_ATTRIBUTE) || ln.equals(SVG_DX_ATTRIBUTE) || ln.equals(SVG_DY_ATTRIBUTE) || ln.equals(SVG_ROTATE_ATTRIBUTE) || ln.equals(SVG_TEXT_LENGTH_ATTRIBUTE) || ln.equals(SVG_LENGTH_ADJUST_ATTRIBUTE)) { // Recompute the layout of the text node. textBridge.computeLaidoutText(ctx, textBridge.e, textBridge.getTextNode()); return; } } super.handleAnimatedAttributeChanged(alav); } }
/** * Invoked when the animated value of an animatable attribute has * changed on a 'tspan' element. */ public void handleAnimatedAttributeChanged (AnimatedLiveAttributeValue alav) { if (alav.getNamespaceURI() == null) { String ln = alav.getLocalName(); if (ln.equals(SVG_X_ATTRIBUTE) || ln.equals(SVG_Y_ATTRIBUTE) || ln.equals(SVG_DX_ATTRIBUTE) || ln.equals(SVG_DY_ATTRIBUTE) || ln.equals(SVG_ROTATE_ATTRIBUTE) || ln.equals(SVG_TEXT_LENGTH_ATTRIBUTE) || ln.equals(SVG_LENGTH_ADJUST_ATTRIBUTE)) { // Recompute the layout of the text node. textBridge.computeLaidoutText(ctx, textBridge.e, textBridge.getTextNode()); return; } } super.handleAnimatedAttributeChanged(alav); } }
/** * Implementation of {@link * org.w3c.dom.svg.SVGTextContentElement#getNumberOfChars()}. */ protected int getNumberOfChars(Element element){ AttributedCharacterIterator aci; aci = getTextNode().getAttributedCharacterIterator(); if (aci == null) return 0; //get the index in the aci for the first character //of the element int firstChar = getElementStartIndex(element); if (firstChar == -1) return 0; // Element not part of aci (no chars in elem usually) int lastChar = getElementEndIndex(element); return( lastChar - firstChar + 1 ); }
/** * Implementation of {@link * org.w3c.dom.svg.SVGTextContentElement#getNumberOfChars()}. */ protected int getNumberOfChars(Element element){ AttributedCharacterIterator aci; aci = getTextNode().getAttributedCharacterIterator(); if (aci == null) return 0; //get the index in the aci for the first character //of the element int firstChar = getElementStartIndex(element); if (firstChar == -1) return 0; // Element not part of aci (no chars in elem usually) int lastChar = getElementEndIndex(element); return( lastChar - firstChar + 1 ); }
/** * Implementation of {@link * org.w3c.dom.svg.SVGTextContentElement#getNumberOfChars()}. */ protected int getNumberOfChars(Element element){ AttributedCharacterIterator aci; aci = getTextNode().getAttributedCharacterIterator(); if (aci == null) return 0; //get the index in the aci for the first character //of the element int firstChar = getElementStartIndex(element); if (firstChar == -1) return 0; // Element not part of aci (no chars in elem usually) int lastChar = getElementEndIndex(element); return( lastChar - firstChar + 1 ); }
protected int getCharNumAtPosition(Element e, float x, float y){ TextNode textNode = getTextNode(); AttributedCharacterIterator aci; aci = textNode.getAttributedCharacterIterator(); if (aci == null) return -1; //check if there is an hit List list = getTextRuns(textNode); //going backward in the list to catch the last character // displayed at that position TextHit hit = null; for( int i = list.size()-1 ; i>= 0 && hit == null; i-- ){ StrokingTextPainter.TextRun textRun; textRun = (StrokingTextPainter.TextRun)list.get(i); hit = textRun.getLayout().hitTestChar(x,y); } if ( hit == null ) return -1; //found an hit, check if it belong to the element int first = getElementStartIndex( e ); int last = getElementEndIndex( e ); int hitIndex = hit.getCharIndex(); if ( hitIndex >= first && hitIndex <= last ) return hitIndex - first; return -1; }
protected int getCharNumAtPosition(Element e, float x, float y){ TextNode textNode = getTextNode(); AttributedCharacterIterator aci; aci = textNode.getAttributedCharacterIterator(); if (aci == null) return -1; //check if there is an hit List list = getTextRuns(textNode); //going backward in the list to catch the last character // displayed at that position TextHit hit = null; for( int i = list.size()-1 ; i>= 0 && hit == null; i-- ){ StrokingTextPainter.TextRun textRun; textRun = (StrokingTextPainter.TextRun)list.get(i); hit = textRun.getLayout().hitTestChar(x,y); } if ( hit == null ) return -1; //found an hit, check if it belong to the element int first = getElementStartIndex( e ); int last = getElementEndIndex( e ); int hitIndex = hit.getCharIndex(); if ( hitIndex >= first && hitIndex <= last ) return hitIndex - first; return -1; }
/** * Implementation of {@link * org.w3c.dom.svg.SVGTextContentElement#getEndPositionOfChar(int charnum)}. */ protected Point2D getEndPositionOfChar(Element element,int charnum ){ TextNode textNode = getTextNode(); AttributedCharacterIterator aci; aci = textNode.getAttributedCharacterIterator(); if (aci == null) return null; int firstChar = getElementStartIndex(element); if ( firstChar == -1 ) return null; //retrieve the text run for the text node List list = getTextRuns(textNode); //find the glyph information for the character 'charnum' CharacterInformation info; info = getCharacterInformation(list, firstChar,charnum, aci); if ( info == null ) return null; return getEndPoint(info); }
/** * Implementation of {@link * org.w3c.dom.svg.SVGTextContentElement#getStartPositionOfChar(int charnum)}. */ protected Point2D getStartPositionOfChar(Element element,int charnum){ TextNode textNode = getTextNode(); AttributedCharacterIterator aci; aci = textNode.getAttributedCharacterIterator(); if (aci == null) return null; int firstChar = getElementStartIndex(element); if ( firstChar == -1 ) return null; //retrieve the text run for the text node List list = getTextRuns(textNode); //find the character 'charnum' in the text run CharacterInformation info; info = getCharacterInformation(list, firstChar,charnum, aci); if ( info == null ) return null; return getStartPoint( info ); }
/** * Implementation of {@link * org.w3c.dom.svg.SVGTextContentElement#getEndPositionOfChar(int charnum)}. */ protected Point2D getEndPositionOfChar(Element element,int charnum ){ TextNode textNode = getTextNode(); AttributedCharacterIterator aci; aci = textNode.getAttributedCharacterIterator(); if (aci == null) return null; int firstChar = getElementStartIndex(element); if ( firstChar == -1 ) return null; //retrieve the text run for the text node List list = getTextRuns(textNode); //find the glyph information for the character 'charnum' CharacterInformation info; info = getCharacterInformation(list, firstChar,charnum, aci); if ( info == null ) return null; return getEndPoint(info); }
/** * Implementation of {@link * org.w3c.dom.svg.SVGTextContentElement#getStartPositionOfChar(int charnum)}. */ protected Point2D getStartPositionOfChar(Element element,int charnum){ TextNode textNode = getTextNode(); AttributedCharacterIterator aci; aci = textNode.getAttributedCharacterIterator(); if (aci == null) return null; int firstChar = getElementStartIndex(element); if ( firstChar == -1 ) return null; //retrieve the text run for the text node List list = getTextRuns(textNode); //find the character 'charnum' in the text run CharacterInformation info; info = getCharacterInformation(list, firstChar,charnum, aci); if ( info == null ) return null; return getStartPoint( info ); }
/** * Implementation of {@link * org.w3c.dom.svg.SVGTextContentElement#getStartPositionOfChar(int charnum)}. */ protected Point2D getStartPositionOfChar(Element element,int charnum){ TextNode textNode = getTextNode(); AttributedCharacterIterator aci; aci = textNode.getAttributedCharacterIterator(); if (aci == null) return null; int firstChar = getElementStartIndex(element); if ( firstChar == -1 ) return null; //retrieve the text run for the text node List list = getTextRuns(textNode); //find the character 'charnum' in the text run CharacterInformation info; info = getCharacterInformation(list, firstChar,charnum, aci); if ( info == null ) return null; return getStartPoint( info ); }
/** * Implementation of {@link * org.w3c.dom.svg.SVGTextContentElement#getEndPositionOfChar(int charnum)}. */ protected Point2D getEndPositionOfChar(Element element,int charnum ){ TextNode textNode = getTextNode(); AttributedCharacterIterator aci; aci = textNode.getAttributedCharacterIterator(); if (aci == null) return null; int firstChar = getElementStartIndex(element); if ( firstChar == -1 ) return null; //retrieve the text run for the text node List list = getTextRuns(textNode); //find the glyph information for the character 'charnum' CharacterInformation info; info = getCharacterInformation(list, firstChar,charnum, aci); if ( info == null ) return null; return getEndPoint(info); }