Codota Logo
TextSpanLayout.hitTestChar
Code IndexAdd Codota 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)

  • Common ways to obtain TextSpanLayout
private void myMethod () {
TextSpanLayout t =
  • Codota IconStrokingTextPainter.TextRun run;run.getLayout()
  • Codota IconAttributedCharacterIterator aci;Point2D offset;FontRenderContext frc;new GlyphLayout(aci, charMap, offset, frc)
  • Smart code suggestions by Codota
}
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
  • putExtra (Intent)
  • startActivity (Activity)
  • onRequestPermissionsResult (Fragment)
  • BigDecimal (java.math)
    An immutable arbitrary-precision signed decimal.A value is represented by an arbitrary-precision "un
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • JTextField (javax.swing)
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now