Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
5065850d
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5065850d
编写于
7月 18, 2008
作者:
M
malenkov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6552812: Add HSL tab to JColorChooser
Reviewed-by: peterz, avu
上级
b8445e0c
变更
26
展开全部
隐藏空白更改
内联
并排
Showing
26 changed file
with
1727 addition
and
1475 deletion
+1727
-1475
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic.properties
.../sun/swing/internal/plaf/basic/resources/basic.properties
+22
-11
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_de.properties
...n/swing/internal/plaf/basic/resources/basic_de.properties
+22
-11
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_es.properties
...n/swing/internal/plaf/basic/resources/basic_es.properties
+22
-11
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_fr.properties
...n/swing/internal/plaf/basic/resources/basic_fr.properties
+22
-11
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_it.properties
...n/swing/internal/plaf/basic/resources/basic_it.properties
+22
-11
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ja.properties
...n/swing/internal/plaf/basic/resources/basic_ja.properties
+22
-11
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ko.properties
...n/swing/internal/plaf/basic/resources/basic_ko.properties
+22
-11
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_sv.properties
...n/swing/internal/plaf/basic/resources/basic_sv.properties
+22
-11
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_CN.properties
...wing/internal/plaf/basic/resources/basic_zh_CN.properties
+22
-11
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_TW.properties
...wing/internal/plaf/basic/resources/basic_zh_TW.properties
+22
-11
src/share/classes/javax/swing/colorchooser/ColorChooserComponentFactory.java
...avax/swing/colorchooser/ColorChooserComponentFactory.java
+9
-10
src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java
...e/classes/javax/swing/colorchooser/ColorChooserPanel.java
+182
-0
src/share/classes/javax/swing/colorchooser/ColorModel.java
src/share/classes/javax/swing/colorchooser/ColorModel.java
+102
-0
src/share/classes/javax/swing/colorchooser/ColorModelCMYK.java
...hare/classes/javax/swing/colorchooser/ColorModelCMYK.java
+94
-0
src/share/classes/javax/swing/colorchooser/ColorModelHSL.java
...share/classes/javax/swing/colorchooser/ColorModelHSL.java
+188
-0
src/share/classes/javax/swing/colorchooser/ColorModelHSV.java
...share/classes/javax/swing/colorchooser/ColorModelHSV.java
+138
-0
src/share/classes/javax/swing/colorchooser/ColorPanel.java
src/share/classes/javax/swing/colorchooser/ColorPanel.java
+210
-0
src/share/classes/javax/swing/colorchooser/DefaultHSBChooserPanel.java
...sses/javax/swing/colorchooser/DefaultHSBChooserPanel.java
+0
-801
src/share/classes/javax/swing/colorchooser/DefaultRGBChooserPanel.java
...sses/javax/swing/colorchooser/DefaultRGBChooserPanel.java
+0
-294
src/share/classes/javax/swing/colorchooser/DiagramComponent.java
...re/classes/javax/swing/colorchooser/DiagramComponent.java
+160
-0
src/share/classes/javax/swing/colorchooser/SlidingSpinner.java
...hare/classes/javax/swing/colorchooser/SlidingSpinner.java
+118
-0
src/share/classes/javax/swing/colorchooser/SyntheticImage.java
...hare/classes/javax/swing/colorchooser/SyntheticImage.java
+0
-166
src/share/classes/javax/swing/colorchooser/ValueFormatter.java
...hare/classes/javax/swing/colorchooser/ValueFormatter.java
+151
-0
src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java
...e/classes/javax/swing/plaf/basic/BasicColorChooserUI.java
+4
-2
test/javax/swing/JColorChooser/Test6524757.java
test/javax/swing/JColorChooser/Test6524757.java
+76
-92
test/javax/swing/JColorChooser/Test6559154.java
test/javax/swing/JColorChooser/Test6559154.java
+75
-0
未找到文件。
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic.properties
浏览文件 @
5065850d
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText
=
Sample Text Sample Text
ColorChooser.sampleText
=
Sample Text Sample Text
ColorChooser.swatchesNameText
=
Swatches
ColorChooser.swatchesNameText
=
Swatches
ColorChooser.swatchesMnemonic
=
83
ColorChooser.swatchesMnemonic
=
83
ColorChooser.swatchesDisplayedMnemonicIndex
=
0
ColorChooser.swatchesRecentText
=
Recent:
ColorChooser.swatchesRecentText
=
Recent:
ColorChooser.hsbNameText
=
HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic
=
72
ColorChooser.hsvNameText
=
HSV
ColorChooser.hsbDisplayedMnemonicIndex
=
0
ColorChooser.hsvMnemonic
=
72
ColorChooser.hsbHueText
=
H
ColorChooser.hsvHueText
=
Hue
ColorChooser.hsbSaturationText
=
S
ColorChooser.hsvSaturationText
=
Saturation
ColorChooser.hsbBrightnessText
=
B
ColorChooser.hsvValueText
=
Value
ColorChooser.hsbRedText
=
R
ColorChooser.hsvTransparencyText
=
Transparency
ColorChooser.hsbGreenText
=
G
ColorChooser.hslNameText
=
HSL
ColorChooser.hsbBlueText
=
B
ColorChooser.hslMnemonic
=
76
ColorChooser.hslHueText
=
Hue
ColorChooser.hslSaturationText
=
Saturation
ColorChooser.hslLightnessText
=
Lightness
ColorChooser.hslTransparencyText
=
Transparency
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbDisplayedMnemonicIndex
=
1
ColorChooser.rgbRedText
=
Red
ColorChooser.rgbRedText
=
Red
ColorChooser.rgbRedMnemonic
=
68
ColorChooser.rgbRedMnemonic
=
68
ColorChooser.rgbGreenText
=
Green
ColorChooser.rgbGreenText
=
Green
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbBlueText
=
Blue
ColorChooser.rgbBlueText
=
Blue
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbAlphaText
=
Alpha
ColorChooser.rgbHexCodeText
=
Color Code
ColorChooser.rgbHexCodeMnemonic
=
67
ColorChooser.cmykNameText
=
CMYK
ColorChooser.cmykMnemonic
=
77
ColorChooser.cmykCyanText
=
Cyan
ColorChooser.cmykMagentaText
=
Magenta
ColorChooser.cmykYellowText
=
Yellow
ColorChooser.cmykBlackText
=
Black
ColorChooser.cmykAlphaText
=
Alpha
############ OPTION PANE STRINGS #############
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
...
...
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_de.properties
浏览文件 @
5065850d
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=90
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=90
ColorChooser.sampleText
=
Beispieltext Beispieltext
ColorChooser.sampleText
=
Beispieltext Beispieltext
ColorChooser.swatchesNameText
=
Muster
ColorChooser.swatchesNameText
=
Muster
ColorChooser.swatchesMnemonic
=
77
ColorChooser.swatchesMnemonic
=
77
ColorChooser.swatchesDisplayedMnemonicIndex
=
0
ColorChooser.swatchesRecentText
=
Aktuell:
ColorChooser.swatchesRecentText
=
Aktuell:
ColorChooser.hsbNameText
=
HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic
=
72
ColorChooser.hsvNameText
=
HSV
ColorChooser.hsbDisplayedMnemonicIndex
=
0
ColorChooser.hsvMnemonic
=
72
ColorChooser.hsbHueText
=
H
ColorChooser.hsvHueText
=
Hue
ColorChooser.hsbSaturationText
=
S
ColorChooser.hsvSaturationText
=
Saturation
ColorChooser.hsbBrightnessText
=
B
ColorChooser.hsvValueText
=
Value
ColorChooser.hsbRedText
=
R
ColorChooser.hsvTransparencyText
=
Transparency
ColorChooser.hsbGreenText
=
G
ColorChooser.hslNameText
=
HSL
ColorChooser.hsbBlueText
=
B
ColorChooser.hslMnemonic
=
76
ColorChooser.hslHueText
=
Hue
ColorChooser.hslSaturationText
=
Saturation
ColorChooser.hslLightnessText
=
Lightness
ColorChooser.hslTransparencyText
=
Transparency
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbDisplayedMnemonicIndex
=
1
ColorChooser.rgbRedText
=
Rot
ColorChooser.rgbRedText
=
Rot
ColorChooser.rgbRedMnemonic
=
82
ColorChooser.rgbRedMnemonic
=
82
ColorChooser.rgbGreenText
=
Gr
\u
00fcn
ColorChooser.rgbGreenText
=
Gr
\u
00fcn
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbBlueText
=
Blau
ColorChooser.rgbBlueText
=
Blau
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbAlphaText
=
Alpha
ColorChooser.rgbHexCodeText
=
Color Code
ColorChooser.rgbHexCodeMnemonic
=
67
ColorChooser.cmykNameText
=
CMYK
ColorChooser.cmykMnemonic
=
77
ColorChooser.cmykCyanText
=
Cyan
ColorChooser.cmykMagentaText
=
Magenta
ColorChooser.cmykYellowText
=
Yellow
ColorChooser.cmykBlackText
=
Black
ColorChooser.cmykAlphaText
=
Alpha
############ OPTION PANE STRINGS #############
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
...
...
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_es.properties
浏览文件 @
5065850d
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText
=
Texto de ejemplo Texto de ejemplo
ColorChooser.sampleText
=
Texto de ejemplo Texto de ejemplo
ColorChooser.swatchesNameText
=
Muestras
ColorChooser.swatchesNameText
=
Muestras
ColorChooser.swatchesMnemonic
=
77
ColorChooser.swatchesMnemonic
=
77
ColorChooser.swatchesDisplayedMnemonicIndex
=
0
ColorChooser.swatchesRecentText
=
Reciente:
ColorChooser.swatchesRecentText
=
Reciente:
ColorChooser.hsbNameText
=
HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic
=
72
ColorChooser.hsvNameText
=
HSV
ColorChooser.hsbDisplayedMnemonicIndex
=
0
ColorChooser.hsvMnemonic
=
72
ColorChooser.hsbHueText
=
H
ColorChooser.hsvHueText
=
Hue
ColorChooser.hsbSaturationText
=
S
ColorChooser.hsvSaturationText
=
Saturation
ColorChooser.hsbBrightnessText
=
B
ColorChooser.hsvValueText
=
Value
ColorChooser.hsbRedText
=
R
ColorChooser.hsvTransparencyText
=
Transparency
ColorChooser.hsbGreenText
=
V
ColorChooser.hslNameText
=
HSL
ColorChooser.hsbBlueText
=
A
ColorChooser.hslMnemonic
=
76
ColorChooser.hslHueText
=
Hue
ColorChooser.hslSaturationText
=
Saturation
ColorChooser.hslLightnessText
=
Lightness
ColorChooser.hslTransparencyText
=
Transparency
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbDisplayedMnemonicIndex
=
1
ColorChooser.rgbRedText
=
Rojo
ColorChooser.rgbRedText
=
Rojo
ColorChooser.rgbRedMnemonic
=
74
ColorChooser.rgbRedMnemonic
=
74
ColorChooser.rgbGreenText
=
Verde
ColorChooser.rgbGreenText
=
Verde
ColorChooser.rgbGreenMnemonic
=
86
ColorChooser.rgbGreenMnemonic
=
86
ColorChooser.rgbBlueText
=
Azul
ColorChooser.rgbBlueText
=
Azul
ColorChooser.rgbBlueMnemonic
=
76
ColorChooser.rgbBlueMnemonic
=
76
ColorChooser.rgbAlphaText
=
Alpha
ColorChooser.rgbHexCodeText
=
Color Code
ColorChooser.rgbHexCodeMnemonic
=
67
ColorChooser.cmykNameText
=
CMYK
ColorChooser.cmykMnemonic
=
77
ColorChooser.cmykCyanText
=
Cyan
ColorChooser.cmykMagentaText
=
Magenta
ColorChooser.cmykYellowText
=
Yellow
ColorChooser.cmykBlackText
=
Black
ColorChooser.cmykAlphaText
=
Alpha
############ OPTION PANE STRINGS #############
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
...
...
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_fr.properties
浏览文件 @
5065850d
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText
=
Echantillon de texte Echantillon de texte
ColorChooser.sampleText
=
Echantillon de texte Echantillon de texte
ColorChooser.swatchesNameText
=
Echantillons
ColorChooser.swatchesNameText
=
Echantillons
ColorChooser.swatchesMnemonic
=
69
ColorChooser.swatchesMnemonic
=
69
ColorChooser.swatchesDisplayedMnemonicIndex
=
0
ColorChooser.swatchesRecentText
=
Dernier :
ColorChooser.swatchesRecentText
=
Dernier :
ColorChooser.hsbNameText
=
HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic
=
72
ColorChooser.hsvNameText
=
HSV
ColorChooser.hsbDisplayedMnemonicIndex
=
0
ColorChooser.hsvMnemonic
=
72
ColorChooser.hsbHueText
=
H
ColorChooser.hsvHueText
=
Hue
ColorChooser.hsbSaturationText
=
S
ColorChooser.hsvSaturationText
=
Saturation
ColorChooser.hsbBrightnessText
=
B
ColorChooser.hsvValueText
=
Value
ColorChooser.hsbRedText
=
R
ColorChooser.hsvTransparencyText
=
Transparency
ColorChooser.hsbGreenText
=
V
ColorChooser.hslNameText
=
HSL
ColorChooser.hsbBlueText
=
B
ColorChooser.hslMnemonic
=
76
ColorChooser.hslHueText
=
Hue
ColorChooser.hslSaturationText
=
Saturation
ColorChooser.hslLightnessText
=
Lightness
ColorChooser.hslTransparencyText
=
Transparency
ColorChooser.rgbNameText
=
RVB
ColorChooser.rgbNameText
=
RVB
ColorChooser.rgbMnemonic
=
86
ColorChooser.rgbMnemonic
=
86
ColorChooser.rgbDisplayedMnemonicIndex
=
1
ColorChooser.rgbRedText
=
Rouge
ColorChooser.rgbRedText
=
Rouge
ColorChooser.rgbRedMnemonic
=
71
ColorChooser.rgbRedMnemonic
=
71
ColorChooser.rgbGreenText
=
Vert
ColorChooser.rgbGreenText
=
Vert
ColorChooser.rgbGreenMnemonic
=
84
ColorChooser.rgbGreenMnemonic
=
84
ColorChooser.rgbBlueText
=
Bleu
ColorChooser.rgbBlueText
=
Bleu
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbAlphaText
=
Alpha
ColorChooser.rgbHexCodeText
=
Color Code
ColorChooser.rgbHexCodeMnemonic
=
67
ColorChooser.cmykNameText
=
CMYK
ColorChooser.cmykMnemonic
=
77
ColorChooser.cmykCyanText
=
Cyan
ColorChooser.cmykMagentaText
=
Magenta
ColorChooser.cmykYellowText
=
Yellow
ColorChooser.cmykBlackText
=
Black
ColorChooser.cmykAlphaText
=
Alpha
############ OPTION PANE STRINGS #############
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
...
...
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_it.properties
浏览文件 @
5065850d
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText
=
Testo di prova Testo di prova
ColorChooser.sampleText
=
Testo di prova Testo di prova
ColorChooser.swatchesNameText
=
Colori campione
ColorChooser.swatchesNameText
=
Colori campione
ColorChooser.swatchesMnemonic
=
67
ColorChooser.swatchesMnemonic
=
67
ColorChooser.swatchesDisplayedMnemonicIndex
=
0
ColorChooser.swatchesRecentText
=
Recenti:
ColorChooser.swatchesRecentText
=
Recenti:
ColorChooser.hsbNameText
=
HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic
=
72
ColorChooser.hsvNameText
=
HSV
ColorChooser.hsbDisplayedMnemonicIndex
=
0
ColorChooser.hsvMnemonic
=
72
ColorChooser.hsbHueText
=
H
ColorChooser.hsvHueText
=
Hue
ColorChooser.hsbSaturationText
=
S
ColorChooser.hsvSaturationText
=
Saturation
ColorChooser.hsbBrightnessText
=
B
ColorChooser.hsvValueText
=
Value
ColorChooser.hsbRedText
=
R
ColorChooser.hsvTransparencyText
=
Transparency
ColorChooser.hsbGreenText
=
G
ColorChooser.hslNameText
=
HSL
ColorChooser.hsbBlueText
=
B
ColorChooser.hslMnemonic
=
76
ColorChooser.hslHueText
=
Hue
ColorChooser.hslSaturationText
=
Saturation
ColorChooser.hslLightnessText
=
Lightness
ColorChooser.hslTransparencyText
=
Transparency
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbDisplayedMnemonicIndex
=
1
ColorChooser.rgbRedText
=
Rosso
ColorChooser.rgbRedText
=
Rosso
ColorChooser.rgbRedMnemonic
=
79
ColorChooser.rgbRedMnemonic
=
79
ColorChooser.rgbGreenText
=
Verde
ColorChooser.rgbGreenText
=
Verde
ColorChooser.rgbGreenMnemonic
=
69
ColorChooser.rgbGreenMnemonic
=
69
ColorChooser.rgbBlueText
=
Blu
ColorChooser.rgbBlueText
=
Blu
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbAlphaText
=
Alpha
ColorChooser.rgbHexCodeText
=
Color Code
ColorChooser.rgbHexCodeMnemonic
=
67
ColorChooser.cmykNameText
=
CMYK
ColorChooser.cmykMnemonic
=
77
ColorChooser.cmykCyanText
=
Cyan
ColorChooser.cmykMagentaText
=
Magenta
ColorChooser.cmykYellowText
=
Yellow
ColorChooser.cmykBlackText
=
Black
ColorChooser.cmykAlphaText
=
Alpha
############ OPTION PANE STRINGS #############
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
...
...
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ja.properties
浏览文件 @
5065850d
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText
=
\u
30b5
\u
30f3
\u
30d7
\u
30eb
\u
30c6
\u
30ad
\u
30b9
\u
30c8
\u
30b5
\u
30f3
\u
30d7
\u
30eb
\u
30c6
\u
30ad
\u
30b9
\u
30c8
ColorChooser.sampleText
=
\u
30b5
\u
30f3
\u
30d7
\u
30eb
\u
30c6
\u
30ad
\u
30b9
\u
30c8
\u
30b5
\u
30f3
\u
30d7
\u
30eb
\u
30c6
\u
30ad
\u
30b9
\u
30c8
ColorChooser.swatchesNameText
=
\u
30b5
\u
30f3
\u
30d7
\u
30eb(S)
ColorChooser.swatchesNameText
=
\u
30b5
\u
30f3
\u
30d7
\u
30eb(S)
ColorChooser.swatchesMnemonic
=
83
ColorChooser.swatchesMnemonic
=
83
ColorChooser.swatchesDisplayedMnemonicIndex
=
5
ColorChooser.swatchesRecentText
=
\u6700\u
65b0:
ColorChooser.swatchesRecentText
=
\u6700\u
65b0:
ColorChooser.hsbNameText
=
HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic
=
72
ColorChooser.hsvNameText
=
HSV
ColorChooser.hsbDisplayedMnemonicIndex
=
0
ColorChooser.hsvMnemonic
=
72
ColorChooser.hsbHueText
=
H
ColorChooser.hsvHueText
=
Hue
ColorChooser.hsbSaturationText
=
S
ColorChooser.hsvSaturationText
=
Saturation
ColorChooser.hsbBrightnessText
=
B
ColorChooser.hsvValueText
=
Value
ColorChooser.hsbRedText
=
R
ColorChooser.hsvTransparencyText
=
Transparency
ColorChooser.hsbGreenText
=
G
ColorChooser.hslNameText
=
HSL
ColorChooser.hsbBlueText
=
B
ColorChooser.hslMnemonic
=
76
ColorChooser.hslHueText
=
Hue
ColorChooser.hslSaturationText
=
Saturation
ColorChooser.hslLightnessText
=
Lightness
ColorChooser.hslTransparencyText
=
Transparency
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbDisplayedMnemonicIndex
=
1
ColorChooser.rgbRedText
=
\u
8d64(D)
ColorChooser.rgbRedText
=
\u
8d64(D)
ColorChooser.rgbRedMnemonic
=
68
ColorChooser.rgbRedMnemonic
=
68
ColorChooser.rgbGreenText
=
\u
7dd1(N)
ColorChooser.rgbGreenText
=
\u
7dd1(N)
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbBlueText
=
\u9752
(B)
ColorChooser.rgbBlueText
=
\u9752
(B)
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbAlphaText
=
Alpha
ColorChooser.rgbHexCodeText
=
Color Code
ColorChooser.rgbHexCodeMnemonic
=
67
ColorChooser.cmykNameText
=
CMYK
ColorChooser.cmykMnemonic
=
77
ColorChooser.cmykCyanText
=
Cyan
ColorChooser.cmykMagentaText
=
Magenta
ColorChooser.cmykYellowText
=
Yellow
ColorChooser.cmykBlackText
=
Black
ColorChooser.cmykAlphaText
=
Alpha
############ OPTION PANE STRINGS #############
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
...
...
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_ko.properties
浏览文件 @
5065850d
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText
=
\u
c0d8
\u
d50c
\u
d14d
\u
c2a4
\u
d2b8
\u
c0d8
\u
d50c
\u
d14d
\u
c2a4
\u
d2b8
ColorChooser.sampleText
=
\u
c0d8
\u
d50c
\u
d14d
\u
c2a4
\u
d2b8
\u
c0d8
\u
d50c
\u
d14d
\u
c2a4
\u
d2b8
ColorChooser.swatchesNameText
=
\u
acac
\u
bcf8(S)
ColorChooser.swatchesNameText
=
\u
acac
\u
bcf8(S)
ColorChooser.swatchesMnemonic
=
83
ColorChooser.swatchesMnemonic
=
83
ColorChooser.swatchesDisplayedMnemonicIndex
=
3
ColorChooser.swatchesRecentText
=
\u
cd5c
\u
adfc
\u
baa9
\u
b85d:
ColorChooser.swatchesRecentText
=
\u
cd5c
\u
adfc
\u
baa9
\u
b85d:
ColorChooser.hsbNameText
=
HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic
=
72
ColorChooser.hsvNameText
=
HSV
ColorChooser.hsbDisplayedMnemonicIndex
=
0
ColorChooser.hsvMnemonic
=
72
ColorChooser.hsbHueText
=
H
ColorChooser.hsvHueText
=
Hue
ColorChooser.hsbSaturationText
=
S
ColorChooser.hsvSaturationText
=
Saturation
ColorChooser.hsbBrightnessText
=
B
ColorChooser.hsvValueText
=
Value
ColorChooser.hsbRedText
=
R
ColorChooser.hsvTransparencyText
=
Transparency
ColorChooser.hsbGreenText
=
G
ColorChooser.hslNameText
=
HSL
ColorChooser.hsbBlueText
=
B
ColorChooser.hslMnemonic
=
76
ColorChooser.hslHueText
=
Hue
ColorChooser.hslSaturationText
=
Saturation
ColorChooser.hslLightnessText
=
Lightness
ColorChooser.hslTransparencyText
=
Transparency
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbDisplayedMnemonicIndex
=
1
ColorChooser.rgbRedText
=
\u
be68
\u
ac04
\u
c0c9(D)
ColorChooser.rgbRedText
=
\u
be68
\u
ac04
\u
c0c9(D)
ColorChooser.rgbRedMnemonic
=
68
ColorChooser.rgbRedMnemonic
=
68
ColorChooser.rgbGreenText
=
\u
b179
\u
c0c9(N)
ColorChooser.rgbGreenText
=
\u
b179
\u
c0c9(N)
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbBlueText
=
\u
d30c
\u
b780
\u
c0c9(B)
ColorChooser.rgbBlueText
=
\u
d30c
\u
b780
\u
c0c9(B)
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbAlphaText
=
Alpha
ColorChooser.rgbHexCodeText
=
Color Code
ColorChooser.rgbHexCodeMnemonic
=
67
ColorChooser.cmykNameText
=
CMYK
ColorChooser.cmykMnemonic
=
77
ColorChooser.cmykCyanText
=
Cyan
ColorChooser.cmykMagentaText
=
Magenta
ColorChooser.cmykYellowText
=
Yellow
ColorChooser.cmykBlackText
=
Black
ColorChooser.cmykAlphaText
=
Alpha
############ OPTION PANE STRINGS #############
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
...
...
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_sv.properties
浏览文件 @
5065850d
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=84
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=84
ColorChooser.sampleText
=
Exempeltext Exempeltext
ColorChooser.sampleText
=
Exempeltext Exempeltext
ColorChooser.swatchesNameText
=
Prov
ColorChooser.swatchesNameText
=
Prov
ColorChooser.swatchesMnemonic
=
80
ColorChooser.swatchesMnemonic
=
80
ColorChooser.swatchesDisplayedMnemonicIndex
=
0
ColorChooser.swatchesRecentText
=
Tidigare:
ColorChooser.swatchesRecentText
=
Tidigare:
ColorChooser.hsbNameText
=
HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic
=
72
ColorChooser.hsvNameText
=
HSV
ColorChooser.hsbDisplayedMnemonicIndex
=
0
ColorChooser.hsvMnemonic
=
72
ColorChooser.hsbHueText
=
H
ColorChooser.hsvHueText
=
Hue
ColorChooser.hsbSaturationText
=
S
ColorChooser.hsvSaturationText
=
Saturation
ColorChooser.hsbBrightnessText
=
B
ColorChooser.hsvValueText
=
Value
ColorChooser.hsbRedText
=
R
ColorChooser.hsvTransparencyText
=
Transparency
ColorChooser.hsbGreenText
=
G
ColorChooser.hslNameText
=
HSL
ColorChooser.hsbBlueText
=
B
ColorChooser.hslMnemonic
=
76
ColorChooser.hslHueText
=
Hue
ColorChooser.hslSaturationText
=
Saturation
ColorChooser.hslLightnessText
=
Lightness
ColorChooser.hslTransparencyText
=
Transparency
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbDisplayedMnemonicIndex
=
1
ColorChooser.rgbRedText
=
R
\u
00f6d
ColorChooser.rgbRedText
=
R
\u
00f6d
ColorChooser.rgbRedMnemonic
=
82
ColorChooser.rgbRedMnemonic
=
82
ColorChooser.rgbGreenText
=
Gr
\u
00f6n
ColorChooser.rgbGreenText
=
Gr
\u
00f6n
ColorChooser.rgbGreenMnemonic
=
71
ColorChooser.rgbGreenMnemonic
=
71
ColorChooser.rgbBlueText
=
Bl
\u
00e5
ColorChooser.rgbBlueText
=
Bl
\u
00e5
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbAlphaText
=
Alpha
ColorChooser.rgbHexCodeText
=
Color Code
ColorChooser.rgbHexCodeMnemonic
=
67
ColorChooser.cmykNameText
=
CMYK
ColorChooser.cmykMnemonic
=
77
ColorChooser.cmykCyanText
=
Cyan
ColorChooser.cmykMagentaText
=
Magenta
ColorChooser.cmykYellowText
=
Yellow
ColorChooser.cmykBlackText
=
Black
ColorChooser.cmykAlphaText
=
Alpha
############ OPTION PANE STRINGS #############
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
...
...
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_CN.properties
浏览文件 @
5065850d
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText
=
\u6837\u
54c1
\u6587\u
672c
\u6837\u
54c1
\u6587\u
672c
ColorChooser.sampleText
=
\u6837\u
54c1
\u6587\u
672c
\u6837\u
54c1
\u6587\u
672c
ColorChooser.swatchesNameText
=
\u6837\u
54c1(S)
ColorChooser.swatchesNameText
=
\u6837\u
54c1(S)
ColorChooser.swatchesMnemonic
=
83
ColorChooser.swatchesMnemonic
=
83
ColorChooser.swatchesDisplayedMnemonicIndex
=
3
ColorChooser.swatchesRecentText
=
\u6700\u
8fd1:
ColorChooser.swatchesRecentText
=
\u6700\u
8fd1:
ColorChooser.hsbNameText
=
HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic
=
72
ColorChooser.hsvNameText
=
HSV
ColorChooser.hsbDisplayedMnemonicIndex
=
0
ColorChooser.hsvMnemonic
=
72
ColorChooser.hsbHueText
=
H
ColorChooser.hsvHueText
=
Hue
ColorChooser.hsbSaturationText
=
S
ColorChooser.hsvSaturationText
=
Saturation
ColorChooser.hsbBrightnessText
=
B
ColorChooser.hsvValueText
=
Value
ColorChooser.hsbRedText
=
R
ColorChooser.hsvTransparencyText
=
Transparency
ColorChooser.hsbGreenText
=
G
ColorChooser.hslNameText
=
HSL
ColorChooser.hsbBlueText
=
B
ColorChooser.hslMnemonic
=
76
ColorChooser.hslHueText
=
Hue
ColorChooser.hslSaturationText
=
Saturation
ColorChooser.hslLightnessText
=
Lightness
ColorChooser.hslTransparencyText
=
Transparency
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbDisplayedMnemonicIndex
=
1
ColorChooser.rgbRedText
=
\u
7ea2
ColorChooser.rgbRedText
=
\u
7ea2
ColorChooser.rgbRedMnemonic
=
68
ColorChooser.rgbRedMnemonic
=
68
ColorChooser.rgbGreenText
=
\u
7eff
ColorChooser.rgbGreenText
=
\u
7eff
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbBlueText
=
\u
84dd
ColorChooser.rgbBlueText
=
\u
84dd
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbAlphaText
=
Alpha
ColorChooser.rgbHexCodeText
=
Color Code
ColorChooser.rgbHexCodeMnemonic
=
67
ColorChooser.cmykNameText
=
CMYK
ColorChooser.cmykMnemonic
=
77
ColorChooser.cmykCyanText
=
Cyan
ColorChooser.cmykMagentaText
=
Magenta
ColorChooser.cmykYellowText
=
Yellow
ColorChooser.cmykBlackText
=
Black
ColorChooser.cmykAlphaText
=
Alpha
############ OPTION PANE STRINGS #############
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
...
...
src/share/classes/com/sun/swing/internal/plaf/basic/resources/basic_zh_TW.properties
浏览文件 @
5065850d
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
...
@@ -101,30 +101,41 @@ ColorChooser.resetMnemonic=82
ColorChooser.sampleText
=
\u
7bc4
\u
4f8b
\u6587\u
5b57
\u
7bc4
\u
4f8b
\u6587\u
5b57
ColorChooser.sampleText
=
\u
7bc4
\u
4f8b
\u6587\u
5b57
\u
7bc4
\u
4f8b
\u6587\u
5b57
ColorChooser.swatchesNameText
=
\u
8abf
\u8272\u
677f(S)
ColorChooser.swatchesNameText
=
\u
8abf
\u8272\u
677f(S)
ColorChooser.swatchesMnemonic
=
83
ColorChooser.swatchesMnemonic
=
83
ColorChooser.swatchesDisplayedMnemonicIndex
=
4
ColorChooser.swatchesRecentText
=
\u6700\u
65b0
\u9078\u
64c7:
ColorChooser.swatchesRecentText
=
\u6700\u
65b0
\u9078\u
64c7:
ColorChooser.hsbNameText
=
HSB
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# Each of the ColorChooser types can define a mnemonic, as a KeyEvent.VK_XXX
# constant, and an index into the text to render the mnemonic as. The
# constant, and an index into the text to render the mnemonic as. The
# mnemonic is xxxMnemonic and the index of the character to underline is
# mnemonic is xxxMnemonic and the index of the character to underline is
# xxxDisplayedMnemonicIndex.
# xxxDisplayedMnemonicIndex.
ColorChooser.hsbMnemonic
=
72
ColorChooser.hsvNameText
=
HSV
ColorChooser.hsbDisplayedMnemonicIndex
=
0
ColorChooser.hsvMnemonic
=
72
ColorChooser.hsbHueText
=
H
ColorChooser.hsvHueText
=
Hue
ColorChooser.hsbSaturationText
=
S
ColorChooser.hsvSaturationText
=
Saturation
ColorChooser.hsbBrightnessText
=
B
ColorChooser.hsvValueText
=
Value
ColorChooser.hsbRedText
=
R
ColorChooser.hsvTransparencyText
=
Transparency
ColorChooser.hsbGreenText
=
G
ColorChooser.hslNameText
=
HSL
ColorChooser.hsbBlueText
=
B
ColorChooser.hslMnemonic
=
76
ColorChooser.hslHueText
=
Hue
ColorChooser.hslSaturationText
=
Saturation
ColorChooser.hslLightnessText
=
Lightness
ColorChooser.hslTransparencyText
=
Transparency
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbNameText
=
RGB
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbMnemonic
=
71
ColorChooser.rgbDisplayedMnemonicIndex
=
1
ColorChooser.rgbRedText
=
\u
7d05
\u8272
(D)
ColorChooser.rgbRedText
=
\u
7d05
\u8272
(D)
ColorChooser.rgbRedMnemonic
=
68
ColorChooser.rgbRedMnemonic
=
68
ColorChooser.rgbGreenText
=
\u
7da0
\u8272
(N)
ColorChooser.rgbGreenText
=
\u
7da0
\u8272
(N)
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbGreenMnemonic
=
78
ColorChooser.rgbBlueText
=
\u
85cd
\u8272
(B)
ColorChooser.rgbBlueText
=
\u
85cd
\u8272
(B)
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbBlueMnemonic
=
66
ColorChooser.rgbAlphaText
=
Alpha
ColorChooser.rgbHexCodeText
=
Color Code
ColorChooser.rgbHexCodeMnemonic
=
67
ColorChooser.cmykNameText
=
CMYK
ColorChooser.cmykMnemonic
=
77
ColorChooser.cmykCyanText
=
Cyan
ColorChooser.cmykMagentaText
=
Magenta
ColorChooser.cmykYellowText
=
Yellow
ColorChooser.cmykBlackText
=
Black
ColorChooser.cmykAlphaText
=
Alpha
############ OPTION PANE STRINGS #############
############ OPTION PANE STRINGS #############
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
# Mnemonic keys correspond to KeyEvent.VK_XXX constant
...
...
src/share/classes/javax/swing/colorchooser/ColorChooserComponentFactory.java
浏览文件 @
5065850d
/*
/*
* Copyright 1998-200
1
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-200
8
Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -25,9 +25,7 @@
...
@@ -25,9 +25,7 @@
package
javax.swing.colorchooser
;
package
javax.swing.colorchooser
;
import
javax.swing.*
;
import
javax.swing.JComponent
;
/**
/**
* A class designed to produce preconfigured "accessory" objects to
* A class designed to produce preconfigured "accessory" objects to
...
@@ -49,16 +47,17 @@ public class ColorChooserComponentFactory {
...
@@ -49,16 +47,17 @@ public class ColorChooserComponentFactory {
private
ColorChooserComponentFactory
()
{
}
// can't instantiate
private
ColorChooserComponentFactory
()
{
}
// can't instantiate
public
static
AbstractColorChooserPanel
[]
getDefaultChooserPanels
()
{
public
static
AbstractColorChooserPanel
[]
getDefaultChooserPanels
()
{
AbstractColorChooserPanel
[]
choosers
=
{
new
DefaultSwatchChooserPanel
(),
return
new
AbstractColorChooserPanel
[]
{
new
DefaultHSBChooserPanel
(),
new
DefaultSwatchChooserPanel
(),
new
DefaultRGBChooserPanel
()
};
new
ColorChooserPanel
(
new
ColorModelHSV
()),
return
choosers
;
new
ColorChooserPanel
(
new
ColorModelHSL
()),
new
ColorChooserPanel
(
new
ColorModel
()),
new
ColorChooserPanel
(
new
ColorModelCMYK
()),
};
}
}
public
static
JComponent
getPreviewPanel
()
{
public
static
JComponent
getPreviewPanel
()
{
return
new
DefaultPreviewPanel
();
return
new
DefaultPreviewPanel
();
}
}
}
}
src/share/classes/javax/swing/colorchooser/ColorChooserPanel.java
0 → 100644
浏览文件 @
5065850d
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
javax.swing.colorchooser
;
import
java.awt.Color
;
import
java.awt.GridBagConstraints
;
import
java.awt.GridBagLayout
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
javax.swing.Icon
;
import
javax.swing.JComponent
;
import
javax.swing.JFormattedTextField
;
import
javax.swing.JLabel
;
import
javax.swing.SwingConstants
;
final
class
ColorChooserPanel
extends
AbstractColorChooserPanel
implements
PropertyChangeListener
{
private
static
final
int
MASK
=
0xFF000000
;
private
final
ColorModel
model
;
private
final
ColorPanel
panel
;
private
final
DiagramComponent
slider
;
private
final
DiagramComponent
diagram
;
private
final
JFormattedTextField
text
;
private
final
JLabel
label
;
ColorChooserPanel
(
ColorModel
model
)
{
this
.
model
=
model
;
this
.
panel
=
new
ColorPanel
(
this
.
model
);
this
.
slider
=
new
DiagramComponent
(
this
.
panel
,
false
);
this
.
diagram
=
new
DiagramComponent
(
this
.
panel
,
true
);
this
.
text
=
new
JFormattedTextField
();
this
.
label
=
new
JLabel
(
null
,
null
,
SwingConstants
.
RIGHT
);
ValueFormatter
.
init
(
6
,
true
,
this
.
text
);
}
@Override
public
void
updateChooser
()
{
Color
color
=
getColorFromModel
();
this
.
panel
.
setColor
(
color
);
this
.
text
.
setValue
(
Integer
.
valueOf
(
color
.
getRGB
()));
this
.
slider
.
repaint
();
this
.
diagram
.
repaint
();
}
@Override
protected
void
buildChooser
()
{
if
(
0
==
getComponentCount
())
{
setLayout
(
new
GridBagLayout
());
GridBagConstraints
gbc
=
new
GridBagConstraints
();
gbc
.
gridx
=
3
;
gbc
.
gridwidth
=
2
;
gbc
.
weighty
=
1.0
;
gbc
.
anchor
=
GridBagConstraints
.
NORTH
;
gbc
.
fill
=
GridBagConstraints
.
HORIZONTAL
;
gbc
.
insets
.
top
=
10
;
gbc
.
insets
.
right
=
10
;
add
(
this
.
panel
,
gbc
);
gbc
.
gridwidth
=
1
;
gbc
.
weightx
=
1.0
;
gbc
.
weighty
=
0.0
;
gbc
.
anchor
=
GridBagConstraints
.
CENTER
;
gbc
.
insets
.
right
=
5
;
gbc
.
insets
.
bottom
=
10
;
add
(
this
.
label
,
gbc
);
gbc
.
gridx
=
4
;
gbc
.
weightx
=
0.0
;
gbc
.
insets
.
right
=
10
;
add
(
this
.
text
,
gbc
);
gbc
.
gridx
=
2
;
gbc
.
gridheight
=
2
;
gbc
.
anchor
=
GridBagConstraints
.
NORTH
;
gbc
.
ipadx
=
this
.
text
.
getPreferredSize
().
height
;
gbc
.
ipady
=
getPreferredSize
().
height
;
add
(
this
.
slider
,
gbc
);
gbc
.
gridx
=
1
;
gbc
.
insets
.
left
=
10
;
gbc
.
ipadx
=
gbc
.
ipady
;
add
(
this
.
diagram
,
gbc
);
this
.
label
.
setLabelFor
(
this
.
text
);
this
.
text
.
addPropertyChangeListener
(
"value"
,
this
);
// NON-NLS: the property name
this
.
slider
.
setBorder
(
this
.
text
.
getBorder
());
this
.
diagram
.
setBorder
(
this
.
text
.
getBorder
());
setInheritsPopupMenu
(
this
,
true
);
// CR:4966112
}
String
label
=
this
.
model
.
getText
(
this
,
"HexCode"
);
// NON-NLS: suffix
boolean
visible
=
label
!=
null
;
this
.
text
.
setVisible
(
visible
);
this
.
label
.
setVisible
(
visible
);
if
(
visible
)
{
this
.
label
.
setText
(
label
);
int
mnemonic
=
this
.
model
.
getInteger
(
this
,
"HexCodeMnemonic"
);
// NON-NLS: suffix
if
(
mnemonic
>
0
)
{
this
.
label
.
setDisplayedMnemonic
(
mnemonic
);
mnemonic
=
this
.
model
.
getInteger
(
this
,
"HexCodeMnemonicIndex"
);
// NON-NLS: suffix
if
(
mnemonic
>=
0
)
{
this
.
label
.
setDisplayedMnemonicIndex
(
mnemonic
);
}
}
}
this
.
panel
.
buildPanel
();
}
@Override
public
String
getDisplayName
()
{
return
this
.
model
.
getText
(
this
,
"Name"
);
// NON-NLS: suffix
}
@Override
public
int
getMnemonic
()
{
return
this
.
model
.
getInteger
(
this
,
"Mnemonic"
);
// NON-NLS: suffix
}
@Override
public
int
getDisplayedMnemonicIndex
()
{
return
this
.
model
.
getInteger
(
this
,
"DisplayedMnemonicIndex"
);
// NON-NLS: suffix
}
@Override
public
Icon
getSmallDisplayIcon
()
{
return
null
;
}
@Override
public
Icon
getLargeDisplayIcon
()
{
return
null
;
}
public
void
propertyChange
(
PropertyChangeEvent
event
)
{
Object
object
=
event
.
getNewValue
();
if
(
object
instanceof
Integer
)
{
int
value
=
MASK
&
getColorFromModel
().
getRGB
()
|
(
Integer
)
object
;
getColorSelectionModel
().
setSelectedColor
(
new
Color
(
value
,
true
));
}
this
.
text
.
selectAll
();
}
/**
* Allows to show context popup for all components recursively.
*
* @param component the root component of the tree
* @param value whether or not the popup menu is inherited
*/
private
static
void
setInheritsPopupMenu
(
JComponent
component
,
boolean
value
)
{
component
.
setInheritsPopupMenu
(
value
);
for
(
Object
object
:
component
.
getComponents
())
{
if
(
object
instanceof
JComponent
)
{
setInheritsPopupMenu
((
JComponent
)
object
,
value
);
}
}
}
}
src/share/classes/javax/swing/colorchooser/ColorModel.java
0 → 100644
浏览文件 @
5065850d
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
javax.swing.colorchooser
;
import
java.awt.Component
;
import
javax.swing.UIManager
;
class
ColorModel
{
private
final
String
prefix
;
private
final
String
[]
labels
;
ColorModel
(
String
name
,
String
...
labels
)
{
this
.
prefix
=
"ColorChooser."
+
name
;
// NON-NLS: default prefix
this
.
labels
=
labels
;
}
ColorModel
()
{
this
(
"rgb"
,
"Red"
,
"Green"
,
"Blue"
,
"Alpha"
);
// NON-NLS: components
}
void
setColor
(
int
color
,
float
[]
model
)
{
model
[
0
]
=
normalize
(
color
>>
16
);
model
[
1
]
=
normalize
(
color
>>
8
);
model
[
2
]
=
normalize
(
color
);
model
[
3
]
=
normalize
(
color
>>
24
);
}
int
getColor
(
float
[]
model
)
{
return
to8bit
(
model
[
2
])
|
(
to8bit
(
model
[
1
])
<<
8
)
|
(
to8bit
(
model
[
0
])
<<
16
)
|
(
to8bit
(
model
[
3
])
<<
24
);
}
int
getCount
()
{
return
this
.
labels
.
length
;
}
int
getMinimum
(
int
index
)
{
return
0
;
}
int
getMaximum
(
int
index
)
{
return
255
;
}
float
getDefault
(
int
index
)
{
return
0.0f
;
}
final
String
getLabel
(
Component
component
,
int
index
)
{
return
getText
(
component
,
this
.
labels
[
index
]);
}
private
static
float
normalize
(
int
value
)
{
return
(
float
)
(
value
&
0xFF
)
/
255.0f
;
}
private
static
int
to8bit
(
float
value
)
{
return
(
int
)
(
255.0f
*
value
);
}
final
String
getText
(
Component
component
,
String
suffix
)
{
return
UIManager
.
getString
(
this
.
prefix
+
suffix
+
"Text"
,
component
.
getLocale
());
// NON-NLS: default postfix
}
final
int
getInteger
(
Component
component
,
String
suffix
)
{
Object
value
=
UIManager
.
get
(
this
.
prefix
+
suffix
,
component
.
getLocale
());
if
(
value
instanceof
Integer
)
{
return
(
Integer
)
value
;
}
if
(
value
instanceof
String
)
{
try
{
return
Integer
.
parseInt
((
String
)
value
);
}
catch
(
NumberFormatException
exception
)
{
}
}
return
-
1
;
}
}
src/share/classes/javax/swing/colorchooser/ColorModelCMYK.java
0 → 100644
浏览文件 @
5065850d
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
javax.swing.colorchooser
;
final
class
ColorModelCMYK
extends
ColorModel
{
ColorModelCMYK
()
{
super
(
"cmyk"
,
"Cyan"
,
"Magenta"
,
"Yellow"
,
"Black"
,
"Alpha"
);
// NON-NLS: components
}
@Override
void
setColor
(
int
color
,
float
[]
space
)
{
super
.
setColor
(
color
,
space
);
space
[
4
]
=
space
[
3
];
RGBtoCMYK
(
space
,
space
);
}
@Override
int
getColor
(
float
[]
space
)
{
CMYKtoRGB
(
space
,
space
);
space
[
3
]
=
space
[
4
];
return
super
.
getColor
(
space
);
}
/**
* Converts CMYK components of a color to a set of RGB components.
*
* @param cmyk a float array with length equal to
* the number of CMYK components
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @return a float array that contains RGB components
*/
private
static
float
[]
CMYKtoRGB
(
float
[]
cmyk
,
float
[]
rgb
)
{
if
(
rgb
==
null
)
{
rgb
=
new
float
[
3
];
}
rgb
[
0
]
=
1.0f
+
cmyk
[
0
]
*
cmyk
[
3
]
-
cmyk
[
3
]
-
cmyk
[
0
];
rgb
[
1
]
=
1.0f
+
cmyk
[
1
]
*
cmyk
[
3
]
-
cmyk
[
3
]
-
cmyk
[
1
];
rgb
[
2
]
=
1.0f
+
cmyk
[
2
]
*
cmyk
[
3
]
-
cmyk
[
3
]
-
cmyk
[
2
];
return
rgb
;
}
/**
* Converts RGB components of a color to a set of CMYK components.
*
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @param cmyk a float array with length equal to
* the number of CMYK components
* @return a float array that contains CMYK components
*/
private
static
float
[]
RGBtoCMYK
(
float
[]
rgb
,
float
[]
cmyk
)
{
if
(
cmyk
==
null
)
{
cmyk
=
new
float
[
4
];
}
float
max
=
ColorModelHSL
.
max
(
rgb
[
0
],
rgb
[
1
],
rgb
[
2
]);
if
(
max
>
0.0f
)
{
cmyk
[
0
]
=
1.0f
-
rgb
[
0
]
/
max
;
cmyk
[
1
]
=
1.0f
-
rgb
[
1
]
/
max
;
cmyk
[
2
]
=
1.0f
-
rgb
[
2
]
/
max
;
}
else
{
cmyk
[
0
]
=
0.0f
;
cmyk
[
1
]
=
0.0f
;
cmyk
[
2
]
=
0.0f
;
}
cmyk
[
3
]
=
1.0f
-
max
;
return
cmyk
;
}
}
src/share/classes/javax/swing/colorchooser/ColorModelHSL.java
0 → 100644
浏览文件 @
5065850d
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
javax.swing.colorchooser
;
final
class
ColorModelHSL
extends
ColorModel
{
ColorModelHSL
()
{
super
(
"hsl"
,
"Hue"
,
"Saturation"
,
"Lightness"
,
"Transparency"
);
// NON-NLS: components
}
@Override
void
setColor
(
int
color
,
float
[]
space
)
{
super
.
setColor
(
color
,
space
);
RGBtoHSL
(
space
,
space
);
space
[
3
]
=
1.0f
-
space
[
3
];
}
@Override
int
getColor
(
float
[]
space
)
{
space
[
3
]
=
1.0f
-
space
[
3
];
HSLtoRGB
(
space
,
space
);
return
super
.
getColor
(
space
);
}
@Override
int
getMaximum
(
int
index
)
{
return
(
index
==
0
)
?
360
:
100
;
}
@Override
float
getDefault
(
int
index
)
{
return
(
index
==
0
)
?
-
1.0f
:
(
index
==
2
)
?
0.5f
:
1.0f
;
}
/**
* Converts HSL components of a color to a set of RGB components.
*
* @param hsl a float array with length equal to
* the number of HSL components
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @return a float array that contains RGB components
*/
private
static
float
[]
HSLtoRGB
(
float
[]
hsl
,
float
[]
rgb
)
{
if
(
rgb
==
null
)
{
rgb
=
new
float
[
3
];
}
float
hue
=
hsl
[
0
];
float
saturation
=
hsl
[
1
];
float
lightness
=
hsl
[
2
];
if
(
saturation
>
0.0f
)
{
hue
=
(
hue
<
1.0f
)
?
hue
*
6.0f
:
0.0f
;
float
q
=
lightness
+
saturation
*
((
lightness
>
0.5f
)
?
1.0f
-
lightness
:
lightness
);
float
p
=
2.0f
*
lightness
-
q
;
rgb
[
0
]=
normalize
(
q
,
p
,
(
hue
<
4.0f
)
?
(
hue
+
2.0f
)
:
(
hue
-
4.0f
));
rgb
[
1
]=
normalize
(
q
,
p
,
hue
);
rgb
[
2
]=
normalize
(
q
,
p
,
(
hue
<
2.0f
)
?
(
hue
+
4.0f
)
:
(
hue
-
2.0f
));
}
else
{
rgb
[
0
]
=
lightness
;
rgb
[
1
]
=
lightness
;
rgb
[
2
]
=
lightness
;
}
return
rgb
;
}
/**
* Converts RGB components of a color to a set of HSL components.
*
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @param hsl a float array with length equal to
* the number of HSL components
* @return a float array that contains HSL components
*/
private
static
float
[]
RGBtoHSL
(
float
[]
rgb
,
float
[]
hsl
)
{
if
(
hsl
==
null
)
{
hsl
=
new
float
[
3
];
}
float
max
=
max
(
rgb
[
0
],
rgb
[
1
],
rgb
[
2
]);
float
min
=
min
(
rgb
[
0
],
rgb
[
1
],
rgb
[
2
]);
float
summa
=
max
+
min
;
float
saturation
=
max
-
min
;
if
(
saturation
>
0.0f
)
{
saturation
/=
(
summa
>
1.0f
)
?
2.0f
-
summa
:
summa
;
}
hsl
[
0
]
=
getHue
(
rgb
[
0
],
rgb
[
1
],
rgb
[
2
],
max
,
min
);
hsl
[
1
]
=
saturation
;
hsl
[
2
]
=
summa
/
2.0f
;
return
hsl
;
}
/**
* Returns the smaller of three color components.
*
* @param red the red component of the color
* @param green the green component of the color
* @param blue the blue component of the color
* @return the smaller of {@code red}, {@code green} and {@code blue}
*/
static
float
min
(
float
red
,
float
green
,
float
blue
)
{
float
min
=
(
red
<
green
)
?
red
:
green
;
return
(
min
<
blue
)
?
min
:
blue
;
}
/**
* Returns the larger of three color components.
*
* @param red the red component of the color
* @param green the green component of the color
* @param blue the blue component of the color
* @return the larger of {@code red}, {@code green} and {@code blue}
*/
static
float
max
(
float
red
,
float
green
,
float
blue
)
{
float
max
=
(
red
>
green
)
?
red
:
green
;
return
(
max
>
blue
)
?
max
:
blue
;
}
/**
* Calculates the hue component for HSL and HSV color spaces.
*
* @param red the red component of the color
* @param green the green component of the color
* @param blue the blue component of the color
* @param max the larger of {@code red}, {@code green} and {@code blue}
* @param min the smaller of {@code red}, {@code green} and {@code blue}
* @return the hue component
*/
static
float
getHue
(
float
red
,
float
green
,
float
blue
,
float
max
,
float
min
)
{
float
hue
=
max
-
min
;
if
(
hue
>
0.0f
)
{
if
(
max
==
red
)
{
hue
=
(
green
-
blue
)
/
hue
;
if
(
hue
<
0.0f
)
{
hue
+=
6.0f
;
}
}
else
if
(
max
==
green
)
{
hue
=
2.0f
+
(
blue
-
red
)
/
hue
;
}
else
/*max == blue*/
{
hue
=
4.0f
+
(
red
-
green
)
/
hue
;
}
hue
/=
6.0f
;
}
return
hue
;
}
private
static
float
normalize
(
float
q
,
float
p
,
float
color
)
{
if
(
color
<
1.0f
)
{
return
p
+
(
q
-
p
)
*
color
;
}
if
(
color
<
3.0f
)
{
return
q
;
}
if
(
color
<
4.0f
)
{
return
p
+
(
q
-
p
)
*
(
4.0f
-
color
);
}
return
p
;
}
}
src/share/classes/javax/swing/colorchooser/ColorModelHSV.java
0 → 100644
浏览文件 @
5065850d
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
javax.swing.colorchooser
;
final
class
ColorModelHSV
extends
ColorModel
{
ColorModelHSV
()
{
super
(
"hsv"
,
"Hue"
,
"Saturation"
,
"Value"
,
"Transparency"
);
// NON-NLS: components
}
@Override
void
setColor
(
int
color
,
float
[]
space
)
{
super
.
setColor
(
color
,
space
);
RGBtoHSV
(
space
,
space
);
space
[
3
]
=
1.0f
-
space
[
3
];
}
@Override
int
getColor
(
float
[]
space
)
{
space
[
3
]
=
1.0f
-
space
[
3
];
HSVtoRGB
(
space
,
space
);
return
super
.
getColor
(
space
);
}
@Override
int
getMaximum
(
int
index
)
{
return
(
index
==
0
)
?
360
:
100
;
}
@Override
float
getDefault
(
int
index
)
{
return
(
index
==
0
)
?
-
1.0f
:
1.0f
;
}
/**
* Converts HSV components of a color to a set of RGB components.
*
* @param hsv a float array with length equal to
* the number of HSV components
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @return a float array that contains RGB components
*/
private
static
float
[]
HSVtoRGB
(
float
[]
hsv
,
float
[]
rgb
)
{
if
(
rgb
==
null
)
{
rgb
=
new
float
[
3
];
}
float
hue
=
hsv
[
0
];
float
saturation
=
hsv
[
1
];
float
value
=
hsv
[
2
];
rgb
[
0
]
=
value
;
rgb
[
1
]
=
value
;
rgb
[
2
]
=
value
;
if
(
saturation
>
0.0f
)
{
hue
=
(
hue
<
1.0f
)
?
hue
*
6.0f
:
0.0f
;
int
integer
=
(
int
)
hue
;
float
f
=
hue
-
(
float
)
integer
;
switch
(
integer
)
{
case
0
:
rgb
[
1
]
*=
1.0f
-
saturation
*
(
1.0f
-
f
);
rgb
[
2
]
*=
1.0f
-
saturation
;
break
;
case
1
:
rgb
[
0
]
*=
1.0f
-
saturation
*
f
;
rgb
[
2
]
*=
1.0f
-
saturation
;
break
;
case
2
:
rgb
[
0
]
*=
1.0f
-
saturation
;
rgb
[
2
]
*=
1.0f
-
saturation
*
(
1.0f
-
f
);
break
;
case
3
:
rgb
[
0
]
*=
1.0f
-
saturation
;
rgb
[
1
]
*=
1.0f
-
saturation
*
f
;
break
;
case
4
:
rgb
[
0
]
*=
1.0f
-
saturation
*
(
1.0f
-
f
);
rgb
[
1
]
*=
1.0f
-
saturation
;
break
;
case
5
:
rgb
[
1
]
*=
1.0f
-
saturation
;
rgb
[
2
]
*=
1.0f
-
saturation
*
f
;
break
;
}
}
return
rgb
;
}
/**
* Converts RGB components of a color to a set of HSV components.
*
* @param rgb a float array with length of at least 3
* that contains RGB components of a color
* @param hsv a float array with length equal to
* the number of HSV components
* @return a float array that contains HSV components
*/
private
static
float
[]
RGBtoHSV
(
float
[]
rgb
,
float
[]
hsv
)
{
if
(
hsv
==
null
)
{
hsv
=
new
float
[
3
];
}
float
max
=
ColorModelHSL
.
max
(
rgb
[
0
],
rgb
[
1
],
rgb
[
2
]);
float
min
=
ColorModelHSL
.
min
(
rgb
[
0
],
rgb
[
1
],
rgb
[
2
]);
float
saturation
=
max
-
min
;
if
(
saturation
>
0.0f
)
{
saturation
/=
max
;
}
hsv
[
0
]
=
ColorModelHSL
.
getHue
(
rgb
[
0
],
rgb
[
1
],
rgb
[
2
],
max
,
min
);
hsv
[
1
]
=
saturation
;
hsv
[
2
]
=
max
;
return
hsv
;
}
}
src/share/classes/javax/swing/colorchooser/ColorPanel.java
0 → 100644
浏览文件 @
5065850d
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
javax.swing.colorchooser
;
import
java.awt.Color
;
import
java.awt.ContainerOrderFocusTraversalPolicy
;
import
java.awt.GridBagConstraints
;
import
java.awt.GridBagLayout
;
import
java.awt.Insets
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
javax.swing.ButtonGroup
;
import
javax.swing.JLabel
;
import
javax.swing.JPanel
;
import
javax.swing.JRadioButton
;
import
javax.swing.border.EmptyBorder
;
final
class
ColorPanel
extends
JPanel
implements
ActionListener
{
private
final
SlidingSpinner
[]
spinners
=
new
SlidingSpinner
[
5
];
private
final
float
[]
values
=
new
float
[
this
.
spinners
.
length
];
private
final
ColorModel
model
;
private
Color
color
;
private
int
x
=
1
;
private
int
y
=
2
;
private
int
z
;
ColorPanel
(
ColorModel
model
)
{
super
(
new
GridBagLayout
());
GridBagConstraints
gbc
=
new
GridBagConstraints
();
gbc
.
fill
=
GridBagConstraints
.
HORIZONTAL
;
gbc
.
gridx
=
1
;
ButtonGroup
group
=
new
ButtonGroup
();
EmptyBorder
border
=
null
;
for
(
int
i
=
0
;
i
<
this
.
spinners
.
length
;
i
++)
{
if
(
i
<
3
)
{
JRadioButton
button
=
new
JRadioButton
();
if
(
i
==
0
)
{
Insets
insets
=
button
.
getInsets
();
insets
.
left
=
button
.
getPreferredSize
().
width
;
border
=
new
EmptyBorder
(
insets
);
button
.
setSelected
(
true
);
gbc
.
insets
.
top
=
5
;
}
add
(
button
,
gbc
);
group
.
add
(
button
);
button
.
setActionCommand
(
Integer
.
toString
(
i
));
button
.
addActionListener
(
this
);
this
.
spinners
[
i
]
=
new
SlidingSpinner
(
this
,
button
);
}
else
{
JLabel
label
=
new
JLabel
();
add
(
label
,
gbc
);
label
.
setBorder
(
border
);
label
.
setFocusable
(
false
);
this
.
spinners
[
i
]
=
new
SlidingSpinner
(
this
,
label
);
}
}
gbc
.
gridx
=
2
;
gbc
.
weightx
=
1.0
;
gbc
.
insets
.
top
=
0
;
gbc
.
insets
.
left
=
5
;
for
(
SlidingSpinner
spinner
:
this
.
spinners
)
{
add
(
spinner
.
getSlider
(),
gbc
);
gbc
.
insets
.
top
=
5
;
}
gbc
.
gridx
=
3
;
gbc
.
weightx
=
0.0
;
gbc
.
insets
.
top
=
0
;
for
(
SlidingSpinner
spinner
:
this
.
spinners
)
{
add
(
spinner
.
getSpinner
(),
gbc
);
gbc
.
insets
.
top
=
5
;
}
setFocusTraversalPolicy
(
new
ContainerOrderFocusTraversalPolicy
());
setFocusTraversalPolicyProvider
(
true
);
setFocusable
(
false
);
this
.
model
=
model
;
}
public
void
actionPerformed
(
ActionEvent
event
)
{
try
{
this
.
z
=
Integer
.
parseInt
(
event
.
getActionCommand
());
this
.
y
=
(
this
.
z
!=
2
)
?
2
:
1
;
this
.
x
=
(
this
.
z
!=
0
)
?
0
:
1
;
getParent
().
repaint
();
}
catch
(
NumberFormatException
exception
)
{
}
}
void
buildPanel
()
{
int
count
=
this
.
model
.
getCount
();
this
.
spinners
[
4
].
setVisible
(
count
>
4
);
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
Object
object
=
this
.
spinners
[
i
].
getLabel
();
if
(
object
instanceof
JRadioButton
)
{
JRadioButton
button
=
(
JRadioButton
)
object
;
button
.
setText
(
this
.
model
.
getLabel
(
this
,
i
));
}
else
if
(
object
instanceof
JLabel
)
{
JLabel
label
=
(
JLabel
)
object
;
label
.
setText
(
this
.
model
.
getLabel
(
this
,
i
));
}
this
.
spinners
[
i
].
setRange
(
this
.
model
.
getMinimum
(
i
),
this
.
model
.
getMaximum
(
i
));
this
.
spinners
[
i
].
setValue
(
this
.
values
[
i
]);
}
}
void
colorChanged
()
{
this
.
color
=
new
Color
(
getColor
(
0
),
true
);
Object
parent
=
getParent
();
if
(
parent
instanceof
ColorChooserPanel
)
{
ColorChooserPanel
chooser
=
(
ColorChooserPanel
)
parent
;
chooser
.
getColorSelectionModel
().
setSelectedColor
(
this
.
color
);
chooser
.
repaint
();
}
}
float
getValueX
()
{
return
this
.
spinners
[
this
.
x
].
getValue
();
}
float
getValueY
()
{
return
1.0f
-
this
.
spinners
[
this
.
y
].
getValue
();
}
float
getValueZ
()
{
return
1.0f
-
this
.
spinners
[
this
.
z
].
getValue
();
}
void
setValue
(
float
z
)
{
this
.
spinners
[
this
.
z
].
setValue
(
1.0f
-
z
);
colorChanged
();
}
void
setValue
(
float
x
,
float
y
)
{
this
.
spinners
[
this
.
x
].
setValue
(
x
);
this
.
spinners
[
this
.
y
].
setValue
(
1.0f
-
y
);
colorChanged
();
}
int
getColor
(
float
z
)
{
setDefaultValue
(
this
.
x
);
setDefaultValue
(
this
.
y
);
this
.
values
[
this
.
z
]
=
1.0f
-
z
;
return
getColor
(
3
);
}
int
getColor
(
float
x
,
float
y
)
{
this
.
values
[
this
.
x
]
=
x
;
this
.
values
[
this
.
y
]
=
1.0f
-
y
;
setValue
(
this
.
z
);
return
getColor
(
3
);
}
void
setColor
(
Color
color
)
{
if
(!
color
.
equals
(
this
.
color
))
{
this
.
color
=
color
;
this
.
model
.
setColor
(
color
.
getRGB
(),
this
.
values
);
for
(
int
i
=
0
;
i
<
this
.
model
.
getCount
();
i
++)
{
this
.
spinners
[
i
].
setValue
(
this
.
values
[
i
]);
}
}
}
private
int
getColor
(
int
index
)
{
while
(
index
<
this
.
model
.
getCount
())
{
setValue
(
index
++);
}
return
this
.
model
.
getColor
(
this
.
values
);
}
private
void
setValue
(
int
index
)
{
this
.
values
[
index
]
=
this
.
spinners
[
index
].
getValue
();
}
private
void
setDefaultValue
(
int
index
)
{
float
value
=
this
.
model
.
getDefault
(
index
);
this
.
values
[
index
]
=
(
value
<
0.0f
)
?
this
.
spinners
[
index
].
getValue
()
:
value
;
}
}
src/share/classes/javax/swing/colorchooser/DefaultHSBChooserPanel.java
已删除
100644 → 0
浏览文件 @
b8445e0c
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/colorchooser/DefaultRGBChooserPanel.java
已删除
100644 → 0
浏览文件 @
b8445e0c
/*
* Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
javax.swing.colorchooser
;
import
javax.swing.*
;
import
javax.swing.event.*
;
import
java.awt.*
;
import
java.util.Locale
;
/**
* The standard RGB chooser.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans<sup><font size="-2">TM</font></sup>
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Steve Wilson
* @author Mark Davidson
* @see JColorChooser
* @see AbstractColorChooserPanel
*/
class
DefaultRGBChooserPanel
extends
AbstractColorChooserPanel
implements
ChangeListener
{
protected
JSlider
redSlider
;
protected
JSlider
greenSlider
;
protected
JSlider
blueSlider
;
protected
JSpinner
redField
;
protected
JSpinner
blueField
;
protected
JSpinner
greenField
;
private
final
int
minValue
=
0
;
private
final
int
maxValue
=
255
;
private
boolean
isAdjusting
=
false
;
// indicates the fields are being set internally
public
DefaultRGBChooserPanel
()
{
super
();
setInheritsPopupMenu
(
true
);
}
/**
* Sets the values of the controls to reflect the color
*/
private
void
setColor
(
Color
newColor
)
{
int
red
=
newColor
.
getRed
();
int
blue
=
newColor
.
getBlue
();
int
green
=
newColor
.
getGreen
();
if
(
redSlider
.
getValue
()
!=
red
)
{
redSlider
.
setValue
(
red
);
}
if
(
greenSlider
.
getValue
()
!=
green
)
{
greenSlider
.
setValue
(
green
);
}
if
(
blueSlider
.
getValue
()
!=
blue
)
{
blueSlider
.
setValue
(
blue
);
}
if
(((
Integer
)
redField
.
getValue
()).
intValue
()
!=
red
)
redField
.
setValue
(
new
Integer
(
red
));
if
(((
Integer
)
greenField
.
getValue
()).
intValue
()
!=
green
)
greenField
.
setValue
(
new
Integer
(
green
));
if
(((
Integer
)
blueField
.
getValue
()).
intValue
()
!=
blue
)
blueField
.
setValue
(
new
Integer
(
blue
));
}
public
String
getDisplayName
()
{
return
UIManager
.
getString
(
"ColorChooser.rgbNameText"
,
getLocale
());
}
/**
* Provides a hint to the look and feel as to the
* <code>KeyEvent.VK</code> constant that can be used as a mnemonic to
* access the panel. A return value <= 0 indicates there is no mnemonic.
* <p>
* The return value here is a hint, it is ultimately up to the look
* and feel to honor the return value in some meaningful way.
* <p>
* This implementation looks up the value from the default
* <code>ColorChooser.rgbMnemonic</code>, or if it
* isn't available (or not an <code>Integer</code>) returns -1.
* The lookup for the default is done through the <code>UIManager</code>:
* <code>UIManager.get("ColorChooser.rgbMnemonic");</code>.
*
* @return KeyEvent.VK constant identifying the mnemonic; <= 0 for no
* mnemonic
* @see #getDisplayedMnemonicIndex
* @since 1.4
*/
public
int
getMnemonic
()
{
return
getInt
(
"ColorChooser.rgbMnemonic"
,
-
1
);
}
/**
* Provides a hint to the look and feel as to the index of the character in
* <code>getDisplayName</code> that should be visually identified as the
* mnemonic. The look and feel should only use this if
* <code>getMnemonic</code> returns a value > 0.
* <p>
* The return value here is a hint, it is ultimately up to the look
* and feel to honor the return value in some meaningful way. For example,
* a look and feel may wish to render each
* <code>AbstractColorChooserPanel</code> in a <code>JTabbedPane</code>,
* and further use this return value to underline a character in
* the <code>getDisplayName</code>.
* <p>
* This implementation looks up the value from the default
* <code>ColorChooser.rgbDisplayedMnemonicIndex</code>, or if it
* isn't available (or not an <code>Integer</code>) returns -1.
* The lookup for the default is done through the <code>UIManager</code>:
* <code>UIManager.get("ColorChooser.rgbDisplayedMnemonicIndex");</code>.
*
* @return Character index to render mnemonic for; -1 to provide no
* visual identifier for this panel.
* @see #getMnemonic
* @since 1.4
*/
public
int
getDisplayedMnemonicIndex
()
{
return
getInt
(
"ColorChooser.rgbDisplayedMnemonicIndex"
,
-
1
);
}
public
Icon
getSmallDisplayIcon
()
{
return
null
;
}
public
Icon
getLargeDisplayIcon
()
{
return
null
;
}
/**
* The background color, foreground color, and font are already set to the
* defaults from the defaults table before this method is called.
*/
public
void
installChooserPanel
(
JColorChooser
enclosingChooser
)
{
super
.
installChooserPanel
(
enclosingChooser
);
}
protected
void
buildChooser
()
{
Locale
locale
=
getLocale
();
String
redString
=
UIManager
.
getString
(
"ColorChooser.rgbRedText"
,
locale
);
String
greenString
=
UIManager
.
getString
(
"ColorChooser.rgbGreenText"
,
locale
);
String
blueString
=
UIManager
.
getString
(
"ColorChooser.rgbBlueText"
,
locale
);
setLayout
(
new
BorderLayout
()
);
Color
color
=
getColorFromModel
();
JPanel
enclosure
=
new
JPanel
();
enclosure
.
setLayout
(
new
SmartGridLayout
(
3
,
3
)
);
enclosure
.
setInheritsPopupMenu
(
true
);
// The panel that holds the sliders
add
(
enclosure
,
BorderLayout
.
CENTER
);
// sliderPanel.setBorder(new LineBorder(Color.black));
// The row for the red value
JLabel
l
=
new
JLabel
(
redString
);
l
.
setDisplayedMnemonic
(
getInt
(
"ColorChooser.rgbRedMnemonic"
,
-
1
));
enclosure
.
add
(
l
);
redSlider
=
new
JSlider
(
JSlider
.
HORIZONTAL
,
0
,
255
,
color
.
getRed
());
redSlider
.
setMajorTickSpacing
(
85
);
redSlider
.
setMinorTickSpacing
(
17
);
redSlider
.
setPaintTicks
(
true
);
redSlider
.
setPaintLabels
(
true
);
redSlider
.
setInheritsPopupMenu
(
true
);
enclosure
.
add
(
redSlider
);
redField
=
new
JSpinner
(
new
SpinnerNumberModel
(
color
.
getRed
(),
minValue
,
maxValue
,
1
));
l
.
setLabelFor
(
redSlider
);
redField
.
setInheritsPopupMenu
(
true
);
JPanel
redFieldHolder
=
new
JPanel
(
new
CenterLayout
());
redFieldHolder
.
setInheritsPopupMenu
(
true
);
redField
.
addChangeListener
(
this
);
redFieldHolder
.
add
(
redField
);
enclosure
.
add
(
redFieldHolder
);
// The row for the green value
l
=
new
JLabel
(
greenString
);
l
.
setDisplayedMnemonic
(
getInt
(
"ColorChooser.rgbGreenMnemonic"
,
-
1
));
enclosure
.
add
(
l
);
greenSlider
=
new
JSlider
(
JSlider
.
HORIZONTAL
,
0
,
255
,
color
.
getGreen
());
greenSlider
.
setMajorTickSpacing
(
85
);
greenSlider
.
setMinorTickSpacing
(
17
);
greenSlider
.
setPaintTicks
(
true
);
greenSlider
.
setPaintLabels
(
true
);
greenSlider
.
setInheritsPopupMenu
(
true
);
enclosure
.
add
(
greenSlider
);
greenField
=
new
JSpinner
(
new
SpinnerNumberModel
(
color
.
getGreen
(),
minValue
,
maxValue
,
1
));
l
.
setLabelFor
(
greenSlider
);
greenField
.
setInheritsPopupMenu
(
true
);
JPanel
greenFieldHolder
=
new
JPanel
(
new
CenterLayout
());
greenFieldHolder
.
add
(
greenField
);
greenFieldHolder
.
setInheritsPopupMenu
(
true
);
greenField
.
addChangeListener
(
this
);
enclosure
.
add
(
greenFieldHolder
);
// The slider for the blue value
l
=
new
JLabel
(
blueString
);
l
.
setDisplayedMnemonic
(
getInt
(
"ColorChooser.rgbBlueMnemonic"
,
-
1
));
enclosure
.
add
(
l
);
blueSlider
=
new
JSlider
(
JSlider
.
HORIZONTAL
,
0
,
255
,
color
.
getBlue
());
blueSlider
.
setMajorTickSpacing
(
85
);
blueSlider
.
setMinorTickSpacing
(
17
);
blueSlider
.
setPaintTicks
(
true
);
blueSlider
.
setPaintLabels
(
true
);
blueSlider
.
setInheritsPopupMenu
(
true
);
enclosure
.
add
(
blueSlider
);
blueField
=
new
JSpinner
(
new
SpinnerNumberModel
(
color
.
getBlue
(),
minValue
,
maxValue
,
1
));
l
.
setLabelFor
(
blueSlider
);
blueField
.
setInheritsPopupMenu
(
true
);
JPanel
blueFieldHolder
=
new
JPanel
(
new
CenterLayout
());
blueFieldHolder
.
add
(
blueField
);
blueField
.
addChangeListener
(
this
);
blueFieldHolder
.
setInheritsPopupMenu
(
true
);
enclosure
.
add
(
blueFieldHolder
);
redSlider
.
addChangeListener
(
this
);
greenSlider
.
addChangeListener
(
this
);
blueSlider
.
addChangeListener
(
this
);
redSlider
.
putClientProperty
(
"JSlider.isFilled"
,
Boolean
.
TRUE
);
greenSlider
.
putClientProperty
(
"JSlider.isFilled"
,
Boolean
.
TRUE
);
blueSlider
.
putClientProperty
(
"JSlider.isFilled"
,
Boolean
.
TRUE
);
}
public
void
uninstallChooserPanel
(
JColorChooser
enclosingChooser
)
{
super
.
uninstallChooserPanel
(
enclosingChooser
);
removeAll
();
}
public
void
updateChooser
()
{
if
(!
isAdjusting
)
{
isAdjusting
=
true
;
setColor
(
getColorFromModel
());
isAdjusting
=
false
;
}
}
public
void
stateChanged
(
ChangeEvent
e
)
{
if
(
e
.
getSource
()
instanceof
JSlider
&&
!
isAdjusting
)
{
int
red
=
redSlider
.
getValue
();
int
green
=
greenSlider
.
getValue
();
int
blue
=
blueSlider
.
getValue
()
;
Color
color
=
new
Color
(
red
,
green
,
blue
);
getColorSelectionModel
().
setSelectedColor
(
color
);
}
else
if
(
e
.
getSource
()
instanceof
JSpinner
&&
!
isAdjusting
)
{
int
red
=
((
Integer
)
redField
.
getValue
()).
intValue
();
int
green
=
((
Integer
)
greenField
.
getValue
()).
intValue
();
int
blue
=
((
Integer
)
blueField
.
getValue
()).
intValue
();
Color
color
=
new
Color
(
red
,
green
,
blue
);
getColorSelectionModel
().
setSelectedColor
(
color
);
}
}
}
src/share/classes/javax/swing/colorchooser/DiagramComponent.java
0 → 100644
浏览文件 @
5065850d
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
javax.swing.colorchooser
;
import
java.awt.Color
;
import
java.awt.Graphics
;
import
java.awt.Insets
;
import
java.awt.event.MouseEvent
;
import
java.awt.event.MouseListener
;
import
java.awt.event.MouseMotionListener
;
import
java.awt.image.BufferedImage
;
import
javax.swing.JComponent
;
final
class
DiagramComponent
extends
JComponent
implements
MouseListener
,
MouseMotionListener
{
private
final
ColorPanel
panel
;
private
final
boolean
diagram
;
private
final
Insets
insets
=
new
Insets
(
0
,
0
,
0
,
0
);
private
int
width
;
private
int
height
;
private
int
[]
array
;
private
BufferedImage
image
;
DiagramComponent
(
ColorPanel
panel
,
boolean
diagram
)
{
this
.
panel
=
panel
;
this
.
diagram
=
diagram
;
addMouseListener
(
this
);
addMouseMotionListener
(
this
);
}
@Override
protected
void
paintComponent
(
Graphics
g
)
{
getInsets
(
this
.
insets
);
this
.
width
=
getWidth
()
-
this
.
insets
.
left
-
this
.
insets
.
right
;
this
.
height
=
getHeight
()
-
this
.
insets
.
top
-
this
.
insets
.
bottom
;
boolean
update
=
(
this
.
image
==
null
)
||
(
this
.
width
!=
this
.
image
.
getWidth
())
||
(
this
.
height
!=
this
.
image
.
getHeight
());
if
(
update
)
{
int
size
=
this
.
width
*
this
.
height
;
if
((
this
.
array
==
null
)
||
(
this
.
array
.
length
<
size
))
{
this
.
array
=
new
int
[
size
];
}
this
.
image
=
new
BufferedImage
(
this
.
width
,
this
.
height
,
BufferedImage
.
TYPE_INT_RGB
);
}
{
float
dx
=
1.0f
/
(
float
)
(
this
.
width
-
1
);
float
dy
=
1.0f
/
(
float
)
(
this
.
height
-
1
);
int
offset
=
0
;
float
y
=
0.0f
;
for
(
int
h
=
0
;
h
<
this
.
height
;
h
++,
y
+=
dy
)
{
if
(
this
.
diagram
)
{
float
x
=
0.0f
;
for
(
int
w
=
0
;
w
<
this
.
width
;
w
++,
x
+=
dx
,
offset
++)
{
this
.
array
[
offset
]
=
this
.
panel
.
getColor
(
x
,
y
);
}
}
else
{
int
color
=
this
.
panel
.
getColor
(
y
);
for
(
int
w
=
0
;
w
<
this
.
width
;
w
++,
offset
++)
{
this
.
array
[
offset
]
=
color
;
}
}
}
}
this
.
image
.
setRGB
(
0
,
0
,
this
.
width
,
this
.
height
,
this
.
array
,
0
,
this
.
width
);
g
.
drawImage
(
this
.
image
,
this
.
insets
.
left
,
this
.
insets
.
top
,
this
.
width
,
this
.
height
,
this
);
if
(
isEnabled
())
{
this
.
width
--;
this
.
height
--;
g
.
setXORMode
(
Color
.
WHITE
);
g
.
setColor
(
Color
.
BLACK
);
if
(
this
.
diagram
)
{
int
x
=
getValue
(
this
.
panel
.
getValueX
(),
this
.
insets
.
left
,
this
.
width
);
int
y
=
getValue
(
this
.
panel
.
getValueY
(),
this
.
insets
.
top
,
this
.
height
);
g
.
drawLine
(
x
-
8
,
y
,
x
+
8
,
y
);
g
.
drawLine
(
x
,
y
-
8
,
x
,
y
+
8
);
}
else
{
int
z
=
getValue
(
this
.
panel
.
getValueZ
(),
this
.
insets
.
top
,
this
.
height
);
g
.
drawLine
(
this
.
insets
.
left
,
z
,
this
.
insets
.
left
+
this
.
width
,
z
);
}
g
.
setPaintMode
();
}
}
public
void
mousePressed
(
MouseEvent
event
)
{
mouseDragged
(
event
);
}
public
void
mouseReleased
(
MouseEvent
event
)
{
}
public
void
mouseClicked
(
MouseEvent
event
)
{
}
public
void
mouseEntered
(
MouseEvent
event
)
{
}
public
void
mouseExited
(
MouseEvent
event
)
{
}
public
void
mouseMoved
(
MouseEvent
event
)
{
}
public
void
mouseDragged
(
MouseEvent
event
)
{
if
(
isEnabled
())
{
float
y
=
getValue
(
event
.
getY
(),
this
.
insets
.
top
,
this
.
height
);
if
(
this
.
diagram
)
{
float
x
=
getValue
(
event
.
getX
(),
this
.
insets
.
left
,
this
.
width
);
this
.
panel
.
setValue
(
x
,
y
);
}
else
{
this
.
panel
.
setValue
(
y
);
}
}
}
private
static
int
getValue
(
float
value
,
int
min
,
int
max
)
{
return
min
+
(
int
)
(
value
*
(
float
)
(
max
));
}
private
static
float
getValue
(
int
value
,
int
min
,
int
max
)
{
if
(
min
<
value
)
{
value
-=
min
;
return
(
value
<
max
)
?
(
float
)
value
/
(
float
)
max
:
1.0f
;
}
return
0.0f
;
}
}
src/share/classes/javax/swing/colorchooser/SlidingSpinner.java
0 → 100644
浏览文件 @
5065850d
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
javax.swing.colorchooser
;
import
javax.swing.JComponent
;
import
javax.swing.JSlider
;
import
javax.swing.JSpinner
;
import
javax.swing.JSpinner.DefaultEditor
;
import
javax.swing.SpinnerNumberModel
;
import
javax.swing.event.ChangeEvent
;
import
javax.swing.event.ChangeListener
;
final
class
SlidingSpinner
implements
ChangeListener
{
private
final
ColorPanel
panel
;
private
final
JComponent
label
;
private
final
SpinnerNumberModel
model
=
new
SpinnerNumberModel
();
private
final
JSlider
slider
=
new
JSlider
();
private
final
JSpinner
spinner
=
new
JSpinner
(
this
.
model
);
private
float
value
;
private
boolean
internal
;
SlidingSpinner
(
ColorPanel
panel
,
JComponent
label
)
{
this
.
panel
=
panel
;
this
.
label
=
label
;
this
.
slider
.
addChangeListener
(
this
);
this
.
spinner
.
addChangeListener
(
this
);
DefaultEditor
editor
=
(
DefaultEditor
)
this
.
spinner
.
getEditor
();
ValueFormatter
.
init
(
3
,
false
,
editor
.
getTextField
());
editor
.
setFocusable
(
false
);
this
.
spinner
.
setFocusable
(
false
);
}
JComponent
getLabel
()
{
return
this
.
label
;
}
JSlider
getSlider
()
{
return
this
.
slider
;
}
JSpinner
getSpinner
()
{
return
this
.
spinner
;
}
float
getValue
()
{
return
this
.
value
;
}
void
setValue
(
float
value
)
{
int
min
=
this
.
slider
.
getMinimum
();
int
max
=
this
.
slider
.
getMaximum
();
this
.
internal
=
true
;
this
.
slider
.
setValue
(
min
+
(
int
)
(
value
*
(
float
)
(
max
-
min
)));
this
.
spinner
.
setValue
(
Integer
.
valueOf
(
this
.
slider
.
getValue
()));
this
.
internal
=
false
;
this
.
value
=
value
;
}
void
setRange
(
int
min
,
int
max
)
{
this
.
internal
=
true
;
this
.
slider
.
setMinimum
(
min
);
this
.
slider
.
setMaximum
(
max
);
this
.
model
.
setMinimum
(
Integer
.
valueOf
(
min
));
this
.
model
.
setMaximum
(
Integer
.
valueOf
(
max
));
this
.
internal
=
false
;
}
void
setVisible
(
boolean
visible
)
{
this
.
label
.
setVisible
(
visible
);
this
.
slider
.
setVisible
(
visible
);
this
.
spinner
.
setVisible
(
visible
);
}
public
void
stateChanged
(
ChangeEvent
event
)
{
if
(!
this
.
internal
)
{
if
(
this
.
spinner
==
event
.
getSource
())
{
Object
value
=
this
.
spinner
.
getValue
();
if
(
value
instanceof
Integer
)
{
this
.
internal
=
true
;
this
.
slider
.
setValue
((
Integer
)
value
);
this
.
internal
=
false
;
}
}
int
value
=
this
.
slider
.
getValue
();
this
.
internal
=
true
;
this
.
spinner
.
setValue
(
Integer
.
valueOf
(
value
));
this
.
internal
=
false
;
int
min
=
this
.
slider
.
getMinimum
();
int
max
=
this
.
slider
.
getMaximum
();
this
.
value
=
(
float
)
(
value
-
min
)
/
(
float
)
(
max
-
min
);
this
.
panel
.
colorChanged
();
}
}
}
src/share/classes/javax/swing/colorchooser/SyntheticImage.java
已删除
100644 → 0
浏览文件 @
b8445e0c
/*
* Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
javax.swing.colorchooser
;
import
java.awt.*
;
import
java.awt.image.*
;
/** A helper class to make computing synthetic images a little easier.
* All you need to do is define a subclass that overrides computeRow
* to compute a row of the image. It is passed the y coordinate of the
* row and an array into which to put the pixels in
* <a href="http://java.sun.com/products/jdk/1.1/docs/api/java.awt.image.ColorModel.html#getRGBdefault()">
* standard ARGB format</a>.
* <p>Normal usage looks something like this:
* <pre> Image i = createImage(new SyntheticImage(200, 100) {
* protected void computeRow(int y, int[] row) {
* for(int i = width; --i>=0; ) {
* int grey = i*255/(width-1);
* row[i] = (255<<24)|(grey<<16)|(grey<<8)|grey;
* }
* }
* }
* </pre>This creates a image 200 pixels wide and 100 pixels high
* that is a horizontal grey ramp, going from black on the left to
* white on the right.
* <p>
* If the image is to be a movie, override isStatic to return false,
* <i>y</i> cycling back to 0 is computeRow's signal that the next
* frame has started. It is acceptable (expected?) for computeRow(0,r)
* to pause until the appropriate time to start the next frame.
*
* @author James Gosling
*/
abstract
class
SyntheticImage
implements
ImageProducer
{
private
SyntheticImageGenerator
root
;
protected
int
width
=
10
,
height
=
100
;
static
final
ColorModel
cm
=
ColorModel
.
getRGBdefault
();
public
static
final
int
pixMask
=
0xFF
;
private
Thread
runner
;
protected
SyntheticImage
()
{
}
protected
SyntheticImage
(
int
w
,
int
h
)
{
width
=
w
;
height
=
h
;
}
protected
void
computeRow
(
int
y
,
int
[]
row
)
{
int
p
=
255
-
255
*
y
/(
height
-
1
);
p
=
(
pixMask
<<
24
)|(
p
<<
16
)|(
p
<<
8
)|
p
;
for
(
int
i
=
row
.
length
;
--
i
>=
0
;
)
row
[
i
]
=
p
;
}
public
synchronized
void
addConsumer
(
ImageConsumer
ic
){
for
(
SyntheticImageGenerator
ics
=
root
;
ics
!=
null
;
ics
=
ics
.
next
)
if
(
ics
.
ic
==
ic
)
return
;
root
=
new
SyntheticImageGenerator
(
ic
,
root
,
this
);
}
public
synchronized
boolean
isConsumer
(
ImageConsumer
ic
){
for
(
SyntheticImageGenerator
ics
=
root
;
ics
!=
null
;
ics
=
ics
.
next
)
if
(
ics
.
ic
==
ic
)
return
true
;
return
false
;
}
public
synchronized
void
removeConsumer
(
ImageConsumer
ic
)
{
SyntheticImageGenerator
prev
=
null
;
for
(
SyntheticImageGenerator
ics
=
root
;
ics
!=
null
;
ics
=
ics
.
next
)
{
if
(
ics
.
ic
==
ic
)
{
ics
.
useful
=
false
;
if
(
prev
!=
null
)
prev
.
next
=
ics
.
next
;
else
root
=
ics
.
next
;
return
;
}
prev
=
ics
;
}
}
public
synchronized
void
startProduction
(
ImageConsumer
ic
)
{
addConsumer
(
ic
);
for
(
SyntheticImageGenerator
ics
=
root
;
ics
!=
null
;
ics
=
ics
.
next
)
if
(
ics
.
useful
&&
!
ics
.
isAlive
())
ics
.
start
();
}
protected
boolean
isStatic
()
{
return
true
;
}
public
void
nextFrame
(
int
param
)
{}
//Override if !isStatic
public
void
requestTopDownLeftRightResend
(
ImageConsumer
ic
){}
protected
volatile
boolean
aborted
=
false
;
}
class
SyntheticImageGenerator
extends
Thread
{
ImageConsumer
ic
;
boolean
useful
;
SyntheticImageGenerator
next
;
SyntheticImage
parent
;
SyntheticImageGenerator
(
ImageConsumer
ic
,
SyntheticImageGenerator
next
,
SyntheticImage
parent
)
{
super
(
"SyntheticImageGenerator"
);
this
.
ic
=
ic
;
this
.
next
=
next
;
this
.
parent
=
parent
;
useful
=
true
;
setDaemon
(
true
);
}
public
void
run
()
{
ImageConsumer
ic
=
this
.
ic
;
int
w
=
parent
.
width
;
int
h
=
parent
.
height
;
int
hints
=
ic
.
SINGLEPASS
|
ic
.
COMPLETESCANLINES
|
ic
.
TOPDOWNLEFTRIGHT
;
if
(
parent
.
isStatic
())
hints
|=
ic
.
SINGLEFRAME
;
ic
.
setHints
(
hints
);
ic
.
setDimensions
(
w
,
h
);
ic
.
setProperties
(
null
);
ic
.
setColorModel
(
parent
.
cm
);
if
(
useful
)
{
int
[]
row
=
new
int
[
w
];
doPrivileged
(
new
Runnable
()
{
public
void
run
()
{
Thread
.
currentThread
().
setPriority
(
Thread
.
MIN_PRIORITY
);
}
});
do
{
for
(
int
y
=
0
;
y
<
h
&&
useful
;
y
++)
{
parent
.
computeRow
(
y
,
row
);
if
(
parent
.
aborted
)
{
ic
.
imageComplete
(
ic
.
IMAGEABORTED
);
return
;
}
ic
.
setPixels
(
0
,
y
,
w
,
1
,
parent
.
cm
,
row
,
0
,
w
);
}
ic
.
imageComplete
(
parent
.
isStatic
()
?
ic
.
STATICIMAGEDONE
:
ic
.
SINGLEFRAMEDONE
);
}
while
(!
parent
.
isStatic
()
&&
useful
);
}
}
private
final
static
void
doPrivileged
(
final
Runnable
doRun
)
{
java
.
security
.
AccessController
.
doPrivileged
(
new
java
.
security
.
PrivilegedAction
()
{
public
Object
run
()
{
doRun
.
run
();
return
null
;
}
}
);
}
}
src/share/classes/javax/swing/colorchooser/ValueFormatter.java
0 → 100644
浏览文件 @
5065850d
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
javax.swing.colorchooser
;
import
java.awt.event.FocusEvent
;
import
java.awt.event.FocusListener
;
import
java.text.ParseException
;
import
static
java
.
util
.
Locale
.
ENGLISH
;
import
javax.swing.JFormattedTextField
;
import
javax.swing.JFormattedTextField.AbstractFormatter
;
import
javax.swing.SwingConstants
;
import
javax.swing.SwingUtilities
;
import
javax.swing.text.AttributeSet
;
import
javax.swing.text.BadLocationException
;
import
javax.swing.text.DefaultFormatterFactory
;
import
javax.swing.text.DocumentFilter
;
final
class
ValueFormatter
extends
AbstractFormatter
implements
FocusListener
,
Runnable
{
static
void
init
(
int
length
,
boolean
hex
,
JFormattedTextField
text
)
{
ValueFormatter
formatter
=
new
ValueFormatter
(
length
,
hex
);
text
.
setColumns
(
length
);
text
.
setFormatterFactory
(
new
DefaultFormatterFactory
(
formatter
));
text
.
setHorizontalAlignment
(
SwingConstants
.
RIGHT
);
text
.
setMinimumSize
(
text
.
getPreferredSize
());
text
.
addFocusListener
(
formatter
);
}
private
final
DocumentFilter
filter
=
new
DocumentFilter
()
{
@Override
public
void
remove
(
FilterBypass
fb
,
int
offset
,
int
length
)
throws
BadLocationException
{
if
(
isValid
(
fb
.
getDocument
().
getLength
()
-
length
))
{
fb
.
remove
(
offset
,
length
);
}
}
@Override
public
void
replace
(
FilterBypass
fb
,
int
offset
,
int
length
,
String
text
,
AttributeSet
set
)
throws
BadLocationException
{
if
(
isValid
(
fb
.
getDocument
().
getLength
()
+
text
.
length
()
-
length
)
&&
isValid
(
text
))
{
fb
.
replace
(
offset
,
length
,
text
.
toUpperCase
(
ENGLISH
),
set
);
}
}
@Override
public
void
insertString
(
FilterBypass
fb
,
int
offset
,
String
text
,
AttributeSet
set
)
throws
BadLocationException
{
if
(
isValid
(
fb
.
getDocument
().
getLength
()
+
text
.
length
())
&&
isValid
(
text
))
{
fb
.
insertString
(
offset
,
text
.
toUpperCase
(
ENGLISH
),
set
);
}
}
};
private
final
int
length
;
private
final
int
radix
;
private
JFormattedTextField
text
;
ValueFormatter
(
int
length
,
boolean
hex
)
{
this
.
length
=
length
;
this
.
radix
=
hex
?
16
:
10
;
}
@Override
public
Object
stringToValue
(
String
text
)
throws
ParseException
{
try
{
return
Integer
.
valueOf
(
text
,
this
.
radix
);
}
catch
(
NumberFormatException
nfe
)
{
ParseException
pe
=
new
ParseException
(
"illegal format"
,
0
);
pe
.
initCause
(
nfe
);
throw
pe
;
}
}
@Override
public
String
valueToString
(
Object
object
)
throws
ParseException
{
if
(
object
instanceof
Integer
)
{
if
(
this
.
radix
==
10
)
{
return
object
.
toString
();
}
int
value
=
(
Integer
)
object
;
int
index
=
this
.
length
;
char
[]
array
=
new
char
[
index
];
while
(
0
<
index
--)
{
array
[
index
]
=
Character
.
forDigit
(
value
&
0x0F
,
this
.
radix
);
value
>>=
4
;
}
return
new
String
(
array
).
toUpperCase
(
ENGLISH
);
}
throw
new
ParseException
(
"illegal object"
,
0
);
}
@Override
protected
DocumentFilter
getDocumentFilter
()
{
return
this
.
filter
;
}
public
void
focusGained
(
FocusEvent
event
)
{
Object
source
=
event
.
getSource
();
if
(
source
instanceof
JFormattedTextField
)
{
this
.
text
=
(
JFormattedTextField
)
source
;
SwingUtilities
.
invokeLater
(
this
);
}
}
public
void
focusLost
(
FocusEvent
event
)
{
}
public
void
run
()
{
if
(
this
.
text
!=
null
)
{
this
.
text
.
selectAll
();
}
}
private
boolean
isValid
(
int
length
)
{
return
(
0
<=
length
)
&&
(
length
<=
this
.
length
);
}
private
boolean
isValid
(
String
text
)
{
int
length
=
text
.
length
();
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
char
ch
=
text
.
charAt
(
i
);
if
(
Character
.
digit
(
ch
,
this
.
radix
)
<
0
)
{
return
false
;
}
}
return
true
;
}
}
src/share/classes/javax/swing/plaf/basic/BasicColorChooserUI.java
浏览文件 @
5065850d
...
@@ -299,8 +299,10 @@ public class BasicColorChooserUI extends ColorChooserUI
...
@@ -299,8 +299,10 @@ public class BasicColorChooserUI extends ColorChooserUI
tabbedPane
.
addTab
(
name
,
centerWrapper
);
tabbedPane
.
addTab
(
name
,
centerWrapper
);
if
(
mnemonic
>
0
)
{
if
(
mnemonic
>
0
)
{
tabbedPane
.
setMnemonicAt
(
i
,
mnemonic
);
tabbedPane
.
setMnemonicAt
(
i
,
mnemonic
);
tabbedPane
.
setDisplayedMnemonicIndexAt
(
int
index
=
newPanels
[
i
].
getDisplayedMnemonicIndex
();
i
,
newPanels
[
i
].
getDisplayedMnemonicIndex
());
if
(
index
>=
0
)
{
tabbedPane
.
setDisplayedMnemonicIndexAt
(
i
,
index
);
}
}
}
}
}
}
}
...
...
test/javax/swing/JColorChooser/Test6524757.java
浏览文件 @
5065850d
/*
/*
* Copyright 2007 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2007
-2008
Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -34,14 +34,13 @@ import java.awt.Dimension;
...
@@ -34,14 +34,13 @@ import java.awt.Dimension;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Locale
;
import
javax.swing.
J
Button
;
import
javax.swing.
Abstract
Button
;
import
javax.swing.JColorChooser
;
import
javax.swing.JColorChooser
;
import
javax.swing.JComponent
;
import
javax.swing.JComponent
;
import
javax.swing.JDialog
;
import
javax.swing.JDialog
;
import
javax.swing.JFrame
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
import
javax.swing.JLabel
;
import
javax.swing.JPanel
;
import
javax.swing.JPanel
;
import
javax.swing.JRadioButton
;
import
javax.swing.UIManager
;
import
javax.swing.UIManager
;
import
javax.swing.WindowConstants
;
import
javax.swing.WindowConstants
;
import
javax.swing.colorchooser.AbstractColorChooserPanel
;
import
javax.swing.colorchooser.AbstractColorChooserPanel
;
...
@@ -59,31 +58,41 @@ public class Test6524757 {
...
@@ -59,31 +58,41 @@ public class Test6524757 {
"ColorChooser.swatchesNameText"
,
// NON-NLS: string key from DefaultSwatchChooserPanel
"ColorChooser.swatchesNameText"
,
// NON-NLS: string key from DefaultSwatchChooserPanel
"ColorChooser.swatchesMnemonic"
,
// NON-NLS: string key from DefaultSwatchChooserPanel:int
"ColorChooser.swatchesMnemonic"
,
// NON-NLS: string key from DefaultSwatchChooserPanel:int
"ColorChooser.swatchesDisplayedMnemonicIndex"
,
// NON-NLS: int key from DefaultSwatchChooserPanel
"ColorChooser.swatchesSwatchSize"
,
// NON-NLS: dimension key from DefaultSwatchChooserPanel
"ColorChooser.swatchesSwatchSize"
,
// NON-NLS: dimension key from DefaultSwatchChooserPanel
"ColorChooser.swatchesRecentText"
,
// NON-NLS: string key from DefaultSwatchChooserPanel
"ColorChooser.swatchesRecentText"
,
// NON-NLS: string key from DefaultSwatchChooserPanel
"ColorChooser.swatchesRecentSwatchSize"
,
// NON-NLS: dimension key from DefaultSwatchChooserPanel
"ColorChooser.swatchesRecentSwatchSize"
,
// NON-NLS: dimension key from DefaultSwatchChooserPanel
//NotAvail: "ColorChooser.swatchesDefaultRecentColor", // NON-NLS: color key from DefaultSwatchChooserPanel
//NotAvail: "ColorChooser.swatchesDefaultRecentColor", // NON-NLS: color key from DefaultSwatchChooserPanel
"ColorChooser.hsbNameText"
,
// NON-NLS: string key from DefaultHSBChooserPanel
"ColorChooser.hsvNameText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.hsbMnemonic"
,
// NON-NLS: int key from DefaultHSBChooserPanel
"ColorChooser.hsvMnemonic"
,
// NON-NLS: int key from HSV ColorChooserPanel
"ColorChooser.hsbDisplayedMnemonicIndex"
,
// NON-NLS: int key from DefaultHSBChooserPanel
"ColorChooser.hsvHueText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.hsbHueText"
,
// NON-NLS: string key from DefaultHSBChooserPanel
"ColorChooser.hsvSaturationText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.hsbSaturationText"
,
// NON-NLS: string key from DefaultHSBChooserPanel
"ColorChooser.hsvValueText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.hsbBrightnessText"
,
// NON-NLS: string key from DefaultHSBChooserPanel
"ColorChooser.hsvTransparencyText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.hsbRedText"
,
// NON-NLS: string key from DefaultHSBChooserPanel
"ColorChooser.hsbGreenText"
,
// NON-NLS: string key from DefaultHSBChooserPanel
"ColorChooser.hslNameText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.hsbBlueText"
,
// NON-NLS: string key from DefaultHSBChooserPanel
"ColorChooser.hslMnemonic"
,
// NON-NLS: int key from HSV ColorChooserPanel
"ColorChooser.hslHueText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.rgbNameText"
,
// NON-NLS: string key from DefaultRGBChooserPanel
"ColorChooser.hslSaturationText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.rgbMnemonic"
,
// NON-NLS: int key from DefaultRGBChooserPanel
"ColorChooser.hslLightnessText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.rgbDisplayedMnemonicIndex"
,
// NON-NLS: int key from DefaultRGBChooserPanel
"ColorChooser.hslTransparencyText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.rgbRedText"
,
// NON-NLS: string key from DefaultRGBChooserPanel
"ColorChooser.rgbGreenText"
,
// NON-NLS: string key from DefaultRGBChooserPanel
"ColorChooser.rgbNameText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.rgbBlueText"
,
// NON-NLS: string key from DefaultRGBChooserPanel
"ColorChooser.rgbMnemonic"
,
// NON-NLS: int key from HSV ColorChooserPanel
"ColorChooser.rgbRedMnemonic"
,
// NON-NLS: int key from DefaultRGBChooserPanel
"ColorChooser.rgbRedText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.rgbGreenMnemonic"
,
// NON-NLS: int key from DefaultRGBChooserPanel
"ColorChooser.rgbGreenText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.rgbBlueMnemonic"
,
// NON-NLS: int key from DefaultRGBChooserPanel
"ColorChooser.rgbBlueText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.rgbAlphaText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.rgbHexCodeText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.rgbHexCodeMnemonic"
,
// NON-NLS: int key from HSV ColorChooserPanel
"ColorChooser.cmykNameText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.cmykMnemonic"
,
// NON-NLS: int key from HSV ColorChooserPanel
"ColorChooser.cmykCyanText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.cmykMagentaText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.cmykYellowText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.cmykBlackText"
,
// NON-NLS: string key from HSV ColorChooserPanel
"ColorChooser.cmykAlphaText"
,
// NON-NLS: string key from HSV ColorChooserPanel
};
};
private
static
final
Object
[]
KOREAN
=
convert
(
Locale
.
KOREAN
,
KEYS
);
private
static
final
Object
[]
KOREAN
=
convert
(
Locale
.
KOREAN
,
KEYS
);
private
static
final
Object
[]
FRENCH
=
convert
(
Locale
.
FRENCH
,
KEYS
);
private
static
final
Object
[]
FRENCH
=
convert
(
Locale
.
FRENCH
,
KEYS
);
...
@@ -91,19 +100,15 @@ public class Test6524757 {
...
@@ -91,19 +100,15 @@ public class Test6524757 {
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
// it affects Swing because it is not initialized
// it affects Swing because it is not initialized
Locale
.
setDefault
(
Locale
.
KOREAN
);
Locale
.
setDefault
(
Locale
.
KOREAN
);
Object
[]
korean
=
create
(
);
validate
(
KOREAN
,
create
()
);
// it does not affect Swing because it is initialized
// it does not affect Swing because it is initialized
Locale
.
setDefault
(
Locale
.
CANADA
);
Locale
.
setDefault
(
Locale
.
CANADA
);
Object
[]
canada
=
create
(
);
validate
(
KOREAN
,
create
()
);
// it definitely should affect Swing
// it definitely should affect Swing
JComponent
.
setDefaultLocale
(
Locale
.
FRENCH
);
JComponent
.
setDefaultLocale
(
Locale
.
FRENCH
);
Object
[]
french
=
create
();
validate
(
FRENCH
,
create
());
validate
(
KOREAN
,
korean
);
validate
(
KOREAN
,
canada
);
validate
(
FRENCH
,
french
);
}
}
private
static
void
validate
(
Object
[]
expected
,
Object
[]
actual
)
{
private
static
void
validate
(
Object
[]
expected
,
Object
[]
actual
)
{
...
@@ -153,10 +158,47 @@ public class Test6524757 {
...
@@ -153,10 +158,47 @@ public class Test6524757 {
// process all values
// process all values
List
<
Object
>
list
=
new
ArrayList
<
Object
>(
KEYS
.
length
);
List
<
Object
>
list
=
new
ArrayList
<
Object
>(
KEYS
.
length
);
addMain
(
list
,
dialog
);
addSwatch
(
list
,
chooser
);
Component
component
=
getC
(
getC
(
dialog
.
getLayeredPane
(),
0
),
1
);
addHSB
(
list
,
chooser
);
AbstractButton
ok
=
(
AbstractButton
)
getC
(
component
,
0
);
addRGB
(
list
,
chooser
);
AbstractButton
cancel
=
(
AbstractButton
)
getC
(
component
,
1
);
AbstractButton
reset
=
(
AbstractButton
)
getC
(
component
,
2
);
list
.
add
(
ok
.
getText
());
list
.
add
(
cancel
.
getText
());
list
.
add
(
reset
.
getText
());
list
.
add
(
Integer
.
valueOf
(
reset
.
getMnemonic
()));
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
AbstractColorChooserPanel
panel
=
(
AbstractColorChooserPanel
)
getC
(
getC
(
getC
(
chooser
,
0
),
i
),
0
);
list
.
add
(
panel
.
getDisplayName
());
list
.
add
(
Integer
.
valueOf
(
panel
.
getMnemonic
()));
if
(
i
==
0
)
{
JLabel
label
=
(
JLabel
)
getC
(
getC
(
panel
,
0
),
1
);
JPanel
upper
=
(
JPanel
)
getC
(
getC
(
getC
(
panel
,
0
),
0
),
0
);
JPanel
lower
=
(
JPanel
)
getC
(
getC
(
getC
(
panel
,
0
),
2
),
0
);
addSize
(
list
,
upper
,
1
,
1
,
31
,
9
);
list
.
add
(
label
.
getText
());
addSize
(
list
,
lower
,
1
,
1
,
5
,
7
);
}
else
{
Component
container
=
getC
(
panel
,
0
);
for
(
int
j
=
0
;
j
<
3
;
j
++)
{
AbstractButton
button
=
(
AbstractButton
)
getC
(
container
,
j
);
list
.
add
(
button
.
getText
());
}
JLabel
label
=
(
JLabel
)
getC
(
container
,
3
);
list
.
add
(
label
.
getText
());
if
(
i
==
4
)
{
label
=
(
JLabel
)
getC
(
container
,
4
);
list
.
add
(
label
.
getText
());
}
if
(
i
==
3
)
{
label
=
(
JLabel
)
getC
(
panel
,
1
);
list
.
add
(
label
.
getText
());
list
.
add
(
Integer
.
valueOf
(
label
.
getDisplayedMnemonic
()));
}
}
}
// close dialog
// close dialog
dialog
.
setVisible
(
false
);
dialog
.
setVisible
(
false
);
...
@@ -169,56 +211,6 @@ public class Test6524757 {
...
@@ -169,56 +211,6 @@ public class Test6524757 {
return
list
.
toArray
();
return
list
.
toArray
();
}
}
private
static
void
addMain
(
List
<
Object
>
list
,
JDialog
dialog
)
{
Component
component
=
getC
(
getC
(
dialog
.
getLayeredPane
(),
0
),
1
);
JButton
ok
=
(
JButton
)
getC
(
component
,
0
);
JButton
cancel
=
(
JButton
)
getC
(
component
,
1
);
JButton
reset
=
(
JButton
)
getC
(
component
,
2
);
list
.
add
(
ok
.
getText
());
list
.
add
(
cancel
.
getText
());
list
.
add
(
reset
.
getText
());
list
.
add
(
Integer
.
valueOf
(
reset
.
getMnemonic
()));
}
private
static
void
addSwatch
(
List
<
Object
>
list
,
JColorChooser
chooser
)
{
Component
component
=
addPanel
(
list
,
chooser
,
0
);
JLabel
label
=
(
JLabel
)
getC
(
getC
(
component
,
0
),
1
);
JPanel
upper
=
(
JPanel
)
getC
(
getC
(
getC
(
component
,
0
),
0
),
0
);
JPanel
lower
=
(
JPanel
)
getC
(
getC
(
getC
(
component
,
0
),
2
),
0
);
addSize
(
list
,
upper
,
1
,
1
,
31
,
9
);
list
.
add
(
label
.
getText
());
addSize
(
list
,
lower
,
1
,
1
,
5
,
7
);
}
private
static
void
addHSB
(
List
<
Object
>
list
,
JColorChooser
chooser
)
{
Component
component
=
addPanel
(
list
,
chooser
,
1
);
JRadioButton
h
=
(
JRadioButton
)
getC
(
getC
(
getC
(
component
,
1
),
0
),
0
);
JRadioButton
s
=
(
JRadioButton
)
getC
(
getC
(
getC
(
component
,
1
),
0
),
2
);
JRadioButton
b
=
(
JRadioButton
)
getC
(
getC
(
getC
(
component
,
1
),
0
),
4
);
list
.
add
(
h
.
getText
());
list
.
add
(
s
.
getText
());
list
.
add
(
b
.
getText
());
JLabel
red
=
(
JLabel
)
getC
(
getC
(
getC
(
component
,
1
),
2
),
0
);
JLabel
green
=
(
JLabel
)
getC
(
getC
(
getC
(
component
,
1
),
2
),
2
);
JLabel
blue
=
(
JLabel
)
getC
(
getC
(
getC
(
component
,
1
),
2
),
4
);
list
.
add
(
red
.
getText
());
list
.
add
(
green
.
getText
());
list
.
add
(
blue
.
getText
());
}
private
static
void
addRGB
(
List
<
Object
>
list
,
JColorChooser
chooser
)
{
Component
component
=
addPanel
(
list
,
chooser
,
2
);
JLabel
red
=
(
JLabel
)
getC
(
getC
(
component
,
0
),
0
);
JLabel
green
=
(
JLabel
)
getC
(
getC
(
component
,
0
),
3
);
JLabel
blue
=
(
JLabel
)
getC
(
getC
(
component
,
0
),
6
);
list
.
add
(
red
.
getText
());
list
.
add
(
green
.
getText
());
list
.
add
(
blue
.
getText
());
list
.
add
(
Integer
.
valueOf
(
red
.
getDisplayedMnemonic
()));
list
.
add
(
Integer
.
valueOf
(
green
.
getDisplayedMnemonic
()));
list
.
add
(
Integer
.
valueOf
(
blue
.
getDisplayedMnemonic
()));
}
private
static
void
addSize
(
List
<
Object
>
list
,
Component
component
,
int
x
,
int
y
,
int
w
,
int
h
)
{
private
static
void
addSize
(
List
<
Object
>
list
,
Component
component
,
int
x
,
int
y
,
int
w
,
int
h
)
{
Dimension
size
=
component
.
getPreferredSize
();
Dimension
size
=
component
.
getPreferredSize
();
int
width
=
(
size
.
width
+
1
)
/
w
-
x
;
int
width
=
(
size
.
width
+
1
)
/
w
-
x
;
...
@@ -226,14 +218,6 @@ public class Test6524757 {
...
@@ -226,14 +218,6 @@ public class Test6524757 {
list
.
add
(
new
Dimension
(
width
,
height
));
list
.
add
(
new
Dimension
(
width
,
height
));
}
}
private
static
Component
addPanel
(
List
<
Object
>
list
,
JColorChooser
chooser
,
int
index
)
{
AbstractColorChooserPanel
panel
=
(
AbstractColorChooserPanel
)
getC
(
getC
(
getC
(
chooser
,
0
),
index
),
0
);
list
.
add
(
panel
.
getDisplayName
());
list
.
add
(
Integer
.
valueOf
(
panel
.
getMnemonic
()));
list
.
add
(
Integer
.
valueOf
(
panel
.
getDisplayedMnemonicIndex
()));
return
panel
;
}
private
static
Component
getC
(
Component
component
,
int
index
)
{
private
static
Component
getC
(
Component
component
,
int
index
)
{
Container
container
=
(
Container
)
component
;
Container
container
=
(
Container
)
component
;
return
container
.
getComponent
(
index
);
return
container
.
getComponent
(
index
);
...
...
test/javax/swing/JColorChooser/Test6559154.java
0 → 100644
浏览文件 @
5065850d
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 6559154
* @summary Tests EDT hanging
* @author Sergey Malenkov
*/
import
java.awt.Component
;
import
java.awt.Container
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
javax.swing.JColorChooser
;
import
javax.swing.JDialog
;
import
javax.swing.SwingUtilities
;
import
javax.swing.Timer
;
public
class
Test6559154
implements
ActionListener
,
Runnable
{
private
JDialog
dialog
;
public
void
actionPerformed
(
ActionEvent
event
)
{
if
(
this
.
dialog
!=
null
)
{
this
.
dialog
.
dispose
();
}
}
public
void
run
()
{
Timer
timer
=
new
Timer
(
1000
,
this
);
timer
.
setRepeats
(
false
);
timer
.
start
();
JColorChooser
chooser
=
new
JColorChooser
();
setEnabledRecursive
(
chooser
,
false
);
this
.
dialog
=
new
JDialog
();
this
.
dialog
.
add
(
chooser
);
this
.
dialog
.
setVisible
(
true
);
}
private
static
void
setEnabledRecursive
(
Container
container
,
boolean
enabled
)
{
for
(
Component
component
:
container
.
getComponents
())
{
component
.
setEnabled
(
enabled
);
if
(
component
instanceof
Container
)
{
setEnabledRecursive
((
Container
)
component
,
enabled
);
}
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Test6559154
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录