net.ranides.assira.text.format
Class AnsiStringWrapper

java.lang.Object
  extended by net.ranides.assira.text.format.AnsiStringWrapper
All Implemented Interfaces:
CharSequence, AnsiAttr, AnsiCharSequence

public abstract class AnsiStringWrapper
extends Object
implements AnsiCharSequence

Klasa abstrakcyjna ułatwiająca pisanie wrapperów, które opakowują standardową sekwencję znaków nadając wszystkim elementom atrybuty zwrócone przez metodę getAttr. Metoda musi zwracać numery kolorów i czcionek kompatybilne ze schematami zwracanymi przez metody getScheme oraz getFonts. Implementacja metody subAnsiSequence najczęściej będzie miała w klasie pochodnej TWrapper bardzo prostą implementację, jeśli tylko zostanie dostarczony odpowiedni konstruktor:

return new TWrapper(subSequence(begin, end));
 

Author:
ranides

Nested Class Summary
 
Nested classes/interfaces inherited from interface net.ranides.assira.text.format.AnsiAttr
AnsiAttr.IndirectAt
 
Field Summary
 
Fields inherited from interface net.ranides.assira.text.format.AnsiAttr
bold, BOLD, changed, CHANGED, fresh, FRESH, invert, INVERT, MASK_INTERNAL, MASK_PUBLIC, narrow, NARROW, normal, NORMAL, SPLIT_ALL, SPLIT_BACK, SPLIT_FLAGS, SPLIT_FLAGS_ALL, SPLIT_FONT, SPLIT_FORE, strike, STRIKE, symbol, SYMBOL, underline, UNDERLINE
 
Constructor Summary
AnsiStringWrapper(CharSequence value)
          Opakowuje podaną sekwencję znaków.
 
Method Summary
 char charAt(int index)
           
 AnsiAttr getAttrAt(int index)
          Zwraca wszystkie właściwości przypisane do znaku o podanym indeksie (kolor, tło, czcionka, styl).
 int getBack()
          Zwraca przypisany numer koloru tła.
 int getBackAt(int index)
          Zwraca numer koloru tła przypisany do znaku o podanym indeksie.
 char getCharAt(int index)
          Odczytuje z sekwencji znak o podanym indeksie.
 Color getComputedBack()
          Metoda opcjonalna: zwraca przypisany kolor tła.
 Color getComputedBackAt(int index)
          Metoda opcjonalna: zwraca kolor tła przypisany do znaku o podanym indeksie.
 Font getComputedFont()
          Metoda opcjonalna: zwraca przypisaną czcionkę.
 Font getComputedFontAt(int index)
          Metoda opcjonalna: zwraca numer czcionki przypisany do znaku o podanym indeksie.
 Color getComputedFore()
          Metoda opcjonalna: zwraca przypisany kolor tekstu.
 Color getComputedForeAt(int index)
          Metoda opcjonalna: zwraca kolor tekstu przypisany do znaku o podanym indeksie.
 int getFlags()
          Zwraca przypisane atrybuty tekstu.
 int getFlagsAt(int index)
          Zwraca atrybuty przypisane do znaku o podanym indeksie.
 int getFont()
          Zwraca przypisany numer czcionki.
 int getFontAt(int index)
          Zwraca numer czcionki przypisany do znaku o podanym indeksie.
 int getFore()
          Zwraca przypisany numer koloru tekstu.
 int getForeAt(int index)
          Zwraca numer koloru tekstu przypisany do znaku o podanym indeksie.
 int length()
           
 Iterable<? extends AnsiCharSequence> split(int options)
           Rozbija tekst na fragmenty zawierające znaki zgrupowane według kryteriów podanych w opcjach.
 CharSequence subSequence(int start, int end)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.ranides.assira.text.format.AnsiCharSequence
getAttr, getFonts, getScheme, subAnsiSequence
 
Methods inherited from interface java.lang.CharSequence
toString
 

Constructor Detail

AnsiStringWrapper

public AnsiStringWrapper(CharSequence value)
Opakowuje podaną sekwencję znaków.

Parameters:
value -
Method Detail

getFore

public int getFore()
Description copied from interface: AnsiAttr
Zwraca przypisany numer koloru tekstu. Numer może być zamieniony na graficzną reprezentację za pomocą AnsiColorScheme.

Specified by:
getFore in interface AnsiAttr
Returns:
See Also:
AnsiAttr.getComputedFore()

getBack

public int getBack()
Description copied from interface: AnsiAttr
Zwraca przypisany numer koloru tła. Numer może być zamieniony na graficzną reprezentację za pomocą AnsiColorScheme.

Specified by:
getBack in interface AnsiAttr
Returns:
See Also:
AnsiAttr.getComputedBack()

getFlags

public int getFlags()
Description copied from interface: AnsiAttr
Zwraca przypisane atrybuty tekstu.

Specified by:
getFlags in interface AnsiAttr
Returns:

getFont

public int getFont()
Description copied from interface: AnsiAttr
Zwraca przypisany numer czcionki. Numer może być zamieniony na graficzną reprezentację za pomocą AnsiFontScheme.

Specified by:
getFont in interface AnsiAttr
Returns:
See Also:
AnsiAttr.getComputedFont()

getComputedFore

public Color getComputedFore()
Description copied from interface: AnsiAttr
Metoda opcjonalna: zwraca przypisany kolor tekstu. Ogólnie metoda zwraca rozsądny wynik, jeśli obiekt został powiązany z odpowiednim schematem kolorów (AnsiColorScheme.

Specified by:
getComputedFore in interface AnsiAttr
Returns:

getComputedBack

public Color getComputedBack()
Description copied from interface: AnsiAttr
Metoda opcjonalna: zwraca przypisany kolor tła. Ogólnie metoda zwraca rozsądny wynik, jeśli obiekt został powiązany z odpowiednim schematem kolorów (AnsiColorScheme.

Specified by:
getComputedBack in interface AnsiAttr
Returns:

getComputedFont

public Font getComputedFont()
Description copied from interface: AnsiAttr
Metoda opcjonalna: zwraca przypisaną czcionkę. Ogólnie metoda zwraca rozsądny wynik, jeśli obiekt został powiązany z odpowiednim schematem czcionek (AnsiFontScheme.

Specified by:
getComputedFont in interface AnsiAttr
Returns:

getCharAt

public char getCharAt(int index)
Description copied from interface: AnsiCharSequence
Odczytuje z sekwencji znak o podanym indeksie. Zwraca wynik identyczny jak CharSequence.charAt(int). Metoda istniejąca w celu uzyskania pełnej kompatybilności sekwencji znaków z konwencją JavaBeans.

Specified by:
getCharAt in interface AnsiCharSequence
Returns:

getForeAt

public int getForeAt(int index)
Description copied from interface: AnsiCharSequence
Zwraca numer koloru tekstu przypisany do znaku o podanym indeksie. Numer może być zamieniony na graficzną reprezentację za pomocą AnsiColorScheme.

Specified by:
getForeAt in interface AnsiCharSequence
Returns:
See Also:
AnsiCharSequence.getComputedForeAt(int)

getBackAt

public int getBackAt(int index)
Description copied from interface: AnsiCharSequence
Zwraca numer koloru tła przypisany do znaku o podanym indeksie. Numer może być zamieniony na graficzną reprezentację za pomocą AnsiColorScheme.

Specified by:
getBackAt in interface AnsiCharSequence
Returns:
See Also:
AnsiCharSequence.getComputedBackAt(int)

getFlagsAt

public int getFlagsAt(int index)
Description copied from interface: AnsiCharSequence
Zwraca atrybuty przypisane do znaku o podanym indeksie.

Specified by:
getFlagsAt in interface AnsiCharSequence
Returns:

getFontAt

public int getFontAt(int index)
Description copied from interface: AnsiCharSequence
Zwraca numer czcionki przypisany do znaku o podanym indeksie. Numer może być zamieniony na graficzną reprezentację za pomocą AnsiFontScheme.

Specified by:
getFontAt in interface AnsiCharSequence
Returns:
See Also:
AnsiCharSequence.getComputedFontAt(int)

getAttrAt

public AnsiAttr getAttrAt(int index)
Description copied from interface: AnsiCharSequence
Zwraca wszystkie właściwości przypisane do znaku o podanym indeksie (kolor, tło, czcionka, styl).

Specified by:
getAttrAt in interface AnsiCharSequence
Returns:

getComputedForeAt

public Color getComputedForeAt(int index)
Description copied from interface: AnsiCharSequence
Metoda opcjonalna: zwraca kolor tekstu przypisany do znaku o podanym indeksie. Ogólnie metoda zwraca rozsądny wynik, jeśli obiekt został powiązany z odpowiednim schematem kolorów (AnsiColorScheme.

Specified by:
getComputedForeAt in interface AnsiCharSequence
Returns:

getComputedBackAt

public Color getComputedBackAt(int index)
Description copied from interface: AnsiCharSequence
Metoda opcjonalna: zwraca kolor tła przypisany do znaku o podanym indeksie. Ogólnie metoda zwraca rozsądny wynik, jeśli obiekt został powiązany z odpowiednim schematem kolorów (AnsiColorScheme.

Specified by:
getComputedBackAt in interface AnsiCharSequence
Returns:

getComputedFontAt

public Font getComputedFontAt(int index)
Description copied from interface: AnsiCharSequence
Metoda opcjonalna: zwraca numer czcionki przypisany do znaku o podanym indeksie. Ogólnie metoda zwraca rozsądny wynik, jeśli obiekt został powiązany z odpowiednim schematem czcionek (AnsiFontScheme.

Specified by:
getComputedFontAt in interface AnsiCharSequence
Returns:

split

public Iterable<? extends AnsiCharSequence> split(int options)
Description copied from interface: AnsiCharSequence

Rozbija tekst na fragmenty zawierające znaki zgrupowane według kryteriów podanych w opcjach. Opcje są zbiorem flag z klasy AnsiAttr.

Rozdziela tekst na fragmenty o jednym kolorze tekstu i tła:
text.split(AnsiAttr.SPLIT_FORE | AnsiAttr.SPLIT_BACK)

Rozdziela tekst na fragmenty o tym samym stylu pogrubienia:
text.split(AnsiAttr.SPLIT_FLAGS | AnsiAttr.BOLD)

Specified by:
split in interface AnsiCharSequence
Returns:

length

public int length()
Specified by:
length in interface CharSequence

charAt

public char charAt(int index)
Specified by:
charAt in interface CharSequence

subSequence

public CharSequence subSequence(int start,
                                int end)
Specified by:
subSequence in interface CharSequence


Copyright © 2013. All Rights Reserved.