Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
e6cfccf9
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看板
提交
e6cfccf9
编写于
12月 10, 2009
作者:
L
lana
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
132ada70
49d9d970
变更
98
展开全部
隐藏空白更改
内联
并排
Showing
98 changed file
with
3995 addition
and
1483 deletion
+3995
-1483
make/javax/sound/Makefile
make/javax/sound/Makefile
+8
-16
src/share/classes/com/sun/beans/WeakCache.java
src/share/classes/com/sun/beans/WeakCache.java
+7
-0
src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
...share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
+0
-1
src/share/classes/com/sun/media/sound/MidiDeviceReceiver.java
...share/classes/com/sun/media/sound/MidiDeviceReceiver.java
+41
-0
src/share/classes/com/sun/media/sound/SoftAudioBuffer.java
src/share/classes/com/sun/media/sound/SoftAudioBuffer.java
+24
-0
src/share/classes/com/sun/media/sound/SoftChannel.java
src/share/classes/com/sun/media/sound/SoftChannel.java
+25
-5
src/share/classes/com/sun/media/sound/SoftLimiter.java
src/share/classes/com/sun/media/sound/SoftLimiter.java
+1
-1
src/share/classes/com/sun/media/sound/SoftMainMixer.java
src/share/classes/com/sun/media/sound/SoftMainMixer.java
+167
-51
src/share/classes/com/sun/media/sound/SoftReceiver.java
src/share/classes/com/sun/media/sound/SoftReceiver.java
+7
-2
src/share/classes/com/sun/media/sound/SoftSynthesizer.java
src/share/classes/com/sun/media/sound/SoftSynthesizer.java
+5
-0
src/share/classes/com/sun/media/sound/SoftVoice.java
src/share/classes/com/sun/media/sound/SoftVoice.java
+68
-27
src/share/classes/java/beans/IndexedPropertyDescriptor.java
src/share/classes/java/beans/IndexedPropertyDescriptor.java
+7
-4
src/share/classes/java/beans/Introspector.java
src/share/classes/java/beans/Introspector.java
+39
-69
src/share/classes/java/beans/PropertyDescriptor.java
src/share/classes/java/beans/PropertyDescriptor.java
+9
-7
src/share/classes/javax/swing/AbstractListModel.java
src/share/classes/javax/swing/AbstractListModel.java
+3
-1
src/share/classes/javax/swing/DefaultListCellRenderer.java
src/share/classes/javax/swing/DefaultListCellRenderer.java
+2
-2
src/share/classes/javax/swing/DefaultListModel.java
src/share/classes/javax/swing/DefaultListModel.java
+27
-24
src/share/classes/javax/swing/JList.java
src/share/classes/javax/swing/JList.java
+117
-60
src/share/classes/javax/swing/JTable.java
src/share/classes/javax/swing/JTable.java
+5
-1
src/share/classes/javax/swing/ListCellRenderer.java
src/share/classes/javax/swing/ListCellRenderer.java
+9
-5
src/share/classes/javax/swing/ListModel.java
src/share/classes/javax/swing/ListModel.java
+4
-2
src/share/classes/javax/swing/plaf/ComponentUI.java
src/share/classes/javax/swing/plaf/ComponentUI.java
+10
-10
src/share/classes/javax/swing/plaf/basic/BasicComboBoxEditor.java
...e/classes/javax/swing/plaf/basic/BasicComboBoxEditor.java
+11
-10
src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java
...share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java
+25
-20
src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java
src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java
+4
-5
src/share/classes/javax/swing/plaf/basic/BasicListUI.java
src/share/classes/javax/swing/plaf/basic/BasicListUI.java
+7
-7
src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java
...share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java
+6
-2
src/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java
...hare/classes/javax/swing/plaf/basic/BasicScrollBarUI.java
+11
-8
src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
+8
-6
src/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java
src/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java
+14
-19
src/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java
...hare/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java
+6
-6
src/share/classes/javax/swing/plaf/basic/BasicTableHeaderUI.java
...re/classes/javax/swing/plaf/basic/BasicTableHeaderUI.java
+4
-5
src/share/classes/javax/swing/plaf/basic/BasicTextUI.java
src/share/classes/javax/swing/plaf/basic/BasicTextUI.java
+14
-14
src/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java
src/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java
+2
-2
src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
+43
-15
src/share/classes/javax/swing/plaf/basic/DefaultMenuLayout.java
...are/classes/javax/swing/plaf/basic/DefaultMenuLayout.java
+1
-1
src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java
...re/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java
+29
-1
src/share/classes/javax/swing/plaf/nimbus/package.html
src/share/classes/javax/swing/plaf/nimbus/package.html
+3
-4
src/share/classes/javax/swing/plaf/synth/SynthBorder.java
src/share/classes/javax/swing/plaf/synth/SynthBorder.java
+0
-1
src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
+80
-20
src/share/classes/javax/swing/plaf/synth/SynthCheckBoxMenuItemUI.java
...asses/javax/swing/plaf/synth/SynthCheckBoxMenuItemUI.java
+19
-25
src/share/classes/javax/swing/plaf/synth/SynthCheckBoxUI.java
...share/classes/javax/swing/plaf/synth/SynthCheckBoxUI.java
+22
-7
src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java
...e/classes/javax/swing/plaf/synth/SynthColorChooserUI.java
+57
-13
src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java
...share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java
+69
-126
src/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java
...re/classes/javax/swing/plaf/synth/SynthDefaultLookup.java
+0
-1
src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
...re/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
+80
-35
src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java
...re/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java
+60
-15
src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java
...are/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java
+41
-13
src/share/classes/javax/swing/plaf/synth/SynthFormattedTextFieldUI.java
...ses/javax/swing/plaf/synth/SynthFormattedTextFieldUI.java
+15
-5
src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java
...s/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java
+0
-5
src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java
.../classes/javax/swing/plaf/synth/SynthInternalFrameUI.java
+68
-21
src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
+57
-18
src/share/classes/javax/swing/plaf/synth/SynthListUI.java
src/share/classes/javax/swing/plaf/synth/SynthListUI.java
+47
-22
src/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
...hare/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
+25
-44
src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java
src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java
+54
-20
src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java
...share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java
+61
-16
src/share/classes/javax/swing/plaf/synth/SynthMenuLayout.java
...share/classes/javax/swing/plaf/synth/SynthMenuLayout.java
+5
-20
src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
+63
-18
src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java
...are/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java
+67
-13
src/share/classes/javax/swing/plaf/synth/SynthPainter.java
src/share/classes/javax/swing/plaf/synth/SynthPainter.java
+0
-1
src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java
src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java
+63
-11
src/share/classes/javax/swing/plaf/synth/SynthPasswordFieldUI.java
.../classes/javax/swing/plaf/synth/SynthPasswordFieldUI.java
+20
-8
src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java
...hare/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java
+54
-26
src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
...re/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
+68
-11
src/share/classes/javax/swing/plaf/synth/SynthRadioButtonMenuItemUI.java
...es/javax/swing/plaf/synth/SynthRadioButtonMenuItemUI.java
+20
-23
src/share/classes/javax/swing/plaf/synth/SynthRadioButtonUI.java
...re/classes/javax/swing/plaf/synth/SynthRadioButtonUI.java
+22
-6
src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java
...share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java
+41
-9
src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
...hare/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
+91
-35
src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java
...are/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java
+43
-16
src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
...hare/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
+71
-15
src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
+150
-47
src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java
src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java
+51
-74
src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
...hare/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
+49
-18
src/share/classes/javax/swing/plaf/synth/SynthStyle.java
src/share/classes/javax/swing/plaf/synth/SynthStyle.java
+0
-1
src/share/classes/javax/swing/plaf/synth/SynthStyleFactory.java
...are/classes/javax/swing/plaf/synth/SynthStyleFactory.java
+1
-4
src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java
...are/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java
+110
-30
src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java
...re/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java
+61
-19
src/share/classes/javax/swing/plaf/synth/SynthTableUI.java
src/share/classes/javax/swing/plaf/synth/SynthTableUI.java
+50
-15
src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java
...share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java
+51
-23
src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
...hare/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
+50
-35
src/share/classes/javax/swing/plaf/synth/SynthTextPaneUI.java
...share/classes/javax/swing/plaf/synth/SynthTextPaneUI.java
+14
-2
src/share/classes/javax/swing/plaf/synth/SynthToggleButtonUI.java
...e/classes/javax/swing/plaf/synth/SynthToggleButtonUI.java
+18
-3
src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
+81
-18
src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java
src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java
+57
-10
src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
+97
-106
src/share/classes/javax/swing/plaf/synth/SynthUI.java
src/share/classes/javax/swing/plaf/synth/SynthUI.java
+10
-2
src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java
...share/classes/javax/swing/plaf/synth/SynthViewportUI.java
+66
-12
src/solaris/native/com/sun/media/sound/PLATFORM_API_LinuxOS_ALSA_PCM.c
...ative/com/sun/media/sound/PLATFORM_API_LinuxOS_ALSA_PCM.c
+6
-2
src/windows/lib/tzmappings
src/windows/lib/tzmappings
+3
-2
src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_DirectSound.cpp
...ve/com/sun/media/sound/PLATFORM_API_WinOS_DirectSound.cpp
+1
-1
test/java/beans/EventHandler/Test6788531.java
test/java/beans/EventHandler/Test6788531.java
+1
-1
test/java/beans/Introspector/Test5102804.java
test/java/beans/Introspector/Test5102804.java
+155
-0
test/java/beans/XMLEncoder/6329581/Test6329581.java
test/java/beans/XMLEncoder/6329581/Test6329581.java
+53
-26
test/javax/sound/midi/Gervill/SoftChannel/NoteOverFlowTest2.java
...vax/sound/midi/Gervill/SoftChannel/NoteOverFlowTest2.java
+103
-0
test/javax/sound/midi/Gervill/SoftReceiver/GetMidiDevice.java
.../javax/sound/midi/Gervill/SoftReceiver/GetMidiDevice.java
+48
-0
test/javax/sound/midi/Gervill/SoftSynthesizer/TestPreciseTimestampRendering.java
...ervill/SoftSynthesizer/TestPreciseTimestampRendering.java
+208
-0
test/javax/swing/JList/6823603/bug6823603.java
test/javax/swing/JList/6823603/bug6823603.java
+247
-0
test/javax/swing/JTable/Test6888156.java
test/javax/swing/JTable/Test6888156.java
+98
-0
未找到文件。
make/javax/sound/Makefile
浏览文件 @
e6cfccf9
...
...
@@ -108,22 +108,14 @@ ifeq ($(PLATFORM), linux)
endif
# PLATFORM linux
ifeq
($(PLATFORM), solaris)
ifneq
($(ARCH), amd64)
# build with ports and direct audio
CPPFLAGS
+=
-DUSE_PORTS
=
TRUE
\
-DUSE_DAUDIO
=
TRUE
INCLUDE_PORTS
=
TRUE
INCLUDE_DAUDIO
=
TRUE
INCLUDE_MIDI
=
TRUE
else
# build with empty MIDI i/o
INCLUDE_MIDI
=
TRUE
# build with empty ports
INCLUDE_PORTS
=
TRUE
# build with empty direct audio
INCLUDE_DAUDIO
=
TRUE
endif
# build with ports and direct audio
CPPFLAGS
+=
-DUSE_PORTS
=
TRUE
\
-DUSE_DAUDIO
=
TRUE
INCLUDE_PORTS
=
TRUE
INCLUDE_DAUDIO
=
TRUE
# build with empty MIDI i/o
INCLUDE_MIDI
=
TRUE
endif
# PLATFORM solaris
# for dynamic inclusion of extra sound libs: these
...
...
src/share/classes/com/sun/beans/WeakCache.java
浏览文件 @
e6cfccf9
...
...
@@ -81,4 +81,11 @@ public final class WeakCache<K, V> {
this
.
map
.
remove
(
key
);
}
}
/**
* Removes all of the mappings from this cache.
*/
public
void
clear
()
{
this
.
map
.
clear
();
}
}
src/share/classes/com/sun/java/swing/plaf/gtk/GTKPainter.java
浏览文件 @
e6cfccf9
...
...
@@ -24,7 +24,6 @@
*/
package
com.sun.java.swing.plaf.gtk
;
import
sun.swing.plaf.synth.SynthUI
;
import
sun.awt.UNIXToolkit
;
import
javax.swing.plaf.synth.*
;
...
...
src/share/classes/com/sun/media/sound/MidiDeviceReceiver.java
0 → 100644
浏览文件 @
e6cfccf9
/*
* Copyright 2009 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
com.sun.media.sound
;
import
javax.sound.midi.MidiDevice
;
import
javax.sound.midi.Receiver
;
/**
* A Receiver with reference to it's MidiDevice object.
*
* @author Karl Helgason
*/
public
interface
MidiDeviceReceiver
extends
Receiver
{
/** Obtains the MidiDevice object associated with this Receiver.
*/
public
MidiDevice
getMidiDevice
();
}
src/share/classes/com/sun/media/sound/SoftAudioBuffer.java
浏览文件 @
e6cfccf9
...
...
@@ -48,6 +48,30 @@ public class SoftAudioBuffer {
converter
=
AudioFloatConverter
.
getConverter
(
format
);
}
public
void
swap
(
SoftAudioBuffer
swap
)
{
int
bak_size
=
size
;
float
[]
bak_buffer
=
buffer
;
boolean
bak_empty
=
empty
;
AudioFormat
bak_format
=
format
;
AudioFloatConverter
bak_converter
=
converter
;
byte
[]
bak_converter_buffer
=
converter_buffer
;
size
=
swap
.
size
;
buffer
=
swap
.
buffer
;
empty
=
swap
.
empty
;
format
=
swap
.
format
;
converter
=
swap
.
converter
;
converter_buffer
=
swap
.
converter_buffer
;
swap
.
size
=
bak_size
;
swap
.
buffer
=
bak_buffer
;
swap
.
empty
=
bak_empty
;
swap
.
format
=
bak_format
;
swap
.
converter
=
bak_converter
;
swap
.
converter_buffer
=
bak_converter_buffer
;
}
public
AudioFormat
getFormat
()
{
return
format
;
}
...
...
src/share/classes/com/sun/media/sound/SoftChannel.java
浏览文件 @
e6cfccf9
...
...
@@ -218,6 +218,15 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
}
private
int
findFreeVoice
(
int
x
)
{
if
(
x
==
-
1
)
{
// x = -1 means that there where no available voice
// last time we called findFreeVoice
// and it hasn't changed because no audio has been
// rendered in the meantime.
// Therefore we have to return -1.
return
-
1
;
}
for
(
int
i
=
x
;
i
<
voices
.
length
;
i
++)
if
(!
voices
[
i
].
active
)
return
i
;
...
...
@@ -328,7 +337,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
}
protected
void
initVoice
(
SoftVoice
voice
,
SoftPerformer
p
,
int
voiceID
,
int
noteNumber
,
int
velocity
,
ModelConnectionBlock
[]
connectionBlocks
,
int
noteNumber
,
int
velocity
,
int
delay
,
ModelConnectionBlock
[]
connectionBlocks
,
ModelChannelMixer
channelmixer
,
boolean
releaseTriggered
)
{
if
(
voice
.
active
)
{
// Voice is active , we must steal the voice
...
...
@@ -363,7 +372,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
voice
.
objects
.
put
(
"midi_cc"
,
co_midi_cc
);
voice
.
objects
.
put
(
"midi_rpn"
,
co_midi_rpn
);
voice
.
objects
.
put
(
"midi_nrpn"
,
co_midi_nrpn
);
voice
.
noteOn
(
noteNumber
,
velocity
);
voice
.
noteOn
(
noteNumber
,
velocity
,
delay
);
voice
.
setMute
(
mute
);
voice
.
setSoloMute
(
solomute
);
if
(
releaseTriggered
)
...
...
@@ -399,14 +408,21 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
}
public
void
noteOn
(
int
noteNumber
,
int
velocity
)
{
noteOn
(
noteNumber
,
velocity
,
0
);
}
/* A special noteOn with delay parameter, which is used to
* start note within control buffers.
*/
protected
void
noteOn
(
int
noteNumber
,
int
velocity
,
int
delay
)
{
noteNumber
=
restrict7Bit
(
noteNumber
);
velocity
=
restrict7Bit
(
velocity
);
noteOn_internal
(
noteNumber
,
velocity
);
noteOn_internal
(
noteNumber
,
velocity
,
delay
);
if
(
current_mixer
!=
null
)
current_mixer
.
noteOn
(
noteNumber
,
velocity
);
}
private
void
noteOn_internal
(
int
noteNumber
,
int
velocity
)
{
private
void
noteOn_internal
(
int
noteNumber
,
int
velocity
,
int
delay
)
{
if
(
velocity
==
0
)
{
noteOff_internal
(
noteNumber
,
64
);
...
...
@@ -490,6 +506,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
int
tunedKey
=
(
int
)(
Math
.
round
(
tuning
.
getTuning
()[
noteNumber
]/
100.0
));
play_noteNumber
=
noteNumber
;
play_velocity
=
velocity
;
play_delay
=
delay
;
play_releasetriggered
=
false
;
lastVelocity
[
noteNumber
]
=
velocity
;
current_director
.
noteOn
(
tunedKey
,
velocity
);
...
...
@@ -594,6 +611,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
play_noteNumber
=
noteNumber
;
play_velocity
=
lastVelocity
[
noteNumber
];
play_releasetriggered
=
true
;
play_delay
=
0
;
current_director
.
noteOff
(
tunedKey
,
velocity
);
}
...
...
@@ -604,12 +622,14 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
private
int
voiceNo
=
0
;
private
int
play_noteNumber
=
0
;
private
int
play_velocity
=
0
;
private
int
play_delay
=
0
;
private
boolean
play_releasetriggered
=
false
;
public
void
play
(
int
performerIndex
,
ModelConnectionBlock
[]
connectionBlocks
)
{
int
noteNumber
=
play_noteNumber
;
int
velocity
=
play_velocity
;
int
delay
=
play_delay
;
boolean
releasetriggered
=
play_releasetriggered
;
SoftPerformer
p
=
current_instrument
.
getPerformers
()[
performerIndex
];
...
...
@@ -633,7 +653,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer {
if
(
voiceNo
==
-
1
)
return
;
initVoice
(
voices
[
voiceNo
],
p
,
prevVoiceID
,
noteNumber
,
velocity
,
initVoice
(
voices
[
voiceNo
],
p
,
prevVoiceID
,
noteNumber
,
velocity
,
delay
,
connectionBlocks
,
current_mixer
,
releasetriggered
);
}
...
...
src/share/classes/com/sun/media/sound/SoftLimiter.java
浏览文件 @
e6cfccf9
...
...
@@ -79,7 +79,7 @@ public class SoftLimiter implements SoftAudioProcessor {
if
(
silentcounter
>
60
)
{
if
(!
mix
)
{
bufferLout
.
clear
();
bufferRout
.
clear
();
if
(
bufferRout
!=
null
)
bufferRout
.
clear
();
}
return
;
}
...
...
src/share/classes/com/sun/media/sound/SoftMainMixer.java
浏览文件 @
e6cfccf9
...
...
@@ -26,7 +26,6 @@ package com.sun.media.sound;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Arrays
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Set
;
...
...
@@ -46,28 +45,37 @@ import javax.sound.sampled.AudioSystem;
*/
public
class
SoftMainMixer
{
// A private class thats contains a ModelChannelMixer and it's private buffers.
// This becomes necessary when we want to have separate delay buffers for each channel mixer.
private
class
SoftChannelMixerContainer
{
ModelChannelMixer
mixer
;
SoftAudioBuffer
[]
buffers
;
}
public
final
static
int
CHANNEL_LEFT
=
0
;
public
final
static
int
CHANNEL_RIGHT
=
1
;
public
final
static
int
CHANNEL_MONO
=
2
;
public
final
static
int
CHANNEL_EFFECT1
=
3
;
public
final
static
int
CHANNEL_EFFECT2
=
4
;
public
final
static
int
CHANNEL_EFFECT3
=
5
;
public
final
static
int
CHANNEL_EFFECT4
=
6
;
public
final
static
int
CHANNEL_DELAY_LEFT
=
3
;
public
final
static
int
CHANNEL_DELAY_RIGHT
=
4
;
public
final
static
int
CHANNEL_DELAY_MONO
=
5
;
public
final
static
int
CHANNEL_EFFECT1
=
6
;
public
final
static
int
CHANNEL_EFFECT2
=
7
;
public
final
static
int
CHANNEL_DELAY_EFFECT1
=
8
;
public
final
static
int
CHANNEL_DELAY_EFFECT2
=
9
;
public
final
static
int
CHANNEL_LEFT_DRY
=
10
;
public
final
static
int
CHANNEL_RIGHT_DRY
=
11
;
public
final
static
int
CHANNEL_SCRATCH1
=
12
;
public
final
static
int
CHANNEL_SCRATCH2
=
13
;
public
final
static
int
CHANNEL_CHANNELMIXER_LEFT
=
14
;
public
final
static
int
CHANNEL_CHANNELMIXER_RIGHT
=
15
;
public
final
static
int
CHANNEL_CHANNELMIXER_MONO
=
16
;
protected
boolean
active_sensing_on
=
false
;
private
long
msec_last_activity
=
-
1
;
private
boolean
pusher_silent
=
false
;
private
int
pusher_silent_count
=
0
;
private
long
msec
_pos
=
0
;
private
long
sample
_pos
=
0
;
protected
boolean
readfully
=
true
;
private
Object
control_mutex
;
private
SoftSynthesizer
synth
;
private
float
samplerate
=
44100
;
private
int
nrofchannels
=
2
;
private
SoftVoice
[]
voicestatus
=
null
;
private
SoftAudioBuffer
[]
buffers
;
...
...
@@ -75,7 +83,10 @@ public class SoftMainMixer {
private
SoftAudioProcessor
chorus
;
private
SoftAudioProcessor
agc
;
private
long
msec_buffer_len
=
0
;
private
int
buffer_len
=
0
;
protected
TreeMap
<
Long
,
Object
>
midimessages
=
new
TreeMap
<
Long
,
Object
>();
private
int
delay_midievent
=
0
;
private
int
max_delay_midievent
=
0
;
double
last_volume_left
=
1.0
;
double
last_volume_right
=
1.0
;
private
double
[]
co_master_balance
=
new
double
[
1
];
...
...
@@ -83,9 +94,9 @@ public class SoftMainMixer {
private
double
[]
co_master_coarse_tuning
=
new
double
[
1
];
private
double
[]
co_master_fine_tuning
=
new
double
[
1
];
private
AudioInputStream
ais
;
private
Set
<
ModelChannelMix
er
>
registeredMixers
=
null
;
private
Set
<
SoftChannelMixerContain
er
>
registeredMixers
=
null
;
private
Set
<
ModelChannelMixer
>
stoppedMixers
=
null
;
private
ModelChannelMix
er
[]
cur_registeredMixers
=
null
;
private
SoftChannelMixerContain
er
[]
cur_registeredMixers
=
null
;
protected
SoftControl
co_master
=
new
SoftControl
()
{
double
[]
balance
=
co_master_balance
;
...
...
@@ -413,26 +424,68 @@ public class SoftMainMixer {
Iterator
<
Entry
<
Long
,
Object
>>
iter
=
midimessages
.
entrySet
().
iterator
();
while
(
iter
.
hasNext
())
{
Entry
<
Long
,
Object
>
entry
=
iter
.
next
();
if
(
entry
.
getKey
()
>
(
timeStamp
+
100
))
if
(
entry
.
getKey
()
>
=
(
timeStamp
+
msec_buffer_len
))
return
;
long
msec_delay
=
entry
.
getKey
()
-
timeStamp
;
delay_midievent
=
(
int
)(
msec_delay
*
(
samplerate
/
1000000.0
)
+
0.5
);
if
(
delay_midievent
>
max_delay_midievent
)
delay_midievent
=
max_delay_midievent
;
if
(
delay_midievent
<
0
)
delay_midievent
=
0
;
processMessage
(
entry
.
getValue
());
iter
.
remove
();
}
delay_midievent
=
0
;
}
protected
void
processAudioBuffers
()
{
if
(
synth
.
weakstream
!=
null
&&
synth
.
weakstream
.
silent_samples
!=
0
)
{
sample_pos
+=
synth
.
weakstream
.
silent_samples
;
synth
.
weakstream
.
silent_samples
=
0
;
}
for
(
int
i
=
0
;
i
<
buffers
.
length
;
i
++)
{
buffers
[
i
].
clear
();
if
(
i
!=
CHANNEL_DELAY_LEFT
&&
i
!=
CHANNEL_DELAY_RIGHT
&&
i
!=
CHANNEL_DELAY_MONO
&&
i
!=
CHANNEL_DELAY_EFFECT1
&&
i
!=
CHANNEL_DELAY_EFFECT2
)
buffers
[
i
].
clear
();
}
if
(!
buffers
[
CHANNEL_DELAY_LEFT
].
isSilent
())
{
buffers
[
CHANNEL_LEFT
].
swap
(
buffers
[
CHANNEL_DELAY_LEFT
]);
}
if
(!
buffers
[
CHANNEL_DELAY_RIGHT
].
isSilent
())
{
buffers
[
CHANNEL_RIGHT
].
swap
(
buffers
[
CHANNEL_DELAY_RIGHT
]);
}
if
(!
buffers
[
CHANNEL_DELAY_MONO
].
isSilent
())
{
buffers
[
CHANNEL_MONO
].
swap
(
buffers
[
CHANNEL_DELAY_MONO
]);
}
if
(!
buffers
[
CHANNEL_DELAY_EFFECT1
].
isSilent
())
{
buffers
[
CHANNEL_EFFECT1
].
swap
(
buffers
[
CHANNEL_DELAY_EFFECT1
]);
}
if
(!
buffers
[
CHANNEL_DELAY_EFFECT2
].
isSilent
())
{
buffers
[
CHANNEL_EFFECT2
].
swap
(
buffers
[
CHANNEL_DELAY_EFFECT2
]);
}
double
volume_left
;
double
volume_right
;
ModelChannelMix
er
[]
act_registeredMixers
;
SoftChannelMixerContain
er
[]
act_registeredMixers
;
// perform control logic
synchronized
(
control_mutex
)
{
long
msec_pos
=
(
long
)(
sample_pos
*
(
1000000.0
/
samplerate
));
processMessages
(
msec_pos
);
if
(
active_sensing_on
)
{
...
...
@@ -450,7 +503,7 @@ public class SoftMainMixer {
for
(
int
i
=
0
;
i
<
voicestatus
.
length
;
i
++)
if
(
voicestatus
[
i
].
active
)
voicestatus
[
i
].
processControlLogic
();
msec_pos
+=
msec_
buffer_len
;
sample_pos
+=
buffer_len
;
double
volume
=
co_master_volume
[
0
];
volume_left
=
volume
;
...
...
@@ -469,7 +522,7 @@ public class SoftMainMixer {
if
(
cur_registeredMixers
==
null
)
{
if
(
registeredMixers
!=
null
)
{
cur_registeredMixers
=
new
ModelChannelMix
er
[
registeredMixers
.
size
()];
new
SoftChannelMixerContain
er
[
registeredMixers
.
size
()];
registeredMixers
.
toArray
(
cur_registeredMixers
);
}
}
...
...
@@ -483,44 +536,61 @@ public class SoftMainMixer {
if
(
act_registeredMixers
!=
null
)
{
// Reroute default left,right output
// to channelmixer left,right input/output
// Make backup of left,right,mono channels
SoftAudioBuffer
leftbak
=
buffers
[
CHANNEL_LEFT
];
SoftAudioBuffer
rightbak
=
buffers
[
CHANNEL_RIGHT
];
SoftAudioBuffer
monobak
=
buffers
[
CHANNEL_MONO
];
buffers
[
CHANNEL_LEFT
]
=
buffers
[
CHANNEL_CHANNELMIXER
_LEFT
];
buffers
[
CHANNEL_RIGHT
]
=
buffers
[
CHANNEL_CHANNELMIXER
_RIGHT
];
buffers
[
CHANNEL_MONO
]
=
buffers
[
CHANNEL_CHANNELMIXER
_MONO
];
SoftAudioBuffer
delayleftbak
=
buffers
[
CHANNEL_DELAY
_LEFT
];
SoftAudioBuffer
delayrightbak
=
buffers
[
CHANNEL_DELAY
_RIGHT
];
SoftAudioBuffer
delaymonobak
=
buffers
[
CHANNEL_DELAY
_MONO
];
int
bufferlen
=
buffers
[
CHANNEL_LEFT
].
getSize
();
float
[][]
cbuffer
=
new
float
[
nrofchannels
][];
cbuffer
[
0
]
=
buffers
[
CHANNEL_LEFT
].
array
();
if
(
nrofchannels
!=
1
)
cbuffer
[
1
]
=
buffers
[
CHANNEL_RIGHT
].
array
();
float
[][]
obuffer
=
new
float
[
nrofchannels
][];
obuffer
[
0
]
=
leftbak
.
array
();
if
(
nrofchannels
!=
1
)
obuffer
[
1
]
=
rightbak
.
array
();
for
(
ModelChannelMixer
cmixer
:
act_registeredMixers
)
{
for
(
int
i
=
0
;
i
<
cbuffer
.
length
;
i
++)
Arrays
.
fill
(
cbuffer
[
i
],
0
);
for
(
SoftChannelMixerContainer
cmixer
:
act_registeredMixers
)
{
// Reroute default left,right output
// to channelmixer left,right input/output
buffers
[
CHANNEL_LEFT
]
=
cmixer
.
buffers
[
CHANNEL_LEFT
];
buffers
[
CHANNEL_RIGHT
]
=
cmixer
.
buffers
[
CHANNEL_RIGHT
];
buffers
[
CHANNEL_MONO
]
=
cmixer
.
buffers
[
CHANNEL_MONO
];
buffers
[
CHANNEL_DELAY_LEFT
]
=
cmixer
.
buffers
[
CHANNEL_DELAY_LEFT
];
buffers
[
CHANNEL_DELAY_RIGHT
]
=
cmixer
.
buffers
[
CHANNEL_DELAY_RIGHT
];
buffers
[
CHANNEL_DELAY_MONO
]
=
cmixer
.
buffers
[
CHANNEL_DELAY_MONO
];
buffers
[
CHANNEL_LEFT
].
clear
();
buffers
[
CHANNEL_RIGHT
].
clear
();
buffers
[
CHANNEL_MONO
].
clear
();
if
(!
buffers
[
CHANNEL_DELAY_LEFT
].
isSilent
())
{
buffers
[
CHANNEL_LEFT
].
swap
(
buffers
[
CHANNEL_DELAY_LEFT
]);
}
if
(!
buffers
[
CHANNEL_DELAY_RIGHT
].
isSilent
())
{
buffers
[
CHANNEL_RIGHT
].
swap
(
buffers
[
CHANNEL_DELAY_RIGHT
]);
}
if
(!
buffers
[
CHANNEL_DELAY_MONO
].
isSilent
())
{
buffers
[
CHANNEL_MONO
].
swap
(
buffers
[
CHANNEL_DELAY_MONO
]);
}
cbuffer
[
0
]
=
buffers
[
CHANNEL_LEFT
].
array
();
if
(
nrofchannels
!=
1
)
cbuffer
[
1
]
=
buffers
[
CHANNEL_RIGHT
].
array
();
boolean
hasactivevoices
=
false
;
for
(
int
i
=
0
;
i
<
voicestatus
.
length
;
i
++)
if
(
voicestatus
[
i
].
active
)
if
(
voicestatus
[
i
].
channelmixer
==
cmixer
)
{
if
(
voicestatus
[
i
].
channelmixer
==
cmixer
.
mixer
)
{
voicestatus
[
i
].
processAudioLogic
(
buffers
);
hasactivevoices
=
true
;
}
if
(!
cmixer
.
process
(
cbuffer
,
0
,
bufferlen
))
{
synchronized
(
control_mutex
)
{
registeredMixers
.
remove
(
cmixer
);
cur_registeredMixers
=
null
;
}
}
if
(!
buffers
[
CHANNEL_MONO
].
isSilent
())
{
...
...
@@ -542,6 +612,13 @@ public class SoftMainMixer {
}
}
if
(!
cmixer
.
mixer
.
process
(
cbuffer
,
0
,
bufferlen
))
{
synchronized
(
control_mutex
)
{
registeredMixers
.
remove
(
cmixer
);
cur_registeredMixers
=
null
;
}
}
for
(
int
i
=
0
;
i
<
cbuffer
.
length
;
i
++)
{
float
[]
cbuff
=
cbuffer
[
i
];
float
[]
obuff
=
obuffer
[
i
];
...
...
@@ -554,7 +631,7 @@ public class SoftMainMixer {
if
(
stoppedMixers
!=
null
)
{
if
(
stoppedMixers
.
contains
(
cmixer
))
{
stoppedMixers
.
remove
(
cmixer
);
cmixer
.
stop
();
cmixer
.
mixer
.
stop
();
}
}
}
...
...
@@ -565,6 +642,9 @@ public class SoftMainMixer {
buffers
[
CHANNEL_LEFT
]
=
leftbak
;
buffers
[
CHANNEL_RIGHT
]
=
rightbak
;
buffers
[
CHANNEL_MONO
]
=
monobak
;
buffers
[
CHANNEL_DELAY_LEFT
]
=
delayleftbak
;
buffers
[
CHANNEL_DELAY_RIGHT
]
=
delayrightbak
;
buffers
[
CHANNEL_DELAY_MONO
]
=
delaymonobak
;
}
...
...
@@ -650,14 +730,23 @@ public class SoftMainMixer {
if
(
buffers
[
CHANNEL_LEFT
].
isSilent
()
&&
buffers
[
CHANNEL_RIGHT
].
isSilent
())
{
pusher_silent_count
++;
if
(
pusher_silent_count
>
5
)
int
midimessages_size
;
synchronized
(
control_mutex
)
{
midimessages_size
=
midimessages
.
size
();
}
if
(
midimessages_size
==
0
)
{
pusher_silent_count
=
0
;
synchronized
(
control_mutex
)
{
pusher_silent
=
true
;
if
(
synth
.
weakstream
!=
null
)
synth
.
weakstream
.
setInputStream
(
null
);
pusher_silent_count
++;
if
(
pusher_silent_count
>
5
)
{
pusher_silent_count
=
0
;
synchronized
(
control_mutex
)
{
pusher_silent
=
true
;
if
(
synth
.
weakstream
!=
null
)
synth
.
weakstream
.
setInputStream
(
null
);
}
}
}
}
...
...
@@ -672,13 +761,18 @@ public class SoftMainMixer {
// Must only we called within control_mutex synchronization
public
void
activity
()
{
msec_last_activity
=
msec_pos
;
long
silent_samples
=
0
;
if
(
pusher_silent
)
{
pusher_silent
=
false
;
if
(
synth
.
weakstream
!=
null
)
{
synth
.
weakstream
.
setInputStream
(
ais
);
silent_samples
=
synth
.
weakstream
.
silent_samples
;
}
}
msec_last_activity
=
(
long
)((
sample_pos
+
silent_samples
)
*
(
1000000.0
/
samplerate
));
}
public
void
stopMixer
(
ModelChannelMixer
mixer
)
{
...
...
@@ -689,15 +783,22 @@ public class SoftMainMixer {
public
void
registerMixer
(
ModelChannelMixer
mixer
)
{
if
(
registeredMixers
==
null
)
registeredMixers
=
new
HashSet
<
ModelChannelMixer
>();
registeredMixers
.
add
(
mixer
);
registeredMixers
=
new
HashSet
<
SoftChannelMixerContainer
>();
SoftChannelMixerContainer
mixercontainer
=
new
SoftChannelMixerContainer
();
mixercontainer
.
buffers
=
new
SoftAudioBuffer
[
6
];
for
(
int
i
=
0
;
i
<
mixercontainer
.
buffers
.
length
;
i
++)
{
mixercontainer
.
buffers
[
i
]
=
new
SoftAudioBuffer
(
buffer_len
,
synth
.
getFormat
());
}
mixercontainer
.
mixer
=
mixer
;
registeredMixers
.
add
(
mixercontainer
);
cur_registeredMixers
=
null
;
}
public
SoftMainMixer
(
SoftSynthesizer
synth
)
{
this
.
synth
=
synth
;
msec
_pos
=
0
;
sample
_pos
=
0
;
co_master_balance
[
0
]
=
0.5
;
co_master_volume
[
0
]
=
1
;
...
...
@@ -705,14 +806,18 @@ public class SoftMainMixer {
co_master_fine_tuning
[
0
]
=
0.5
;
msec_buffer_len
=
(
long
)
(
1000000.0
/
synth
.
getControlRate
());
samplerate
=
synth
.
getFormat
().
getSampleRate
();
nrofchannels
=
synth
.
getFormat
().
getChannels
();
int
buffersize
=
(
int
)
(
synth
.
getFormat
().
getSampleRate
()
/
synth
.
getControlRate
());
buffer_len
=
buffersize
;
max_delay_midievent
=
buffersize
;
control_mutex
=
synth
.
control_mutex
;
buffers
=
new
SoftAudioBuffer
[
1
7
];
buffers
=
new
SoftAudioBuffer
[
1
4
];
for
(
int
i
=
0
;
i
<
buffers
.
length
;
i
++)
{
buffers
[
i
]
=
new
SoftAudioBuffer
(
buffersize
,
synth
.
getFormat
());
}
...
...
@@ -994,7 +1099,10 @@ public class SoftMainMixer {
switch
(
cmd
)
{
case
ShortMessage
.
NOTE_ON
:
softchannel
.
noteOn
(
data1
,
data2
);
if
(
delay_midievent
!=
0
)
softchannel
.
noteOn
(
data1
,
data2
,
delay_midievent
);
else
softchannel
.
noteOn
(
data1
,
data2
);
break
;
case
ShortMessage
.
NOTE_OFF
:
softchannel
.
noteOff
(
data1
,
data2
);
...
...
@@ -1021,7 +1129,15 @@ public class SoftMainMixer {
}
public
long
getMicrosecondPosition
()
{
return
msec_pos
;
if
(
pusher_silent
)
{
if
(
synth
.
weakstream
!=
null
)
{
return
(
long
)((
sample_pos
+
synth
.
weakstream
.
silent_samples
)
*
(
1000000.0
/
samplerate
));
}
}
return
(
long
)(
sample_pos
*
(
1000000.0
/
samplerate
));
}
public
void
close
()
{
...
...
src/share/classes/com/sun/media/sound/SoftReceiver.java
浏览文件 @
e6cfccf9
...
...
@@ -26,8 +26,8 @@ package com.sun.media.sound;
import
java.util.TreeMap
;
import
javax.sound.midi.MidiDevice
;
import
javax.sound.midi.MidiMessage
;
import
javax.sound.midi.Receiver
;
import
javax.sound.midi.ShortMessage
;
/**
...
...
@@ -35,7 +35,7 @@ import javax.sound.midi.ShortMessage;
*
* @author Karl Helgason
*/
public
class
SoftReceiver
implements
Receiver
{
public
class
SoftReceiver
implements
MidiDevice
Receiver
{
protected
boolean
open
=
true
;
private
Object
control_mutex
;
...
...
@@ -51,6 +51,10 @@ public class SoftReceiver implements Receiver {
this
.
midimessages
=
mainmixer
.
midimessages
;
}
public
MidiDevice
getMidiDevice
()
{
return
synth
;
}
public
void
send
(
MidiMessage
message
,
long
timeStamp
)
{
synchronized
(
control_mutex
)
{
...
...
@@ -60,6 +64,7 @@ public class SoftReceiver implements Receiver {
if
(
timeStamp
!=
-
1
)
{
synchronized
(
control_mutex
)
{
mainmixer
.
activity
();
while
(
midimessages
.
get
(
timeStamp
)
!=
null
)
timeStamp
++;
if
(
message
instanceof
ShortMessage
...
...
src/share/classes/com/sun/media/sound/SoftSynthesizer.java
浏览文件 @
e6cfccf9
...
...
@@ -66,6 +66,8 @@ public class SoftSynthesizer implements AudioSynthesizer,
public
SoftAudioPusher
pusher
=
null
;
public
AudioInputStream
jitter_stream
=
null
;
public
SourceDataLine
sourceDataLine
=
null
;
public
volatile
long
silent_samples
=
0
;
private
int
framesize
=
0
;
private
WeakReference
<
AudioInputStream
>
weak_stream_link
;
private
AudioFloatConverter
converter
;
private
float
[]
silentbuffer
=
null
;
...
...
@@ -101,6 +103,8 @@ public class SoftSynthesizer implements AudioSynthesizer,
silentbuffer
=
new
float
[
flen
];
converter
.
toByteArray
(
silentbuffer
,
flen
,
b
,
off
);
silent_samples
+=
(
long
)((
len
/
framesize
));
if
(
pusher
!=
null
)
if
(
weak_stream_link
.
get
()
==
null
)
{
...
...
@@ -136,6 +140,7 @@ public class SoftSynthesizer implements AudioSynthesizer,
weak_stream_link
=
new
WeakReference
<
AudioInputStream
>(
stream
);
converter
=
AudioFloatConverter
.
getConverter
(
stream
.
getFormat
());
samplesize
=
stream
.
getFormat
().
getFrameSize
()
/
stream
.
getFormat
().
getChannels
();
framesize
=
stream
.
getFormat
().
getFrameSize
();
}
public
AudioInputStream
getAudioInputStream
()
...
...
src/share/classes/com/sun/media/sound/SoftVoice.java
浏览文件 @
e6cfccf9
...
...
@@ -43,6 +43,7 @@ public class SoftVoice extends VoiceStatus {
private
int
noteOn_noteNumber
=
0
;
private
int
noteOn_velocity
=
0
;
private
int
noteOff_velocity
=
0
;
private
int
delay
=
0
;
protected
ModelChannelMixer
channelmixer
=
null
;
protected
double
tunedKey
=
0
;
protected
SoftTuning
tuning
=
null
;
...
...
@@ -294,7 +295,7 @@ public class SoftVoice extends VoiceStatus {
tunedKey
=
tuning
.
getTuning
(
noteNumber
)
/
100.0
;
}
protected
void
noteOn
(
int
noteNumber
,
int
velocity
)
{
protected
void
noteOn
(
int
noteNumber
,
int
velocity
,
int
delay
)
{
sustain
=
false
;
sostenuto
=
false
;
...
...
@@ -308,6 +309,7 @@ public class SoftVoice extends VoiceStatus {
noteOn_noteNumber
=
noteNumber
;
noteOn_velocity
=
velocity
;
this
.
delay
=
delay
;
lastMuteValue
=
0
;
lastSoloMuteValue
=
0
;
...
...
@@ -562,7 +564,7 @@ public class SoftVoice extends VoiceStatus {
if
(
stealer_channel
!=
null
)
{
stealer_channel
.
initVoice
(
this
,
stealer_performer
,
stealer_voiceID
,
stealer_noteNumber
,
stealer_velocity
,
stealer_voiceID
,
stealer_noteNumber
,
stealer_velocity
,
0
,
stealer_extendedConnectionBlocks
,
stealer_channelmixer
,
stealer_releaseTriggered
);
stealer_releaseTriggered
=
false
;
...
...
@@ -733,23 +735,55 @@ public class SoftVoice extends VoiceStatus {
}
protected
void
mixAudioStream
(
SoftAudioBuffer
in
,
SoftAudioBuffer
out
,
SoftAudioBuffer
dout
,
float
amp_from
,
float
amp_to
)
{
int
bufferlen
=
in
.
getSize
();
if
(
amp_from
<
0.000000001
&&
amp_to
<
0.000000001
)
return
;
if
(
amp_from
==
amp_to
)
{
float
[]
fout
=
out
.
array
();
float
[]
fin
=
in
.
array
();
for
(
int
i
=
0
;
i
<
bufferlen
;
i
++)
fout
[
i
]
+=
fin
[
i
]
*
amp_to
;
}
else
{
float
amp
=
amp_from
;
float
amp_delta
=
(
amp_to
-
amp_from
)
/
bufferlen
;
float
[]
fout
=
out
.
array
();
float
[]
fin
=
in
.
array
();
for
(
int
i
=
0
;
i
<
bufferlen
;
i
++)
{
amp
+=
amp_delta
;
fout
[
i
]
+=
fin
[
i
]
*
amp
;
if
(
dout
!=
null
&&
delay
!=
0
)
{
if
(
amp_from
==
amp_to
)
{
float
[]
fout
=
out
.
array
();
float
[]
fin
=
in
.
array
();
int
j
=
0
;
for
(
int
i
=
delay
;
i
<
bufferlen
;
i
++)
fout
[
i
]
+=
fin
[
j
++]
*
amp_to
;
fout
=
dout
.
array
();
for
(
int
i
=
0
;
i
<
delay
;
i
++)
fout
[
i
]
+=
fin
[
j
++]
*
amp_to
;
}
else
{
float
amp
=
amp_from
;
float
amp_delta
=
(
amp_to
-
amp_from
)
/
bufferlen
;
float
[]
fout
=
out
.
array
();
float
[]
fin
=
in
.
array
();
int
j
=
0
;
for
(
int
i
=
delay
;
i
<
bufferlen
;
i
++)
{
amp
+=
amp_delta
;
fout
[
i
]
+=
fin
[
j
++]
*
amp
;
}
fout
=
dout
.
array
();
for
(
int
i
=
0
;
i
<
delay
;
i
++)
{
amp
+=
amp_delta
;
fout
[
i
]
+=
fin
[
j
++]
*
amp
;
}
}
}
else
{
if
(
amp_from
==
amp_to
)
{
float
[]
fout
=
out
.
array
();
float
[]
fin
=
in
.
array
();
for
(
int
i
=
0
;
i
<
bufferlen
;
i
++)
fout
[
i
]
+=
fin
[
i
]
*
amp_to
;
}
else
{
float
amp
=
amp_from
;
float
amp_delta
=
(
amp_to
-
amp_from
)
/
bufferlen
;
float
[]
fout
=
out
.
array
();
float
[]
fin
=
in
.
array
();
for
(
int
i
=
0
;
i
<
bufferlen
;
i
++)
{
amp
+=
amp_delta
;
fout
[
i
]
+=
fin
[
i
]
*
amp
;
}
}
}
...
...
@@ -785,6 +819,13 @@ public class SoftVoice extends VoiceStatus {
SoftAudioBuffer
mono
=
buffer
[
SoftMainMixer
.
CHANNEL_MONO
];
SoftAudioBuffer
eff1
=
buffer
[
SoftMainMixer
.
CHANNEL_EFFECT1
];
SoftAudioBuffer
eff2
=
buffer
[
SoftMainMixer
.
CHANNEL_EFFECT2
];
SoftAudioBuffer
dleft
=
buffer
[
SoftMainMixer
.
CHANNEL_DELAY_LEFT
];
SoftAudioBuffer
dright
=
buffer
[
SoftMainMixer
.
CHANNEL_DELAY_RIGHT
];
SoftAudioBuffer
dmono
=
buffer
[
SoftMainMixer
.
CHANNEL_DELAY_MONO
];
SoftAudioBuffer
deff1
=
buffer
[
SoftMainMixer
.
CHANNEL_DELAY_EFFECT1
];
SoftAudioBuffer
deff2
=
buffer
[
SoftMainMixer
.
CHANNEL_DELAY_EFFECT2
];
SoftAudioBuffer
leftdry
=
buffer
[
SoftMainMixer
.
CHANNEL_LEFT_DRY
];
SoftAudioBuffer
rightdry
=
buffer
[
SoftMainMixer
.
CHANNEL_RIGHT_DRY
];
...
...
@@ -799,42 +840,42 @@ public class SoftVoice extends VoiceStatus {
if
(
nrofchannels
==
1
)
{
out_mixer_left
=
(
out_mixer_left
+
out_mixer_right
)
/
2
;
mixAudioStream
(
leftdry
,
left
,
last_out_mixer_left
,
out_mixer_left
);
mixAudioStream
(
leftdry
,
left
,
dleft
,
last_out_mixer_left
,
out_mixer_left
);
if
(
rightdry
!=
null
)
mixAudioStream
(
rightdry
,
left
,
last_out_mixer_left
,
mixAudioStream
(
rightdry
,
left
,
dleft
,
last_out_mixer_left
,
out_mixer_left
);
}
else
{
if
(
rightdry
==
null
&&
last_out_mixer_left
==
last_out_mixer_right
&&
out_mixer_left
==
out_mixer_right
)
{
mixAudioStream
(
leftdry
,
mono
,
last_out_mixer_left
,
out_mixer_left
);
mixAudioStream
(
leftdry
,
mono
,
dmono
,
last_out_mixer_left
,
out_mixer_left
);
}
else
{
mixAudioStream
(
leftdry
,
left
,
last_out_mixer_left
,
out_mixer_left
);
mixAudioStream
(
leftdry
,
left
,
dleft
,
last_out_mixer_left
,
out_mixer_left
);
if
(
rightdry
!=
null
)
mixAudioStream
(
rightdry
,
right
,
last_out_mixer_right
,
mixAudioStream
(
rightdry
,
right
,
dright
,
last_out_mixer_right
,
out_mixer_right
);
else
mixAudioStream
(
leftdry
,
right
,
last_out_mixer_right
,
mixAudioStream
(
leftdry
,
right
,
dright
,
last_out_mixer_right
,
out_mixer_right
);
}
}
if
(
rightdry
==
null
)
{
mixAudioStream
(
leftdry
,
eff1
,
last_out_mixer_effect1
,
mixAudioStream
(
leftdry
,
eff1
,
deff1
,
last_out_mixer_effect1
,
out_mixer_effect1
);
mixAudioStream
(
leftdry
,
eff2
,
last_out_mixer_effect2
,
mixAudioStream
(
leftdry
,
eff2
,
deff2
,
last_out_mixer_effect2
,
out_mixer_effect2
);
}
else
{
mixAudioStream
(
leftdry
,
eff1
,
last_out_mixer_effect1
*
0.5f
,
mixAudioStream
(
leftdry
,
eff1
,
deff1
,
last_out_mixer_effect1
*
0.5f
,
out_mixer_effect1
*
0.5f
);
mixAudioStream
(
leftdry
,
eff2
,
last_out_mixer_effect2
*
0.5f
,
mixAudioStream
(
leftdry
,
eff2
,
deff2
,
last_out_mixer_effect2
*
0.5f
,
out_mixer_effect2
*
0.5f
);
mixAudioStream
(
rightdry
,
eff1
,
last_out_mixer_effect1
*
0.5f
,
mixAudioStream
(
rightdry
,
eff1
,
deff1
,
last_out_mixer_effect1
*
0.5f
,
out_mixer_effect1
*
0.5f
);
mixAudioStream
(
rightdry
,
eff2
,
last_out_mixer_effect2
*
0.5f
,
mixAudioStream
(
rightdry
,
eff2
,
deff2
,
last_out_mixer_effect2
*
0.5f
,
out_mixer_effect2
*
0.5f
);
}
...
...
src/share/classes/java/beans/IndexedPropertyDescriptor.java
浏览文件 @
e6cfccf9
...
...
@@ -313,11 +313,14 @@ perty.
}
/**
* Gets the <code>Class</code> object of the indexed properties' type.
* The returned <code>Class</code> may describe a primitive type such as <code>int</code>.
* Returns the Java type info for the indexed property.
* Note that the {@code Class} object may describe
* primitive Java types such as {@code int}.
* This type is returned by the indexed read method
* or is used as the parameter type of the indexed write method.
*
* @return
The <code>Class</code> for the indexed properties' type; may return <code>null</code>
*
if the type cannot be determined.
* @return
the {@code Class} object that represents the Java type info,
*
or {@code null} if the type cannot be determined
*/
public
synchronized
Class
<?>
getIndexedPropertyType
()
{
Class
type
=
getIndexedPropertyType0
();
...
...
src/share/classes/java/beans/Introspector.java
浏览文件 @
e6cfccf9
...
...
@@ -25,26 +25,19 @@
package
java.beans
;
import
com.sun.beans.WeakCache
;
import
com.sun.beans.finder.BeanInfoFinder
;
import
com.sun.beans.finder.ClassFinder
;
import
java.lang.ref.Reference
;
import
java.lang.ref.SoftReference
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Modifier
;
import
java.security.AccessController
;
import
java.security.PrivilegedAction
;
import
java.util.Collections
;
import
java.util.Map
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.EventListener
;
import
java.util.List
;
import
java.util.WeakHashMap
;
import
java.util.TreeMap
;
import
sun.awt.AppContext
;
...
...
@@ -85,20 +78,7 @@ import sun.reflect.misc.ReflectUtil;
* patterns to identify property accessors, event sources, or public
* methods. We then proceed to analyze the class's superclass and add
* in the information from it (and possibly on up the superclass chain).
*
* <p>
* Because the Introspector caches BeanInfo classes for better performance,
* take care if you use it in an application that uses
* multiple class loaders.
* In general, when you destroy a <code>ClassLoader</code>
* that has been used to introspect classes,
* you should use the
* {@link #flushCaches <code>Introspector.flushCaches</code>}
* or
* {@link #flushFromCaches <code>Introspector.flushFromCaches</code>} method
* to flush all of the introspected classes out of the cache.
*
* <P>
* For more information about introspection and design patterns, please
* consult the
* <a href="http://java.sun.com/products/javabeans/docs/index.html">JavaBeans specification</a>.
...
...
@@ -112,8 +92,8 @@ public class Introspector {
public
final
static
int
IGNORE_ALL_BEANINFO
=
3
;
// Static Caches to speed up introspection.
private
static
Map
declaredMethodCache
=
Collections
.
synchronizedMap
(
new
WeakHashMap
()
);
private
static
WeakCache
<
Class
<?>,
Method
[]>
declaredMethodCache
=
new
WeakCache
<
Class
<?>,
Method
[]>(
);
private
static
final
Object
BEANINFO_CACHE
=
new
Object
();
...
...
@@ -174,20 +154,21 @@ public class Introspector {
if
(!
ReflectUtil
.
isPackageAccessible
(
beanClass
))
{
return
(
new
Introspector
(
beanClass
,
null
,
USE_ALL_BEANINFO
)).
getBeanInfo
();
}
Map
<
Class
<?>,
BeanInfo
>
map
;
synchronized
(
BEANINFO_CACHE
)
{
map
=
(
Map
<
Class
<?>,
BeanInfo
>)
AppContext
.
getAppContext
().
get
(
BEANINFO_CACHE
);
if
(
map
==
null
)
{
map
=
Collections
.
synchronizedMap
(
new
WeakHashMap
<
Class
<?>,
BeanInfo
>());
AppContext
.
getAppContext
().
put
(
BEANINFO_CACHE
,
map
);
WeakCache
<
Class
<?>,
BeanInfo
>
beanInfoCache
=
(
WeakCache
<
Class
<?>,
BeanInfo
>)
AppContext
.
getAppContext
().
get
(
BEANINFO_CACHE
);
if
(
beanInfoCache
==
null
)
{
beanInfoCache
=
new
WeakCache
<
Class
<?>,
BeanInfo
>();
AppContext
.
getAppContext
().
put
(
BEANINFO_CACHE
,
beanInfoCache
);
}
BeanInfo
beanInfo
=
beanInfoCache
.
get
(
beanClass
);
if
(
beanInfo
==
null
)
{
beanInfo
=
(
new
Introspector
(
beanClass
,
null
,
USE_ALL_BEANINFO
)).
getBeanInfo
();
beanInfoCache
.
put
(
beanClass
,
beanInfo
);
}
return
beanInfo
;
}
BeanInfo
bi
=
map
.
get
(
beanClass
);
if
(
bi
==
null
)
{
bi
=
(
new
Introspector
(
beanClass
,
null
,
USE_ALL_BEANINFO
)).
getBeanInfo
();
map
.
put
(
beanClass
,
bi
);
}
return
bi
;
}
/**
...
...
@@ -359,11 +340,13 @@ public class Introspector {
*/
public
static
void
flushCaches
()
{
Map
map
=
(
Map
)
AppContext
.
getAppContext
().
get
(
BEANINFO_CACHE
);
if
(
map
!=
null
)
{
map
.
clear
();
synchronized
(
BEANINFO_CACHE
)
{
WeakCache
beanInfoCache
=
(
WeakCache
)
AppContext
.
getAppContext
().
get
(
BEANINFO_CACHE
);
if
(
beanInfoCache
!=
null
)
{
beanInfoCache
.
clear
();
}
declaredMethodCache
.
clear
();
}
declaredMethodCache
.
clear
();
}
/**
...
...
@@ -385,11 +368,13 @@ public class Introspector {
if
(
clz
==
null
)
{
throw
new
NullPointerException
();
}
Map
map
=
(
Map
)
AppContext
.
getAppContext
().
get
(
BEANINFO_CACHE
);
if
(
map
!=
null
)
{
map
.
remove
(
clz
);
synchronized
(
BEANINFO_CACHE
)
{
WeakCache
beanInfoCache
=
(
WeakCache
)
AppContext
.
getAppContext
().
get
(
BEANINFO_CACHE
);
if
(
beanInfoCache
!=
null
)
{
beanInfoCache
.
put
(
clz
,
null
);
}
declaredMethodCache
.
put
(
clz
,
null
);
}
declaredMethodCache
.
remove
(
clz
);
}
//======================================================================
...
...
@@ -1272,41 +1257,26 @@ public class Introspector {
/*
* Internal method to return *public* methods within a class.
*/
private
static
synchronized
Method
[]
getPublicDeclaredMethods
(
Class
clz
)
{
private
static
Method
[]
getPublicDeclaredMethods
(
Class
clz
)
{
// Looking up Class.getDeclaredMethods is relatively expensive,
// so we cache the results.
Method
[]
result
=
null
;
if
(!
ReflectUtil
.
isPackageAccessible
(
clz
))
{
return
new
Method
[
0
];
}
final
Class
fclz
=
clz
;
Reference
ref
=
(
Reference
)
declaredMethodCache
.
get
(
fclz
);
if
(
ref
!=
null
)
{
result
=
(
Method
[])
ref
.
get
();
if
(
result
!=
null
)
{
return
result
;
}
}
// We have to raise privilege for getDeclaredMethods
result
=
(
Method
[])
AccessController
.
doPrivileged
(
new
PrivilegedAction
()
{
public
Object
run
()
{
return
fclz
.
getDeclaredMethods
();
synchronized
(
BEANINFO_CACHE
)
{
Method
[]
result
=
declaredMethodCache
.
get
(
clz
);
if
(
result
==
null
)
{
result
=
clz
.
getMethods
();
for
(
int
i
=
0
;
i
<
result
.
length
;
i
++)
{
Method
method
=
result
[
i
];
if
(!
method
.
getDeclaringClass
().
equals
(
clz
))
{
result
[
i
]
=
null
;
}
}
});
// Null out any non-public methods.
for
(
int
i
=
0
;
i
<
result
.
length
;
i
++)
{
Method
method
=
result
[
i
];
int
mods
=
method
.
getModifiers
();
if
(!
Modifier
.
isPublic
(
mods
))
{
result
[
i
]
=
null
;
declaredMethodCache
.
put
(
clz
,
result
);
}
return
result
;
}
// Add it to the cache.
declaredMethodCache
.
put
(
fclz
,
new
SoftReference
(
result
));
return
result
;
}
//======================================================================
...
...
src/share/classes/java/beans/PropertyDescriptor.java
浏览文件 @
e6cfccf9
...
...
@@ -164,14 +164,16 @@ public class PropertyDescriptor extends FeatureDescriptor {
}
/**
* Gets the Class object for the property.
* Returns the Java type info for the property.
* Note that the {@code Class} object may describe
* primitive Java types such as {@code int}.
* This type is returned by the read method
* or is used as the parameter type of the write method.
* Returns {@code null} if the type is an indexed property
* that does not support non-indexed access.
*
* @return The Java type info for the property. Note that
* the "Class" object may describe a built-in Java type such as "int".
* The result may be "null" if this is an indexed property that
* does not support non-indexed access.
* <p>
* This is the type that will be returned by the ReadMethod.
* @return the {@code Class} object that represents the Java type info,
* or {@code null} if the type cannot be determined
*/
public
synchronized
Class
<?>
getPropertyType
()
{
Class
type
=
getPropertyType0
();
...
...
src/share/classes/javax/swing/AbstractListModel.java
浏览文件 @
e6cfccf9
...
...
@@ -42,9 +42,11 @@ import java.util.EventListener;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @param <E> the type of the elements of this model
*
* @author Hans Muller
*/
public
abstract
class
AbstractListModel
implements
ListModel
,
Serializable
public
abstract
class
AbstractListModel
<
E
>
implements
ListModel
<
E
>
,
Serializable
{
protected
EventListenerList
listenerList
=
new
EventListenerList
();
...
...
src/share/classes/javax/swing/DefaultListCellRenderer.java
浏览文件 @
e6cfccf9
...
...
@@ -71,7 +71,7 @@ import sun.swing.DefaultLookup;
* @author Hans Muller
*/
public
class
DefaultListCellRenderer
extends
JLabel
implements
ListCellRenderer
,
Serializable
implements
ListCellRenderer
<
Object
>
,
Serializable
{
/**
...
...
@@ -111,7 +111,7 @@ public class DefaultListCellRenderer extends JLabel
}
public
Component
getListCellRendererComponent
(
JList
list
,
JList
<?>
list
,
Object
value
,
int
index
,
boolean
isSelected
,
...
...
src/share/classes/javax/swing/DefaultListModel.java
浏览文件 @
e6cfccf9
...
...
@@ -48,11 +48,13 @@ import javax.swing.event.*;
* has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @param <E> the type of the elements of this model
*
* @author Hans Muller
*/
public
class
DefaultListModel
extends
AbstractListModel
public
class
DefaultListModel
<
E
>
extends
AbstractListModel
<
E
>
{
private
Vector
delegate
=
new
Vector
();
private
Vector
<
E
>
delegate
=
new
Vector
<
E
>
();
/**
* Returns the number of components in this list.
...
...
@@ -83,7 +85,7 @@ public class DefaultListModel extends AbstractListModel
* list
* @see #get(int)
*/
public
Object
getElementAt
(
int
index
)
{
public
E
getElementAt
(
int
index
)
{
return
delegate
.
elementAt
(
index
);
}
...
...
@@ -175,7 +177,7 @@ public class DefaultListModel extends AbstractListModel
* @return an enumeration of the components of this list
* @see Vector#elements()
*/
public
Enumeration
<
?
>
elements
()
{
public
Enumeration
<
E
>
elements
()
{
return
delegate
.
elements
();
}
...
...
@@ -260,7 +262,7 @@ public class DefaultListModel extends AbstractListModel
* @see #get(int)
* @see Vector#elementAt(int)
*/
public
Object
elementAt
(
int
index
)
{
public
E
elementAt
(
int
index
)
{
return
delegate
.
elementAt
(
index
);
}
...
...
@@ -271,7 +273,7 @@ public class DefaultListModel extends AbstractListModel
* @return the first component of this list
* @see Vector#firstElement()
*/
public
Object
firstElement
()
{
public
E
firstElement
()
{
return
delegate
.
firstElement
();
}
...
...
@@ -283,13 +285,13 @@ public class DefaultListModel extends AbstractListModel
* @return the last component of the list
* @see Vector#lastElement()
*/
public
Object
lastElement
()
{
public
E
lastElement
()
{
return
delegate
.
lastElement
();
}
/**
* Sets the component at the specified <code>index</code> of this
* list to be the specified
objec
t. The previous component at that
* list to be the specified
elemen
t. The previous component at that
* position is discarded.
* <p>
* Throws an <code>ArrayIndexOutOfBoundsException</code> if the index
...
...
@@ -300,13 +302,13 @@ public class DefaultListModel extends AbstractListModel
* <code>List</code> interface defined in the 1.2 Collections framework.
* </blockquote>
*
* @param
obj
what the component is to be set to
* @param
element
what the component is to be set to
* @param index the specified index
* @see #set(int,Object)
* @see Vector#setElementAt(Object,int)
*/
public
void
setElementAt
(
Object
obj
,
int
index
)
{
delegate
.
setElementAt
(
obj
,
index
);
public
void
setElementAt
(
E
element
,
int
index
)
{
delegate
.
setElementAt
(
element
,
index
);
fireContentsChanged
(
this
,
index
,
index
);
}
...
...
@@ -331,7 +333,7 @@ public class DefaultListModel extends AbstractListModel
}
/**
* Inserts the specified
objec
t as a component in this list at the
* Inserts the specified
elemen
t as a component in this list at the
* specified <code>index</code>.
* <p>
* Throws an <code>ArrayIndexOutOfBoundsException</code> if the index
...
...
@@ -342,26 +344,26 @@ public class DefaultListModel extends AbstractListModel
* <code>List</code> interface defined in the 1.2 Collections framework.
* </blockquote>
*
* @param
obj
the component to insert
* @param
element
the component to insert
* @param index where to insert the new component
* @exception ArrayIndexOutOfBoundsException if the index was invalid
* @see #add(int,Object)
* @see Vector#insertElementAt(Object,int)
*/
public
void
insertElementAt
(
Object
obj
,
int
index
)
{
delegate
.
insertElementAt
(
obj
,
index
);
public
void
insertElementAt
(
E
element
,
int
index
)
{
delegate
.
insertElementAt
(
element
,
index
);
fireIntervalAdded
(
this
,
index
,
index
);
}
/**
* Adds the specified component to the end of this list.
*
* @param
obj
the component to be added
* @param
element
the component to be added
* @see Vector#addElement(Object)
*/
public
void
addElement
(
Object
obj
)
{
public
void
addElement
(
E
element
)
{
int
index
=
delegate
.
size
();
delegate
.
addElement
(
obj
);
delegate
.
addElement
(
element
);
fireIntervalAdded
(
this
,
index
,
index
);
}
...
...
@@ -441,7 +443,7 @@ public class DefaultListModel extends AbstractListModel
*
* @param index index of element to return
*/
public
Object
get
(
int
index
)
{
public
E
get
(
int
index
)
{
return
delegate
.
elementAt
(
index
);
}
...
...
@@ -457,8 +459,8 @@ public class DefaultListModel extends AbstractListModel
* @param element element to be stored at the specified position
* @return the element previously at the specified position
*/
public
Object
set
(
int
index
,
Object
element
)
{
Object
rv
=
delegate
.
elementAt
(
index
);
public
E
set
(
int
index
,
E
element
)
{
E
rv
=
delegate
.
elementAt
(
index
);
delegate
.
setElementAt
(
element
,
index
);
fireContentsChanged
(
this
,
index
,
index
);
return
rv
;
...
...
@@ -474,7 +476,7 @@ public class DefaultListModel extends AbstractListModel
* @param index index at which the specified element is to be inserted
* @param element element to be inserted
*/
public
void
add
(
int
index
,
Object
element
)
{
public
void
add
(
int
index
,
E
element
)
{
delegate
.
insertElementAt
(
element
,
index
);
fireIntervalAdded
(
this
,
index
,
index
);
}
...
...
@@ -488,9 +490,10 @@ public class DefaultListModel extends AbstractListModel
* (<code>index < 0 || index >= size()</code>).
*
* @param index the index of the element to removed
* @return the element previously at the specified position
*/
public
Object
remove
(
int
index
)
{
Object
rv
=
delegate
.
elementAt
(
index
);
public
E
remove
(
int
index
)
{
E
rv
=
delegate
.
elementAt
(
index
);
delegate
.
removeElementAt
(
index
);
fireIntervalRemoved
(
this
,
index
,
index
);
return
rv
;
...
...
src/share/classes/javax/swing/JList.java
浏览文件 @
e6cfccf9
...
...
@@ -25,11 +25,24 @@
package
javax.swing
;
import
java.awt.Color
;
import
java.awt.Component
;
import
java.awt.Cursor
;
import
java.awt.Dimension
;
import
java.awt.Font
;
import
java.awt.FontMetrics
;
import
java.awt.GraphicsEnvironment
;
import
java.awt.HeadlessException
;
import
java.awt.Insets
;
import
java.awt.Point
;
import
java.awt.Rectangle
;
import
java.awt.event.*
;
import
java.awt.*
;
import
java.util.Vector
;
import
java.util.Locale
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
...
...
@@ -59,28 +72,30 @@ import static sun.swing.SwingUtilities2.Section.*;
* constructor that automatically builds a read-only {@code ListModel} instance
* for you:
* <pre>
* {@code
* // Create a JList that displays strings from an array
*
* String[] data = {"one", "two", "three", "four"};
* JList
myList = new JList
(data);
* JList
<String> myList = new JList<String>
(data);
*
* // Create a JList that displays the superclasses of JList.class, by
* // creating it with a Vector populated with this data
*
* Vector
superClasses = new Vector
();
* Class rootClass = javax.swing.JList.class;
* for(Class cls = rootClass; cls != null; cls = cls.getSuperclass()) {
* Vector
<Class<?>> superClasses = new Vector<Class<?>>
();
* Class
<JList>
rootClass = javax.swing.JList.class;
* for(Class
<?>
cls = rootClass; cls != null; cls = cls.getSuperclass()) {
* superClasses.addElement(cls);
* }
* JList
myList = new JList
(superClasses);
* JList
<Class<?>> myList = new JList<Class<?>>
(superClasses);
*
* // The automatically created model is stored in JList's "model"
* // property, which you can retrieve
*
* ListModel model = myList.getModel();
* ListModel
<Class<?>>
model = myList.getModel();
* for(int i = 0; i < model.getSize(); i++) {
* System.out.println(model.getElementAt(i));
* }
* }
* </pre>
* <p>
* A {@code ListModel} can be supplied directly to a {@code JList} by way of a
...
...
@@ -103,12 +118,14 @@ import static sun.swing.SwingUtilities2.Section.*;
* notifying listeners. For example, a read-only implementation of
* {@code AbstractListModel}:
* <pre>
* {@code
* // This list model has about 2^16 elements. Enjoy scrolling.
*
* ListModel
bigData = new AbstractListModel
() {
* ListModel
<String> bigData = new AbstractListModel<String>
() {
* public int getSize() { return Short.MAX_VALUE; }
* public
Object
getElementAt(int index) { return "Index " + index; }
* public
String
getElementAt(int index) { return "Index " + index; }
* };
* }
* </pre>
* <p>
* The selection state of a {@code JList} is managed by another separate
...
...
@@ -150,9 +167,10 @@ import static sun.swing.SwingUtilities2.Section.*;
* component to render, is installed by the lists's {@code ListUI}. You can
* substitute your own renderer using code like this:
* <pre>
* {@code
* // Display an icon and a string for each object in the list.
*
* class MyCellRenderer extends JLabel implements ListCellRenderer {
* class MyCellRenderer extends JLabel implements ListCellRenderer
<Object>
{
* final static ImageIcon longIcon = new ImageIcon("long.gif");
* final static ImageIcon shortIcon = new ImageIcon("short.gif");
*
...
...
@@ -160,7 +178,7 @@ import static sun.swing.SwingUtilities2.Section.*;
* // We just reconfigure the JLabel each time we're called.
*
* public Component getListCellRendererComponent(
* JList
list,
// the list
* JList
<?> list,
// the list
* Object value, // value to display
* int index, // cell index
* boolean isSelected, // is the cell selected
...
...
@@ -184,6 +202,7 @@ import static sun.swing.SwingUtilities2.Section.*;
* }
*
* myList.setCellRenderer(new MyCellRenderer());
* }
* </pre>
* <p>
* Another job for the cell renderer is in helping to determine sizing
...
...
@@ -195,7 +214,8 @@ import static sun.swing.SwingUtilities2.Section.*;
* automatically based on a single prototype value:
* <a name="prototype_example">
* <pre>
* JList bigDataList = new JList(bigData);
* {@code
* JList<String> bigDataList = new JList<String>(bigData);
*
* // We don't want the JList implementation to compute the width
* // or height of all of the list cells, so we give it a string
...
...
@@ -204,6 +224,7 @@ import static sun.swing.SwingUtilities2.Section.*;
* // properties.
*
* bigDataList.setPrototypeCellValue("Index 1234567890");
* }
* </pre>
* <p>
* {@code JList} doesn't implement scrolling directly. To create a list that
...
...
@@ -260,13 +281,15 @@ import static sun.swing.SwingUtilities2.Section.*;
* @see ListCellRenderer
* @see DefaultListCellRenderer
*
* @param <E> the type of the elements of this list
*
* @beaninfo
* attribute: isContainer false
* description: A component which allows for the selection of one or more objects from a list.
*
* @author Hans Muller
*/
public
class
JList
extends
JComponent
implements
Scrollable
,
Accessible
public
class
JList
<
E
>
extends
JComponent
implements
Scrollable
,
Accessible
{
/**
* @see #getUIClassID
...
...
@@ -301,15 +324,15 @@ public class JList extends JComponent implements Scrollable, Accessible
private
int
fixedCellWidth
=
-
1
;
private
int
fixedCellHeight
=
-
1
;
private
int
horizontalScrollIncrement
=
-
1
;
private
Object
prototypeCellValue
;
private
E
prototypeCellValue
;
private
int
visibleRowCount
=
8
;
private
Color
selectionForeground
;
private
Color
selectionBackground
;
private
boolean
dragEnabled
;
private
ListSelectionModel
selectionModel
;
private
ListModel
dataModel
;
private
ListCellRenderer
cellRenderer
;
private
ListModel
<
E
>
dataModel
;
private
ListCellRenderer
<?
super
E
>
cellRenderer
;
private
ListSelectionListener
selectionListener
;
/**
...
...
@@ -402,7 +425,7 @@ public class JList extends JComponent implements Scrollable, Accessible
* @param dataModel the model for the list
* @exception IllegalArgumentException if the model is {@code null}
*/
public
JList
(
ListModel
dataModel
)
public
JList
(
ListModel
<
E
>
dataModel
)
{
if
(
dataModel
==
null
)
{
throw
new
IllegalArgumentException
(
"dataModel must be non null"
);
...
...
@@ -437,12 +460,12 @@ public class JList extends JComponent implements Scrollable, Accessible
* @param listData the array of Objects to be loaded into the data model,
* {@code non-null}
*/
public
JList
(
final
Object
[]
listData
)
public
JList
(
final
E
[]
listData
)
{
this
(
new
AbstractListModel
()
{
new
AbstractListModel
<
E
>
()
{
public
int
getSize
()
{
return
listData
.
length
;
}
public
Object
getElementAt
(
int
i
)
{
return
listData
[
i
];
}
public
E
getElementAt
(
int
i
)
{
return
listData
[
i
];
}
}
);
}
...
...
@@ -462,11 +485,11 @@ public class JList extends JComponent implements Scrollable, Accessible
* @param listData the <code>Vector</code> to be loaded into the
* data model, {@code non-null}
*/
public
JList
(
final
Vector
<?>
listData
)
{
public
JList
(
final
Vector
<?
extends
E
>
listData
)
{
this
(
new
AbstractListModel
()
{
new
AbstractListModel
<
E
>
()
{
public
int
getSize
()
{
return
listData
.
size
();
}
public
Object
getElementAt
(
int
i
)
{
return
listData
.
elementAt
(
i
);
}
public
E
getElementAt
(
int
i
)
{
return
listData
.
elementAt
(
i
);
}
}
);
}
...
...
@@ -477,9 +500,9 @@ public class JList extends JComponent implements Scrollable, Accessible
*/
public
JList
()
{
this
(
new
AbstractListModel
()
{
new
AbstractListModel
<
E
>
()
{
public
int
getSize
()
{
return
0
;
}
public
Object
getElementAt
(
int
i
)
{
return
"No Data Model"
;
}
public
E
getElementAt
(
int
i
)
{
throw
new
IndexOutOfBoundsException
(
"No Data Model"
)
;
}
}
);
}
...
...
@@ -526,7 +549,7 @@ public class JList extends JComponent implements Scrollable, Accessible
public
void
updateUI
()
{
setUI
((
ListUI
)
UIManager
.
getUI
(
this
));
ListCellRenderer
renderer
=
getCellRenderer
();
ListCellRenderer
<?
super
E
>
renderer
=
getCellRenderer
();
if
(
renderer
instanceof
Component
)
{
SwingUtilities
.
updateComponentTreeUI
((
Component
)
renderer
);
}
...
...
@@ -560,8 +583,8 @@ public class JList extends JComponent implements Scrollable, Accessible
*/
private
void
updateFixedCellSize
()
{
ListCellRenderer
cr
=
getCellRenderer
();
Object
value
=
getPrototypeCellValue
();
ListCellRenderer
<?
super
E
>
cr
=
getCellRenderer
();
E
value
=
getPrototypeCellValue
();
if
((
cr
!=
null
)
&&
(
value
!=
null
))
{
Component
c
=
cr
.
getListCellRendererComponent
(
this
,
value
,
0
,
false
,
false
);
...
...
@@ -592,7 +615,7 @@ public class JList extends JComponent implements Scrollable, Accessible
* @return the value of the {@code prototypeCellValue} property
* @see #setPrototypeCellValue
*/
public
Object
getPrototypeCellValue
()
{
public
E
getPrototypeCellValue
()
{
return
prototypeCellValue
;
}
...
...
@@ -632,8 +655,8 @@ public class JList extends JComponent implements Scrollable, Accessible
* attribute: visualUpdate true
* description: The cell prototype value, used to compute cell width and height.
*/
public
void
setPrototypeCellValue
(
Object
prototypeCellValue
)
{
Object
oldValue
=
this
.
prototypeCellValue
;
public
void
setPrototypeCellValue
(
E
prototypeCellValue
)
{
E
oldValue
=
this
.
prototypeCellValue
;
this
.
prototypeCellValue
=
prototypeCellValue
;
/* If the prototypeCellValue has changed and is non-null,
...
...
@@ -727,7 +750,7 @@ public class JList extends JComponent implements Scrollable, Accessible
* @see #setCellRenderer
*/
@Transient
public
ListCellRenderer
getCellRenderer
()
{
public
ListCellRenderer
<?
super
E
>
getCellRenderer
()
{
return
cellRenderer
;
}
...
...
@@ -755,8 +778,8 @@ public class JList extends JComponent implements Scrollable, Accessible
* attribute: visualUpdate true
* description: The component used to draw the cells.
*/
public
void
setCellRenderer
(
ListCellRenderer
cellRenderer
)
{
ListCellRenderer
oldValue
=
this
.
cellRenderer
;
public
void
setCellRenderer
(
ListCellRenderer
<?
super
E
>
cellRenderer
)
{
ListCellRenderer
<?
super
E
>
oldValue
=
this
.
cellRenderer
;
this
.
cellRenderer
=
cellRenderer
;
/* If the cellRenderer has changed and prototypeCellValue
...
...
@@ -1455,7 +1478,7 @@ public class JList extends JComponent implements Scrollable, Accessible
* @since 1.4
*/
public
int
getNextMatch
(
String
prefix
,
int
startIndex
,
Position
.
Bias
bias
)
{
ListModel
model
=
getModel
();
ListModel
<
E
>
model
=
getModel
();
int
max
=
model
.
getSize
();
if
(
prefix
==
null
)
{
throw
new
IllegalArgumentException
();
...
...
@@ -1469,16 +1492,16 @@ public class JList extends JComponent implements Scrollable, Accessible
int
increment
=
(
bias
==
Position
.
Bias
.
Forward
)
?
1
:
-
1
;
int
index
=
startIndex
;
do
{
Object
o
=
model
.
getElementAt
(
index
);
E
element
=
model
.
getElementAt
(
index
);
if
(
o
!=
null
)
{
if
(
element
!=
null
)
{
String
string
;
if
(
o
instanceof
String
)
{
string
=
((
String
)
o
).
toUpperCase
();
if
(
element
instanceof
String
)
{
string
=
((
String
)
element
).
toUpperCase
();
}
else
{
string
=
o
.
toString
();
string
=
element
.
toString
();
if
(
string
!=
null
)
{
string
=
string
.
toUpperCase
();
}
...
...
@@ -1516,7 +1539,7 @@ public class JList extends JComponent implements Scrollable, Accessible
if
(
event
!=
null
)
{
Point
p
=
event
.
getPoint
();
int
index
=
locationToIndex
(
p
);
ListCellRenderer
r
=
getCellRenderer
();
ListCellRenderer
<?
super
E
>
r
=
getCellRenderer
();
Rectangle
cellBounds
;
if
(
index
!=
-
1
&&
r
!=
null
&&
(
cellBounds
=
...
...
@@ -1634,7 +1657,7 @@ public class JList extends JComponent implements Scrollable, Accessible
* list of items
* @see #setModel
*/
public
ListModel
getModel
()
{
public
ListModel
<
E
>
getModel
()
{
return
dataModel
;
}
...
...
@@ -1656,11 +1679,11 @@ public class JList extends JComponent implements Scrollable, Accessible
* attribute: visualUpdate true
* description: The object that contains the data to be drawn by this JList.
*/
public
void
setModel
(
ListModel
model
)
{
public
void
setModel
(
ListModel
<
E
>
model
)
{
if
(
model
==
null
)
{
throw
new
IllegalArgumentException
(
"model must be non null"
);
}
ListModel
oldValue
=
dataModel
;
ListModel
<
E
>
oldValue
=
dataModel
;
dataModel
=
model
;
firePropertyChange
(
"model"
,
oldValue
,
dataModel
);
clearSelection
();
...
...
@@ -1668,7 +1691,7 @@ public class JList extends JComponent implements Scrollable, Accessible
/**
* Constructs a read-only <code>ListModel</code> from an array of
object
s,
* Constructs a read-only <code>ListModel</code> from an array of
item
s,
* and calls {@code setModel} with this model.
* <p>
* Attempts to pass a {@code null} value to this method results in
...
...
@@ -1676,15 +1699,15 @@ public class JList extends JComponent implements Scrollable, Accessible
* references the given array directly. Attempts to modify the array
* after invoking this method results in undefined behavior.
*
* @param listData an array of {@code
Objects
} containing the items to
* @param listData an array of {@code
E
} containing the items to
* display in the list
* @see #setModel
*/
public
void
setListData
(
final
Object
[]
listData
)
{
public
void
setListData
(
final
E
[]
listData
)
{
setModel
(
new
AbstractListModel
()
{
new
AbstractListModel
<
E
>
()
{
public
int
getSize
()
{
return
listData
.
length
;
}
public
Object
getElementAt
(
int
i
)
{
return
listData
[
i
];
}
public
E
getElementAt
(
int
i
)
{
return
listData
[
i
];
}
}
);
}
...
...
@@ -1703,11 +1726,11 @@ public class JList extends JComponent implements Scrollable, Accessible
* display in the list
* @see #setModel
*/
public
void
setListData
(
final
Vector
<?>
listData
)
{
public
void
setListData
(
final
Vector
<?
extends
E
>
listData
)
{
setModel
(
new
AbstractListModel
()
{
new
AbstractListModel
<
E
>
()
{
public
int
getSize
()
{
return
listData
.
size
();
}
public
Object
getElementAt
(
int
i
)
{
return
listData
.
elementAt
(
i
);
}
public
E
getElementAt
(
int
i
)
{
return
listData
.
elementAt
(
i
);
}
}
);
}
...
...
@@ -2235,10 +2258,13 @@ public class JList extends JComponent implements Scrollable, Accessible
* @see #isSelectedIndex
* @see #getModel
* @see #addListSelectionListener
*
* @deprecated As of JDK 1.7, replaced by {@link #getSelectedValuesList()}
*/
@Deprecated
public
Object
[]
getSelectedValues
()
{
ListSelectionModel
sm
=
getSelectionModel
();
ListModel
dm
=
getModel
();
ListModel
<
E
>
dm
=
getModel
();
int
iMin
=
sm
.
getMinSelectionIndex
();
int
iMax
=
sm
.
getMaxSelectionIndex
();
...
...
@@ -2259,6 +2285,37 @@ public class JList extends JComponent implements Scrollable, Accessible
return
rv
;
}
/**
* Returns a list of all the selected items, in increasing order based
* on their indices in the list.
*
* @return the selected items, or an empty list if nothing is selected
* @see #isSelectedIndex
* @see #getModel
* @see #addListSelectionListener
*
* @since 1.7
*/
public
List
<
E
>
getSelectedValuesList
()
{
ListSelectionModel
sm
=
getSelectionModel
();
ListModel
<
E
>
dm
=
getModel
();
int
iMin
=
sm
.
getMinSelectionIndex
();
int
iMax
=
sm
.
getMaxSelectionIndex
();
if
((
iMin
<
0
)
||
(
iMax
<
0
))
{
return
Collections
.
emptyList
();
}
List
<
E
>
selectedItems
=
new
ArrayList
<
E
>();
for
(
int
i
=
iMin
;
i
<=
iMax
;
i
++)
{
if
(
sm
.
isSelectedIndex
(
i
))
{
selectedItems
.
add
(
dm
.
getElementAt
(
i
));
}
}
return
selectedItems
;
}
/**
* Returns the smallest selected cell index; <i>the selection</i> when only
...
...
@@ -2291,7 +2348,7 @@ public class JList extends JComponent implements Scrollable, Accessible
* @see #getModel
* @see #addListSelectionListener
*/
public
Object
getSelectedValue
()
{
public
E
getSelectedValue
()
{
int
i
=
getMinSelectionIndex
();
return
(
i
==
-
1
)
?
null
:
getModel
().
getElementAt
(
i
);
}
...
...
@@ -2309,7 +2366,7 @@ public class JList extends JComponent implements Scrollable, Accessible
setSelectedIndex
(-
1
);
else
if
(!
anObject
.
equals
(
getSelectedValue
()))
{
int
i
,
c
;
ListModel
dm
=
getModel
();
ListModel
<
E
>
dm
=
getModel
();
for
(
i
=
0
,
c
=
dm
.
getSize
();
i
<
c
;
i
++)
if
(
anObject
.
equals
(
dm
.
getElementAt
(
i
))){
setSelectedIndex
(
i
);
...
...
@@ -3138,14 +3195,14 @@ public class JList extends JComponent implements Scrollable, Accessible
*/
protected
class
AccessibleJListChild
extends
AccessibleContext
implements
Accessible
,
AccessibleComponent
{
private
JList
parent
=
null
;
private
JList
<
E
>
parent
=
null
;
private
int
indexInParent
;
private
Component
component
=
null
;
private
AccessibleContext
accessibleContext
=
null
;
private
ListModel
listModel
;
private
ListCellRenderer
cellRenderer
=
null
;
private
ListModel
<
E
>
listModel
;
private
ListCellRenderer
<?
super
E
>
cellRenderer
=
null
;
public
AccessibleJListChild
(
JList
parent
,
int
indexInParent
)
{
public
AccessibleJListChild
(
JList
<
E
>
parent
,
int
indexInParent
)
{
this
.
parent
=
parent
;
this
.
setAccessibleParent
(
parent
);
this
.
indexInParent
=
indexInParent
;
...
...
@@ -3175,7 +3232,7 @@ public class JList extends JComponent implements Scrollable, Accessible
if
((
parent
!=
null
)
&&
(
listModel
!=
null
)
&&
cellRenderer
!=
null
)
{
Object
value
=
listModel
.
getElementAt
(
index
);
E
value
=
listModel
.
getElementAt
(
index
);
boolean
isSelected
=
parent
.
isSelectedIndex
(
index
);
boolean
isFocussed
=
parent
.
isFocusOwner
()
&&
(
index
==
parent
.
getLeadSelectionIndex
());
...
...
src/share/classes/javax/swing/JTable.java
浏览文件 @
e6cfccf9
...
...
@@ -1337,7 +1337,11 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
return
(
TableCellRenderer
)
renderer
;
}
else
{
return
getDefaultRenderer
(
columnClass
.
getSuperclass
());
Class
c
=
columnClass
.
getSuperclass
();
if
(
c
==
null
&&
columnClass
!=
Object
.
class
)
{
c
=
Object
.
class
;
}
return
getDefaultRenderer
(
c
);
}
}
}
...
...
src/share/classes/javax/swing/ListCellRenderer.java
浏览文件 @
e6cfccf9
...
...
@@ -33,12 +33,13 @@ import java.awt.Component;
* the cells in a JList. For example, to use a JLabel as a
* ListCellRenderer, you would write something like this:
* <pre>
* class MyCellRenderer extends JLabel implements ListCellRenderer {
* {@code
* class MyCellRenderer extends JLabel implements ListCellRenderer<Object> {
* public MyCellRenderer() {
* setOpaque(true);
* }
*
* public Component getListCellRendererComponent(JList list,
* public Component getListCellRendererComponent(JList
<?>
list,
* Object value,
* int index,
* boolean isSelected,
...
...
@@ -75,14 +76,17 @@ import java.awt.Component;
* return this;
* }
* }
* }
* </pre>
*
* @param <E> the type of values this renderer can be used for
*
* @see JList
* @see DefaultListCellRenderer
*
* @author Hans Muller
*/
public
interface
ListCellRenderer
public
interface
ListCellRenderer
<
E
>
{
/**
* Return a component that has been configured to display the specified
...
...
@@ -104,8 +108,8 @@ public interface ListCellRenderer
* @see ListModel
*/
Component
getListCellRendererComponent
(
JList
list
,
Object
value
,
JList
<?
extends
E
>
list
,
E
value
,
int
index
,
boolean
isSelected
,
boolean
cellHasFocus
);
...
...
src/share/classes/javax/swing/ListModel.java
浏览文件 @
e6cfccf9
...
...
@@ -35,10 +35,12 @@ import javax.swing.event.ListDataListener;
* length of the data model must be reported to all of the
* ListDataListeners.
*
* @param <E> the type of the elements of this model
*
* @author Hans Muller
* @see JList
*/
public
interface
ListModel
public
interface
ListModel
<
E
>
{
/**
* Returns the length of the list.
...
...
@@ -51,7 +53,7 @@ public interface ListModel
* @param index the requested index
* @return the value at <code>index</code>
*/
Object
getElementAt
(
int
index
);
E
getElementAt
(
int
index
);
/**
* Adds a listener to the list that's notified each time a change
...
...
src/share/classes/javax/swing/plaf/ComponentUI.java
浏览文件 @
e6cfccf9
...
...
@@ -60,13 +60,13 @@ public abstract class ComponentUI {
}
/**
* Configures the specified component appropriate for the look and feel.
* Configures the specified component appropriate
ly
for the look and feel.
* This method is invoked when the <code>ComponentUI</code> instance is being installed
* as the UI delegate on the specified component. This method should
* completely configure the component for the look and feel,
* including the following:
* <ol>
* <li>Install
any
default property values for color, fonts, borders,
* <li>Install default property values for color, fonts, borders,
* icons, opacity, etc. on the component. Whenever possible,
* property values initialized by the client program should <i>not</i>
* be overridden.
...
...
@@ -116,7 +116,7 @@ public abstract class ComponentUI {
}
/**
* Paints the specified component appropriate for the look and feel.
* Paints the specified component appropriate
ly
for the look and feel.
* This method is invoked from the <code>ComponentUI.update</code> method when
* the specified component is being painted. Subclasses should override
* this method and use the specified <code>Graphics</code> object to
...
...
@@ -134,15 +134,15 @@ public abstract class ComponentUI {
}
/**
* Notifies this UI delegate that it
'
s time to paint the specified
* Notifies this UI delegate that it
i
s time to paint the specified
* component. This method is invoked by <code>JComponent</code>
* when the specified component is being painted.
*
By default this method will fill the specified component with
*
its background color (if its <code>opaque</code> property is
*
<code>true</code>) and then immediately call <code>paint</code>.
*
In general this method need not be overridden by subclasses;
*
all look-and-feel rendering code should reside in the <code>paint</code>
* method.
*
*
<p>By default this method fills the specified component with
*
its background color if its {@code opaque} property is {@code true},
*
and then immediately calls {@code paint}. In general this method need
*
not be overridden by subclasses; all look-and-feel rendering code should
*
reside in the {@code paint}
method.
*
* @param g the <code>Graphics</code> context in which to paint
* @param c the component being painted;
...
...
src/share/classes/javax/swing/plaf/basic/BasicComboBoxEditor.java
浏览文件 @
e6cfccf9
...
...
@@ -24,14 +24,10 @@
*/
package
javax.swing.plaf.basic
;
import
javax.swing.*
;
import
javax.swing.ComboBoxEditor
;
import
javax.swing.JTextField
;
import
javax.swing.border.Border
;
import
javax.swing.text.AttributeSet
;
import
javax.swing.text.BadLocationException
;
import
javax.swing.text.PlainDocument
;
import
java.awt.*
;
import
java.awt.Component
;
import
java.awt.event.*
;
import
java.lang.reflect.Method
;
...
...
@@ -73,12 +69,17 @@ public class BasicComboBoxEditor implements ComboBoxEditor,FocusListener {
* @param anObject the displayed value of the editor
*/
public
void
setItem
(
Object
anObject
)
{
if
(
anObject
!=
null
)
{
editor
.
setText
(
anObject
.
toString
());
String
text
;
if
(
anObject
!=
null
)
{
text
=
anObject
.
toString
();
oldValue
=
anObject
;
}
else
{
editor
.
setText
(
""
);
text
=
""
;
}
// workaround for 4530952
if
(!
text
.
equals
(
editor
.
getText
()))
{
editor
.
setText
(
text
);
}
}
...
...
src/share/classes/javax/swing/plaf/basic/BasicComboBoxUI.java
浏览文件 @
e6cfccf9
...
...
@@ -30,7 +30,6 @@ import java.awt.event.*;
import
javax.swing.*
;
import
javax.accessibility.*
;
import
javax.swing.plaf.*
;
import
javax.swing.border.*
;
import
javax.swing.text.*
;
import
javax.swing.event.*
;
import
java.beans.PropertyChangeListener
;
...
...
@@ -189,19 +188,20 @@ public class BasicComboBoxUI extends ComboBoxUI {
/**
* Indicates whether or not the combo box button should be square.
* If square, then the width and height are equal, and are both set to
* the height of the combo (minus appropriate insets).
* the height of the combo minus appropriate insets.
*
* @since 1.7
*/
pr
ivate
boolean
squareButton
=
true
;
pr
otected
boolean
squareButton
=
true
;
/**
* Optional: if specified, these insets act as padding around the cell
* renderer when laying out and painting the "selected" item in the
* combo box. BasicComboBoxUI uses a single combo box renderer for rendering
* both the main combo box item and also all the items in the dropdown
* for the combo box. padding allows you to specify addition insets in
* addition to those specified by the cell renderer.
* If specified, these insets act as padding around the cell renderer when
* laying out and painting the "selected" item in the combo box. These
* insets add to those specified by the cell renderer.
*
* @since 1.7
*/
pr
ivate
Insets
padding
;
pr
otected
Insets
padding
;
// Used for calculating the default size.
private
static
ListCellRenderer
getDefaultListCellRenderer
()
{
...
...
@@ -345,7 +345,7 @@ public class BasicComboBoxUI extends ComboBoxUI {
}
/**
* Create
and install the
listeners for the combo box and its model.
* Create
s and installs
listeners for the combo box and its model.
* This method is called when the UI is installed.
*/
protected
void
installListeners
()
{
...
...
@@ -379,8 +379,8 @@ public class BasicComboBoxUI extends ComboBoxUI {
}
/**
* Uninstalls the default colors, default font, default renderer,
and default
*
editor into the JComboB
ox.
* Uninstalls the default colors, default font, default renderer,
*
and default editor from the combo b
ox.
*/
protected
void
uninstallDefaults
()
{
LookAndFeel
.
installColorsAndFont
(
comboBox
,
...
...
@@ -391,7 +391,7 @@ public class BasicComboBoxUI extends ComboBoxUI {
}
/**
* Remove the installed listeners from the combo box and its model.
* Remove
s
the installed listeners from the combo box and its model.
* The number and types of listeners removed and in this method should be
* the same that was added in <code>installListeners</code>
*/
...
...
@@ -839,7 +839,7 @@ public class BasicComboBoxUI extends ComboBoxUI {
}
/**
* Creates a
n
button which will be used as the control to show or hide
* Creates a button which will be used as the control to show or hide
* the popup portion of the combo box.
*
* @return a button which represents the popup control
...
...
@@ -1392,12 +1392,17 @@ public class BasicComboBoxUI extends ComboBoxUI {
}
/**
* This has been refactored out in hopes that it may be investigated and
* simplified for the next major release. adding/removing
* the component to the currentValuePane and changing the font may be
* redundant operations.
* Returns the size a component would have if used as a cell renderer.
*
* @param comp a {@code Component} to check
* @return size of the component
* @since 1.7
*/
private
Dimension
getSizeForComponent
(
Component
comp
)
{
protected
Dimension
getSizeForComponent
(
Component
comp
)
{
// This has been refactored out in hopes that it may be investigated and
// simplified for the next major release. adding/removing
// the component to the currentValuePane and changing the font may be
// redundant operations.
currentValuePane
.
add
(
comp
);
comp
.
setFont
(
comboBox
.
getFont
());
Dimension
d
=
comp
.
getPreferredSize
();
...
...
src/share/classes/javax/swing/plaf/basic/BasicLabelUI.java
浏览文件 @
e6cfccf9
...
...
@@ -141,11 +141,10 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
}
/**
* Paint the label text in the foreground color, if the label
* is opaque then paint the entire background with the background
* color. The Label text is drawn by paintEnabledText() or
* paintDisabledText(). The locations of the label parts are computed
* by layoutCL.
* Paints the label text with the foreground color, if the label is opaque
* then paints the entire background with the background color. The Label
* text is drawn by {@link #paintEnabledText} or {@link #paintDisabledText}.
* The locations of the label parts are computed by {@link #layoutCL}.
*
* @see #paintEnabledText
* @see #paintDisabledText
...
...
src/share/classes/javax/swing/plaf/basic/BasicListUI.java
浏览文件 @
e6cfccf9
...
...
@@ -685,7 +685,7 @@ public class BasicListUI extends ListUI
/**
* Create
and install
the listeners for the JList, its model, and its
* Create
s and installs
the listeners for the JList, its model, and its
* selectionModel. This method is called at installUI() time.
*
* @see #installUI
...
...
@@ -728,7 +728,7 @@ public class BasicListUI extends ListUI
/**
* Remove
the listeners for
the JList, its model, and its
* Remove
s the listeners from
the JList, its model, and its
* selectionModel. All of the listener fields, are reset to
* null here. This method is called at uninstallUI() time,
* it should be kept in sync with installListeners.
...
...
@@ -764,8 +764,8 @@ public class BasicListUI extends ListUI
/**
* Initialize
JList properties, e.g.
font, foreground, and background,
* and add
the CellRendererPane.
The font, foreground, and background
* Initialize
s list properties such as
font, foreground, and background,
* and add
s the CellRendererPane.
The font, foreground, and background
* properties are only set if their current value is either null
* or a UIResource, other properties are set if the current
* value is null.
...
...
@@ -820,9 +820,9 @@ public class BasicListUI extends ListUI
/**
* Set
the JList properties that haven'
t been explicitly overridden to
*
null.
A property is considered overridden if its current value
* is not a
UIResource
.
* Set
s the list properties that have no
t been explicitly overridden to
*
{@code null}.
A property is considered overridden if its current value
* is not a
{@code UIResource}
.
*
* @see #installDefaults
* @see #uninstallUI
...
...
src/share/classes/javax/swing/plaf/basic/BasicMenuItemUI.java
浏览文件 @
e6cfccf9
...
...
@@ -32,7 +32,6 @@ import java.beans.PropertyChangeListener;
import
javax.swing.*
;
import
javax.swing.event.*
;
import
javax.swing.border.*
;
import
javax.swing.plaf.*
;
import
javax.swing.text.View
;
...
...
@@ -54,7 +53,12 @@ public class BasicMenuItemUI extends MenuItemUI
protected
Color
disabledForeground
;
protected
Color
acceleratorForeground
;
protected
Color
acceleratorSelectionForeground
;
private
String
acceleratorDelimiter
;
/**
* Accelerator delimiter string, such as {@code '+'} in {@code 'Ctrl+C'}.
* @since 1.7
*/
protected
String
acceleratorDelimiter
;
protected
int
defaultTextIconGap
;
protected
Font
acceleratorFont
;
...
...
src/share/classes/javax/swing/plaf/basic/BasicScrollBarUI.java
浏览文件 @
e6cfccf9
...
...
@@ -93,10 +93,13 @@ public class BasicScrollBarUI
* scrollbar. */
private
boolean
supportsAbsolutePositioning
;
/** Hint as to what width (when vertical) or height (when horizontal)
/**
* Hint as to what width (when vertical) or height (when horizontal)
* should be.
*
* @since 1.7
*/
pr
ivate
int
scrollBarWidth
;
pr
otected
int
scrollBarWidth
;
private
Handler
handler
;
...
...
@@ -117,18 +120,18 @@ public class BasicScrollBarUI
* number. If negative, then an overlap between the button and track will occur,
* which is useful for shaped buttons.
*
*
TODO This should be made protected in a feature release
*
@since 1.7
*/
pr
ivate
int
incrGap
;
pr
otected
int
incrGap
;
/**
* Distance between the decrement button and the track. This may be a negative
* number. If negative, then an overlap between the button and track will occur,
* which is useful for shaped buttons.
*
*
TODO This should be made protected in a feature release
*
@since 1.7
*/
pr
ivate
int
decrGap
;
pr
otected
int
decrGap
;
static
void
loadActionMap
(
LazyActionMap
map
)
{
map
.
put
(
new
Actions
(
Actions
.
POSITIVE_UNIT_INCREMENT
));
...
...
@@ -586,7 +589,7 @@ public class BasicScrollBarUI
/**
* Return the smallest acceptable size for the thumb. If the scrollbar
* Return
s
the smallest acceptable size for the thumb. If the scrollbar
* becomes so small that this size isn't available, the thumb will be
* hidden.
* <p>
...
...
@@ -601,7 +604,7 @@ public class BasicScrollBarUI
}
/**
* Return the largest acceptable size for the thumb. To create a fixed
* Return
s
the largest acceptable size for the thumb. To create a fixed
* size thumb one make this method and <code>getMinimumThumbSize</code>
* return the same value.
* <p>
...
...
src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
浏览文件 @
e6cfccf9
...
...
@@ -1409,9 +1409,10 @@ public class BasicSliderUI extends SliderUI{
}
/**
* Returns a value give a y position. If yPos is past the track at the top or the
* bottom it will set the value to the min or max of the slider, depending if the
* slider is inverted or not.
* Returns the value at the y position. If {@code yPos} is beyond the
* track at the the bottom or the top, this method sets the value to either
* the minimum or maximum value of the slider, depending on if the slider
* is inverted or not.
*/
public
int
valueForYPosition
(
int
yPos
)
{
int
value
;
...
...
@@ -1440,9 +1441,10 @@ public class BasicSliderUI extends SliderUI{
}
/**
* Returns a value give an x position. If xPos is past the track at the left or the
* right it will set the value to the min or max of the slider, depending if the
* slider is inverted or not.
* Returns the value at the x position. If {@code xPos} is beyond the
* track at the left or the right, this method sets the value to either the
* minimum or maximum value of the slider, depending on if the slider is
* inverted or not.
*/
public
int
valueForXPosition
(
int
xPos
)
{
int
value
;
...
...
src/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java
浏览文件 @
e6cfccf9
...
...
@@ -268,7 +268,7 @@ public class BasicSpinnerUI extends SpinnerUI
}
/**
* Create a <code>LayoutManager</code> that manages the <code>editor</code>,
* Create
s
a <code>LayoutManager</code> that manages the <code>editor</code>,
* <code>nextButton</code>, and <code>previousButton</code>
* children of the JSpinner. These three children must be
* added with a constraint that identifies their role:
...
...
@@ -286,7 +286,7 @@ public class BasicSpinnerUI extends SpinnerUI
/**
* Create a <code>PropertyChangeListener</code> that can be
* Create
s
a <code>PropertyChangeListener</code> that can be
* added to the JSpinner itself. Typically, this listener
* will call replaceEditor when the "editor" property changes,
* since it's the <code>SpinnerUI's</code> responsibility to
...
...
@@ -302,16 +302,13 @@ public class BasicSpinnerUI extends SpinnerUI
/**
* Create a component that will replace the spinner models value
* with the object returned by <code>spinner.getPreviousValue</code>.
* By default the <code>previousButton</code> is a JButton. This
* method invokes <code>installPreviousButtonListeners</code> to
* install the necessary listeners to update the <code>JSpinner</code>'s
* model in response to a user gesture. If a previousButton isn't needed
* (in a subclass) then override this method to return null.
* Creates a decrement button, i.e. component that replaces the spinner
* value with the object returned by <code>spinner.getPreviousValue</code>.
* By default the <code>previousButton</code> is a {@code JButton}. If the
* decrement button is not needed this method should return {@code null}.
*
* @return a component that will replace the spinner
s model
with the
*
next value in the sequence, or null
* @return a component that will replace the spinner
's value
with the
*
previous value in the sequence, or {@code null}
* @see #installUI
* @see #createNextButton
* @see #installPreviousButtonListeners
...
...
@@ -325,15 +322,13 @@ public class BasicSpinnerUI extends SpinnerUI
/**
* Create a component that will replace the spinner models value
* with the object returned by <code>spinner.getNextValue</code>.
* By default the <code>nextButton</code> is a JButton
* who's <code>ActionListener</code> updates it's <code>JSpinner</code>
* ancestors model. If a nextButton isn't needed (in a subclass)
* then override this method to return null.
* Creates an increment button, i.e. component that replaces the spinner
* value with the object returned by <code>spinner.getNextValue</code>.
* By default the <code>nextButton</code> is a {@code JButton}. If the
* increment button is not needed this method should return {@code null}.
*
* @return a component that will replace the spinner
s model
with the
* next value in the sequence, or
null
* @return a component that will replace the spinner
's value
with the
* next value in the sequence, or
{@code null}
* @see #installUI
* @see #createPreviousButton
* @see #installNextButtonListeners
...
...
src/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java
浏览文件 @
e6cfccf9
...
...
@@ -829,7 +829,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
* Returns the default non continuous layout divider, which is an
* instance
of Canvas that fills the background in
dark gray.
* instance
of {@code Canvas} that fills in the background with
dark gray.
*/
protected
Component
createDefaultNonContinuousLayoutDivider
()
{
return
new
Canvas
()
{
...
...
@@ -1041,11 +1041,11 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
*
Messaged after the JSplitPane the receiver is providing the look
*
and feel for paints
its children.
*
Called when the specified split pane has finished painting
* its children.
*/
public
void
finishedPaintingChildren
(
JSplitPane
jc
,
Graphics
g
)
{
if
(
jc
==
splitPane
&&
getLastDragLocation
()
!=
-
1
&&
public
void
finishedPaintingChildren
(
JSplitPane
sp
,
Graphics
g
)
{
if
(
sp
==
splitPane
&&
getLastDragLocation
()
!=
-
1
&&
!
isContinuousLayout
()
&&
!
draggingHW
)
{
Dimension
size
=
splitPane
.
getSize
();
...
...
@@ -1062,7 +1062,7 @@ public class BasicSplitPaneUI extends SplitPaneUI
/**
*
Messaged to paint the look and feel.
*
@inheritDoc
*/
public
void
paint
(
Graphics
g
,
JComponent
jc
)
{
if
(!
painted
&&
splitPane
.
getDividerLocation
()<
0
)
{
...
...
src/share/classes/javax/swing/plaf/basic/BasicTableHeaderUI.java
浏览文件 @
e6cfccf9
...
...
@@ -306,7 +306,7 @@ public class BasicTableHeaderUI extends TableHeaderUI {
}
/**
* Initialize
JTableHeader properties, e.g.
font, foreground, and background.
* Initialize
s JTableHeader properties such as
font, foreground, and background.
* The font, foreground, and background properties are only set if their
* current value is either null or a UIResource, other properties are set
* if the current value is null.
...
...
@@ -403,9 +403,9 @@ public class BasicTableHeaderUI extends TableHeaderUI {
}
/**
* This method gets called every time
the
rollover column in the table
* header is updated. Every look and feel
supporting
rollover effect
* in table header should override this method and repaint the header.
* This method gets called every time
when a
rollover column in the table
* header is updated. Every look and feel
that supports a
rollover effect
* in
a
table header should override this method and repaint the header.
*
* @param oldColumn the index of the previous rollover column or -1 if the
* mouse was not over a column
...
...
@@ -736,7 +736,6 @@ public class BasicTableHeaderUI extends TableHeaderUI {
}
private
Dimension
createHeaderSize
(
long
width
)
{
TableColumnModel
columnModel
=
header
.
getColumnModel
();
// None of the callers include the intercell spacing, do it here.
if
(
width
>
Integer
.
MAX_VALUE
)
{
width
=
Integer
.
MAX_VALUE
;
...
...
src/share/classes/javax/swing/plaf/basic/BasicTextUI.java
浏览文件 @
e6cfccf9
...
...
@@ -37,6 +37,7 @@ import javax.swing.text.*;
import
javax.swing.event.*
;
import
javax.swing.border.Border
;
import
javax.swing.plaf.UIResource
;
import
javax.swing.plaf.synth.SynthUI
;
import
sun.swing.DefaultLookup
;
import
sun.awt.AppContext
;
import
javax.swing.plaf.basic.DragRecognitionSupport.BeforeDrag
;
...
...
@@ -221,8 +222,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
// is ==, which is the case for the windows look and feel.
// Until an appropriate solution is found, the code is being
// reverted to what it was before the original fix.
if
(
this
instanceof
sun
.
swing
.
plaf
.
synth
.
SynthUI
||
(
c
instanceof
JTextArea
))
{
if
(
this
instanceof
SynthUI
||
(
c
instanceof
JTextArea
))
{
return
;
}
Color
background
=
c
.
getBackground
();
...
...
@@ -289,7 +289,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
protected
abstract
String
getPropertyPrefix
();
/**
* Initializes component properties,
e.g.
font, foreground,
* Initializes component properties,
such as
font, foreground,
* background, caret color, selection color, selected text color,
* disabled text color, and border color. The font, foreground, and
* background properties are only set if their current value is either null
...
...
@@ -377,9 +377,9 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
}
/**
* Sets the component properties that have
n't been explicitly overridden to
*
null. A property is considered overridden if its current value
*
is not a UIResource
.
* Sets the component properties that have
not been explicitly overridden
*
to {@code null}. A property is considered overridden if its current
*
value is not a {@code UIResource}
.
*
* @see #installDefaults
* @see #uninstallUI
...
...
@@ -756,18 +756,18 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
* things.
* <ol>
* <li>
* Set the associated component to opaque (can be changed
* Set
s
the associated component to opaque (can be changed
* easily by a subclass or on JTextComponent directly),
* which is the most common case. This will cause the
* component's background color to be painted.
* <li>
* Install the default caret and highlighter into the
* Install
s
the default caret and highlighter into the
* associated component.
* <li>
* Attach to the editor and model. If there is no
* Attach
es
to the editor and model. If there is no
* model, a default one is created.
* <li>
*
create
the view factory and the view hierarchy used
*
Creates
the view factory and the view hierarchy used
* to represent the model.
* </ol>
*
...
...
@@ -784,7 +784,7 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
// This is a workaround as these should not override what synth has
// set them to
if
(!
(
this
instanceof
sun
.
swing
.
plaf
.
synth
.
SynthUI
))
{
if
(!
(
this
instanceof
SynthUI
))
{
// common case is background painted... this can
// easily be changed by subclasses or from outside
// of the component.
...
...
@@ -857,9 +857,9 @@ public abstract class BasicTextUI extends TextUI implements ViewFactory {
* To prevent this from happening twice, this method is
* reimplemented to simply paint.
* <p>
* <em>NOTE:</em>
Superclass is also not thread-safe in
*
it's rendering of the background, although that's not
*
an issue with the
default rendering.
* <em>NOTE:</em>
NOTE: Superclass is also not thread-safe in its
*
rendering of the background, although that is not an issue with the
* default rendering.
*/
public
void
update
(
Graphics
g
,
JComponent
c
)
{
paint
(
g
,
c
);
...
...
src/share/classes/javax/swing/plaf/basic/BasicToolBarUI.java
浏览文件 @
e6cfccf9
...
...
@@ -669,7 +669,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
/**
* Sets the border of the component to have a rollover border which
* was created by
<code>createRolloverBorder</code>
.
* was created by
the {@link #createRolloverBorder} method
.
*
* @param c component which will have a rollover border installed
* @see #createRolloverBorder
...
...
@@ -709,7 +709,7 @@ public class BasicToolBarUI extends ToolBarUI implements SwingConstants
/**
* Sets the border of the component to have a non-rollover border which
* was created by
<code>createNonRolloverBorder</code>
.
* was created by
the {@link #createNonRolloverBorder} method
.
*
* @param c component which will have a non-rollover border installed
* @see #createNonRolloverBorder
...
...
src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java
浏览文件 @
e6cfccf9
...
...
@@ -30,16 +30,12 @@ import javax.swing.event.*;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.awt.datatransfer.*
;
import
java.awt.dnd.*
;
import
java.beans.*
;
import
java.io.*
;
import
java.util.Enumeration
;
import
java.util.Hashtable
;
import
java.util.TooManyListenersException
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
javax.swing.plaf.ActionMapUIResource
;
import
javax.swing.plaf.ComponentUI
;
import
javax.swing.plaf.UIResource
;
import
javax.swing.plaf.TreeUI
;
...
...
@@ -1244,11 +1240,26 @@ public class BasicTreeUI extends TreeUI
drawingCache
.
clear
();
}
private
boolean
isDropLine
(
JTree
.
DropLocation
loc
)
{
/**
* Tells if a {@code DropLocation} should be indicated by a line between
* nodes. This is meant for {@code javax.swing.DropMode.INSERT} and
* {@code javax.swing.DropMode.ON_OR_INSERT} drop modes.
*
* @param loc a {@code DropLocation}
* @return {@code true} if the drop location should be shown as a line
* @since 1.7
*/
protected
boolean
isDropLine
(
JTree
.
DropLocation
loc
)
{
return
loc
!=
null
&&
loc
.
getPath
()
!=
null
&&
loc
.
getChildIndex
()
!=
-
1
;
}
private
void
paintDropLine
(
Graphics
g
)
{
/**
* Paints the drop line.
*
* @param g {@code Graphics} object to draw on
* @since 1.7
*/
protected
void
paintDropLine
(
Graphics
g
)
{
JTree
.
DropLocation
loc
=
tree
.
getDropLocation
();
if
(!
isDropLine
(
loc
))
{
return
;
...
...
@@ -1262,7 +1273,14 @@ public class BasicTreeUI extends TreeUI
}
}
private
Rectangle
getDropLineRect
(
JTree
.
DropLocation
loc
)
{
/**
* Returns a ubounding box for the drop line.
*
* @param loc a {@code DropLocation}
* @return bounding box for the drop line
* @since 1.7
*/
protected
Rectangle
getDropLineRect
(
JTree
.
DropLocation
loc
)
{
Rectangle
rect
;
TreePath
path
=
loc
.
getPath
();
int
index
=
loc
.
getChildIndex
();
...
...
@@ -1684,7 +1702,7 @@ public class BasicTreeUI extends TreeUI
treeState
.
setExpandedState
(
path
,
true
);
}
}
updateLeadRow
();
updateLead
Selection
Row
();
updateSize
();
}
}
...
...
@@ -2425,11 +2443,21 @@ public class BasicTreeUI extends TreeUI
return
tree
.
getLeadSelectionPath
();
}
private
void
updateLeadRow
()
{
/**
* Updates the lead row of the selection.
* @since 1.7
*/
protected
void
updateLeadSelectionRow
()
{
leadRow
=
getRowForPath
(
tree
,
getLeadSelectionPath
());
}
private
int
getLeadSelectionRow
()
{
/**
* Returns the lead row of the selection.
*
* @return selection lead row
* @since 1.7
*/
protected
int
getLeadSelectionRow
()
{
return
leadRow
;
}
...
...
@@ -3345,7 +3373,7 @@ public class BasicTreeUI extends TreeUI
if
(
changeName
==
JTree
.
LEAD_SELECTION_PATH_PROPERTY
)
{
if
(!
ignoreLAChange
)
{
updateLeadRow
();
updateLead
Selection
Row
();
repaintPath
((
TreePath
)
event
.
getOldValue
());
repaintPath
((
TreePath
)
event
.
getNewValue
());
}
...
...
@@ -3763,7 +3791,7 @@ public class BasicTreeUI extends TreeUI
completeEditing
();
if
(
path
!=
null
&&
tree
.
isVisible
(
path
))
{
treeState
.
setExpandedState
(
path
,
false
);
updateLeadRow
();
updateLead
Selection
Row
();
updateSize
();
}
}
...
...
@@ -3823,7 +3851,7 @@ public class BasicTreeUI extends TreeUI
if
(
treeState
!=
null
&&
e
!=
null
)
{
treeState
.
treeNodesInserted
(
e
);
updateLeadRow
();
updateLead
Selection
Row
();
TreePath
path
=
e
.
getTreePath
();
...
...
@@ -3848,7 +3876,7 @@ public class BasicTreeUI extends TreeUI
if
(
treeState
!=
null
&&
e
!=
null
)
{
treeState
.
treeNodesRemoved
(
e
);
updateLeadRow
();
updateLead
Selection
Row
();
TreePath
path
=
e
.
getTreePath
();
...
...
@@ -3862,7 +3890,7 @@ public class BasicTreeUI extends TreeUI
if
(
treeState
!=
null
&&
e
!=
null
)
{
treeState
.
treeStructureChanged
(
e
);
updateLeadRow
();
updateLead
Selection
Row
();
TreePath
pPath
=
e
.
getTreePath
();
...
...
src/share/classes/javax/swing/plaf/basic/DefaultMenuLayout.java
浏览文件 @
e6cfccf9
...
...
@@ -34,7 +34,7 @@ import java.awt.Dimension;
/**
* The default layout manager for Popup menus and menubars. This
* class is an extension of BoxLayout which adds the UIResource tag
* so that pl
a
uggable L&Fs can distinguish it from user-installed
* so that pluggable L&Fs can distinguish it from user-installed
* layout managers on menus.
*
* @author Georges Saab
...
...
src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java
浏览文件 @
e6cfccf9
...
...
@@ -257,12 +257,40 @@ public class NimbusLookAndFeel extends SynthLookAndFeel {
/**
* @inheritDoc
* @return
true
* @return
{@code true}
*/
@Override
public
boolean
shouldUpdateStyleOnAncestorChanged
()
{
return
true
;
}
/**
* @inheritDoc
*
* <p>Overridden to return {@code true} when one of the following
* properties change:
* <ul>
* <li>{@code "Nimbus.Overrides"}
* <li>{@code "Nimbus.Overrides.InheritDefaults"}
* <li>{@code "JComponent.sizeVariant"}
* </ul>
*
* @since 1.7
*/
@Override
protected
boolean
shouldUpdateStyleOnEvent
(
PropertyChangeEvent
ev
)
{
String
eName
=
ev
.
getPropertyName
();
// Always update when overrides or size variant change
if
(
"Nimbus.Overrides"
==
eName
||
"Nimbus.Overrides.InheritDefaults"
==
eName
||
"JComponent.sizeVariant"
==
eName
)
{
return
true
;
}
return
super
.
shouldUpdateStyleOnEvent
(
ev
);
}
/**
* <p>Registers a third party component with the NimbusLookAndFeel.</p>
*
...
...
src/share/classes/javax/swing/plaf/nimbus/package.html
浏览文件 @
e6cfccf9
...
...
@@ -88,12 +88,11 @@ encouraged.
<p><strong>
Note:
</strong>
Most of the Swing API is
<em>
not
</em>
thread safe.
For details, see
<a
href=
"http://java.sun.com/docs/books/tutorial/uiswing/overview/threads.html"
target=
"_top"
>
Threads and Swing
</a>
,
<a
href=
"http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html"
target=
"_top"
>
Concurrency in Swing
</a>
,
a section in
<em><a
href=
"http://java.sun.com/docs/books/tutorial/"
target=
"_top"
>
The Java Tutorial
</a></em>
.
target=
"_top"
>
The Java Tutorial
</a></em>
.
@since 1.7
@serial exclude
...
...
src/share/classes/javax/swing/plaf/synth/SynthBorder.java
浏览文件 @
e6cfccf9
...
...
@@ -29,7 +29,6 @@ import javax.swing.*;
import
javax.swing.text.JTextComponent
;
import
javax.swing.border.*
;
import
javax.swing.plaf.UIResource
;
import
sun.swing.plaf.synth.SynthUI
;
/**
* SynthBorder is a border that delegates to a Painter. The Insets
...
...
src/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
浏览文件 @
e6cfccf9
...
...
@@ -25,40 +25,49 @@
package
javax.swing.plaf.synth
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.io.Serializable
;
import
javax.swing.*
;
import
javax.swing.border.*
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.beans.*
;
import
javax.swing.plaf.*
;
import
javax.swing.plaf.basic.BasicButtonUI
;
import
javax.swing.plaf.basic.BasicHTML
;
import
javax.swing.text.View
;
import
sun.swing.plaf.synth.SynthUI
;
import
sun.swing.plaf.synth.DefaultSynthStyle
;
/**
* Synth's ButtonUI implementation.
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JButton}.
*
* @author Scott Violet
* @since 1.7
*/
class
SynthButtonUI
extends
BasicButtonUI
implements
public
class
SynthButtonUI
extends
BasicButtonUI
implements
PropertyChangeListener
,
SynthUI
{
private
SynthStyle
style
;
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public
static
ComponentUI
createUI
(
JComponent
c
)
{
return
new
SynthButtonUI
();
}
/**
* @inheritDoc
*/
@Override
protected
void
installDefaults
(
AbstractButton
b
)
{
updateStyle
(
b
);
LookAndFeel
.
installProperty
(
b
,
"rolloverEnabled"
,
Boolean
.
TRUE
);
}
/**
* @inheritDoc
*/
@Override
protected
void
installListeners
(
AbstractButton
b
)
{
super
.
installListeners
(
b
);
b
.
addPropertyChangeListener
(
this
);
...
...
@@ -99,11 +108,19 @@ class SynthButtonUI extends BasicButtonUI implements
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallListeners
(
AbstractButton
b
)
{
super
.
uninstallListeners
(
b
);
b
.
removePropertyChangeListener
(
this
);
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDefaults
(
AbstractButton
b
)
{
SynthContext
context
=
getContext
(
b
,
ENABLED
);
...
...
@@ -112,20 +129,20 @@ class SynthButtonUI extends BasicButtonUI implements
style
=
null
;
}
/**
* @inheritDoc
*/
@Override
public
SynthContext
getContext
(
JComponent
c
)
{
return
getContext
(
c
,
getComponentState
(
c
));
}
SynthContext
getContext
(
JComponent
c
,
int
state
)
{
Region
region
=
getRegion
(
c
);
Region
region
=
SynthLookAndFeel
.
getRegion
(
c
);
return
SynthContext
.
getContext
(
SynthContext
.
class
,
c
,
region
,
style
,
state
);
}
private
Region
getRegion
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getRegion
(
c
);
}
/**
* Returns the current state of the passed in <code>AbstractButton</code>.
*/
...
...
@@ -164,6 +181,10 @@ class SynthButtonUI extends BasicButtonUI implements
return
state
;
}
/**
* @inheritDoc
*/
@Override
public
int
getBaseline
(
JComponent
c
,
int
width
,
int
height
)
{
if
(
c
==
null
)
{
throw
new
NullPointerException
(
"Component must be non-null"
);
...
...
@@ -215,6 +236,10 @@ class SynthButtonUI extends BasicButtonUI implements
// Paint Methods
// ********************************
/**
* @inheritDoc
*/
@Override
public
void
update
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -224,6 +249,10 @@ class SynthButtonUI extends BasicButtonUI implements
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
public
void
paint
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -231,6 +260,12 @@ class SynthButtonUI extends BasicButtonUI implements
context
.
dispose
();
}
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected
void
paint
(
SynthContext
context
,
Graphics
g
)
{
AbstractButton
b
=
(
AbstractButton
)
context
.
getComponent
();
...
...
@@ -253,19 +288,22 @@ class SynthButtonUI extends BasicButtonUI implements
}
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintButtonBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
}
/**
* Returns the default icon. This should
NOT
callback
* Returns the default icon. This should
not
callback
* to the JComponent.
*
* @param b
AbstractB
utton the icon is associated with
* @param b
b
utton the icon is associated with
* @return default icon
*/
protected
Icon
getDefaultIcon
(
AbstractButton
b
)
{
SynthContext
context
=
getContext
(
b
);
Icon
icon
=
context
.
getStyle
().
getIcon
(
context
,
getPropertyPrefix
()
+
"icon"
);
...
...
@@ -274,7 +312,11 @@ class SynthButtonUI extends BasicButtonUI implements
}
/**
* Returns the Icon to use in painting the button.
* Returns the Icon to use for painting the button. The icon is chosen with
* respect to the current state of the button.
*
* @param b button the icon is associated with
* @return an icon
*/
protected
Icon
getIcon
(
AbstractButton
b
)
{
Icon
icon
=
b
.
getIcon
();
...
...
@@ -374,7 +416,7 @@ class SynthButtonUI extends BasicButtonUI implements
/**
* Returns the amount to shift the text/icon when painting.
*/
pr
otected
int
getTextShiftOffset
(
SynthContext
state
)
{
pr
ivate
int
getTextShiftOffset
(
SynthContext
state
)
{
AbstractButton
button
=
(
AbstractButton
)
state
.
getComponent
();
ButtonModel
model
=
button
.
getModel
();
...
...
@@ -389,6 +431,11 @@ class SynthButtonUI extends BasicButtonUI implements
// ********************************
// Layout Methods
// ********************************
/**
* @inheritDoc
*/
@Override
public
Dimension
getMinimumSize
(
JComponent
c
)
{
if
(
c
.
getComponentCount
()
>
0
&&
c
.
getLayout
()
!=
null
)
{
return
null
;
...
...
@@ -406,6 +453,10 @@ class SynthButtonUI extends BasicButtonUI implements
return
size
;
}
/**
* @inheritDoc
*/
@Override
public
Dimension
getPreferredSize
(
JComponent
c
)
{
if
(
c
.
getComponentCount
()
>
0
&&
c
.
getLayout
()
!=
null
)
{
return
null
;
...
...
@@ -423,6 +474,10 @@ class SynthButtonUI extends BasicButtonUI implements
return
size
;
}
/**
* @inheritDoc
*/
@Override
public
Dimension
getMaximumSize
(
JComponent
c
)
{
if
(
c
.
getComponentCount
()
>
0
&&
c
.
getLayout
()
!=
null
)
{
return
null
;
...
...
@@ -442,7 +497,8 @@ class SynthButtonUI extends BasicButtonUI implements
}
/**
* Returns the Icon used in calculating the pref/min/max size.
* Returns the Icon used in calculating the
* preferred/minimum/maximum size.
*/
protected
Icon
getSizingIcon
(
AbstractButton
b
)
{
Icon
icon
=
getEnabledIcon
(
b
,
b
.
getIcon
());
...
...
@@ -452,6 +508,10 @@ class SynthButtonUI extends BasicButtonUI implements
return
icon
;
}
/**
* @inheritDoc
*/
@Override
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
if
(
SynthLookAndFeel
.
shouldUpdateStyle
(
e
))
{
updateStyle
((
AbstractButton
)
e
.
getSource
());
...
...
src/share/classes/javax/swing/plaf/synth/SynthCheckBoxMenuItemUI.java
浏览文件 @
e6cfccf9
...
...
@@ -27,56 +27,50 @@ package javax.swing.plaf.synth;
import
java.awt.*
;
import
java.awt.event.*
;
import
javax.swing.*
;
import
javax.swing.plaf.*
;
import
javax.swing.border.*
;
import
java.io.Serializable
;
/**
* Synth's CheckBoxMenuItemUI.
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JCheckBoxMenuItem}.
*
* @author Leif Samuelsson
* @author Georges Saab
* @author David Karlton
* @author Arnaud Weber
* @since 1.7
*/
class
SynthCheckBoxMenuItemUI
extends
SynthMenuItemUI
{
public
class
SynthCheckBoxMenuItemUI
extends
SynthMenuItemUI
{
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public
static
ComponentUI
createUI
(
JComponent
c
)
{
return
new
SynthCheckBoxMenuItemUI
();
}
/**
* @inheritDoc
*/
@Override
protected
String
getPropertyPrefix
()
{
return
"CheckBoxMenuItem"
;
}
public
void
processMouseEvent
(
JMenuItem
item
,
MouseEvent
e
,
MenuElement
path
[],
MenuSelectionManager
manager
)
{
Point
p
=
e
.
getPoint
();
if
(
p
.
x
>=
0
&&
p
.
x
<
item
.
getWidth
()
&&
p
.
y
>=
0
&&
p
.
y
<
item
.
getHeight
())
{
if
(
e
.
getID
()
==
MouseEvent
.
MOUSE_RELEASED
)
{
manager
.
clearSelectedPath
();
item
.
doClick
(
0
);
}
else
{
manager
.
setSelectedPath
(
path
);
}
}
else
if
(
item
.
getModel
().
isArmed
())
{
int
c
=
path
.
length
-
1
;
MenuElement
newPath
[]
=
new
MenuElement
[
c
];
for
(
int
i
=
0
;
i
<
c
;
i
++)
{
newPath
[
i
]
=
path
[
i
];
}
manager
.
setSelectedPath
(
newPath
);
}
}
@Override
void
paintBackground
(
SynthContext
context
,
Graphics
g
,
JComponent
c
)
{
context
.
getPainter
().
paintCheckBoxMenuItemBackground
(
context
,
g
,
0
,
0
,
c
.
getWidth
(),
c
.
getHeight
());
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintCheckBoxMenuItemBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
...
...
src/share/classes/javax/swing/plaf/synth/SynthCheckBoxUI.java
浏览文件 @
e6cfccf9
...
...
@@ -25,36 +25,51 @@
package
javax.swing.plaf.synth
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.*
;
import
javax.swing.plaf.*
;
import
java.io.Serializable
;
import
javax.swing.JComponent
;
import
java.awt.Graphics
;
import
javax.swing.plaf.ComponentUI
;
/**
* Synth's CheckBoxUI.
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JCheckBox}.
*
* @author Jeff Dinkins
* @since 1.7
*/
class
SynthCheckBoxUI
extends
SynthRadioButtonUI
{
public
class
SynthCheckBoxUI
extends
SynthRadioButtonUI
{
// ********************************
// Create PLAF
// ********************************
/**
* Creates a new UI object for the given component.
*
* @param b component to create UI object for
* @return the UI object
*/
public
static
ComponentUI
createUI
(
JComponent
b
)
{
return
new
SynthCheckBoxUI
();
}
/**
* @inheritDoc
*/
@Override
protected
String
getPropertyPrefix
()
{
return
"CheckBox."
;
}
@Override
void
paintBackground
(
SynthContext
context
,
Graphics
g
,
JComponent
c
)
{
context
.
getPainter
().
paintCheckBoxBackground
(
context
,
g
,
0
,
0
,
c
.
getWidth
(),
c
.
getHeight
());
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintCheckBoxBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
...
...
src/share/classes/javax/swing/plaf/synth/SynthColorChooserUI.java
浏览文件 @
e6cfccf9
...
...
@@ -28,34 +28,39 @@ package javax.swing.plaf.synth;
import
javax.swing.*
;
import
javax.swing.colorchooser.*
;
import
javax.swing.event.*
;
import
javax.swing.border.*
;
import
javax.swing.plaf.*
;
import
javax.swing.plaf.basic.BasicColorChooserUI
;
import
java.util.*
;
import
java.awt.*
;
import
java.awt.image.*
;
import
java.awt.event.*
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.io.Serializable
;
import
sun.swing.plaf.synth.SynthUI
;
/**
* Synth's ColorChooserUI.
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JColorChooser}.
*
* @author Tom Santos
* @author Steve Wilson
* @since 1.7
*/
class
SynthColorChooserUI
extends
BasicColorChooserUI
implements
public
class
SynthColorChooserUI
extends
BasicColorChooserUI
implements
PropertyChangeListener
,
SynthUI
{
private
SynthStyle
style
;
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public
static
ComponentUI
createUI
(
JComponent
c
)
{
return
new
SynthColorChooserUI
();
}
/**
* @inheritDoc
*/
@Override
protected
AbstractColorChooserPanel
[]
createDefaultChoosers
()
{
SynthContext
context
=
getContext
(
chooser
,
ENABLED
);
AbstractColorChooserPanel
[]
panels
=
(
AbstractColorChooserPanel
[])
...
...
@@ -68,6 +73,10 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
return
panels
;
}
/**
* @inheritDoc
*/
@Override
protected
void
installDefaults
()
{
super
.
installDefaults
();
updateStyle
(
chooser
);
...
...
@@ -79,6 +88,10 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDefaults
()
{
SynthContext
context
=
getContext
(
chooser
,
ENABLED
);
...
...
@@ -88,16 +101,28 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
super
.
uninstallDefaults
();
}
/**
* @inheritDoc
*/
@Override
protected
void
installListeners
()
{
super
.
installListeners
();
chooser
.
addPropertyChangeListener
(
this
);
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallListeners
()
{
chooser
.
removePropertyChangeListener
(
this
);
super
.
uninstallListeners
();
}
/**
* @inheritDoc
*/
@Override
public
SynthContext
getContext
(
JComponent
c
)
{
return
getContext
(
c
,
getComponentState
(
c
));
}
...
...
@@ -107,14 +132,14 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
SynthLookAndFeel
.
getRegion
(
c
),
style
,
state
);
}
private
Region
getRegion
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getRegion
(
c
);
}
private
int
getComponentState
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getComponentState
(
c
);
}
/**
* @inheritDoc
*/
@Override
public
void
update
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -125,6 +150,10 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
public
void
paint
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -132,14 +161,29 @@ class SynthColorChooserUI extends BasicColorChooserUI implements
context
.
dispose
();
}
/**
* Paints the specified component.
* This implementation does not perform any actions.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected
void
paint
(
SynthContext
context
,
Graphics
g
)
{
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintColorChooserBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
}
/**
* @inheritDoc
*/
@Override
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
if
(
SynthLookAndFeel
.
shouldUpdateStyle
(
e
))
{
updateStyle
((
JColorChooser
)
e
.
getSource
());
...
...
src/share/classes/javax/swing/plaf/synth/SynthComboBoxUI.java
浏览文件 @
e6cfccf9
...
...
@@ -27,21 +27,21 @@ package javax.swing.plaf.synth;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.lang.reflect.*
;
import
javax.swing.*
;
import
javax.swing.plaf.*
;
import
javax.swing.event.*
;
import
javax.swing.plaf.basic.*
;
import
java.beans.PropertyChangeListener
;
import
java.beans.PropertyChangeEvent
;
import
sun.swing.plaf.synth.SynthUI
;
/**
* Synth's ComboBoxUI.
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JComboBox}.
*
* @author Scott Violet
* @since 1.7
*/
class
SynthComboBoxUI
extends
BasicComboBoxUI
implements
public
class
SynthComboBoxUI
extends
BasicComboBoxUI
implements
PropertyChangeListener
,
SynthUI
{
private
SynthStyle
style
;
private
boolean
useListColors
;
...
...
@@ -93,12 +93,11 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
private
boolean
forceOpaque
=
false
;
/**
* NOTE: This serves the same purpose as the same field in BasicComboBoxUI.
* It is here because I could not give the padding field in
* BasicComboBoxUI protected access in an update release.
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
private
Insets
padding
;
public
static
ComponentUI
createUI
(
JComponent
c
)
{
return
new
SynthComboBoxUI
();
}
...
...
@@ -118,21 +117,6 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
@Override
protected
void
installDefaults
()
{
//NOTE: This next line of code was added because, since squareButton in
//BasicComboBoxUI is private, I need to have some way of reading it from UIManager.
//This is an incomplete solution (since it implies that squareButons,
//once set, cannot be reset per state. Probably ok, but not always ok).
//This line of code should be removed at the same time that squareButton
//is made protected in the super class.
super
.
installDefaults
();
//This is here instead of in updateStyle because the value for padding
//needs to remain consistent with the value for padding in
//BasicComboBoxUI. I wouldn't have this value here at all if not
//for the fact that I cannot make "padding" protected in any way
//for an update release. This *should* be fixed in Java 7
padding
=
UIManager
.
getInsets
(
"ComboBox.padding"
);
updateStyle
(
comboBox
);
}
...
...
@@ -142,6 +126,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
style
=
SynthLookAndFeel
.
updateStyle
(
context
,
this
);
if
(
style
!=
oldStyle
)
{
padding
=
(
Insets
)
style
.
get
(
context
,
"ComboBox.padding"
);
popupInsets
=
(
Insets
)
style
.
get
(
context
,
"ComboBox.popupInsets"
);
useListColors
=
style
.
getBoolean
(
context
,
"ComboBox.rendererUseListColors"
,
true
);
...
...
@@ -149,6 +134,8 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
"ComboBox.buttonWhenNotEditable"
,
false
);
pressedWhenPopupVisible
=
style
.
getBoolean
(
context
,
"ComboBox.pressedWhenPopupVisible"
,
false
);
squareButton
=
style
.
getBoolean
(
context
,
"ComboBox.squareButton"
,
true
);
if
(
oldStyle
!=
null
)
{
uninstallKeyboardActions
();
...
...
@@ -164,6 +151,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
}
}
/**
* @inheritDoc
*/
@Override
protected
void
installListeners
()
{
comboBox
.
addPropertyChangeListener
(
this
);
...
...
@@ -172,6 +162,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
super
.
installListeners
();
}
/**
* @inheritDoc
*/
@Override
public
void
uninstallUI
(
JComponent
c
)
{
if
(
popup
instanceof
SynthComboPopup
)
{
...
...
@@ -181,6 +174,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
buttonHandler
=
null
;
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDefaults
()
{
SynthContext
context
=
getContext
(
comboBox
,
ENABLED
);
...
...
@@ -190,6 +186,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
style
=
null
;
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallListeners
()
{
editorFocusHandler
.
unregister
();
...
...
@@ -200,6 +199,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
super
.
uninstallListeners
();
}
/**
* @inheritDoc
*/
@Override
public
SynthContext
getContext
(
JComponent
c
)
{
return
getContext
(
c
,
getComponentState
(
c
));
...
...
@@ -210,10 +212,6 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
SynthLookAndFeel
.
getRegion
(
c
),
style
,
state
);
}
private
Region
getRegion
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getRegion
(
c
);
}
private
int
getComponentState
(
JComponent
c
)
{
// currently we have a broken situation where if a developer
// takes the border from a JComboBox and sets it on a JTextField
...
...
@@ -252,6 +250,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
}
}
/**
* @inheritDoc
*/
@Override
protected
ComboPopup
createPopup
()
{
SynthComboPopup
p
=
new
SynthComboPopup
(
comboBox
);
...
...
@@ -259,11 +260,17 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
return
p
;
}
/**
* @inheritDoc
*/
@Override
protected
ListCellRenderer
createRenderer
()
{
return
new
SynthComboBoxRenderer
();
}
/**
* @inheritDoc
*/
@Override
protected
ComboBoxEditor
createEditor
()
{
return
new
SynthComboBoxEditor
();
...
...
@@ -273,6 +280,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
// end UI Initialization
//======================
/**
* @inheritDoc
*/
@Override
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
if
(
SynthLookAndFeel
.
shouldUpdateStyle
(
e
))
{
...
...
@@ -280,6 +290,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
}
}
/**
* @inheritDoc
*/
@Override
protected
JButton
createArrowButton
()
{
SynthArrowButton
button
=
new
SynthArrowButton
(
SwingConstants
.
SOUTH
);
...
...
@@ -291,6 +304,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
//=================================
// begin ComponentUI Implementation
/**
* @inheritDoc
*/
@Override
public
void
update
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -302,6 +318,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
public
void
paint
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -310,6 +329,12 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
context
.
dispose
();
}
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected
void
paint
(
SynthContext
context
,
Graphics
g
)
{
hasFocus
=
comboBox
.
hasFocus
();
if
(
!
comboBox
.
isEditable
()
)
{
...
...
@@ -318,6 +343,9 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
}
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
...
...
@@ -375,7 +403,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
}
/**
* Return the default size of an empty display area of the combo box using
* Return
s
the default size of an empty display area of the combo box using
* the current renderer and font.
*
* This method was overridden to use SynthComboBoxRenderer instead of
...
...
@@ -393,23 +421,6 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
return
new
Dimension
(
d
.
width
,
d
.
height
);
}
/**
* This has been refactored out in hopes that it may be investigated and
* simplified for the next major release. adding/removing
* the component to the currentValuePane and changing the font may be
* redundant operations.
*
* NOTE: This method was copied in its entirety from BasicComboBoxUI. Might
* want to make it protected in BasicComboBoxUI in Java 7
*/
private
Dimension
getSizeForComponent
(
Component
comp
)
{
currentValuePane
.
add
(
comp
);
comp
.
setFont
(
comboBox
.
getFont
());
Dimension
d
=
comp
.
getPreferredSize
();
currentValuePane
.
remove
(
comp
);
return
d
;
}
/**
* From BasicComboBoxRenderer v 1.18.
*
...
...
@@ -478,85 +489,17 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
}
/**
* From BasicCombBoxEditor v 1.24.
*/
private
static
class
SynthComboBoxEditor
implements
ComboBoxEditor
,
UIResource
{
protected
JTextField
editor
;
private
Object
oldValue
;
public
SynthComboBoxEditor
()
{
editor
=
new
JTextField
(
""
,
9
);
editor
.
setName
(
"ComboBox.textField"
);
}
@Override
public
Component
getEditorComponent
()
{
return
editor
;
}
/**
* Sets the item that should be edited.
*
* @param anObject the displayed value of the editor
*/
@Override
public
void
setItem
(
Object
anObject
)
{
String
text
;
if
(
anObject
!=
null
)
{
text
=
anObject
.
toString
();
oldValue
=
anObject
;
}
else
{
text
=
""
;
}
// workaround for 4530952
if
(!
text
.
equals
(
editor
.
getText
()))
{
editor
.
setText
(
text
);
}
}
@Override
public
Object
getItem
()
{
Object
newValue
=
editor
.
getText
();
if
(
oldValue
!=
null
&&
!(
oldValue
instanceof
String
))
{
// The original value is not a string. Should return the value in it's
// original type.
if
(
newValue
.
equals
(
oldValue
.
toString
()))
{
return
oldValue
;
}
else
{
// Must take the value from the editor and get the value and cast it to the new type.
Class
<?>
cls
=
oldValue
.
getClass
();
try
{
Method
method
=
cls
.
getMethod
(
"valueOf"
,
new
Class
[]{
String
.
class
});
newValue
=
method
.
invoke
(
oldValue
,
new
Object
[]
{
editor
.
getText
()});
}
catch
(
Exception
ex
)
{
// Fail silently and return the newValue (a String object)
}
}
}
return
newValue
;
}
@Override
public
void
selectAll
()
{
editor
.
selectAll
();
editor
.
requestFocus
();
}
@Override
public
void
addActionListener
(
ActionListener
l
)
{
editor
.
addActionListener
(
l
);
}
private
static
class
SynthComboBoxEditor
extends
BasicComboBoxEditor
.
UIResource
{
@Override
public
void
removeActionListener
(
ActionListener
l
)
{
editor
.
removeActionListener
(
l
);
@Override
public
JTextField
createEditorComponent
()
{
JTextField
f
=
new
JTextField
(
""
,
9
);
f
.
setName
(
"ComboBox.textField"
);
return
f
;
}
}
/**
* Handles all the logic for treating the combo as a button when it is
* not editable, and when shouldActLikeButton() is true. This class is a
...
...
@@ -620,7 +563,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
//------------------------------------------------------------------
/**
*
{@inheritDoc}
*
@inheritDoc
*
* Ensures that isPressed() will return true if the combo is pressed,
* or the arrowButton is pressed, <em>or</em> if the combo popup is
...
...
@@ -634,7 +577,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
}
/**
*
{@inheritDoc}
*
@inheritDoc
*
* Ensures that the armed state is in sync with the pressed state
* if shouldActLikeButton is true. Without this method, the arrow
...
...
@@ -649,7 +592,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
}
/**
*
{@inheritDoc}
*
@inheritDoc
*
* Ensures that isRollover() will return true if the combo is
* rolled over, or the arrowButton is rolled over.
...
...
@@ -660,7 +603,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
}
/**
*
{@inheritDoc}
*
@inheritDoc
*
* Forwards pressed states to the internal "pressed" field
*/
...
...
@@ -671,7 +614,7 @@ class SynthComboBoxUI extends BasicComboBoxUI implements
}
/**
*
{@inheritDoc}
*
@inheritDoc
*
* Forwards rollover states to the internal "over" field
*/
...
...
src/share/classes/javax/swing/plaf/synth/SynthDefaultLookup.java
浏览文件 @
e6cfccf9
...
...
@@ -27,7 +27,6 @@ package javax.swing.plaf.synth;
import
sun.swing.DefaultLookup
;
import
javax.swing.JComponent
;
import
javax.swing.plaf.ComponentUI
;
import
sun.swing.plaf.synth.SynthUI
;
/**
* SynthDefaultLookup redirects all lookup calls to the SynthContext.
...
...
src/share/classes/javax/swing/plaf/synth/SynthDesktopIconUI.java
浏览文件 @
e6cfccf9
...
...
@@ -28,36 +28,44 @@ package javax.swing.plaf.synth;
import
java.awt.*
;
import
java.awt.event.*
;
import
javax.swing.*
;
import
javax.swing.event.*
;
import
javax.swing.border.*
;
import
javax.swing.plaf.*
;
import
javax.swing.plaf.basic.BasicDesktopIconUI
;
import
java.beans.*
;
import
java.io.Serializable
;
import
sun.swing.plaf.synth.SynthUI
;
/**
*
Synth L&F for a minimized window
on a desktop.
*
Provides the Synth L&F UI delegate for a minimized internal frame
on a desktop.
*
* @author Joshua Outwater
* @since 1.7
*/
class
SynthDesktopIconUI
extends
BasicDesktopIconUI
implements
SynthUI
,
ActionListener
,
PropertyChangeListener
{
public
class
SynthDesktopIconUI
extends
BasicDesktopIconUI
implements
SynthUI
,
PropertyChangeListener
{
private
SynthStyle
style
;
private
Handler
handler
=
new
Handler
();
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public
static
ComponentUI
createUI
(
JComponent
c
)
{
return
new
SynthDesktopIconUI
();
}
/**
* @inheritDoc
*/
@Override
protected
void
installComponents
()
{
if
(
UIManager
.
getBoolean
(
"InternalFrame.useTaskBar"
))
{
iconPane
=
new
JToggleButton
(
frame
.
getTitle
(),
frame
.
getFrameIcon
())
{
public
String
getToolTipText
()
{
@Override
public
String
getToolTipText
()
{
return
getText
();
}
public
JPopupMenu
getComponentPopupMenu
()
{
@Override
public
JPopupMenu
getComponentPopupMenu
()
{
return
frame
.
getComponentPopupMenu
();
}
};
...
...
@@ -73,24 +81,37 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
desktopIcon
.
add
(
iconPane
,
BorderLayout
.
CENTER
);
}
/**
* @inheritDoc
*/
@Override
protected
void
installListeners
()
{
super
.
installListeners
();
desktopIcon
.
addPropertyChangeListener
(
this
);
if
(
iconPane
instanceof
JToggleButton
)
{
frame
.
addPropertyChangeListener
(
this
);
((
JToggleButton
)
iconPane
).
addActionListener
(
this
);
((
JToggleButton
)
iconPane
).
addActionListener
(
handler
);
}
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallListeners
()
{
if
(
iconPane
instanceof
JToggleButton
)
{
((
JToggleButton
)
iconPane
).
removeActionListener
(
handler
);
frame
.
removePropertyChangeListener
(
this
);
}
desktopIcon
.
removePropertyChangeListener
(
this
);
super
.
uninstallListeners
();
}
/**
* @inheritDoc
*/
@Override
protected
void
installDefaults
()
{
updateStyle
(
desktopIcon
);
}
...
...
@@ -101,6 +122,10 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDefaults
()
{
SynthContext
context
=
getContext
(
desktopIcon
,
ENABLED
);
style
.
uninstallDefaults
(
context
);
...
...
@@ -108,12 +133,16 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
style
=
null
;
}
/**
* @inheritDoc
*/
@Override
public
SynthContext
getContext
(
JComponent
c
)
{
return
getContext
(
c
,
getComponentState
(
c
));
}
private
SynthContext
getContext
(
JComponent
c
,
int
state
)
{
Region
region
=
getRegion
(
c
);
Region
region
=
SynthLookAndFeel
.
getRegion
(
c
);
return
SynthContext
.
getContext
(
SynthContext
.
class
,
c
,
region
,
style
,
state
);
}
...
...
@@ -122,10 +151,10 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
return
SynthLookAndFeel
.
getComponentState
(
c
);
}
Region
getRegion
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getRegion
(
c
);
}
/**
* @inheritDoc
*/
@Override
public
void
update
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -136,6 +165,10 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
public
void
paint
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -143,33 +176,24 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
context
.
dispose
();
}
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected
void
paint
(
SynthContext
context
,
Graphics
g
)
{
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintDesktopIconBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
}
public
void
actionPerformed
(
ActionEvent
evt
)
{
if
(
evt
.
getSource
()
instanceof
JToggleButton
)
{
// Either iconify the frame or deiconify and activate it.
JToggleButton
button
=
(
JToggleButton
)
evt
.
getSource
();
try
{
boolean
selected
=
button
.
isSelected
();
if
(!
selected
&&
!
frame
.
isIconifiable
())
{
button
.
setSelected
(
true
);
}
else
{
frame
.
setIcon
(!
selected
);
if
(
selected
)
{
frame
.
setSelected
(
true
);
}
}
}
catch
(
PropertyVetoException
e2
)
{
}
}
}
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
if
(
evt
.
getSource
()
instanceof
JInternalFrame
.
JDesktopIcon
)
{
if
(
SynthLookAndFeel
.
shouldUpdateStyle
(
evt
))
{
...
...
@@ -191,4 +215,25 @@ class SynthDesktopIconUI extends BasicDesktopIconUI implements SynthUI,
}
}
}
private
final
class
Handler
implements
ActionListener
{
public
void
actionPerformed
(
ActionEvent
evt
)
{
if
(
evt
.
getSource
()
instanceof
JToggleButton
)
{
// Either iconify the frame or deiconify and activate it.
JToggleButton
button
=
(
JToggleButton
)
evt
.
getSource
();
try
{
boolean
selected
=
button
.
isSelected
();
if
(!
selected
&&
!
frame
.
isIconifiable
())
{
button
.
setSelected
(
true
);
}
else
{
frame
.
setIcon
(!
selected
);
if
(
selected
)
{
frame
.
setSelected
(
true
);
}
}
}
catch
(
PropertyVetoException
e2
)
{
}
}
}
}
}
src/share/classes/javax/swing/plaf/synth/SynthDesktopPaneUI.java
浏览文件 @
e6cfccf9
...
...
@@ -29,34 +29,38 @@ import javax.swing.*;
import
javax.swing.border.*
;
import
javax.swing.plaf.*
;
import
javax.swing.plaf.basic.BasicDesktopPaneUI
;
import
java.beans.*
;
import
java.awt.event.*
;
import
java.awt.Dimension
;
import
java.awt.Insets
;
import
java.awt.Graphics
;
import
java.awt.KeyboardFocusManager
;
import
java.awt.*
;
import
java.util.Vector
;
import
sun.swing.plaf.synth.SynthUI
;
/**
* Synth L&F for a desktop.
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JDesktopPane}.
*
* @author Joshua Outwater
* @author Steve Wilson
* @since 1.7
*/
class
SynthDesktopPaneUI
extends
BasicDesktopPaneUI
implements
public
class
SynthDesktopPaneUI
extends
BasicDesktopPaneUI
implements
PropertyChangeListener
,
SynthUI
{
private
SynthStyle
style
;
private
TaskBar
taskBar
;
private
DesktopManager
oldDesktopManager
;
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public
static
ComponentUI
createUI
(
JComponent
c
)
{
return
new
SynthDesktopPaneUI
();
}
/**
* @inheritDoc
*/
@Override
protected
void
installListeners
()
{
super
.
installListeners
();
desktop
.
addPropertyChangeListener
(
this
);
...
...
@@ -68,6 +72,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
}
}
/**
* @inheritDoc
*/
@Override
protected
void
installDefaults
()
{
updateStyle
(
desktop
);
...
...
@@ -114,6 +122,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallListeners
()
{
if
(
taskBar
!=
null
)
{
desktop
.
removeComponentListener
(
taskBar
);
...
...
@@ -123,6 +135,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
super
.
uninstallListeners
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDefaults
()
{
SynthContext
context
=
getContext
(
desktop
,
ENABLED
);
...
...
@@ -147,6 +163,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
}
}
/**
* @inheritDoc
*/
@Override
protected
void
installDesktopManager
()
{
if
(
UIManager
.
getBoolean
(
"InternalFrame.useTaskBar"
))
{
desktopManager
=
oldDesktopManager
=
desktop
.
getDesktopManager
();
...
...
@@ -159,6 +179,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
}
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDesktopManager
()
{
if
(
oldDesktopManager
!=
null
&&
!(
oldDesktopManager
instanceof
UIResource
))
{
desktopManager
=
desktop
.
getDesktopManager
();
...
...
@@ -397,7 +421,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
}
}
/**
* @inheritDoc
*/
@Override
public
SynthContext
getContext
(
JComponent
c
)
{
return
getContext
(
c
,
getComponentState
(
c
));
}
...
...
@@ -407,14 +434,14 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
SynthLookAndFeel
.
getRegion
(
c
),
style
,
state
);
}
private
Region
getRegion
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getRegion
(
c
);
}
private
int
getComponentState
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getComponentState
(
c
);
}
/**
* @inheritDoc
*/
@Override
public
void
update
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -425,6 +452,10 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
public
void
paint
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -432,14 +463,28 @@ class SynthDesktopPaneUI extends BasicDesktopPaneUI implements
context
.
dispose
();
}
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected
void
paint
(
SynthContext
context
,
Graphics
g
)
{
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintDesktopPaneBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
}
/**
* @inheritDoc
*/
@Override
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
if
(
SynthLookAndFeel
.
shouldUpdateStyle
(
evt
))
{
updateStyle
((
JDesktopPane
)
evt
.
getSource
());
...
...
src/share/classes/javax/swing/plaf/synth/SynthEditorPaneUI.java
浏览文件 @
e6cfccf9
...
...
@@ -31,47 +31,52 @@ import javax.swing.text.*;
import
javax.swing.plaf.*
;
import
javax.swing.plaf.basic.BasicEditorPaneUI
;
import
java.beans.PropertyChangeEvent
;
import
sun.swing.plaf.synth.SynthUI
;
/**
* Provides the
look and feel for a JEditorPane in the
*
Synth look and feel
.
* Provides the
Synth L&F UI delegate for
*
{@link javax.swing.JEditorPane}
.
*
* @author Shannon Hickey
* @since 1.7
*/
class
SynthEditorPaneUI
extends
BasicEditorPaneUI
implements
SynthUI
{
public
class
SynthEditorPaneUI
extends
BasicEditorPaneUI
implements
SynthUI
{
private
SynthStyle
style
;
/*
* I would prefer to use UIResource instad of this.
* Unfortunately Boolean is a final class
*/
private
Boolean
localTrue
=
Boolean
.
TRUE
;
private
Boolean
localFalse
=
Boolean
.
FALSE
;
/**
* Creates a
UI for the JTextPane
.
* Creates a
new UI object for the given component
.
*
* @param c
the JTextPane component
* @return the UI
* @param c
component to create UI object for
* @return the UI
object
*/
public
static
ComponentUI
createUI
(
JComponent
c
)
{
return
new
SynthEditorPaneUI
();
}
/**
* @inheritDoc
*/
@Override
protected
void
installDefaults
()
{
// Installs the text cursor on the component
super
.
installDefaults
();
JComponent
c
=
getComponent
();
Object
clientProperty
=
c
.
getClientProperty
(
JEditorPane
.
HONOR_DISPLAY_PROPERTIES
);
if
(
clientProperty
==
null
||
clientProperty
==
localFalse
)
{
c
.
putClientProperty
(
JEditorPane
.
HONOR_DISPLAY_PROPERTIES
,
localTrue
);
if
(
clientProperty
==
null
)
{
c
.
putClientProperty
(
JEditorPane
.
HONOR_DISPLAY_PROPERTIES
,
localTrue
);
}
updateStyle
(
getComponent
());
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDefaults
()
{
SynthContext
context
=
getContext
(
getComponent
(),
ENABLED
);
JComponent
c
=
getComponent
();
...
...
@@ -84,7 +89,7 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
Object
clientProperty
=
c
.
getClientProperty
(
JEditorPane
.
HONOR_DISPLAY_PROPERTIES
);
if
(
clientProperty
==
localTrue
)
{
getComponent
()
.
putClientProperty
(
JEditorPane
.
HONOR_DISPLAY_PROPERTIES
,
c
.
putClientProperty
(
JEditorPane
.
HONOR_DISPLAY_PROPERTIES
,
Boolean
.
FALSE
);
}
super
.
uninstallDefaults
();
...
...
@@ -100,6 +105,7 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
*
* @param evt the property change event
*/
@Override
protected
void
propertyChange
(
PropertyChangeEvent
evt
)
{
if
(
SynthLookAndFeel
.
shouldUpdateStyle
(
evt
))
{
updateStyle
((
JTextComponent
)
evt
.
getSource
());
...
...
@@ -124,6 +130,10 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
public
SynthContext
getContext
(
JComponent
c
)
{
return
getContext
(
c
,
getComponentState
(
c
));
}
...
...
@@ -137,6 +147,10 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
return
SynthLookAndFeel
.
getComponentState
(
c
);
}
/**
* @inheritDoc
*/
@Override
public
void
update
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -146,10 +160,20 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
context
.
dispose
();
}
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected
void
paint
(
SynthContext
context
,
Graphics
g
)
{
super
.
paint
(
g
,
getComponent
());
}
/**
* @inheritDoc
*/
@Override
protected
void
paintBackground
(
Graphics
g
)
{
// Overriden to do nothing, all our painting is done from update/paint.
}
...
...
@@ -159,6 +183,10 @@ class SynthEditorPaneUI extends BasicEditorPaneUI implements SynthUI {
c
.
getWidth
(),
c
.
getHeight
());
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintEditorPaneBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
...
...
src/share/classes/javax/swing/plaf/synth/SynthFormattedTextFieldUI.java
浏览文件 @
e6cfccf9
...
...
@@ -24,16 +24,17 @@
*/
package
javax.swing.plaf.synth
;
import
java.awt.
*
;
import
javax.swing.
*
;
import
java.awt.
Graphics
;
import
javax.swing.
JComponent
;
import
javax.swing.plaf.ComponentUI
;
/**
* Provides the
look and feel implementation
for
*
<code>JFormattedTextField</code>
.
* Provides the
Synth L&F UI delegate
for
*
{@link javax.swing.JFormattedTextField}
.
*
* @since 1.7
*/
class
SynthFormattedTextFieldUI
extends
SynthTextFieldUI
{
public
class
SynthFormattedTextFieldUI
extends
SynthTextFieldUI
{
/**
* Creates a UI for a JFormattedTextField.
*
...
...
@@ -51,15 +52,24 @@ class SynthFormattedTextFieldUI extends SynthTextFieldUI {
*
* @return the name "FormattedTextField"
*/
@Override
protected
String
getPropertyPrefix
()
{
return
"FormattedTextField"
;
}
/**
* @inheritDoc
*/
@Override
void
paintBackground
(
SynthContext
context
,
Graphics
g
,
JComponent
c
)
{
context
.
getPainter
().
paintFormattedTextFieldBackground
(
context
,
g
,
0
,
0
,
c
.
getWidth
(),
c
.
getHeight
());
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintFormattedTextFieldBorder
(
context
,
g
,
x
,
y
,
...
...
src/share/classes/javax/swing/plaf/synth/SynthInternalFrameTitlePane.java
浏览文件 @
e6cfccf9
...
...
@@ -30,14 +30,9 @@ import java.awt.event.*;
import
javax.swing.*
;
import
javax.swing.plaf.*
;
import
javax.swing.plaf.basic.BasicInternalFrameTitlePane
;
import
javax.swing.border.*
;
import
javax.swing.event.InternalFrameEvent
;
import
java.util.EventListener
;
import
java.beans.PropertyChangeListener
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.VetoableChangeListener
;
import
java.beans.PropertyVetoException
;
import
sun.swing.plaf.synth.SynthUI
;
import
sun.swing.SwingUtilities2
;
/**
...
...
src/share/classes/javax/swing/plaf/synth/SynthInternalFrameUI.java
浏览文件 @
e6cfccf9
...
...
@@ -27,52 +27,61 @@ package javax.swing.plaf.synth;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.awt.peer.LightweightPeer
;
import
javax.swing.*
;
import
javax.swing.plaf.*
;
import
javax.swing.plaf.basic.BasicInternalFrameUI
;
import
javax.swing.event.*
;
import
java.beans.*
;
import
java.io.Serializable
;
import
sun.swing.plaf.synth.SynthUI
;
/**
* Synth's InternalFrameUI.
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JInternalFrame}.
*
* @author David Kloba
* @author Joshua Outwater
* @author Rich Schiavi
* @since 1.7
*/
class
SynthInternalFrameUI
extends
BasicInternalFrameUI
implements
SynthUI
,
PropertyChangeListener
{
public
class
SynthInternalFrameUI
extends
BasicInternalFrameUI
implements
SynthUI
,
PropertyChangeListener
{
private
SynthStyle
style
;
private
static
DesktopManager
sharedDesktopManager
;
private
boolean
componentListenerAdded
=
false
;
private
Rectangle
parentBounds
;
/**
* Creates a new UI object for the given component.
*
* @param b component to create UI object for
* @return the UI object
*/
public
static
ComponentUI
createUI
(
JComponent
b
)
{
return
new
SynthInternalFrameUI
((
JInternalFrame
)
b
);
}
p
ublic
SynthInternalFrameUI
(
JInternalFrame
b
)
{
p
rotected
SynthInternalFrameUI
(
JInternalFrame
b
)
{
super
(
b
);
}
/**
* @inheritDoc
*/
@Override
public
void
installDefaults
()
{
frame
.
setLayout
(
internalFrameLayout
=
createLayoutManager
());
updateStyle
(
frame
);
}
/**
* @inheritDoc
*/
@Override
protected
void
installListeners
()
{
super
.
installListeners
();
frame
.
addPropertyChangeListener
(
this
);
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallComponents
()
{
if
(
frame
.
getComponentPopupMenu
()
instanceof
UIResource
)
{
frame
.
setComponentPopupMenu
(
null
);
...
...
@@ -80,6 +89,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
super
.
uninstallComponents
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallListeners
()
{
frame
.
removePropertyChangeListener
(
this
);
super
.
uninstallListeners
();
...
...
@@ -104,6 +117,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDefaults
()
{
SynthContext
context
=
getContext
(
frame
,
ENABLED
);
style
.
uninstallDefaults
(
context
);
...
...
@@ -115,6 +132,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
}
/**
* @inheritDoc
*/
@Override
public
SynthContext
getContext
(
JComponent
c
)
{
return
getContext
(
c
,
getComponentState
(
c
));
}
...
...
@@ -124,24 +145,28 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
SynthLookAndFeel
.
getRegion
(
c
),
style
,
state
);
}
private
Region
getRegion
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getRegion
(
c
);
}
public
int
getComponentState
(
JComponent
c
)
{
private
int
getComponentState
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getComponentState
(
c
);
}
/**
* @inheritDoc
*/
@Override
protected
JComponent
createNorthPane
(
JInternalFrame
w
)
{
titlePane
=
new
SynthInternalFrameTitlePane
(
w
);
titlePane
.
setName
(
"InternalFrame.northPane"
);
return
titlePane
;
}
/**
* @inheritDoc
*/
@Override
protected
ComponentListener
createComponentListener
()
{
if
(
UIManager
.
getBoolean
(
"InternalFrame.useTaskBar"
))
{
return
new
ComponentHandler
()
{
public
void
componentResized
(
ComponentEvent
e
)
{
@Override
public
void
componentResized
(
ComponentEvent
e
)
{
if
(
frame
!=
null
&&
frame
.
isMaximum
())
{
JDesktopPane
desktop
=
(
JDesktopPane
)
e
.
getSource
();
for
(
Component
comp
:
desktop
.
getComponents
())
{
...
...
@@ -168,6 +193,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
}
}
/**
* @inheritDoc
*/
@Override
public
void
update
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -178,6 +207,10 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
public
void
paint
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -185,15 +218,29 @@ class SynthInternalFrameUI extends BasicInternalFrameUI implements SynthUI,
context
.
dispose
();
}
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected
void
paint
(
SynthContext
context
,
Graphics
g
)
{
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintInternalFrameBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
}
/**
* @inheritDoc
*/
@Override
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
SynthStyle
oldStyle
=
style
;
JInternalFrame
f
=
(
JInternalFrame
)
evt
.
getSource
();
...
...
src/share/classes/javax/swing/plaf/synth/SynthLabelUI.java
浏览文件 @
e6cfccf9
...
...
@@ -29,38 +29,37 @@ import javax.swing.*;
import
javax.swing.plaf.*
;
import
javax.swing.plaf.basic.*
;
import
javax.swing.text.View
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.Component
;
import
java.awt.Container
;
import
java.awt.Dimension
;
import
java.awt.Rectangle
;
import
java.awt.Insets
;
import
java.awt.Color
;
import
java.awt.Graphics
;
import
java.awt.Font
;
import
java.awt.FontMetrics
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
sun.swing.plaf.synth.SynthUI
;
/**
* Synth's LabelUI.
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JLabel}.
*
* @author Scott Violet
* @since 1.7
*/
class
SynthLabelUI
extends
BasicLabelUI
implements
SynthUI
{
public
class
SynthLabelUI
extends
BasicLabelUI
implements
SynthUI
{
private
SynthStyle
style
;
/**
* Returns the LabelUI implementation used for the skins look and feel.
*
* @param c component to create UI object for
* @return the UI object
*/
public
static
ComponentUI
createUI
(
JComponent
c
){
return
new
SynthLabelUI
();
}
/**
* @inheritDoc
*/
@Override
protected
void
installDefaults
(
JLabel
c
)
{
updateStyle
(
c
);
}
...
...
@@ -71,6 +70,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDefaults
(
JLabel
c
){
SynthContext
context
=
getContext
(
c
,
ENABLED
);
...
...
@@ -79,6 +82,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
style
=
null
;
}
/**
* @inheritDoc
*/
@Override
public
SynthContext
getContext
(
JComponent
c
)
{
return
getContext
(
c
,
getComponentState
(
c
));
}
...
...
@@ -88,10 +95,6 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
SynthLookAndFeel
.
getRegion
(
c
),
style
,
state
);
}
private
Region
getRegion
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getRegion
(
c
);
}
private
int
getComponentState
(
JComponent
c
)
{
int
state
=
SynthLookAndFeel
.
getComponentState
(
c
);
if
(
SynthLookAndFeel
.
selectedUI
==
this
&&
...
...
@@ -101,6 +104,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
return
state
;
}
/**
* @inheritDoc
*/
@Override
public
int
getBaseline
(
JComponent
c
,
int
width
,
int
height
)
{
if
(
c
==
null
)
{
throw
new
NullPointerException
(
"Component must be non-null"
);
...
...
@@ -153,6 +160,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
* component. This method is invoked by <code>JComponent</code>
* when the specified component is being painted.
*/
/**
* @inheritDoc
*/
@Override
public
void
update
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -163,6 +174,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
public
void
paint
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -170,6 +185,12 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
context
.
dispose
();
}
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected
void
paint
(
SynthContext
context
,
Graphics
g
)
{
JLabel
label
=
(
JLabel
)
context
.
getComponent
();
Icon
icon
=
(
label
.
isEnabled
())
?
label
.
getIcon
()
:
...
...
@@ -185,11 +206,19 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
label
.
getIconTextGap
(),
label
.
getDisplayedMnemonicIndex
(),
0
);
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintLabelBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
}
/**
* @inheritDoc
*/
@Override
public
Dimension
getPreferredSize
(
JComponent
c
)
{
JLabel
label
=
(
JLabel
)
c
;
Icon
icon
=
(
label
.
isEnabled
())
?
label
.
getIcon
()
:
...
...
@@ -207,7 +236,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
return
size
;
}
/**
* @inheritDoc
*/
@Override
public
Dimension
getMinimumSize
(
JComponent
c
)
{
JLabel
label
=
(
JLabel
)
c
;
Icon
icon
=
(
label
.
isEnabled
())
?
label
.
getIcon
()
:
...
...
@@ -225,6 +257,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
return
size
;
}
/**
* @inheritDoc
*/
@Override
public
Dimension
getMaximumSize
(
JComponent
c
)
{
JLabel
label
=
(
JLabel
)
c
;
Icon
icon
=
(
label
.
isEnabled
())
?
label
.
getIcon
()
:
...
...
@@ -242,7 +278,10 @@ class SynthLabelUI extends BasicLabelUI implements SynthUI {
return
size
;
}
/**
* @inheritDoc
*/
@Override
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
super
.
propertyChange
(
e
);
if
(
SynthLookAndFeel
.
shouldUpdateStyle
(
e
))
{
...
...
src/share/classes/javax/swing/plaf/synth/SynthListUI.java
浏览文件 @
e6cfccf9
...
...
@@ -27,38 +27,39 @@ package javax.swing.plaf.synth;
import
javax.swing.*
;
import
javax.swing.border.*
;
import
javax.swing.event.*
;
import
javax.swing.plaf.*
;
import
javax.swing.plaf.basic.*
;
import
javax.swing.text.Position
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.awt.datatransfer.Transferable
;
import
java.awt.dnd.*
;
import
java.util.ArrayList
;
import
java.util.TooManyListenersException
;
import
java.beans.PropertyChangeListener
;
import
java.beans.PropertyChangeEvent
;
import
sun.swing.plaf.synth.SynthUI
;
/**
* Synth's ListUI.
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JList}.
*
* @author Scott Violet
* @since 1.7
*/
class
SynthListUI
extends
BasicListUI
implements
PropertyChangeListener
,
SynthUI
{
public
class
SynthListUI
extends
BasicListUI
implements
PropertyChangeListener
,
SynthUI
{
private
SynthStyle
style
;
private
boolean
useListColors
;
private
boolean
useUIBorder
;
/**
* Creates a new UI object for the given component.
*
* @param list component to create UI object for
* @return the UI object
*/
public
static
ComponentUI
createUI
(
JComponent
list
)
{
return
new
SynthListUI
();
}
/**
* @inheritDoc
*/
@Override
public
void
update
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -69,27 +70,47 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener,
paint
(
g
,
c
);
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintListBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
}
/**
* @inheritDoc
*/
@Override
protected
void
installListeners
()
{
super
.
installListeners
();
list
.
addPropertyChangeListener
(
this
);
}
/**
* @inheritDoc
*/
@Override
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
if
(
SynthLookAndFeel
.
shouldUpdateStyle
(
e
))
{
updateStyle
((
JList
)
e
.
getSource
());
}
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallListeners
()
{
super
.
uninstallListeners
();
list
.
removePropertyChangeListener
(
this
);
}
/**
* @inheritDoc
*/
@Override
protected
void
installDefaults
()
{
if
(
list
.
getCellRenderer
()
==
null
||
(
list
.
getCellRenderer
()
instanceof
UIResource
))
{
...
...
@@ -135,6 +156,10 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener,
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDefaults
()
{
super
.
uninstallDefaults
();
...
...
@@ -145,6 +170,10 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener,
style
=
null
;
}
/**
* @inheritDoc
*/
@Override
public
SynthContext
getContext
(
JComponent
c
)
{
return
getContext
(
c
,
getComponentState
(
c
));
}
...
...
@@ -154,27 +183,23 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener,
SynthLookAndFeel
.
getRegion
(
c
),
style
,
state
);
}
private
Region
getRegion
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getRegion
(
c
);
}
private
int
getComponentState
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getComponentState
(
c
);
}
private
class
SynthListCellRenderer
extends
DefaultListCellRenderer
.
UIResource
{
public
String
getName
()
{
@Override
public
String
getName
()
{
return
"List.cellRenderer"
;
}
public
void
setBorder
(
Border
b
)
{
@Override
public
void
setBorder
(
Border
b
)
{
if
(
useUIBorder
||
b
instanceof
SynthBorder
)
{
super
.
setBorder
(
b
);
}
}
public
Component
getListCellRendererComponent
(
JList
list
,
Object
value
,
@Override
public
Component
getListCellRendererComponent
(
JList
list
,
Object
value
,
int
index
,
boolean
isSelected
,
boolean
cellHasFocus
)
{
if
(!
useListColors
&&
(
isSelected
||
cellHasFocus
))
{
SynthLookAndFeel
.
setSelectedUI
((
SynthLabelUI
)
SynthLookAndFeel
.
...
...
@@ -190,7 +215,7 @@ class SynthListUI extends BasicListUI implements PropertyChangeListener,
return
this
;
}
public
void
paint
(
Graphics
g
)
{
@Override
public
void
paint
(
Graphics
g
)
{
super
.
paint
(
g
);
SynthLookAndFeel
.
resetSelectedUI
();
}
...
...
src/share/classes/javax/swing/plaf/synth/SynthLookAndFeel.java
浏览文件 @
e6cfccf9
...
...
@@ -234,44 +234,9 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
* <code>shouldUpdateStyleOnAncestorChanged</code> as necessary.
*/
static
boolean
shouldUpdateStyle
(
PropertyChangeEvent
event
)
{
String
eName
=
event
.
getPropertyName
();
if
(
"name"
==
eName
)
{
// Always update on a name change
return
true
;
}
else
if
(
"componentOrientation"
==
eName
)
{
// Always update on a component orientation change
return
true
;
}
else
if
(
"ancestor"
==
eName
&&
event
.
getNewValue
()
!=
null
)
{
// Only update on an ancestor change when getting a valid
// parent and the LookAndFeel wants this.
LookAndFeel
laf
=
UIManager
.
getLookAndFeel
();
return
(
laf
instanceof
SynthLookAndFeel
&&
((
SynthLookAndFeel
)
laf
).
shouldUpdateStyleOnAncestorChanged
());
}
// Note: The following two nimbus based overrides should be refactored
// to be in the Nimbus LAF. Due to constraints in an update release,
// we couldn't actually provide the public API necessary to allow
// NimbusLookAndFeel (a subclass of SynthLookAndFeel) to provide its
// own rules for shouldUpdateStyle.
else
if
(
"Nimbus.Overrides"
==
eName
)
{
// Always update when the Nimbus.Overrides client property has
// been changed
return
true
;
}
else
if
(
"Nimbus.Overrides.InheritDefaults"
==
eName
)
{
// Always update when the Nimbus.Overrides.InheritDefaults
// client property has changed
return
true
;
}
else
if
(
"JComponent.sizeVariant"
==
eName
)
{
// Always update when the JComponent.sizeVariant
// client property has changed
return
true
;
}
return
false
;
LookAndFeel
laf
=
UIManager
.
getLookAndFeel
();
return
(
laf
instanceof
SynthLookAndFeel
&&
((
SynthLookAndFeel
)
laf
).
shouldUpdateStyleOnEvent
(
event
));
}
/**
...
...
@@ -303,12 +268,6 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
* @param c Component to update style for.
*/
public
static
void
updateStyles
(
Component
c
)
{
_updateStyles
(
c
);
c
.
repaint
();
}
// Implementation for updateStyles
private
static
void
_updateStyles
(
Component
c
)
{
if
(
c
instanceof
JComponent
)
{
// Yes, this is hacky. A better solution is to get the UI
// and cast, but JComponent doesn't expose a getter for the UI
...
...
@@ -332,6 +291,7 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
updateStyles
(
child
);
}
}
c
.
repaint
();
}
/**
...
...
@@ -788,6 +748,27 @@ public class SynthLookAndFeel extends BasicLookAndFeel {
return
false
;
}
/**
* Returns whether or not the UIs should update their styles when a
* particular event occurs.
*
* @param ev a {@code PropertyChangeEvent}
* @return whether or not the UIs should update their styles
* @since 1.7
*/
protected
boolean
shouldUpdateStyleOnEvent
(
PropertyChangeEvent
ev
)
{
String
eName
=
ev
.
getPropertyName
();
if
(
"name"
==
eName
||
"componentOrientation"
==
eName
)
{
return
true
;
}
if
(
"ancestor"
==
eName
&&
ev
.
getNewValue
()
!=
null
)
{
// Only update on an ancestor change when getting a valid
// parent and the LookAndFeel wants this.
return
shouldUpdateStyleOnAncestorChanged
();
}
return
false
;
}
/**
* Returns the antialiasing information as specified by the host desktop.
* Antialiasing might be forced off if the desktop is GNOME and the user
...
...
src/share/classes/javax/swing/plaf/synth/SynthMenuBarUI.java
浏览文件 @
e6cfccf9
...
...
@@ -25,45 +25,49 @@
package
javax.swing.plaf.synth
;
import
javax.swing.*
;
import
javax.swing.event.*
;
import
java.awt.Color
;
import
java.awt.Component
;
import
java.awt.Container
;
import
java.awt.Dimension
;
import
java.awt.Graphics
;
import
java.awt.Insets
;
import
java.awt.Point
;
import
java.awt.Rectangle
;
import
java.awt.event.*
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
javax.swing.border.*
;
import
javax.swing.plaf.*
;
import
javax.swing.plaf.basic.*
;
import
sun.swing.plaf.synth.SynthUI
;
/**
* Synth's MenuBarUI.
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JMenuBar}.
*
* @author Scott Violet
* @since 1.7
*/
class
SynthMenuBarUI
extends
BasicMenuBarUI
implements
PropertyChangeListener
,
SynthUI
{
public
class
SynthMenuBarUI
extends
BasicMenuBarUI
implements
PropertyChangeListener
,
SynthUI
{
private
SynthStyle
style
;
/**
* Creates a new UI object for the given component.
*
* @param x component to create UI object for
* @return the UI object
*/
public
static
ComponentUI
createUI
(
JComponent
x
)
{
return
new
SynthMenuBarUI
();
}
/**
* @inheritDoc
*/
@Override
protected
void
installDefaults
()
{
if
(
menuBar
.
getLayout
()
==
null
||
menuBar
.
getLayout
()
instanceof
UIResource
)
{
menuBar
.
setLayout
(
new
Default
MenuLayout
(
menuBar
,
BoxLayout
.
LINE_AXIS
));
menuBar
.
setLayout
(
new
Synth
MenuLayout
(
menuBar
,
BoxLayout
.
LINE_AXIS
));
}
updateStyle
(
menuBar
);
}
/**
* @inheritDoc
*/
@Override
protected
void
installListeners
()
{
super
.
installListeners
();
menuBar
.
addPropertyChangeListener
(
this
);
...
...
@@ -82,6 +86,10 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener,
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDefaults
()
{
SynthContext
context
=
getContext
(
menuBar
,
ENABLED
);
...
...
@@ -90,11 +98,19 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener,
style
=
null
;
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallListeners
()
{
super
.
uninstallListeners
();
menuBar
.
removePropertyChangeListener
(
this
);
}
/**
* @inheritDoc
*/
@Override
public
SynthContext
getContext
(
JComponent
c
)
{
return
getContext
(
c
,
getComponentState
(
c
));
}
...
...
@@ -104,14 +120,14 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener,
SynthLookAndFeel
.
getRegion
(
c
),
style
,
state
);
}
private
Region
getRegion
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getRegion
(
c
);
}
private
int
getComponentState
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getComponentState
(
c
);
}
/**
* @inheritDoc
*/
@Override
public
void
update
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -122,6 +138,10 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener,
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
public
void
paint
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -129,14 +149,28 @@ class SynthMenuBarUI extends BasicMenuBarUI implements PropertyChangeListener,
context
.
dispose
();
}
/**
* Paints the specified component. This implementation does nothing.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected
void
paint
(
SynthContext
context
,
Graphics
g
)
{
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintMenuBarBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
}
/**
* @inheritDoc
*/
@Override
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
if
(
SynthLookAndFeel
.
shouldUpdateStyle
(
e
))
{
updateStyle
((
JMenuBar
)
e
.
getSource
());
...
...
src/share/classes/javax/swing/plaf/synth/SynthMenuItemUI.java
浏览文件 @
e6cfccf9
...
...
@@ -24,41 +24,44 @@
*/
package
javax.swing.plaf.synth
;
import
javax.swing.plaf.basic.BasicHTML
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
javax.swing.*
;
import
javax.swing.event.*
;
import
javax.swing.border.*
;
import
javax.swing.plaf.*
;
import
javax.swing.plaf.basic.*
;
import
javax.swing.text.View
;
import
sun.swing.plaf.synth.*
;
import
sun.swing.MenuItemLayoutHelper
;
/**
* Synth's MenuItemUI.
* Provides the Synth L&F UI delegate for
* {@link javax.swing.JMenuItem}.
*
* @author Georges Saab
* @author David Karlton
* @author Arnaud Weber
* @author Fredrik Lagerblad
* @since 1.7
*/
class
SynthMenuItemUI
extends
BasicMenuItemUI
implements
public
class
SynthMenuItemUI
extends
BasicMenuItemUI
implements
PropertyChangeListener
,
SynthUI
{
private
SynthStyle
style
;
private
SynthStyle
accStyle
;
private
String
acceleratorDelimiter
;
/**
* Creates a new UI object for the given component.
*
* @param c component to create UI object for
* @return the UI object
*/
public
static
ComponentUI
createUI
(
JComponent
c
)
{
return
new
SynthMenuItemUI
();
}
/**
* @inheritDoc
*/
@Override
public
void
uninstallUI
(
JComponent
c
)
{
super
.
uninstallUI
(
c
);
// Remove values from the parent's Client Properties.
...
...
@@ -69,10 +72,18 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
}
}
/**
* @inheritDoc
*/
@Override
protected
void
installDefaults
()
{
updateStyle
(
menuItem
);
}
/**
* @inheritDoc
*/
@Override
protected
void
installListeners
()
{
super
.
installListeners
();
menuItem
.
addPropertyChangeListener
(
this
);
...
...
@@ -122,6 +133,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
accContext
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallDefaults
()
{
SynthContext
context
=
getContext
(
menuItem
,
ENABLED
);
style
.
uninstallDefaults
(
context
);
...
...
@@ -137,11 +152,19 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
super
.
uninstallDefaults
();
}
/**
* @inheritDoc
*/
@Override
protected
void
uninstallListeners
()
{
super
.
uninstallListeners
();
menuItem
.
removePropertyChangeListener
(
this
);
}
/**
* @inheritDoc
*/
@Override
public
SynthContext
getContext
(
JComponent
c
)
{
return
getContext
(
c
,
getComponentState
(
c
));
}
...
...
@@ -151,7 +174,7 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
SynthLookAndFeel
.
getRegion
(
c
),
style
,
state
);
}
public
SynthContext
getContext
(
JComponent
c
,
Region
region
)
{
SynthContext
getContext
(
JComponent
c
,
Region
region
)
{
return
getContext
(
c
,
region
,
getComponentState
(
c
,
region
));
}
...
...
@@ -160,10 +183,6 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
region
,
accStyle
,
state
);
}
private
Region
getRegion
(
JComponent
c
)
{
return
SynthLookAndFeel
.
getRegion
(
c
);
}
private
int
getComponentState
(
JComponent
c
)
{
int
state
;
...
...
@@ -186,6 +205,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
return
getComponentState
(
c
);
}
/**
* @inheritDoc
*/
@Override
protected
Dimension
getPreferredMenuItemSize
(
JComponent
c
,
Icon
checkIcon
,
Icon
arrowIcon
,
...
...
@@ -203,6 +226,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
}
/**
* @inheritDoc
*/
@Override
public
void
update
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -212,6 +239,10 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
context
.
dispose
();
}
/**
* @inheritDoc
*/
@Override
public
void
paint
(
Graphics
g
,
JComponent
c
)
{
SynthContext
context
=
getContext
(
c
);
...
...
@@ -219,6 +250,12 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
context
.
dispose
();
}
/**
* Paints the specified component.
*
* @param context context for the component being painted
* @param g {@code Graphics} object used for painting
*/
protected
void
paint
(
SynthContext
context
,
Graphics
g
)
{
SynthContext
accContext
=
getContext
(
menuItem
,
Region
.
MENU_ITEM_ACCELERATOR
);
...
...
@@ -236,11 +273,19 @@ class SynthMenuItemUI extends BasicMenuItemUI implements
SynthGraphicsUtils
.
paintBackground
(
context
,
g
,
c
);
}
/**
* @inheritDoc
*/
@Override
public
void
paintBorder
(
SynthContext
context
,
Graphics
g
,
int
x
,
int
y
,
int
w
,
int
h
)
{
context
.
getPainter
().
paintMenuItemBorder
(
context
,
g
,
x
,
y
,
w
,
h
);
}
/**
* @inheritDoc
*/
@Override
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
if
(
SynthLookAndFeel
.
shouldUpdateStyle
(
e
))
{
updateStyle
((
JMenuItem
)
e
.
getSource
());
...
...
src/share/classes/javax/swing/plaf/synth/
Default
MenuLayout.java
→
src/share/classes/javax/swing/plaf/synth/
Synth
MenuLayout.java
浏览文件 @
e6cfccf9
...
...
@@ -25,44 +25,29 @@
package
javax.swing.plaf.synth
;
import
javax.swing.*
;
import
javax.swing.plaf.UIResource
;
import
javax.swing.plaf.basic.DefaultMenuLayout
;
import
javax.swing.JPopupMenu
;
import
java.awt.Container
;
import
java.awt.Dimension
;
/**
* The default layout manager for Popup menus and menubars. This
* class is an extension of BoxLayout which adds the UIResource tag
* so that plauggable L&Fs can distinguish it from user-installed
* layout managers on menus.
*
* Derived from javax.swing.plaf.basic.DefaultMenuLayout
* @inheritDoc
*
* @author Georges Saab
*/
class
DefaultMenuLayout
extends
BoxLayout
implements
UIResource
{
public
Default
MenuLayout
(
Container
target
,
int
axis
)
{
class
SynthMenuLayout
extends
DefaultMenuLayout
{
public
Synth
MenuLayout
(
Container
target
,
int
axis
)
{
super
(
target
,
axis
);
}
public
Dimension
preferredLayoutSize
(
Container
target
)
{
if
(
target
instanceof
JPopupMenu
)
{
JPopupMenu
popupMenu
=
(
JPopupMenu
)
target
;
popupMenu
.
putClientProperty
(
SynthMenuItemLayoutHelper
.
MAX_ACC_OR_ARROW_WIDTH
,
null
);
sun
.
swing
.
MenuItemLayoutHelper
.
clearUsedClientProperties
(
popupMenu
);
if
(
popupMenu
.
getComponentCount
()
==
0
)
{
return
new
Dimension
(
0
,
0
);
}
}
// Make BoxLayout recalculate cached preferred sizes
super
.
invalidateLayout
(
target
);
return
super
.
preferredLayoutSize
(
target
);
}
}
src/share/classes/javax/swing/plaf/synth/SynthMenuUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthOptionPaneUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthPainter.java
浏览文件 @
e6cfccf9
...
...
@@ -25,7 +25,6 @@
package
javax.swing.plaf.synth
;
import
java.awt.*
;
import
javax.swing.*
;
/**
* <code>SynthPainter</code> is used for painting portions of
...
...
src/share/classes/javax/swing/plaf/synth/SynthPanelUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthPasswordFieldUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthPopupMenuUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthRadioButtonMenuItemUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthRadioButtonUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthRootPaneUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthScrollBarUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthScrollPaneUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthSeparatorUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthSliderUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthSpinnerUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthSplitPaneUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthStyle.java
浏览文件 @
e6cfccf9
...
...
@@ -33,7 +33,6 @@ import javax.swing.text.DefaultEditorKit;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.swing.text.JTextComponent
;
import
sun.swing.plaf.synth.SynthUI
;
/**
* <code>SynthStyle</code> is a set of style properties.
...
...
src/share/classes/javax/swing/plaf/synth/SynthStyleFactory.java
浏览文件 @
e6cfccf9
...
...
@@ -24,10 +24,7 @@
*/
package
javax.swing.plaf.synth
;
import
java.awt.*
;
import
java.util.*
;
import
javax.swing.plaf.*
;
import
javax.swing.*
;
import
javax.swing.JComponent
;
/**
* Factory used for obtaining <code>SynthStyle</code>s. Each of the
...
...
src/share/classes/javax/swing/plaf/synth/SynthTabbedPaneUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthTableHeaderUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthTableUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthTextAreaUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthTextFieldUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthTextPaneUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthToggleButtonUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthToolTipUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/
sun
/swing/plaf/synth/SynthUI.java
→
src/share/classes/
javax
/swing/plaf/synth/SynthUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/share/classes/javax/swing/plaf/synth/SynthViewportUI.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/solaris/native/com/sun/media/sound/PLATFORM_API_LinuxOS_ALSA_PCM.c
浏览文件 @
e6cfccf9
...
...
@@ -143,8 +143,12 @@ void DAUDIO_GetFormats(INT32 mixerIndex, INT32 deviceID, int isSource, void* cre
ERROR1
(
"snd_pcm_hw_params_malloc returned error %d
\n
"
,
ret
);
}
else
{
ret
=
snd_pcm_hw_params_any
(
handle
,
hwParams
);
if
(
ret
!=
0
)
{
ERROR1
(
"snd_pcm_hw_params_any returned error %d
\n
"
,
ret
);
/* snd_pcm_hw_params_any can return a positive value on success too */
if
(
ret
<
0
)
{
ERROR1
(
"snd_pcm_hw_params_any returned error %d
\n
"
,
ret
);
}
else
{
/* for the logic following this code, set ret to 0 to indicate success */
ret
=
0
;
}
}
snd_pcm_hw_params_get_format_mask
(
hwParams
,
formatMask
);
...
...
src/windows/lib/tzmappings
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
src/windows/native/com/sun/media/sound/PLATFORM_API_WinOS_DirectSound.cpp
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
test/java/beans/EventHandler/Test6788531.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
test/java/beans/Introspector/Test5102804.java
0 → 100644
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
test/java/beans/XMLEncoder/6329581/Test6329581.java
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
test/javax/sound/midi/Gervill/SoftChannel/NoteOverFlowTest2.java
0 → 100644
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
test/javax/sound/midi/Gervill/SoftReceiver/GetMidiDevice.java
0 → 100644
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
test/javax/sound/midi/Gervill/SoftSynthesizer/TestPreciseTimestampRendering.java
0 → 100644
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
test/javax/swing/JList/6823603/bug6823603.java
0 → 100644
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
test/javax/swing/JTable/Test6888156.java
0 → 100644
浏览文件 @
e6cfccf9
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录