/** * Selects the first glyph in the text node. */ public Mark selectFirst(TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; TextHit textHit = new TextHit(aci.getBeginIndex(), false); return new BasicTextPainter.BasicMark(node, textHit); }
/** * Selects the first glyph in the text node. */ public Mark selectFirst(TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; TextHit textHit = new TextHit(aci.getBeginIndex(), false); return new BasicTextPainter.BasicMark(node, textHit); }
/** * Selects the first glyph in the text node. */ public Mark selectFirst(TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; TextHit textHit = new TextHit(aci.getBeginIndex(), false); return new BasicTextPainter.BasicMark(node, textHit); }
/** * Selects the last glyph in the text node. */ public Mark selectLast(TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; TextHit textHit = new TextHit(aci.getEndIndex()-1, false); return new BasicTextPainter.BasicMark(node, textHit); }
/** * Selects the last glyph in the text node. */ public Mark selectLast(TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; TextHit textHit = new TextHit(aci.getEndIndex()-1, false); return new BasicTextPainter.BasicMark(node, textHit); }
/** * Selects the last glyph in the text node. */ public Mark selectLast(TextNode node) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; TextHit textHit = new TextHit(aci.getEndIndex()-1, false); return new BasicTextPainter.BasicMark(node, textHit); }
private void report(GraphicsNodeEvent evt, String message) { GraphicsNode source = evt.getGraphicsNode(); String label = "(non-text node)"; if (source instanceof TextNode) { char[] cbuff; java.text.CharacterIterator iter = ((TextNode) source).getAttributedCharacterIterator(); cbuff = new char[iter.getEndIndex()]; if (cbuff.length > 0) cbuff[0] = iter.first(); for (int i=1; i<cbuff.length;++i) { cbuff[i] = iter.next(); } label = new String(cbuff); } System.out.println("Mouse "+message+" in "+label); } }
private void report(GraphicsNodeEvent evt, String message) { GraphicsNode source = evt.getGraphicsNode(); String label = "(non-text node)"; if (source instanceof TextNode) { char[] cbuff; java.text.CharacterIterator iter = ((TextNode) source).getAttributedCharacterIterator(); cbuff = new char[iter.getEndIndex()]; if (cbuff.length > 0) cbuff[0] = iter.first(); for (int i=1; i<cbuff.length;++i) { cbuff[i] = iter.next(); } label = new String(cbuff); } System.out.println("Mouse "+message+" in "+label); } }
private void report(GraphicsNodeEvent evt, String message) { GraphicsNode source = evt.getGraphicsNode(); String label = "(non-text node)"; if (source instanceof TextNode) { char[] cbuff; java.text.CharacterIterator iter = ((TextNode) source).getAttributedCharacterIterator(); cbuff = new char[iter.getEndIndex()]; if (cbuff.length > 0) cbuff[0] = iter.first(); for (int i=1; i<cbuff.length;++i) { cbuff[i] = iter.next(); } label = new String(cbuff); } System.out.println("Mouse "+message+" in "+label); } }
/** * 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 ); }
public Mark getMark(TextNode node, int index, boolean leadingEdge) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; if ((index < aci.getBeginIndex()) || (index > aci.getEndIndex())) return null; TextHit textHit = new TextHit(index, leadingEdge); return new BasicTextPainter.BasicMark(node, textHit); }
public Mark getMark(TextNode node, int index, boolean leadingEdge) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; if ((index < aci.getBeginIndex()) || (index > aci.getEndIndex())) return null; TextHit textHit = new TextHit(index, leadingEdge); return new BasicTextPainter.BasicMark(node, textHit); }
public Mark getMark(TextNode node, int index, boolean leadingEdge) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return null; if ((index < aci.getBeginIndex()) || (index > aci.getEndIndex())) return null; TextHit textHit = new TextHit(index, leadingEdge); return new BasicTextPainter.BasicMark(node, textHit); }
/** * Paints the specified text node using the specified Graphics2D. * * @param node the text node to paint * @param g2d the Graphics2D to use */ public void paint(TextNode node, Graphics2D g2d) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return; List textRuns = getTextRuns(node, aci); // draw the underline and overline first, then the actual text // and finally the strikethrough paintDecorations(textRuns, g2d, TextSpanLayout.DECORATION_UNDERLINE); paintDecorations(textRuns, g2d, TextSpanLayout.DECORATION_OVERLINE); paintTextRuns(textRuns, g2d); paintDecorations (textRuns, g2d, TextSpanLayout.DECORATION_STRIKETHROUGH); }
/** * Paints the specified text node using the specified Graphics2D. * * @param node the text node to paint * @param g2d the Graphics2D to use */ public void paint(TextNode node, Graphics2D g2d) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return; List textRuns = getTextRuns(node, aci); // draw the underline and overline first, then the actual text // and finally the strikethrough paintDecorations(textRuns, g2d, TextSpanLayout.DECORATION_UNDERLINE); paintDecorations(textRuns, g2d, TextSpanLayout.DECORATION_OVERLINE); paintTextRuns(textRuns, g2d); paintDecorations (textRuns, g2d, TextSpanLayout.DECORATION_STRIKETHROUGH); }
/** * Paints the specified text node using the specified Graphics2D. * * @param node the text node to paint * @param g2d the Graphics2D to use */ public void paint(TextNode node, Graphics2D g2d) { AttributedCharacterIterator aci; aci = node.getAttributedCharacterIterator(); if (aci == null) return; List textRuns = getTextRuns(node, aci); // draw the underline and overline first, then the actual text // and finally the strikethrough paintDecorations(textRuns, g2d, TextSpanLayout.DECORATION_UNDERLINE); paintDecorations(textRuns, g2d, TextSpanLayout.DECORATION_OVERLINE); paintTextRuns(textRuns, g2d); paintDecorations (textRuns, g2d, TextSpanLayout.DECORATION_STRIKETHROUGH); }
/** * 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 ); }
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; }