/** * 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; }
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; }
/** * 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); }
/** * 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); }
/** * 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); }
int lastChar = getElementEndIndex(element);
int lastChar = getElementEndIndex(element);
int lastChar = getElementEndIndex(element);