Tabnine Logo
TextSpanLayout.hitTestChar
Code IndexAdd Tabnine to your IDE (free)

How to use
hitTestChar
method
in
org.apache.batik.bridge.TextSpanLayout

Best Java code snippets using org.apache.batik.bridge.TextSpanLayout.hitTestChar (Showing top 12 results out of 315)

origin: fr.avianey.apache-xmlgraphics/batik

/**
 * 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;
}
origin: org.apache.xmlgraphics/batik-bridge

/**
 * 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;
}
origin: fr.avianey.apache-xmlgraphics/batik

AttributedCharacterIterator aci = run.getACI();
TextSpanLayout layout = run.getLayout();
TextHit textHit = layout.hitTestChar(x, y);
Rectangle2D bounds = layout.getBounds2D();
if ((textHit != null) &&
origin: apache/batik

/**
 * 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;
}
origin: fr.avianey.apache-xmlgraphics/batik

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;
}
origin: apache/batik

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;
}
origin: fr.avianey.apache-xmlgraphics/batik

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;
}
origin: org.apache.xmlgraphics/batik-bridge

AttributedCharacterIterator aci = run.getACI();
TextSpanLayout layout = run.getLayout();
TextHit textHit = layout.hitTestChar(x, y);
Rectangle2D bounds = layout.getBounds2D();
if ((textHit != null) &&
origin: org.apache.xmlgraphics/batik-bridge

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;
}
origin: apache/batik

AttributedCharacterIterator aci = run.getACI();
TextSpanLayout layout = run.getLayout();
TextHit textHit = layout.hitTestChar(x, y);
Rectangle2D bounds = layout.getBounds2D();
if ((textHit != null) &&
origin: org.apache.xmlgraphics/batik-bridge

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;
}
origin: apache/batik

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;
}
org.apache.batik.bridgeTextSpanLayouthitTestChar

Javadoc

Perform hit testing for coordinate at x, y.

Popular methods of TextSpanLayout

  • draw
    Paints the specified text layout using the specified Graphics2D and rendering context.
  • getAdvance2D
    Returns the current text position at the completion of glyph layout. (This is the position that shou
  • getGlyphAdvances
    Returns the advance between each glyph in text progression direction.
  • getGlyphCount
    Returns the number of glyphs in this layout.
  • getGlyphIndex
    Returns the glyph index of the glyph that has the specified char index.
  • getGlyphVector
    Return the glyph vector asociated to this layout.
  • getBounds2D
    Returns the rectangular bounds of the completed glyph layout. This includes stroking information, th
  • getCharacterCount
    Returns the number of chars represented by the glyphs within the specified range.
  • getComputedOrientationAngle
    Return the rotation angle applied to the character.
  • getDecorationOutline
    Returns the outline of the specified decorations on the glyphs, transformed by an AffineTransform.
  • getGlyphMetrics
    Returns the Metrics for a particular glyph.
  • getHighlightShape
    Returns a Shape which encloses the currently selected glyphs as specified by glyph indices begin and
  • getGlyphMetrics,
  • getHighlightShape,
  • getLineMetrics,
  • getOutline,
  • getTextPathAdvance,
  • hasCharacterIndex,
  • isLeftToRight,
  • isOnATextPath,
  • isVertical

Popular in Java

  • Making http requests using okhttp
  • getSharedPreferences (Context)
  • setScale (BigDecimal)
  • getSupportFragmentManager (FragmentActivity)
  • BigInteger (java.math)
    An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Set (java.util)
    A Set is a data structure which does not allow duplicate elements.
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now