/** * 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; }
/** * 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 (Object aList : list) { StrokingTextPainter.TextRun run = (StrokingTextPainter.TextRun) aList; 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; }
AttributedCharacterIterator aci = run.getACI(); TextSpanLayout layout = run.getLayout(); TextHit textHit = layout.hitTestChar(x, y); Rectangle2D bounds = layout.getBounds2D(); if ((textHit != null) &&
/** * 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 (Object aList : list) { StrokingTextPainter.TextRun run = (StrokingTextPainter.TextRun) aList; 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; }
protected Mark hitTest(double x, double y, TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; // get the list of text runs List textRuns = getTextRuns(node, aci); if (textRuns != null) { // for each text run, see if its been hit for (int i = 0; i < textRuns.size(); ++i) { TextRun textRun = (TextRun)textRuns.get(i); TextSpanLayout layout = textRun.getLayout(); TextHit textHit = layout.hitTestChar((float) x, (float) y); Rectangle2D bounds = layout.getBounds2D(); if ((textHit != null) && (bounds != null) && bounds.contains(x,y)) return new BasicTextPainter.BasicMark(node, textHit); } } return null; }
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; }
AttributedCharacterIterator aci = run.getACI(); TextSpanLayout layout = run.getLayout(); TextHit textHit = layout.hitTestChar(x, y); Rectangle2D bounds = layout.getBounds2D(); if ((textHit != null) &&
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; }
AttributedCharacterIterator aci = run.getACI(); TextSpanLayout layout = run.getLayout(); TextHit textHit = layout.hitTestChar(x, y); Rectangle2D bounds = layout.getBounds2D(); if ((textHit != null) &&
protected Mark hitTest(double x, double y, TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; // get the list of text runs List textRuns = getTextRuns(node, aci); if (textRuns != null) { // for each text run, see if its been hit for (Object textRun1 : textRuns) { TextRun textRun = (TextRun) textRun1; TextSpanLayout layout = textRun.getLayout(); TextHit textHit = layout.hitTestChar((float) x, (float) y); Rectangle2D bounds = layout.getBounds2D(); if ((textHit != null) && (bounds != null) && bounds.contains(x, y)) return new BasicMark(node, textHit); } } return null; }
protected Mark hitTest(double x, double y, TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; // get the list of text runs List textRuns = getTextRuns(node, aci); if (textRuns != null) { // for each text run, see if its been hit for (Object textRun1 : textRuns) { TextRun textRun = (TextRun) textRun1; TextSpanLayout layout = textRun.getLayout(); TextHit textHit = layout.hitTestChar((float) x, (float) y); Rectangle2D bounds = layout.getBounds2D(); if ((textHit != null) && (bounds != null) && bounds.contains(x, y)) return new BasicMark(node, textHit); } } return null; }