public final class NumericShaper extends Object implements Serializable
NumericShaperã¯ã©ã¹ã¯ãLatin-1 (ãšãŒãããèšèª)ã®æ°åãã»ãã®Unicode 10鲿°ã«å€æããããã«äœ¿çšããŸãã ãã®ã¯ã©ã¹ã¯äž»ã«ãããŒã¿ã®æç€ºã«ååœã®æ°åã®åœ¢ç¶ã䜿ããªããå
éšçã«ã¯Latin-1 (ãšãŒãããèšèª)ã®æ°åã䜿ã£ãã»ãã䟿å©ãªå Žåã«äœ¿çšããŸãã éæšå¥šã®æ°å圢ç¶ã»ã¬ã¯ã¿æå(U+206E)ã¯è§£éããŸããã
NumericShaperã®ã€ã³ã¹ã¿ã³ã¹ã¯éåžžãTextAttributeã¯ã©ã¹ã®NUMERIC_SHAPING屿§ãæã€ããã¹ãã®å±æ§ãšããŠé©çšãããŸãã ããšãã°æ¬¡ã®ã³ãŒãéšåã§ã¯ãã¢ã©ãã¢èªã®ã³ã³ããã¹ãå
ã§ã¯TextLayoutã®ãšãŒãããèšèªã®æ°åãã¢ã©ãã¢èªã®æ°åã«å€æããŸãã
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ã®ã€ã³ã¹ã¿ã³ã¹ã䜿çšããŠæ°åã®åœ¢ç¶æ±ºå®ãæç€ºçã«è¡ãããšãã§ããŸãã
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);
ãããã»ãã¹ã¯ããŒã¹ããã³enumããŒã¹ã®Unicodeç¯å²
ãã®ã¯ã©ã¹ã¯ãã¹ã¯ãªããåºæã®æ°åã®Unicodeç¯å²ã衚ãããã«ç°ãªã2ã€ã®ããã°ã©ãã³ã°ã»ã€ã³ã¿ãã§ãŒã¹ããµããŒãããŠããŸããã€ãŸããNumericShaper.ARABICã®ãããªãããã»ãã¹ã¯ããŒã¹ã®ãã®ãšãNumericShaper.Range.ARABICã®ãããªenumããŒã¹ã®ãã®ã§ãã è€æ°ã®ç¯å²ãæå®ããã«ã¯ã次ã®ããã«ãããã»ãã¹ã¯ããŒã¹ã®å®æ°ã®è«çåã䜿çšããŸãã
ãããã¯ã次ã®ããã«NumericShaper.ARABIC | NumericShaper.TAMIL
NumericShaper.Range宿°ã䜿çšããŠSetãäœæããŸãã
enumããŒã¹ã®ç¯å²ã¯ããããã»ãã¹ã¯ããŒã¹ã®ç¯å²ã®ã¹ãŒããŒã»ã»ããã§ããEnumSet.of(NumericShaper.Scirpt.ARABIC, NumericShaper.Range.TAMIL)
2ã€ã®ã€ã³ã¿ãã§ãŒã¹ãæ··åšããå Žå(çŽååãå«ã)ããããã³ã°ãå¯èœã§ããã°ãUnicodeç¯å²ã®å€ã¯äºãã«å¯Ÿå¿ããå€ã«ããããããŸããããšãã°ãNumericShaper.Range.ARABICãšNumericShaper.ARABICãããããããŸãã NumericShaper.Range.BALINESEãªã©ã®ãããã§ããªãç¯å²å€ãæå®ãããå Žåããã®ãããªç¯å²ã¯ç¡èŠãããŸãã
10鲿°ã®åªå é äœ
1ã€ã®Unicodeç¯å²ã«10鲿°ã®ã»ãããè€æ°å«ãŸããããšããããŸãã åãUnicodeç¯å²ã«10鲿°ã®ã»ãããè€æ°æå®ãããŠããå Žåã¯ã次ã®ããã«ã»ããã®1ã€ãåªå ãããŸãã
| Unicodeç¯å² | NumericShaper宿° |
åªå é äœ |
|---|---|---|
| ã¢ã©ãã¢èª | NumericShaper.ARABICNumericShaper.EASTERN_ARABIC |
NumericShaper.EASTERN_ARABIC |
NumericShaper.Range.ARABICNumericShaper.Range.EASTERN_ARABIC |
NumericShaper.Range.EASTERN_ARABIC |
|
| ã¿ã€ã»ã¿ã | NumericShaper.Range.TAI_THAM_HORANumericShaper.Range.TAI_THAM_THAM |
NumericShaper.Range.TAI_THAM_THAM |
| 修食åãšå | ã¯ã©ã¹ | 説æ |
|---|---|---|
static class |
NumericShaper.Range |
NumericShaper.Rangeã¯åºæã®10鲿°ãæã€ã¹ã¯ãªããã®Unicodeç¯å²ã衚ããŸãã |
| 修食åãšå | ãã£ãŒã«ã | 説æ |
|---|---|---|
static int |
ALL_RANGES |
ãã¹ãŠã®ç¯å²ãèå¥ããŸããå®å
šãªã³ã³ããã¹ãäŸåã®åœ¢ç¶æ±ºå®ã«äœ¿çšããŸãã
|
static int |
ARABIC |
ARABICã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
BENGALI |
BENGALIã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
DEVANAGARI |
DEVANAGARIã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
EASTERN_ARABIC |
ARABICã®ç¯å²ãšARABIC_EXTENDEDã®10鲿°ãèå¥ããŸãã
|
static int |
ETHIOPIC |
ETHIOPICã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
EUROPEAN |
Latin-1 (ãšãŒãããèšèª)ãšæ¡åŒµç¯å²ãããã³Latin-1 (ãšãŒãããèšèª)ã®10鲿°ãèå¥ããŸãã
|
static int |
GUJARATI |
GUJARATIã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
GURMUKHI |
GURMUKHIã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
KANNADA |
KANNADAã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
KHMER |
KHMERã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
LAO |
LAOã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
MALAYALAM |
MALAYALAMã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
MONGOLIAN |
MONGOLIANã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
MYANMAR |
MYANMARã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
ORIYA |
ORIYAã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
TAMIL |
TAMILã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
TELUGU |
TELUGUã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
THAI |
THAIã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
static int |
TIBETAN |
TIBETANã®ç¯å²ãš10鲿°ãèå¥ããŸãã
|
| 修食åãšå | ã¡ãœãã | 説æ |
|---|---|---|
boolean |
equals(Object o) |
æå®ããããªããžã§ã¯ãã
NumericShaperã®ã€ã³ã¹ã¿ã³ã¹ã§ãç¯å²è¡šçŸããããã»ãã¹ã¯ããŸãã¯åæãšé¢ä¿ãªãããããšåãæ¹æ³ã§åœ¢ç¶æ±ºå®ãè¡ãå Žåã¯trueãè¿ããŸãã |
static NumericShaper |
getContextualShaper(int ranges) |
æå®ãããUnicodeã®1ã€ãŸãã¯è€æ°ã®ç¯å²ã«å¯Ÿãããã³ã³ããã¹ãäŸåã®åœ¢ç¶æ±ºå®èŠå ãè¿ããŸãã
|
static NumericShaper |
getContextualShaper(int ranges, int defaultContext) |
æå®ãããUnicodeã®1ã€ãŸãã¯è€æ°ã®ç¯å²ã«å¯Ÿãããã³ã³ããã¹ãäŸåã®åœ¢ç¶æ±ºå®èŠå ãè¿ããŸãã
|
static NumericShaper |
getContextualShaper(Set<NumericShaper.Range> ranges) |
æå®ãããUnicodeã®1ã€ãŸãã¯è€æ°ã®ç¯å²ã«å¯Ÿãããã³ã³ããã¹ãäŸåã®åœ¢ç¶æ±ºå®èŠå ãè¿ããŸãã
|
static NumericShaper |
getContextualShaper(Set<NumericShaper.Range> ranges, NumericShaper.Range defaultContext) |
æå®ãããUnicodeã®1ã€ãŸãã¯è€æ°ã®ç¯å²ã«å¯Ÿãããã³ã³ããã¹ãäŸåã®åœ¢ç¶æ±ºå®èŠå ãè¿ããŸãã
|
int |
getRanges() |
åœ¢ç¶æ±ºå®ãè¡ããã¹ãŠã®ç¯å²ã«å¯Ÿããå€ã®è«çåãæ±ãã
intãè¿ããŸãã |
Set<NumericShaper.Range> |
getRangeSet() |
åœ¢ç¶æ±ºå®ãè¡ããã®
NumericShaperã®ãã¹ãŠã®Unicodeç¯å²ã衚ãSetãè¿ããŸãã |
static NumericShaper |
getShaper(int singleRange) |
æå®ãããUnicodeã®ç¯å²ã«å¯Ÿããåœ¢ç¶æ±ºå®èŠå ãè¿ããŸãã
|
static NumericShaper |
getShaper(NumericShaper.Range singleRange) |
æå®ãããUnicodeã®ç¯å²ã«å¯Ÿããåœ¢ç¶æ±ºå®èŠå ãè¿ããŸãã
|
int |
hashCode() |
ãã®åœ¢ç¶æ±ºå®èŠå ã®ããã·ã¥ã»ã³ãŒããè¿ããŸãã
|
boolean |
isContextual() |
ãã®åœ¢ç¶æ±ºå®èŠå ãã³ã³ããã¹ãäŸåãã©ããã瀺ã
booleanãè¿ããŸãã |
void |
shape(char[] text, int start, int count) |
startãšstart+countã®éã«åºçŸãããããã¹ãå
ã®æ°åã倿ããŸãã
|
void |
shape(char[] text, int start, int count, int context) |
æå®ãããã³ã³ããã¹ãã䜿çšããŠãstartãšstart+countã®éã«åºçŸããããã¹ãå
ã®æ°åã倿ããŸãã
|
void |
shape(char[] text, int start, int count, NumericShaper.Range context) |
æå®ããã
contextã䜿çšããŠãstartãšstart+countã®éã«åºçŸããããã¹ãå
ã®æ°åã倿ããŸãã |
String |
toString() |
ãã®åœ¢ç¶æ±ºå®èŠå ãèšè¿°ãã
Stringãè¿ããŸãã |
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
ãã®å®æ°ã¯ããããã»ãã¹ã¯ããŒã¹ã®ãã¹ãŠã®ç¯å²ãæå®ããŸãã enumããŒã¹ã®ãã¹ãŠã®ç¯å²ãæå®ããã«ã¯ãEmunSet.allOf(NumericShaper.Range.class)ã䜿çšããŠãã ããã
public static NumericShaper getShaper(int singleRange)
singleRange - æå®ãããUnicodeã®ç¯å²IllegalArgumentException - ç¯å²ã1ã€ã§ãªãå Žåpublic static NumericShaper getShaper(NumericShaper.Range singleRange)
singleRange - NumericShaper.Range宿°ã§æå®ãããUnicodeç¯å²ãNumericShaperãNullPointerException - singleRangeãnullã§ããå Žåpublic static NumericShaper getContextualShaper(int ranges)
NumericShaper.ARABIC|NumericShaper.THAIã®ããã«ãå€ã®è«çåã«ãã£ãŠè¡šãããŸãã åœ¢ç¶æ±ºå®èŠå ã¯ãEUROPEANãéå§ã³ã³ããã¹ããšããŠæ³å®ããŸããã€ãŸããæååå
ã§æ¹åæ§ã®åŒ·ãããã¹ãã®åã«EUROPEANã®æ°åãæ€åºãããå Žåãã³ã³ããã¹ãã¯EUROPEANã§ãããšèŠãªãããæ°åã¯åœ¢ç¶æ±ºå®ãããŸããã ranges - æå®ãããUnicodeã®ç¯å²public static NumericShaper getContextualShaper(Set<NumericShaper.Range> ranges)
åœ¢ç¶æ±ºå®èŠå ã¯ãEUROPEANãéå§ã³ã³ããã¹ããšããŠæ³å®ããŸããã€ãŸããæååå ã§æ¹åæ§ã®åŒ·ãããã¹ãã®åã«EUROPEANã®æ°åãæ€åºãããå Žåãã³ã³ããã¹ãã¯EUROPEANã§ãããšèŠãªãããæ°åã¯åœ¢ç¶æ±ºå®ãããŸããã
ranges - æå®ãããUnicodeã®ç¯å²NullPointerException - rangesãnullã§ããå Žåãpublic static NumericShaper getContextualShaper(int ranges, int defaultContext)
NumericShaper.ARABIC|NumericShaper.THAIã®ããã«ãå€ã®è«çåã«ãã£ãŠè¡šãããŸãã åœ¢ç¶æ±ºå®èŠå ã¯ãdefaultContextãéå§ã³ã³ããã¹ããšããŠäœ¿ããŸãã ranges - æå®ãããUnicodeã®ç¯å²defaultContext - NumericShaper.EUROPEANã®ãããªéå§ã³ã³ããã¹ãIllegalArgumentException - æå®ãããdefaultContextãåäžã®æå¹ãªç¯å²ã§ãªãå Žåãpublic static NumericShaper getContextualShaper(Set<NumericShaper.Range> ranges, NumericShaper.Range defaultContext)
defaultContextãéå§ã³ã³ããã¹ããšããŠäœ¿ããŸãã ranges - æå®ãããUnicodeã®ç¯å²defaultContext - NumericShaper.Range.EUROPEANã®ãããªéå§ã³ã³ããã¹ãNullPointerException - rangesãŸãã¯defaultContextãnullã®å Žåpublic void shape(char[] text,
int start,
int count)
text - 倿ããæåã®é
åstart - 倿ãéå§ããtextå
ã®ã€ã³ããã¯ã¹count - textå
ã®å€æããæåæ°IndexOutOfBoundsException - startãŸãã¯start+countãç¯å²å€ã®å ŽåNullPointerException - textãnullã®å Žåpublic void shape(char[] text,
int start,
int count,
int context)
text - æåã®é
åstart - 倿ãéå§ããtextå
ã®ã€ã³ããã¯ã¹count - textå
ã®å€æããæåæ°context - NumericShaper.EUROPEANã®ãããªæåã®å€æå
ã®ã³ã³ããã¹ãIndexOutOfBoundsException - startãŸãã¯start+countãç¯å²å€ã®å ŽåNullPointerException - textãnullã®å ŽåIllegalArgumentException - ãããã³ã³ããã¹ãäŸåã®åœ¢ç¶æ±ºå®èŠå ã§ãããæå®ãããcontextãåäžã®æå¹ãªç¯å²ã§ãªãå Žåãpublic void shape(char[] text,
int start,
int count,
NumericShaper.Range context)
contextã䜿çšããŠãstartãšstart+countã®éã«åºçŸããããã¹ãå
ã®æ°åã倿ããŸãã åœ¢ç¶æ±ºå®èŠå ãã³ã³ããã¹ãäŸåã§ãªãå ŽåãContextã¯ç¡èŠãããŸãã text - charé
åstart - 倿ãéå§ããtextå
ã®ã€ã³ããã¯ã¹count - textå
ã®å€æããcharã®æ°context - NumericShaper.Range.EUROPEANã®ãããªæåã®å€æå
ã®ã³ã³ããã¹ãIndexOutOfBoundsException - startãŸãã¯start+countãç¯å²å€ã«ããå ŽåNullPointerException - textãŸãã¯contextãnullã®å Žåpublic boolean isContextual()
booleanãè¿ããŸããtrueãããã§ãªãå Žåã¯falseãpublic int getRanges()
intãè¿ããŸãã
ããšãã°ãã¢ã©ãã¢èªãžã®åœ¢ç¶æ±ºå®ãè¡ããããã©ããã調ã¹ãã«ã¯ã次ã®ããã«ããŸãã
if ((shaper.getRanges() & shaper.ARABIC) != 0) { ...
ãã®ã¡ãœããã¯ãããã»ãã¹ã¯ããŒã¹ã®ç¯å²ã ãããµããŒãããŠããŸãã enumããŒã¹ã®ç¯å²ã®å Žåã¯getRangeSet()ãåŒã³åºããŠãã ããã
public Set<NumericShaper.Range> getRangeSet()
NumericShaperã®ãã¹ãŠã®Unicodeç¯å²ã衚ãSetãè¿ããŸããpublic int hashCode()
hashCodeãã¯ã©ã¹ObjectObject.hashCode()public boolean equals(Object o)
NumericShaperã®ã€ã³ã¹ã¿ã³ã¹ã§ãç¯å²è¡šçŸããããã»ãã¹ã¯ããŸãã¯åæãšé¢ä¿ãªãããããšåãæ¹æ³ã§åœ¢ç¶æ±ºå®ãè¡ãå Žåã¯trueãè¿ããŸãã ããšãã°ã次ã®ã³ãŒãã§ã¯"true"ãçæãããŸãã
NumericShaper ns1 = NumericShaper.getShaper(NumericShaper.ARABIC); NumericShaper ns2 = NumericShaper.getShaper(NumericShaper.Range.ARABIC); System.out.println(ns1.equals(ns2));
equalsãã¯ã©ã¹Objecto - NumericShaperãšæ¯èŒãããæå®ããããªããžã§ã¯ãoãNumericShaperã®ã€ã³ã¹ã¿ã³ã¹ã§ãããåãæ¹æ³ã§åœ¢ç¶æ±ºå®ãè¡ãå Žåã¯trueãããã§ãªãå Žåã¯falseãObject.equals(java.lang.Object) ãã°ãŸãã¯æ©èœãéä¿¡
詳现ãªAPIãªãã¡ã¬ã³ã¹ããã³éçºè
ããã¥ã¡ã³ãã«ã€ããŠã¯ãJava SEã®ããã¥ã¡ã³ããåç
§ããŠãã ããã ãã®ããã¥ã¡ã³ãã«ã¯ãæŠå¿µçãªæŠèŠãçšèªã®å®çŸ©ãåé¿æ¹æ³ãæå¹ãªã³ãŒãäŸãªã©ã®ãéçºè
ã察象ã«ãããã詳现ãªèª¬æãå«ãŸããŠããŸãã
Copyright © 1993, 2025, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Documentation Redistribution Policyãåç
§ããŠãã ããã