Java 8 TextAttribute - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 TextAttribute class.

This code example shows how to use the following methods:getBeginIndex, getEndIndex, setIndex, clone
     * @param stop the index of the first character after the subinterval 
     */ 
    public AttributedCharacterSpanIterator(AttributedCharacterIterator aci, 
                                           int start, int stop) {
        this.aci = aci;
        end = Math.min(aci.getEndIndex(), stop);
        begin = Math.max(aci.getBeginIndex(), start);
        this.aci.setIndex(begin);
    } 
 
    //From java.text.AttributedCharacterIterator 
 
    /** 
     * Get the keys of all attributes defined on the iterator's text range. 
     */ 
    public Set getAllAttributeKeys() {
        return aci.getAllAttributeKeys();
        // FIXME: not if there are atts outside the substring! 
    } 
 

6
CodeRank
This code example shows how to use the following methods:getBeginIndex, getEndIndex
                     new Object[] {s, new Float(x), new Float(y)}); 
    } 
 
    public void drawString(AttributedCharacterIterator iterator,
                           int x, int y) {
        Rectangle2D r2d =
            getFontMetrics(getFont() 
                           ).getStringBounds(iterator,
                                             iterator.getBeginIndex(),
                                             iterator.getEndIndex(),
                                             this);
 
        r2d.setRect(x, y - r2d.getHeight() + 1,
                    r2d.getWidth(), r2d.getHeight());
 
        doGraphicsOp(r2d,
                     "drawString", 
                     new Class[] {java.text.AttributedCharacterIterator.class,
                                      int.class, int.class}, 
                     new Object[] {iterator, new Integer(x), new Integer(y)}); 
5
CodeRank
This code example shows how to use the following methods:getAttribute, getRunLimit, setIndex
            // the current char. 
            ret = lineBreakCount;
 
            // Update the lineBreakRunLimit, this is a bit tricky since 
            // The attribute doesn't change until the next glyph... 
            aci.setIndex(aciIdx+charCount);
            lineBreakRunLimit = aci.getRunLimit(FLOW_LINE_BREAK);
            aci.setIndex(aciIdx);  // Restore location...
 
            Object o = aci.getAttribute(FLOW_LINE_BREAK);
            lineBreakCount = (o == null)?0:1;
        } 
        return ret;
    } 
 
    /** 
     * Move iterator to the next char. 
     */ 
    public void nextChar() { 
        if ((ch == SOFT_HYPHEN)      ||
5
CodeRank
This code example shows how to use the following methods:current
    public char last() { 
        return aci.last();
    } 
 
    public char current() { 
        return aci.current();
    } 
 
    public char next() { 
        return aci.next();
    } 
 
    public char previous() { 
        return aci.previous();
    } 
 
    public char setIndex(int position) {
       return aci.setIndex(position);
    } 
 
3
CodeRank
This code example shows how to use the following methods:getEndIndex
    this.lineBreakMeasurer.setPosition(ci.getBeginIndex());
  } 
 
  public boolean hasNext() 
  { 
    return lineBreakMeasurer.getPosition() < ci.getEndIndex();
  } 
 
  public LineBreakIteratorState next() 
  { 
    // For each line produced by the LinebreakMeasurer 
    int start = lineBreakMeasurer.getPosition();
    // float is the worst option to have accurate layouts. So we have to 'adjust' for rounding errors 
    // and hope that no one notices .. 
    TextLayout textLayout = lineBreakMeasurer.nextLayout(wrappingWidth + 0.5f, ci.getEndIndex(), false);
    textLayout = postProcess(start, textLayout, lineBreakMeasurer);
    int end = lineBreakMeasurer.getPosition();
 
    // check if the text must be justified 
 
4
CodeRank
This code example shows how to use the following methods:clone
    /** 
     * Creates a copy of this iterator. 
     */ 
    public Object clone() { 
        return new BidiAttributedCharacterIterator 
            ((AttributedCharacterIterator)reorderedACI.clone(),
             frc, chunkStart, (int [])newCharOrder.clone());
    } 
 
    /** 
     * Gets the character at the current position (as returned by getIndex()). 
     */ 
    public char current() { 
        return reorderedACI.current();
    } 
 
    /** 
     * Sets the position to getBeginIndex() and returns the character at 
     * that position. 
     */ 
3
CodeRank
This code example shows how to use the following methods:first
    public void test_getIterator() { 
        String test = "Test string";
        try { 
            AttributedString attrString = new AttributedString(test);
            AttributedCharacterIterator it = attrString.getIterator();
            assertEquals("Incorrect iteration on AttributedString", it.first(),
                    test.charAt(0));
        } catch (Exception e) {
            fail("Unexpected exceptiption " + e.toString());
        } 
    } 
 
    /** 
     * java.text.AttributedString#getIterator(AttributedCharacterIterator.Attribute[]) 
     *        Test of method 
     *        java.text.AttributedString#getIterator(AttributedCharacterIterator.Attribute[]). 
     */ 
    public void test_getIterator$Ljava_text_AttributedCharacterIterator$Attribute() { 
        String test = "Test string";
        try { 
4
CodeRank
This code example shows how to use the following methods:getBeginIndex, getEndIndex
  } 
 
  private boolean isInputProcess(AttributedCharacterIterator text){
    if(text == null)
      return false; 
    return (text.getEndIndex() - (text.getBeginIndex() + committed_count) > 0);
  } 
 
  public void caretPositionChanged(InputMethodEvent event) {
    event.consume();
  } 
} 
4
CodeRank
This code example shows how to use the following methods:getEndIndex
This code example shows how to use the following methods:getAttribute
        } 
    } 
 
    public void test_getAttributeLAttributedCharacterIterator_Attribute() { 
 
        Object attribute = 
            it.getAttribute(AttributedCharacterIterator.Attribute.LANGUAGE);
        assertEquals("ENGLISH", attribute);
 
        attribute = 
            it.getAttribute(AttributedCharacterIterator.Attribute.READING);
        assertEquals("READ", attribute);
 
        assertNull(it.getAttribute(AttributedCharacterIterator.
                Attribute.INPUT_METHOD_SEGMENT));
    } 
 
    public void test_getAttributes() { 
        Map<AttributedCharacterIterator.Attribute, Object> attributes =
            it.getAttributes();
4
CodeRank
See Code Examples for Java 8 TextAttribute Methods: