| 
 | Java™ Platform Standard Ed. 6 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.font.NumericShaper
public final class NumericShaper
The NumericShaper class is used to convert Latin-1 (European) 
 digits to other Unicode decimal digits.  Users of this class will
 primarily be people who wish to present data using
 national digit shapes, but find it more convenient to represent the
 data internally using Latin-1 (European) digits.  This does not
 interpret the deprecated numeric shape selector character (U+206E).
 
 Instances of NumericShaper are typically applied 
 as attributes to text with the
 NUMERIC_SHAPING attribute
 of the TextAttribute class.  
 For example, this code snippet causes a TextLayout to 
 shape European digits to Arabic in an Arabic context:
 
 Map map = new HashMap();
 map.put(TextAttribute.NUMERIC_SHAPING, 
     NumericShaper.getContextualShaper(NumericShaper.ARABIC));
 FontRenderContext frc = ...;
 TextLayout layout = new TextLayout(text, map, frc);
 layout.draw(g2d, x, y);
 NumericShaper, as this code snippet demonstrates:
   char[] text = ...;
   // shape all EUROPEAN digits (except zero) to ARABIC digits
   NumericShaper shaper = NumericShaper.getShaper(NumericShaper.ARABIC);
   shaper.shape(text, start, count);
   // shape European digits to ARABIC digits if preceding text is Arabic, or
   // shape European digits to TAMIL digits if preceding text is Tamil, or
   // leave European digits alone if there is no preceding text, or 
   // preceding text is neither Arabic nor Tamil
   NumericShaper shaper = 
      NumericShaper.getContextualShaper(NumericShaper.ARABIC | 
                                              NumericShaper.TAMIL,
                                              NumericShaper.EUROPEAN);
   shaper.shape(text. start, count);
 
| Field Summary | |
|---|---|
| static int | ALL_RANGESIdentifies all ranges, for full contextual shaping. | 
| static int | ARABICIdentifies the ARABIC range and decimal base. | 
| static int | BENGALIIdentifies the BENGALI range and decimal base. | 
| static int | DEVANAGARIIdentifies the DEVANAGARI range and decimal base. | 
| static int | EASTERN_ARABICIdentifies the ARABIC range and ARABIC_EXTENDED decimal base. | 
| static int | ETHIOPICIdentifies the ETHIOPIC range and decimal base. | 
| static int | EUROPEANIdentifies the Latin-1 (European) and extended range, and Latin-1 (European) decimal base. | 
| static int | GUJARATIIdentifies the GUJARATI range and decimal base. | 
| static int | GURMUKHIIdentifies the GURMUKHI range and decimal base. | 
| static int | KANNADAIdentifies the KANNADA range and decimal base. | 
| static int | KHMERIdentifies the KHMER range and decimal base. | 
| static int | LAOIdentifies the LAO range and decimal base. | 
| static int | MALAYALAMIdentifies the MALAYALAM range and decimal base. | 
| static int | MONGOLIANIdentifies the MONGOLIAN range and decimal base. | 
| static int | MYANMARIdentifies the MYANMAR range and decimal base. | 
| static int | ORIYAIdentifies the ORIYA range and decimal base. | 
| static int | TAMILIdentifies the TAMIL range and decimal base. | 
| static int | TELUGUIdentifies the TELUGU range and decimal base. | 
| static int | THAIIdentifies the THAI range and decimal base. | 
| static int | TIBETANIdentifies the TIBETAN range and decimal base. | 
| Method Summary | |
|---|---|
|  boolean | equals(Object o)Returns true if the specified object is an instance of NumericShaperand shapes identically to this one. | 
| static NumericShaper | getContextualShaper(int ranges)Returns a contextual shaper for the provided unicode range(s). | 
| static NumericShaper | getContextualShaper(int ranges,
                    int defaultContext)Returns a contextual shaper for the provided unicode range(s). | 
|  int | getRanges()Returns an intthat ORs together the values for
 all the ranges that will be shaped. | 
| static NumericShaper | getShaper(int singleRange)Returns a shaper for the provided unicode range. | 
|  int | hashCode()Returns a hash code for this shaper. | 
|  boolean | isContextual()Returns a booleanindicating whether or not
 this shaper shapes contextually. | 
|  void | shape(char[] text,
      int start,
      int count)Converts the digits in the text that occur between start and start + count. | 
|  void | shape(char[] text,
      int start,
      int count,
      int context)Converts the digits in the text that occur between start and start + count, using the provided context. | 
|  String | toString()Returns a Stringthat describes this shaper. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, finalize, getClass, notify, notifyAll, wait, wait, wait | 
| Field Detail | 
|---|
public static final int EUROPEAN
public static final int ARABIC
public static final int EASTERN_ARABIC
public static final int DEVANAGARI
public static final int BENGALI
public static final int GURMUKHI
public static final int GUJARATI
public static final int ORIYA
public static final int TAMIL
public static final int TELUGU
public static final int KANNADA
public static final int MALAYALAM
public static final int THAI
public static final int LAO
public static final int TIBETAN
public static final int MYANMAR
public static final int ETHIOPIC
public static final int KHMER
public static final int MONGOLIAN
public static final int ALL_RANGES
| Method Detail | 
|---|
public static NumericShaper getShaper(int singleRange)
singleRange - the specified Unicode range
IllegalArgumentException - if the range is not a single rangepublic static NumericShaper getContextualShaper(int ranges)
NumericShaper.ARABIC | NumericShaper.THAI.  The
 shaper assumes EUROPEAN as the starting context, that is, if 
 EUROPEAN digits are encountered before any strong directional 
 text in the string, the context is presumed to be EUROPEAN, and 
 so the digits will not shape.
ranges - the specified Unicode ranges
public static NumericShaper getContextualShaper(int ranges,
                                                int defaultContext)
NumericShaper.ARABIC | NumericShaper.THAI.  The
 shaper uses defaultContext as the starting context.
ranges - the specified Unicode rangesdefaultContext - the starting context, such as 
 NumericShaper.EUROPEAN
IllegalArgumentException - if the specified
 defaultContext is not a single valid range.
public void shape(char[] text,
                  int start,
                  int count)
text - an array of characters to convertstart - the index into text to start 
        convertingcount - the number of characters in text
        to convert
IndexOutOfBoundsException - if start or start + count is
        out of bounds
NullPointerException - if text is null
public void shape(char[] text,
                  int start,
                  int count,
                  int context)
text - an array of charactersstart - the index into text to start
        convertingcount - the number of characters in text
        to convertcontext - the context to which to convert the 
        characters, such as NumericShaper.EUROPEAN
IndexOutOfBoundsException - if start or start + count is
        out of bounds
NullPointerException - if text is null
IllegalArgumentException - if this is a contextual shaper
 and the specified context is not a single valid
 range.public boolean isContextual()
boolean indicating whether or not
 this shaper shapes contextually.
true if this shaper is contextual; 
         false otherwise.public int getRanges()
int that ORs together the values for
 all the ranges that will be shaped.
 For example, to check if a shaper shapes to Arabic, you would use the following:
   if ((shaper.getRanges() & shaper.ARABIC) != 0) { ... 
 
public int hashCode()
hashCode in class ObjectObject.hashCode()public boolean equals(Object o)
NumericShaper and shapes identically to this one.
equals in class Objecto - the specified object to compare to this
          NumericShaper
true if o is an instance
         of NumericShaper and shapes in the same way;
         false otherwise.Object.equals(java.lang.Object)public String toString()
String that describes this shaper. This method 
 is used for debugging purposes only.
toString in class ObjectString describing this shaper.| 
 | Java™ Platform Standard Ed. 6 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
Copyright 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.