Java Doc for NumericShaper.java in  » 6.0-JDK-Core » AWT » java » awt » font » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt.font 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.awt.font.NumericShaper

NumericShaper
final public class NumericShaper implements java.io.Serializable(Code)
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 TextAttribute.NUMERIC_SHAPING 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);
 

It is also possible to perform numeric shaping explicitly using instances of 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);
 

since:
   1.4


Field Summary
final public static  intALL_RANGES
     Identifies all ranges, for full contextual shaping.
final public static  intARABIC
     Identifies the ARABIC range and decimal base.
final public static  intBENGALI
     Identifies the BENGALI range and decimal base.
final public static  intDEVANAGARI
     Identifies the DEVANAGARI range and decimal base.
final public static  intEASTERN_ARABIC
     Identifies the ARABIC range and ARABIC_EXTENDED decimal base.
final public static  intETHIOPIC
     Identifies the ETHIOPIC range and decimal base.
final public static  intEUROPEAN
     Identifies the Latin-1 (European) and extended range, and Latin-1 (European) decimal base.
final public static  intGUJARATI
     Identifies the GUJARATI range and decimal base.
final public static  intGURMUKHI
     Identifies the GURMUKHI range and decimal base.
final public static  intKANNADA
     Identifies the KANNADA range and decimal base.
final public static  intKHMER
     Identifies the KHMER range and decimal base.
final public static  intLAO
     Identifies the LAO range and decimal base.
final public static  intMALAYALAM
     Identifies the MALAYALAM range and decimal base.
final public static  intMONGOLIAN
     Identifies the MONGOLIAN range and decimal base.
final public static  intMYANMAR
     Identifies the MYANMAR range and decimal base.
final public static  intORIYA
     Identifies the ORIYA range and decimal base.
final public static  intTAMIL
     Identifies the TAMIL range and decimal base.
final public static  intTELUGU
     Identifies the TELUGU range and decimal base.
final public static  intTHAI
     Identifies the THAI range and decimal base.
final public static  intTIBETAN
     Identifies the TIBETAN range and decimal base.


Method Summary
public  booleanequals(Object o)
     Returns true if the specified object is an instance of NumericShaper and shapes identically to this one.
public static  NumericShapergetContextualShaper(int ranges)
     Returns a contextual shaper for the provided unicode range(s).
public static  NumericShapergetContextualShaper(int ranges, int defaultContext)
     Returns a contextual shaper for the provided unicode range(s).
public  intgetRanges()
     Returns an 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 static  NumericShapergetShaper(int singleRange)
     Returns a shaper for the provided unicode range.
public  inthashCode()
     Returns a hash code for this shaper.
public  booleanisContextual()
     Returns a boolean indicating whether or not this shaper shapes contextually.
public  voidshape(char[] text, int start, int count)
     Converts the digits in the text that occur between start and start + count.
public  voidshape(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.
public  StringtoString()
     Returns a String that describes this shaper.

Field Detail
ALL_RANGES
final public static int ALL_RANGES(Code)
Identifies all ranges, for full contextual shaping.



ARABIC
final public static int ARABIC(Code)
Identifies the ARABIC range and decimal base.



BENGALI
final public static int BENGALI(Code)
Identifies the BENGALI range and decimal base.



DEVANAGARI
final public static int DEVANAGARI(Code)
Identifies the DEVANAGARI range and decimal base.



EASTERN_ARABIC
final public static int EASTERN_ARABIC(Code)
Identifies the ARABIC range and ARABIC_EXTENDED decimal base.



ETHIOPIC
final public static int ETHIOPIC(Code)
Identifies the ETHIOPIC range and decimal base.



EUROPEAN
final public static int EUROPEAN(Code)
Identifies the Latin-1 (European) and extended range, and Latin-1 (European) decimal base.



GUJARATI
final public static int GUJARATI(Code)
Identifies the GUJARATI range and decimal base.



GURMUKHI
final public static int GURMUKHI(Code)
Identifies the GURMUKHI range and decimal base.



KANNADA
final public static int KANNADA(Code)
Identifies the KANNADA range and decimal base.



KHMER
final public static int KHMER(Code)
Identifies the KHMER range and decimal base.



LAO
final public static int LAO(Code)
Identifies the LAO range and decimal base.



MALAYALAM
final public static int MALAYALAM(Code)
Identifies the MALAYALAM range and decimal base.



MONGOLIAN
final public static int MONGOLIAN(Code)
Identifies the MONGOLIAN range and decimal base.



MYANMAR
final public static int MYANMAR(Code)
Identifies the MYANMAR range and decimal base.



ORIYA
final public static int ORIYA(Code)
Identifies the ORIYA range and decimal base.



TAMIL
final public static int TAMIL(Code)
Identifies the TAMIL range and decimal base. Tamil does not have a decimal digit 0 so Latin-1 (European) 0 is used.



TELUGU
final public static int TELUGU(Code)
Identifies the TELUGU range and decimal base.



THAI
final public static int THAI(Code)
Identifies the THAI range and decimal base.



TIBETAN
final public static int TIBETAN(Code)
Identifies the TIBETAN range and decimal base.





Method Detail
equals
public boolean equals(Object o)(Code)
Returns true if the specified object is an instance of NumericShaper and shapes identically to this one.
Parameters:
  o - the specified object to compare to thisNumericShaper true if o is an instanceof NumericShaper and shapes in the same way;false otherwise.
See Also:   java.lang.Object.equals(java.lang.Object)



getContextualShaper
public static NumericShaper getContextualShaper(int ranges)(Code)
Returns a contextual shaper for the provided unicode range(s). Latin-1 (EUROPEAN) digits are converted to the decimal digits corresponding to the range of the preceding text, if the range is one of the provided ranges. Multiple ranges are represented by or-ing the values together, such as, 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.
Parameters:
  ranges - the specified Unicode ranges a shaper for the specified ranges



getContextualShaper
public static NumericShaper getContextualShaper(int ranges, int defaultContext)(Code)
Returns a contextual shaper for the provided unicode range(s). Latin-1 (EUROPEAN) digits will be converted to the decimal digits corresponding to the range of the preceding text, if the range is one of the provided ranges. Multiple ranges are represented by or-ing the values together, for example, NumericShaper.ARABIC | NumericShaper.THAI. The shaper uses defaultContext as the starting context.
Parameters:
  ranges - the specified Unicode ranges
Parameters:
  defaultContext - the starting context, such as NumericShaper.EUROPEAN a shaper for the specified Unicode ranges.
throws:
  IllegalArgumentException - if the specifieddefaultContext is not a single valid range.



getRanges
public int getRanges()(Code)
Returns an 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) { ...
the values for all the ranges to be shaped.



getShaper
public static NumericShaper getShaper(int singleRange)(Code)
Returns a shaper for the provided unicode range. All Latin-1 (EUROPEAN) digits are converted to the corresponding decimal unicode digits.
Parameters:
  singleRange - the specified Unicode range a non-contextual numeric shaper
throws:
  IllegalArgumentException - if the range is not a single range



hashCode
public int hashCode()(Code)
Returns a hash code for this shaper. this shaper's hash code.
See Also:   java.lang.Object.hashCode



isContextual
public boolean isContextual()(Code)
Returns a boolean indicating whether or not this shaper shapes contextually. true if this shaper is contextual; false otherwise.



shape
public void shape(char[] text, int start, int count)(Code)
Converts the digits in the text that occur between start and start + count.
Parameters:
  text - an array of characters to convert
Parameters:
  start - the index into text to start converting
Parameters:
  count - the number of characters in textto convert
throws:
  IndexOutOfBoundsException - if start or start + count isout of bounds
throws:
  NullPointerException - if text is null



shape
public void shape(char[] text, int start, int count, int context)(Code)
Converts the digits in the text that occur between start and start + count, using the provided context. Context is ignored if the shaper is not a contextual shaper.
Parameters:
  text - an array of characters
Parameters:
  start - the index into text to startconverting
Parameters:
  count - the number of characters in textto convert
Parameters:
  context - the context to which to convert the characters, such as NumericShaper.EUROPEAN
throws:
  IndexOutOfBoundsException - if start or start + count isout of bounds
throws:
  NullPointerException - if text is null
throws:
  IllegalArgumentException - if this is a contextual shaperand the specified context is not a single validrange.



toString
public String toString()(Code)
Returns a String that describes this shaper. This method is used for debugging purposes only. a String describing this shaper.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.