Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
04a8b4d8
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看板
提交
04a8b4d8
编写于
9月 09, 2009
作者:
Y
yan
浏览文件
操作
浏览文件
下载
差异文件
Merge
上级
feb1bd83
a3d57685
变更
133
隐藏空白更改
内联
并排
Showing
133 changed file
with
3112 addition
and
12250 deletion
+3112
-12250
README
README
+5
-15
make/common/Sanity.gmk
make/common/Sanity.gmk
+1
-2
make/common/shared/Defs.gmk
make/common/shared/Defs.gmk
+0
-9
make/common/shared/Sanity-Settings.gmk
make/common/shared/Sanity-Settings.gmk
+0
-1
make/common/shared/Sanity.gmk
make/common/shared/Sanity.gmk
+0
-17
make/javax/swing/plaf/Makefile
make/javax/swing/plaf/Makefile
+23
-10
make/sun/javazic/tzdata/VERSION
make/sun/javazic/tzdata/VERSION
+1
-1
make/sun/javazic/tzdata/africa
make/sun/javazic/tzdata/africa
+60
-17
make/sun/javazic/tzdata/antarctica
make/sun/javazic/tzdata/antarctica
+2
-0
make/sun/javazic/tzdata/asia
make/sun/javazic/tzdata/asia
+57
-2
make/sun/javazic/tzdata/australasia
make/sun/javazic/tzdata/australasia
+39
-0
make/sun/javazic/tzdata/backward
make/sun/javazic/tzdata/backward
+3
-0
make/sun/javazic/tzdata/etcetera
make/sun/javazic/tzdata/etcetera
+3
-0
make/sun/javazic/tzdata/europe
make/sun/javazic/tzdata/europe
+3
-1
make/sun/javazic/tzdata/factory
make/sun/javazic/tzdata/factory
+3
-0
make/sun/javazic/tzdata/iso3166.tab
make/sun/javazic/tzdata/iso3166.tab
+3
-1
make/sun/javazic/tzdata/leapseconds
make/sun/javazic/tzdata/leapseconds
+9
-6
make/sun/javazic/tzdata/northamerica
make/sun/javazic/tzdata/northamerica
+2
-0
make/sun/javazic/tzdata/pacificnew
make/sun/javazic/tzdata/pacificnew
+3
-0
make/sun/javazic/tzdata/solar87
make/sun/javazic/tzdata/solar87
+3
-0
make/sun/javazic/tzdata/solar88
make/sun/javazic/tzdata/solar88
+3
-0
make/sun/javazic/tzdata/solar89
make/sun/javazic/tzdata/solar89
+3
-0
make/sun/javazic/tzdata/southamerica
make/sun/javazic/tzdata/southamerica
+4
-2
make/sun/javazic/tzdata/systemv
make/sun/javazic/tzdata/systemv
+3
-0
make/sun/javazic/tzdata/zone.tab
make/sun/javazic/tzdata/zone.tab
+7
-4
make/tools/Makefile
make/tools/Makefile
+1
-1
make/tools/generate_nimbus/Makefile
make/tools/generate_nimbus/Makefile
+33
-21
make/tools/src/build/tools/generatenimbus/Generator.java
make/tools/src/build/tools/generatenimbus/Generator.java
+98
-120
make/tools/src/build/tools/generatenimbus/ObjectFactory.java
make/tools/src/build/tools/generatenimbus/ObjectFactory.java
+24
-17
make/tools/src/build/tools/generatenimbus/Paint.java
make/tools/src/build/tools/generatenimbus/Paint.java
+181
-0
make/tools/src/build/tools/generatenimbus/PainterGenerator.java
...ools/src/build/tools/generatenimbus/PainterGenerator.java
+181
-312
make/tools/src/build/tools/generatenimbus/Shape.java
make/tools/src/build/tools/generatenimbus/Shape.java
+140
-0
make/tools/src/build/tools/generatenimbus/SynthModel.java
make/tools/src/build/tools/generatenimbus/SynthModel.java
+216
-0
make/tools/src/build/tools/generatenimbus/UIDefault.java
make/tools/src/build/tools/generatenimbus/UIDefault.java
+126
-0
make/tools/src/build/tools/generatenimbus/UIStyle.java
make/tools/src/build/tools/generatenimbus/UIStyle.java
+399
-0
make/tools/src/build/tools/generatenimbus/Utils.java
make/tools/src/build/tools/generatenimbus/Utils.java
+61
-141
make/tools/swing-nimbus/Makefile
make/tools/swing-nimbus/Makefile
+0
-91
make/tools/swing-nimbus/classes/org/jdesktop/beans/AbstractBean.java
...swing-nimbus/classes/org/jdesktop/beans/AbstractBean.java
+0
-475
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/BezierControlPoint.java
...sses/org/jdesktop/swingx/designer/BezierControlPoint.java
+0
-265
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/BlendingMode.java
...us/classes/org/jdesktop/swingx/designer/BlendingMode.java
+0
-100
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/Canvas.java
...g-nimbus/classes/org/jdesktop/swingx/designer/Canvas.java
+0
-308
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/ControlPoint.java
...us/classes/org/jdesktop/swingx/designer/ControlPoint.java
+0
-157
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/Designer.jibx.xml
...us/classes/org/jdesktop/swingx/designer/Designer.jibx.xml
+0
-173
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/EllipseShape.java
...us/classes/org/jdesktop/swingx/designer/EllipseShape.java
+0
-189
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/GraphicsHelper.java
.../classes/org/jdesktop/swingx/designer/GraphicsHelper.java
+0
-45
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/Layer.java
...ng-nimbus/classes/org/jdesktop/swingx/designer/Layer.java
+0
-443
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/LayerContainer.java
.../classes/org/jdesktop/swingx/designer/LayerContainer.java
+0
-67
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/PaintedShape.java
...us/classes/org/jdesktop/swingx/designer/PaintedShape.java
+0
-289
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/PathShape.java
...imbus/classes/org/jdesktop/swingx/designer/PathShape.java
+0
-194
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/RectangleShape.java
.../classes/org/jdesktop/swingx/designer/RectangleShape.java
+0
-266
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/SimpleShape.java
...bus/classes/org/jdesktop/swingx/designer/SimpleShape.java
+0
-81
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/TemplateLayer.java
...s/classes/org/jdesktop/swingx/designer/TemplateLayer.java
+0
-142
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/DropShadowEffect.java
...rg/jdesktop/swingx/designer/effects/DropShadowEffect.java
+0
-137
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/Effect.java
.../classes/org/jdesktop/swingx/designer/effects/Effect.java
+0
-153
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/EffectUtils.java
...ses/org/jdesktop/swingx/designer/effects/EffectUtils.java
+0
-99
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/EffectUtilsTemp.java
...org/jdesktop/swingx/designer/effects/EffectUtilsTemp.java
+0
-82
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/InnerGlowEffect.java
...org/jdesktop/swingx/designer/effects/InnerGlowEffect.java
+0
-55
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/InnerShadowEffect.java
...g/jdesktop/swingx/designer/effects/InnerShadowEffect.java
+0
-142
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/ShadowEffect.java
...es/org/jdesktop/swingx/designer/effects/ShadowEffect.java
+0
-132
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/font/Typeface.java
...s/classes/org/jdesktop/swingx/designer/font/Typeface.java
+0
-484
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/CanvasMapper.java
...rg/jdesktop/swingx/designer/jibxhelpers/CanvasMapper.java
+0
-123
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/ColorMapper.java
...org/jdesktop/swingx/designer/jibxhelpers/ColorMapper.java
+0
-89
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/DimensionMapper.java
...jdesktop/swingx/designer/jibxhelpers/DimensionMapper.java
+0
-101
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/InsetsMapper.java
...rg/jdesktop/swingx/designer/jibxhelpers/InsetsMapper.java
+0
-117
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/AbstractGradient.java
.../org/jdesktop/swingx/designer/paint/AbstractGradient.java
+0
-280
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/Gradient.java
.../classes/org/jdesktop/swingx/designer/paint/Gradient.java
+0
-51
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/GradientStop.java
...sses/org/jdesktop/swingx/designer/paint/GradientStop.java
+0
-123
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/Matte.java
...bus/classes/org/jdesktop/swingx/designer/paint/Matte.java
+0
-610
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/PaintModel.java
...lasses/org/jdesktop/swingx/designer/paint/PaintModel.java
+0
-64
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasPath.java
...s/classes/org/jdesktop/swingx/designer/utils/HasPath.java
+0
-34
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasResources.java
...sses/org/jdesktop/swingx/designer/utils/HasResources.java
+0
-42
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasUIDefaults.java
...ses/org/jdesktop/swingx/designer/utils/HasUIDefaults.java
+0
-36
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/DefaultsGenerator.java
...g/jdesktop/synthdesigner/generator/DefaultsGenerator.java
+0
-726
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/ObjectCodeConvertors.java
...desktop/synthdesigner/generator/ObjectCodeConvertors.java
+0
-108
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/TemplateWriter.java
.../org/jdesktop/synthdesigner/generator/TemplateWriter.java
+0
-114
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/HasUIStyle.java
...ses/org/jdesktop/synthdesigner/synthmodel/HasUIStyle.java
+0
-36
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/PainterBorder.java
.../org/jdesktop/synthdesigner/synthmodel/PainterBorder.java
+0
-43
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/SynthModel.java
...ses/org/jdesktop/synthdesigner/synthmodel/SynthModel.java
+0
-530
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/SynthModel.jibx.xml
...org/jdesktop/synthdesigner/synthmodel/SynthModel.jibx.xml
+0
-181
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIBorder.java
...asses/org/jdesktop/synthdesigner/synthmodel/UIBorder.java
+0
-53
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIColor.java
...lasses/org/jdesktop/synthdesigner/synthmodel/UIColor.java
+0
-58
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIComponent.java
...es/org/jdesktop/synthdesigner/synthmodel/UIComponent.java
+0
-138
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIDefault.java
...sses/org/jdesktop/synthdesigner/synthmodel/UIDefault.java
+0
-116
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIDimension.java
...es/org/jdesktop/synthdesigner/synthmodel/UIDimension.java
+0
-48
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIIconRegion.java
...s/org/jdesktop/synthdesigner/synthmodel/UIIconRegion.java
+0
-55
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIInsets.java
...asses/org/jdesktop/synthdesigner/synthmodel/UIInsets.java
+0
-62
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIPaint.java
...lasses/org/jdesktop/synthdesigner/synthmodel/UIPaint.java
+0
-84
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIRegion.java
...asses/org/jdesktop/synthdesigner/synthmodel/UIRegion.java
+0
-253
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIState.java
...lasses/org/jdesktop/synthdesigner/synthmodel/UIState.java
+0
-298
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIStateType.java
...es/org/jdesktop/synthdesigner/synthmodel/UIStateType.java
+0
-129
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIStyle.java
...lasses/org/jdesktop/synthdesigner/synthmodel/UIStyle.java
+0
-467
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/BorderMapper.java
...op/synthdesigner/synthmodel/jibxhelpers/BorderMapper.java
+0
-285
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/ClassMapper.java
...top/synthdesigner/synthmodel/jibxhelpers/ClassMapper.java
+0
-78
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/FontMapper.java
...ktop/synthdesigner/synthmodel/jibxhelpers/FontMapper.java
+0
-86
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/UIPropertyMapper.java
...ynthdesigner/synthmodel/jibxhelpers/UIPropertyMapper.java
+0
-155
src/share/classes/com/sun/beans/finder/BeanInfoFinder.java
src/share/classes/com/sun/beans/finder/BeanInfoFinder.java
+8
-12
src/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java
...sses/com/sun/java/swing/plaf/windows/DesktopProperty.java
+15
-33
src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java
...com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java
+156
-236
src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
...s/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
+57
-115
src/share/classes/java/util/SimpleTimeZone.java
src/share/classes/java/util/SimpleTimeZone.java
+2
-2
src/share/classes/javax/swing/JEditorPane.java
src/share/classes/javax/swing/JEditorPane.java
+13
-6
src/share/classes/javax/swing/JLayer.java
src/share/classes/javax/swing/JLayer.java
+61
-42
src/share/classes/javax/swing/JList.java
src/share/classes/javax/swing/JList.java
+6
-4
src/share/classes/javax/swing/JTable.java
src/share/classes/javax/swing/JTable.java
+12
-11
src/share/classes/javax/swing/JTextField.java
src/share/classes/javax/swing/JTextField.java
+3
-5
src/share/classes/javax/swing/JTextPane.java
src/share/classes/javax/swing/JTextPane.java
+5
-0
src/share/classes/javax/swing/JTree.java
src/share/classes/javax/swing/JTree.java
+6
-4
src/share/classes/javax/swing/SwingUtilities.java
src/share/classes/javax/swing/SwingUtilities.java
+10
-14
src/share/classes/javax/swing/plaf/LayerUI.java
src/share/classes/javax/swing/plaf/LayerUI.java
+35
-9
src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
+2
-1
src/share/classes/javax/swing/plaf/metal/MetalFontDesktopProperty.java
...sses/javax/swing/plaf/metal/MetalFontDesktopProperty.java
+4
-6
src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
...hare/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
+2
-4
src/share/classes/javax/swing/plaf/nimbus/Defaults.template
src/share/classes/javax/swing/plaf/nimbus/Defaults.template
+113
-136
src/share/classes/javax/swing/plaf/nimbus/DerivedColor.java
src/share/classes/javax/swing/plaf/nimbus/DerivedColor.java
+10
-33
src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java
...re/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java
+64
-2
src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java
src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java
+22
-168
src/share/classes/javax/swing/plaf/synth/SynthMenuItemLayoutHelper.java
...ses/javax/swing/plaf/synth/SynthMenuItemLayoutHelper.java
+1
-1
src/share/classes/javax/swing/text/JTextComponent.java
src/share/classes/javax/swing/text/JTextComponent.java
+27
-6
src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java
...e/classes/javax/swing/tree/DefaultTreeSelectionModel.java
+8
-5
src/share/classes/sun/swing/MenuItemLayoutHelper.java
src/share/classes/sun/swing/MenuItemLayoutHelper.java
+1
-16
src/share/classes/sun/swing/SwingUtilities2.java
src/share/classes/sun/swing/SwingUtilities2.java
+136
-208
src/solaris/native/java/util/TimeZone_md.c
src/solaris/native/java/util/TimeZone_md.c
+19
-50
src/windows/classes/sun/awt/windows/fontconfig.properties
src/windows/classes/sun/awt/windows/fontconfig.properties
+53
-25
src/windows/lib/tzmappings
src/windows/lib/tzmappings
+26
-19
test/com/sun/java/swing/plaf/windows/Test6824600.java
test/com/sun/java/swing/plaf/windows/Test6824600.java
+70
-0
test/java/util/TimeZone/ListTimeZones.java
test/java/util/TimeZone/ListTimeZones.java
+15
-18
test/javax/swing/JFileChooser/6484091/bug6484091.java
test/javax/swing/JFileChooser/6484091/bug6484091.java
+61
-0
test/javax/swing/JLayer/6824395/bug6824395.java
test/javax/swing/JLayer/6824395/bug6824395.java
+80
-0
test/javax/swing/JLayer/6872503/bug6872503.java
test/javax/swing/JLayer/6872503/bug6872503.java
+135
-0
test/javax/swing/JLayer/6875153/bug6875153.java
test/javax/swing/JLayer/6875153/bug6875153.java
+20
-16
test/javax/swing/JLayer/SerializationTest/SerializationTest.java
...vax/swing/JLayer/SerializationTest/SerializationTest.java
+24
-1
test/javax/swing/JSlider/6579827/bug6579827.java
test/javax/swing/JSlider/6579827/bug6579827.java
+68
-0
test/javax/swing/SwingUtilities/6797139/bug6797139.java
test/javax/swing/SwingUtilities/6797139/bug6797139.java
+62
-0
未找到文件。
README
浏览文件 @
04a8b4d8
...
...
@@ -9,35 +9,25 @@ Simple Build Instructions:
http://java.sun.com/javase/downloads/index.jsp
Set the environment variable ALT_BOOTDIR to the location of this JDK 6.
2. Download and install the JIBX libraries, version 1.1.5 from
http://sourceforge.net/project/showfiles.php?group_id=69358&package_id=68290
You'll need the following four JAR files:
bcel.jar
jibx-bind.jar
jibx-run.jar
xpp3.jar
Set the environment variable ALT_JIBX_LIBS_PATH to the location of
these JAR files.
3. Download and install the Binary Plugs for the most recent JDK7 from
2. Download and install the Binary Plugs for the most recent JDK7 from
http://download.java.net/openjdk/jdk7/
Set the environment variable ALT_BINARY_PLUGS_PATH to the location of
these binary plugs.
4
. Either download and install the latest JDK7 from
3
. Either download and install the latest JDK7 from
http://download.java.net/openjdk/jdk7/, or build your own complete
OpenJDK7 by using the top level Makefile in the OpenJDK Mercurial forest.
Set the environment variable ALT_JDK_IMPORT_PATH to the location of
this latest JDK7 or OpenJDK7 build.
5
. Check the sanity of doing a build with the current machine:
4
. Check the sanity of doing a build with the current machine:
cd make && gnumake sanity
See README-builds.html if you run into problems.
6
. Do a partial build of the jdk:
5
. Do a partial build of the jdk:
cd make && gnumake all
7
. Construct the images:
6
. Construct the images:
cd make && gnumake images
The resulting JDK image should be found in build/*/j2sdk-image
...
...
make/common/Sanity.gmk
浏览文件 @
04a8b4d8
...
...
@@ -93,8 +93,7 @@ sanity-all:: sanity-base \
sane-alt_bootdir \
sane-bootdir \
sane-local-bootdir \
sane-alsa-headers \
sane-jibx
sane-alsa-headers
ifdef OPENJDK
sanity-all:: sane-freetype
...
...
make/common/shared/Defs.gmk
浏览文件 @
04a8b4d8
...
...
@@ -536,15 +536,6 @@ endif
# NOTE: ISA_DIR is usually empty, on Solaris it might be /sparcv9 or /amd64
BINDIR = $(OUTPUTDIR)/bin$(ISA_DIR)
# JIBX_LIBS_PATH: path to JIBX libraries, needed for NimbusLookAndFeel
ifdef ALT_JIBX_LIBS_PATH
JIBX_LIBS_PATH:=$(call FullPath,$(ALT_JIBX_LIBS_PATH))
JIBX_LIBS_PATH:=$(call AltCheckSpaces,JIBX_LIBS_PATH)
JIBX_LIBS_PATH:=$(call AltCheckValue,JIBX_LIBS_PATH)
else
JIBX_LIBS_PATH=$(JDK_DEVTOOLS_DIR)/share/jibx/lib
endif
# MOZILLA_HEADERS_PATH: path to mozilla header files for plugin
ifdef ALT_MOZILLA_HEADERS_PATH
MOZILLA_HEADERS_PATH :=$(call FullPath,$(ALT_MOZILLA_HEADERS_PATH))
...
...
make/common/shared/Sanity-Settings.gmk
浏览文件 @
04a8b4d8
...
...
@@ -233,7 +233,6 @@ ifeq ($(PLATFORM),windows)
endif
endif
ALL_SETTINGS+=$(call addAltSetting,CACERTS_FILE)
ALL_SETTINGS+=$(call addAltSetting,JIBX_LIBS_PATH)
ifndef OPENJDK
ALL_SETTINGS+=$(call addAltSetting,MOZILLA_HEADERS_PATH)
endif
...
...
make/common/shared/Sanity.gmk
浏览文件 @
04a8b4d8
...
...
@@ -214,7 +214,6 @@ include $(JDK_MAKE_SHARED_DIR)/Sanity-Settings.gmk
sane-link \
sane-cacerts \
sane-alsa-headers \
sane-jibx \
sane-ant_version \
sane-zip_version \
sane-unzip_version \
...
...
@@ -1516,22 +1515,6 @@ ifeq ($(PLATFORM), solaris)
endif
######################################################
# JIBX_LIBS_PATH must be valid
######################################################
sane-jibx:
ifdef DISABLE_NIMBUS
$(call SanityWarning,Disabling Nimbus will remove public API in javax.swing.plaf.nimbus.)
else
@if [ ! -r $(subst \,/,$(JIBX_LIBS_PATH))/jibx-run.jar ]; then \
$(ECHO) "ERROR: You do not have access to valid JIBX library files. \n" \
" Please check your access to \n" \
" $(subst \,/,$(JIBX_LIBS_PATH))/jibx-run.jar \n" \
" and/or check your value of ALT_JDK_DEVTOOLS_DIR, ALT_JIBX_LIBS_PATH \n" \
"" >> $(ERROR_FILE) ; \
fi
endif
######################################################
# MOZILLA_HEADERS_PATH must be valid
######################################################
...
...
make/javax/swing/plaf/Makefile
浏览文件 @
04a8b4d8
...
...
@@ -34,16 +34,14 @@ include $(BUILDDIR)/common/Defs.gmk
#
include
FILES.gmk
AUTO_FILES_JAVA_DIRS
=
javax/swing/plaf sun/swing com/sun/java/swing/plaf
ifndef
DISABLE_NIMBUS
SUBDIRS
=
nimbus
endif
# Nimbus is handled in its own directory
AUTO_JAVA_PRUNE
=
nimbus
ifeq
($(PLATFORM), windows)
# Don't build GTK L&F on Windows
AUTO_JAVA_PRUNE
+=
gtk
AUTO_JAVA_PRUNE
=
gtk
endif
ifdef
DISABLE_NIMBUS
AUTO_JAVA_PRUNE
+=
nimbus
endif
MISC_FILES
=
$(MISC_SWING_FILES)
...
...
@@ -52,6 +50,10 @@ ifneq ($(PLATFORM), windows)
MISC_FILES
+=
$(MISC_SWING_FILES_UNIX)
endif
NIMBUS_GENSRC_DIR
=
$(GENSRCDIR)
/javax/swing/plaf/nimbus
NIMBUS_SKIN_FILE
=
$(SWING_SRC)
/plaf/nimbus/skin.laf
NIMBUS_GENERATOR_JAR
=
$(BUILDTOOLJARDIR)
/generatenimbus.jar
FILES_java
=
$(FILES_SWING_java)
#
...
...
@@ -75,14 +77,25 @@ endif
# Process LOGO_ICONS and Motif Icons first.
#
build
:
$(LOGO_ICONS) $(MISC_SWING_FILES_MOTIF_GIF) $(MISC_SWING_FILES_MOTIF_PNG) other_files
$
(
SUBDIRS-loop
)
clean clobber
::
$
(
SUBDIRS-loop
)
$(NIMBUS_GENSRC_DIR)
:
$(NIMBUS_SKIN_FILE) $(NIMBUS_GENERATOR_JAR)
@
$(ECHO)
"Generating Nimbus source files:"
$(RM)
-r
$(NIMBUS_GENSRC_DIR)
$(BOOT_JAVA_CMD)
-jar
$(NIMBUS_GENERATOR_JAR)
\
-skinFile
$(NIMBUS_SKIN_FILE)
-buildDir
$(GENSRCDIR)
\
-packagePrefix
$(PACKAGE)
.nimbus
-lafName
Nimbus
@
$(ECHO)
"Finished generating Nimbus source files"
clean
::
classes.clean
$(RM)
-r
$(NIMBUS_GENSRC_DIR)
#
# Include
#
ifndef
DISABLE_NIMBUS
CLASSES_INIT
=
$(NIMBUS_GENSRC_DIR)
endif
include
$(BUILDDIR)/common/Classes.gmk
ifndef
OPENJDK
...
...
make/sun/javazic/tzdata/VERSION
浏览文件 @
04a8b4d8
...
...
@@ -21,4 +21,4 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
tzdata2009
g
tzdata2009
l
make/sun/javazic/tzdata/africa
浏览文件 @
04a8b4d8
...
...
@@ -22,6 +22,8 @@
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# This data is by no means authoritative; if you think you know better,
# go ahead and edit the file (and please send any changes to
...
...
@@ -263,18 +265,18 @@ Rule Egypt 2007 only - Sep Thu>=1 23:00s 0 -
# The following appeared in Red Hat bugzilla[1] (edited):
#
# > $ zdump -v /usr/share/zoneinfo/Africa/Cairo | grep 2009
# > /usr/share/zoneinfo/Africa/Cairo Thu Apr 23 21:59:59 2009 UTC =
3D
Thu =
# > /usr/share/zoneinfo/Africa/Cairo Thu Apr 23 21:59:59 2009 UTC = Thu =
# Apr 23
# > 23:59:59 2009 EET isdst=
3D0 gmtoff=3D
7200
# > /usr/share/zoneinfo/Africa/Cairo Thu Apr 23 22:00:00 2009 UTC =
3D
Fri =
# > 23:59:59 2009 EET isdst=
0 gmtoff=
7200
# > /usr/share/zoneinfo/Africa/Cairo Thu Apr 23 22:00:00 2009 UTC = Fri =
# Apr 24
# > 01:00:00 2009 EEST isdst=
3D1 gmtoff=3D
10800
# > /usr/share/zoneinfo/Africa/Cairo Thu Aug 27 20:59:59 2009 UTC =
3D
Thu =
# > 01:00:00 2009 EEST isdst=
1 gmtoff=
10800
# > /usr/share/zoneinfo/Africa/Cairo Thu Aug 27 20:59:59 2009 UTC = Thu =
# Aug 27
# > 23:59:59 2009 EEST isdst=
3D1 gmtoff=3D
10800
# > /usr/share/zoneinfo/Africa/Cairo Thu Aug 27 21:00:00 2009 UTC =
3D
Thu =
# > 23:59:59 2009 EEST isdst=
1 gmtoff=
10800
# > /usr/share/zoneinfo/Africa/Cairo Thu Aug 27 21:00:00 2009 UTC = Thu =
# Aug 27
# > 23:00:00 2009 EET isdst=
3D0 gmtoff=3D
7200
# > 23:00:00 2009 EET isdst=
0 gmtoff=
7200
#
# > end date should be Thu Sep 24 2009 (Last Thursday in September at 23:59=
# :59)
...
...
@@ -282,11 +284,11 @@ Rule Egypt 2007 only - Sep Thu>=1 23:00s 0 -
#
# timeanddate[2] and another site I've found[3] also support that.
#
# [1] <a href="https://bugzilla.redhat.com/show_bug.cgi?id=
3D
492263">
# https://bugzilla.redhat.com/show_bug.cgi?id=
3D
492263
# [1] <a href="https://bugzilla.redhat.com/show_bug.cgi?id=492263">
# https://bugzilla.redhat.com/show_bug.cgi?id=492263
# </a>
# [2] <a href="http://www.timeanddate.com/worldclock/clockchange.html?n=
3D
53">
# http://www.timeanddate.com/worldclock/clockchange.html?n=
3D
53
# [2] <a href="http://www.timeanddate.com/worldclock/clockchange.html?n=53">
# http://www.timeanddate.com/worldclock/clockchange.html?n=53
# </a>
# [3] <a href="http://wwp.greenwichmeantime.com/time-zone/africa/egypt/">
# http://wwp.greenwichmeantime.com/time-zone/africa/egypt/
...
...
@@ -296,8 +298,27 @@ Rule Egypt 2007 only - Sep Thu>=1 23:00s 0 -
# In 2009 (and for the next several years), Ramadan ends before the fourth
# Thursday in September; Egypt is expected to revert to the last Thursday
# in September.
# From Steffen Thorsen (2009-08-11):
# We have been able to confirm the August change with the Egyptian Cabinet
# Information and Decision Support Center:
# <a href="http://www.timeanddate.com/news/time/egypt-dst-ends-2009.html">
# http://www.timeanddate.com/news/time/egypt-dst-ends-2009.html
# </a>
#
# The Middle East News Agency
# <a href="http://www.mena.org.eg/index.aspx">
# http://www.mena.org.eg/index.aspx
# </a>
# also reports "Egypt starts winter time on August 21"
# today in article numbered "71, 11/08/2009 12:25 GMT."
# Only the title above is available without a subscription to their service,
# and can be found by searching for "winter" in their search engine
# (at least today).
Rule Egypt 2008 only - Aug lastThu 23:00s 0 -
Rule Egypt 2009 max - Sep lastThu 23:00s 0 -
Rule Egypt 2009 only - Aug 20 23:00s 0 -
Rule Egypt 2010 max - Sep lastThu 23:00s 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Cairo 2:05:00 - LMT 1900 Oct
...
...
@@ -499,8 +520,8 @@ Zone Africa/Nouakchott -1:03:48 - LMT 1912
# From Riad M. Hossen Ally (2008-08-03):
# The Government of Mauritius weblink
# <a href="http://www.gov.mu/portal/site/pmosite/menuitem.4ca0efdee47462e7440a600248a521ca/?content_id=
3D
4728ca68b2a5b110VgnVCM1000000a04a8c0RCRD">
# http://www.gov.mu/portal/site/pmosite/menuitem.4ca0efdee47462e7440a600248a521ca/?content_id=
3D
4728ca68b2a5b110VgnVCM1000000a04a8c0RCRD
# <a href="http://www.gov.mu/portal/site/pmosite/menuitem.4ca0efdee47462e7440a600248a521ca/?content_id=4728ca68b2a5b110VgnVCM1000000a04a8c0RCRD">
# http://www.gov.mu/portal/site/pmosite/menuitem.4ca0efdee47462e7440a600248a521ca/?content_id=4728ca68b2a5b110VgnVCM1000000a04a8c0RCRD
# </a>
# Cabinet Decision of July 18th, 2008 states as follows:
#
...
...
@@ -522,11 +543,33 @@ Zone Africa/Nouakchott -1:03:48 - LMT 1912
# http://www.gov.mu/portal/goc/assemblysite/file/bill2708.pdf
# </a>
# From Steffen Thorsen (2009-06-05):
# According to several sources, Mauritius will not continue to observe
# DST the coming summer...
#
# Some sources, in French:
# <a href="http://www.defimedia.info/news/946/Rashid-Beebeejaun-:-%C2%AB-L%E2%80%99heure-d%E2%80%99%C3%A9t%C3%A9-ne-sera-pas-appliqu%C3%A9e-cette-ann%C3%A9e-%C2%BB">
# http://www.defimedia.info/news/946/Rashid-Beebeejaun-:-%C2%AB-L%E2%80%99heure-d%E2%80%99%C3%A9t%C3%A9-ne-sera-pas-appliqu%C3%A9e-cette-ann%C3%A9e-%C2%BB
# </a>
# <a href="http://lexpress.mu/Story/3398~Beebeejaun---Les-objectifs-d-%C3%A9conomie-d-%C3%A9nergie-de-l-heure-d-%C3%A9t%C3%A9-ont-%C3%A9t%C3%A9-atteints-">
# http://lexpress.mu/Story/3398~Beebeejaun---Les-objectifs-d-%C3%A9conomie-d-%C3%A9nergie-de-l-heure-d-%C3%A9t%C3%A9-ont-%C3%A9t%C3%A9-atteints-
# </a>
#
# Our wrap-up:
# <a href="http://www.timeanddate.com/news/time/mauritius-dst-will-not-repeat.html">
# http://www.timeanddate.com/news/time/mauritius-dst-will-not-repeat.html
# </a>
# From Arthur David Olson (2009-07-11):
# The "mauritius-dst-will-not-repeat" wrapup includes this:
# "The trial ended on March 29, 2009, when the clocks moved back by one hour
# at 2am (or 02:00) local time..."
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Mauritius 1982 only - Oct 10 0:00 1:00 S
Rule Mauritius 1983 only - Mar 21 0:00 0 -
Rule Mauritius 2008
max - Oct lastSun 2:00s
1:00 S
Rule Mauritius 2009
max - Mar lastSun 2:00s
0 -
Rule Mauritius 2008
only - Oct lastSun 2:00
1:00 S
Rule Mauritius 2009
only - Mar lastSun 2:00
0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis
4:00 Mauritius MU%sT # Mauritius Time
...
...
make/sun/javazic/tzdata/antarctica
浏览文件 @
04a8b4d8
...
...
@@ -22,6 +22,8 @@
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# From Paul Eggert (1999-11-15):
# To keep things manageable, we list only locations occupied year-round; see
...
...
make/sun/javazic/tzdata/asia
浏览文件 @
04a8b4d8
...
...
@@ -22,6 +22,8 @@
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# This data is by no means authoritative; if you think you know better,
# go ahead and edit the file (and please send any changes to
...
...
@@ -147,6 +149,57 @@ Zone Asia/Bahrain 3:22:20 - LMT 1920 # Al Manamah
3:00 - AST
# Bangladesh
# From Alexander Krivenyshev (2009-05-13):
# According to newspaper Asian Tribune (May 6, 2009) Bangladesh may introduce
# Daylight Saving Time from June 16 to Sept 30
#
# Bangladesh to introduce daylight saving time likely from June 16
# <a href="http://www.asiantribune.com/?q=node/17288">
# http://www.asiantribune.com/?q=node/17288
# </a>
# or
# <a href="http://www.worldtimezone.com/dst_news/dst_news_bangladesh02.html">
# http://www.worldtimezone.com/dst_news/dst_news_bangladesh02.html
# </a>
#
# "... Bangladesh government has decided to switch daylight saving time from
# June
# 16 till September 30 in a bid to ensure maximum use of daylight to cope with
# crippling power crisis. "
#
# The switch will remain in effect from June 16 to Sept 30 (2009) but if
# implemented the next year, it will come in force from April 1, 2010
# From Steffen Thorsen (2009-06-02):
# They have finally decided now, but changed the start date to midnight between
# the 19th and 20th, and they have not set the end date yet.
#
# Some sources:
# <a href="http://in.reuters.com/article/southAsiaNews/idINIndia-40017620090601">
# http://in.reuters.com/article/southAsiaNews/idINIndia-40017620090601
# </a>
# <a href="http://bdnews24.com/details.php?id=85889&cid=2">
# http://bdnews24.com/details.php?id=85889&cid=2
# </a>
#
# Our wrap-up:
# <a href="http://www.timeanddate.com/news/time/bangladesh-daylight-saving-2009.html">
# http://www.timeanddate.com/news/time/bangladesh-daylight-saving-2009.html
# </a>
# From A. N. M. Kamrus Saadat (2009-06-15):
# Finally we've got the official mail regarding DST start time where DST start
# time is mentioned as Jun 19 2009, 23:00 from BTRC (Bangladesh
# Telecommunication Regulatory Commission).
#
# No DST end date has been announced yet.
# From Arthur David Olson (2009-07-11):
# Arbitrarily end DST at the end of 2009 so that a POSIX-sytle time zone string
# can appear in the Dhaka binary file and for the benefit of old glibc
# reimplementations of the time zone software that mishandle permanent DST.
# A change will be required once the end date is known.
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Dhaka 6:01:40 - LMT 1890
5:53:20 - HMT 1941 Oct # Howrah Mean Time?
...
...
@@ -154,7 +207,9 @@ Zone Asia/Dhaka 6:01:40 - LMT 1890
5:30 - IST 1942 Sep
6:30 - BURT 1951 Sep 30
6:00 - DACT 1971 Mar 26 # Dacca Time
6:00 - BDT # Bangladesh Time
6:00 - BDT 2009 Jun 19 23:00 # Bangladesh Time
6:00 1:00 BDST 2010
6:00 - BDT
# Bhutan
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
...
...
@@ -1129,7 +1184,7 @@ Rule Jordan 1995 1998 - Sep Fri>=15 0:00s 0 -
Rule Jordan 1999 only - Jul 1 0:00s 1:00 S
Rule Jordan 1999 2002 - Sep lastFri 0:00s 0 -
Rule Jordan 2000 2001 - Mar lastThu 0:00s 1:00 S
Rule Jordan 2002 max - Mar last
Fri 0:00s
1:00 S
Rule Jordan 2002 max - Mar last
Thu 24:00
1:00 S
Rule Jordan 2003 only - Oct 24 0:00s 0 -
Rule Jordan 2004 only - Oct 15 0:00s 0 -
Rule Jordan 2005 only - Sep lastFri 0:00s 0 -
...
...
make/sun/javazic/tzdata/australasia
浏览文件 @
04a8b4d8
...
...
@@ -22,6 +22,8 @@
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# This file also includes Pacific islands.
...
...
@@ -447,6 +449,22 @@ Zone Pacific/Pago_Pago 12:37:12 - LMT 1879 Jul 5
-11:00 - SST # S=Samoa
# Samoa
# From Alexander Krivenyshev (2008-12-06):
# The Samoa government (Western Samoa) may implement DST on the first Sunday of
# October 2009 (October 4, 2009) until the last Sunday of March 2010 (March 28,
# 2010).
#
# "Selected Committee reports to Cabinet on Daylight Saving Time",
# Government of Samoa:
# <a href="http://www.govt.ws/pr_article.cfm?pr_id=560">
# http://www.govt.ws/pr_article.cfm?pr_id=560
# </a>
# or
# <a href="http://www.worldtimezone.com/dst_news/dst_news_samoa01.html">
# http://www.worldtimezone.com/dst_news/dst_news_samoa01.html
# </a>
Zone Pacific/Apia 12:33:04 - LMT 1879 Jul 5
-11:26:56 - LMT 1911
-11:30 - SAMT 1950 # Samoa Time
...
...
@@ -1141,6 +1159,27 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901
# From Paul Eggert (2007-07-23):
# See "southeast Australia" above for 2008 and later.
# From Steffen Thorsen (2009-04-28):
# According to the official press release, South Australia's extended daylight
# saving period will continue with the same rules as used during the 2008-2009
# summer (southern hemisphere).
#
# From
# <a href="http://www.safework.sa.gov.au/uploaded_files/DaylightDatesSet.pdf">
# http://www.safework.sa.gov.au/uploaded_files/DaylightDatesSet.pdf
# </a>
# The extended daylight saving period that South Australia has been trialling
# for over the last year is now set to be ongoing.
# Daylight saving will continue to start on the first Sunday in October each
# year and finish on the first Sunday in April the following year.
# Industrial Relations Minister, Paul Caica, says this provides South Australia
# with a consistent half hour time difference with NSW, Victoria, Tasmania and
# the ACT for all 52 weeks of the year...
#
# We have a wrap-up here:
# <a href="http://www.timeanddate.com/news/time/south-australia-extends-dst.html">
# http://www.timeanddate.com/news/time/south-australia-extends-dst.html
# </a>
###############################################################################
# New Zealand
...
...
make/sun/javazic/tzdata/backward
浏览文件 @
04a8b4d8
...
...
@@ -21,6 +21,9 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# This file provides links between current names for time zones
# and their old names. Many names changed in late 1993.
...
...
make/sun/javazic/tzdata/etcetera
浏览文件 @
04a8b4d8
...
...
@@ -21,6 +21,9 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# These entries are mostly present for historical reasons, so that
# people in areas not otherwise covered by the tz files could "zic -l"
...
...
make/sun/javazic/tzdata/europe
浏览文件 @
04a8b4d8
...
...
@@ -22,6 +22,8 @@
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# This data is by no means authoritative; if you think you know better,
# go ahead and edit the file (and please send any changes to
...
...
@@ -479,7 +481,7 @@ Rule EU 1979 1995 - Sep lastSun 1:00u 0 -
Rule EU 1981 max - Mar lastSun 1:00u 1:00 S
Rule EU 1996 max - Oct lastSun 1:00u 0 -
# The most recent directive covers the years starting in 2002. See:
# <a
href="http://europa.eu.int/eur-lex/en/lif/dat/2000/en_300L0084.html
">
# <a
="http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32000L0084:EN:NOT
">
# Directive 2000/84/EC of the European Parliament and of the Council
# of 19 January 2001 on summer-time arrangements.
# </a>
...
...
make/sun/javazic/tzdata/factory
浏览文件 @
04a8b4d8
...
...
@@ -21,6 +21,9 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# For companies who don't want to put time zone specification in
# their installation procedures. When users run date, they'll get the message.
...
...
make/sun/javazic/tzdata/iso3166.tab
浏览文件 @
04a8b4d8
...
...
@@ -21,9 +21,11 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# ISO 3166 alpha-2 country codes
#
#
# From Paul Eggert (2006-09-27):
#
# This file contains a table with the following columns:
...
...
make/sun/javazic/tzdata/leapseconds
浏览文件 @
04a8b4d8
...
...
@@ -21,6 +21,9 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# Allowance for leapseconds added to each timezone file.
...
...
@@ -75,13 +78,13 @@ Leap 2008 Dec 31 23:59:60 + S
# SERVICE DE LA ROTATION TERRESTRE
# OBSERVATOIRE DE PARIS
# 61, Av. de l'Observatoire 75014 PARIS (France)
# Tel. : 33 (0) 1 40 51 22 2
9
# Tel. : 33 (0) 1 40 51 22 2
6
# FAX : 33 (0) 1 40 51 22 91
# Internet : services.iers@obspm.fr
#
# Paris,
15 Januar
y 2009
# Paris,
4 Jul
y 2009
#
# Bulletin C 3
7
# Bulletin C 3
8
#
# To authorities responsible
# for the measurement and
...
...
@@ -89,7 +92,7 @@ Leap 2008 Dec 31 23:59:60 + S
#
# INFORMATION ON UTC - TAI
#
# NO positive leap second will be introduced at the end of
June
2009.
# NO positive leap second will be introduced at the end of
December
2009.
# The difference between Coordinated Universal Time UTC and the
# International Atomic Time TAI is :
#
...
...
@@ -101,6 +104,6 @@ Leap 2008 Dec 31 23:59:60 + S
# will be no time step at the next possible date.
#
# Daniel GAMBIS
#
Head
# Earth Orientation Center of
the
IERS
#
Director
# Earth Orientation Center of IERS
# Observatoire de Paris, France
make/sun/javazic/tzdata/northamerica
浏览文件 @
04a8b4d8
...
...
@@ -22,6 +22,8 @@
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# also includes Central America and the Caribbean
...
...
make/sun/javazic/tzdata/pacificnew
浏览文件 @
04a8b4d8
...
...
@@ -21,6 +21,9 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# From Arthur David Olson (1989-04-05):
# On 1989-04-05, the U. S. House of Representatives passed (238-154) a bill
...
...
make/sun/javazic/tzdata/solar87
浏览文件 @
04a8b4d8
...
...
@@ -21,6 +21,9 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# So much for footnotes about Saudi Arabia.
# Apparent noon times below are for Riyadh; your mileage will vary.
...
...
make/sun/javazic/tzdata/solar88
浏览文件 @
04a8b4d8
...
...
@@ -21,6 +21,9 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# Apparent noon times below are for Riyadh; they're a bit off for other places.
# Times were computed using formulas in the U.S. Naval Observatory's
...
...
make/sun/javazic/tzdata/solar89
浏览文件 @
04a8b4d8
...
...
@@ -21,6 +21,9 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# Apparent noon times below are for Riyadh; they're a bit off for other places.
# Times were computed using a formula provided by the U. S. Naval Observatory:
...
...
make/sun/javazic/tzdata/southamerica
浏览文件 @
04a8b4d8
...
...
@@ -22,6 +22,8 @@
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# This data is by no means authoritative; if you think you know better,
# go ahead and edit the file (and please send any changes to
...
...
@@ -696,8 +698,8 @@ Zone America/La_Paz -4:32:36 - LMT 1890
# From Rodrigo Severo (2008-06-24):
# Just correcting the URL:
# <a href="https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=
3Ddo&secao=3D1&pagina=3D1&data=3D
25/04/2008">
# https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=
3Ddo&secao=3D1&pagina=3D1&data=3D
25/04/2008
# <a href="https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=
do&secao=1&pagina=1&data=
25/04/2008">
# https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=
do&secao=1&pagina=1&data=
25/04/2008
# </a>
#
# As a result of the above Decree I believe the America/Rio_Branco
...
...
make/sun/javazic/tzdata/systemv
浏览文件 @
04a8b4d8
...
...
@@ -21,6 +21,9 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
# Old rules, should the need arise.
# No attempt is made to handle Newfoundland, since it cannot be expressed
...
...
make/sun/javazic/tzdata/zone.tab
浏览文件 @
04a8b4d8
...
...
@@ -21,6 +21,9 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
# <pre>
# This file is in the public domain, so clarified as of
# 2009-05-17 by Arthur David Olson.
#
# TZ zone descriptions
#
...
...
@@ -123,7 +126,7 @@ BR -0640-06952 America/Eirunepe W Amazonas
BR -0958-06748 America/Rio_Branco Acre
BS +2505-07721 America/Nassau
BT +2728+08939 Asia/Thimphu
BW -2
545
+02555 Africa/Gaborone
BW -2
439
+02555 Africa/Gaborone
BY +5354+02734 Europe/Minsk
BZ +1730-08812 America/Belize
CA +4734-05243 America/St_Johns Newfoundland Time, including SE Labrador
...
...
@@ -307,7 +310,7 @@ MY +0310+10142 Asia/Kuala_Lumpur peninsular Malaysia
MY +0133+11020 Asia/Kuching Sabah & Sarawak
MZ -2558+03235 Africa/Maputo
NA -2234+01706 Africa/Windhoek
NC -2216+16
530
Pacific/Noumea
NC -2216+16
627
Pacific/Noumea
NE +1331+00207 Africa/Niamey
NF -2903+16758 Pacific/Norfolk
NG +0627+00324 Africa/Lagos
...
...
@@ -387,7 +390,7 @@ TK -0922-17114 Pacific/Fakaofo
TL -0833+12535 Asia/Dili
TM +3757+05823 Asia/Ashgabat
TN +3648+01011 Africa/Tunis
TO -2110
+
17510 Pacific/Tongatapu
TO -2110
-
17510 Pacific/Tongatapu
TR +4101+02858 Europe/Istanbul
TT +1039-06131 America/Port_of_Spain
TV -0831+17913 Pacific/Funafuti
...
...
@@ -431,7 +434,7 @@ US +211825-1575130 Pacific/Honolulu Hawaii
UY -3453-05611 America/Montevideo
UZ +3940+06648 Asia/Samarkand west Uzbekistan
UZ +4120+06918 Asia/Tashkent east Uzbekistan
VA +4154
+01227
Europe/Vatican
VA +4154
08+0122711
Europe/Vatican
VC +1309-06114 America/St_Vincent
VE +1030-06656 America/Caracas
VG +1827-06437 America/Tortola
...
...
make/tools/Makefile
浏览文件 @
04a8b4d8
...
...
@@ -54,7 +54,7 @@ SUBDIRS = \
CharsetMapping
ifndef
DISABLE_NIMBUS
SUBDIRS
+=
swing-
nimbus
SUBDIRS
+=
generate_
nimbus
endif
all build clean clobber
::
...
...
make/
javax/swing/plaf/
nimbus/Makefile
→
make/
tools/generate_
nimbus/Makefile
浏览文件 @
04a8b4d8
#
# Copyright 1998-200
7
Sun Microsystems, Inc. All Rights Reserved.
# Copyright 1998-200
5
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
...
...
@@ -23,38 +23,50 @@
# have any questions.
#
BUILDDIR
=
../../../..
PACKAGE
=
javax.swing.plaf.nimbus
PRODUCT
=
com
SWING_SRC
=
$(SHARE_SRC)
/classes/javax/swing
#
# Makefile for building the Nimbus generator
#
BUILDDIR
=
../..
PACKAGE
=
build.tools.generatenimbus
PRODUCT
=
tools
PROGRAM
=
generatenimbus
include
$(BUILDDIR)/common/Defs.gmk
BUILDTOOL_SOURCE_ROOT
=
$(BUILDDIR)
/tools/src
BUILDTOOL_MAIN
=
$(PKGDIR)
/Generator.java
#
# Files
#
NIMBUS_PKG
=
javax/swing/plaf/nimbus
NIMBUS_COMPAT_PKG
=
com/sun/java/swing/plaf/nimbus
NIMBUS_GENSRC_DIR
=
$(GENSRCDIR)
/
$(NIMBUS_PKG)
NIMBUS_SKIN_FILE
=
$(SHARE_SRC)
/classes/
$(NIMBUS_PKG)
/skin.laf
NIMBUS_GENERATOR_JAR
=
$(BUILDTOOLJARDIR)
/nimbus_generator.jar
AUTO_FILES_JAVA_DIRS
=
$(NIMBUS_PKG)
$(NIMBUS_COMPAT_PKG)
SOURCE_FILES
=
Generator.java
\
ObjectFactory.java
\
Paint.java
\
SynthModel.java
\
UIDefault.java
\
UIStyle.java
TEMPLATE_FILES
=
Defaults.template
\
PainterImpl.template
\
StateImpl.template
TEMPLATE_DEST
=
$(BUILDTOOLCLASSDIR)
/
$(PKGDIR)
/resources
#
# Rules
#
CLASSES_INIT
=
$(NIMBUS_GENSRC_DIR)
include
$(BUILDDIR)/common/Classes.gmk
all
:
$(TEMPLATE_DEST) $(BUILDTOOL_JAR_FILE)
include
$(BUILDDIR)/common/BuildToolJar.gmk
$(TEMPLATE_DEST)
:
$(TEMPLATE_FILES:%=$(SHARE_SRC)/classes/javax/swing/plaf/nimbus/%)
$(MKDIR)
-p
$@
$(RM)
$
(
TEMPLATE_FILES:%
=
$@
/%
)
$(CP)
$^
$@
$(NIMBUS_GENSRC_DIR)
:
$(NIMBUS_SKIN_FILE) $(NIMBUS_GENERATOR_JAR)
@
$(ECHO)
"Generating Nimbus source files:"
$(BOOT_JAVA_CMD)
-jar
$(NIMBUS_GENERATOR_JAR)
\
-skinFile
$(NIMBUS_SKIN_FILE)
\
-buildDir
$(GENSRCDIR)
-srcDir
$(GENSRCDIR)
\
-packagePrefix
$(PACKAGE)
-lafName
Nimbus
@
$(ECHO)
"Finished generating Nimbus source files"
BUILDTOOL_MAIN_SOURCE_FILE
=
$
(
SOURCE_FILES:%
=
$(BUILDTOOL_SOURCE_ROOT)
/
$(PKGDIR)
/%
)
clean clobber
::
$(RM)
-r
$(
NIMBUS_GENSRC_DIR
)
$(RM)
-r
$(
TEMPLATE_DEST
)
make/tools/s
wing-nimbus/classes/org/jdesktop/synthdesigner/generator
/Generator.java
→
make/tools/s
rc/build/tools/generatenimbus
/Generator.java
浏览文件 @
04a8b4d8
...
...
@@ -22,20 +22,13 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.synthdesigner.generator
;
package
build.tools.generatenimbus
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
TemplateWriter
.
read
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
TemplateWriter
.
writeSrcFile
;
import
org.jdesktop.synthdesigner.synthmodel.SynthModel
;
import
org.jibx.runtime.BindingDirectory
;
import
org.jibx.runtime.IBindingFactory
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.*
;
import
java.util.HashMap
;
import
java.util.Map
;
import
javax.xml.bind.JAXBContext
;
import
javax.xml.bind.Unmarshaller
;
/**
* Generates the various Java artifacts based on a SynthModel.
...
...
@@ -51,12 +44,12 @@ import java.util.Map;
* @author Jasper Potts
*/
public
class
Generator
{
private
static
Generator
instance
;
/** A map of variables that are used for variable substitution in the template files. */
private
Map
<
String
,
String
>
variables
;
private
boolean
full
=
false
;
private
File
buildPackageRoot
;
private
File
srcPackageRoot
;
private
String
packageNamePrefix
;
private
String
lafName
;
private
SynthModel
model
;
...
...
@@ -68,7 +61,7 @@ public class Generator {
*
* @param args The commandline arguments
*/
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
.
length
==
0
||
(
args
.
length
%
2
)
!=
0
)
{
System
.
out
.
println
(
"Usage: generator [-options]\n"
+
" -full <true|false> True if we should build the whole LAF or false for building just states and painters.\n"
+
...
...
@@ -76,9 +69,6 @@ public class Generator {
" -buildDir <value> The directory beneath which the build-controlled artifacts (such as the Painters) should\n"
+
" be placed. This is the root directory beneath which the necessary packages and source\n"
+
" files will be created.\n"
+
" -srcDir <value> The directory beneath which the normal user-controlled artifacts (such as the core\n"
+
" LookAndFeel file) should be placed. These are one-time generated files. This is the root\n"
+
" directory beneath which the necessary packages and source files will be created.\n"
+
" -resourcesDir <value> The resources directory containing templates and images.\n"
+
" -packagePrefix <value> The package name associated with this synth look and feel. For example,\n"
+
" \"org.mypackage.mylaf\"\n"
+
...
...
@@ -87,7 +77,6 @@ public class Generator {
boolean
full
=
false
;
File
skinFile
=
new
File
(
System
.
getProperty
(
"user.dir"
));
File
buildDir
=
new
File
(
System
.
getProperty
(
"user.dir"
));
File
srcDir
=
new
File
(
System
.
getProperty
(
"user.dir"
));
File
resourcesDir
=
new
File
(
System
.
getProperty
(
"user.dir"
));
String
packagePrefix
=
"org.mypackage.mylaf"
;
String
lafName
=
"MyLAF"
;
...
...
@@ -100,8 +89,6 @@ public class Generator {
skinFile
=
new
File
(
value
);
}
else
if
(
"-builddir"
.
equals
(
key
))
{
buildDir
=
new
File
(
value
);
}
else
if
(
"-srcdir"
.
equals
(
key
))
{
srcDir
=
new
File
(
value
);
}
else
if
(
"-resourcesdir"
.
equals
(
key
))
{
resourcesDir
=
new
File
(
value
);
}
else
if
(
"-packageprefix"
.
equals
(
key
))
{
...
...
@@ -114,25 +101,15 @@ public class Generator {
System
.
out
.
println
(
" full :"
+
full
);
System
.
out
.
println
(
" skinFile :"
+
skinFile
.
getAbsolutePath
());
System
.
out
.
println
(
" buildDir :"
+
buildDir
.
getAbsolutePath
());
System
.
out
.
println
(
" srcDir :"
+
srcDir
.
getAbsolutePath
());
System
.
out
.
println
(
" resourcesDir :"
+
resourcesDir
.
getAbsolutePath
());
System
.
out
.
println
(
" packagePrefix :"
+
packagePrefix
);
System
.
out
.
println
(
" lafName :"
+
lafName
);
try
{
// LOAD SKIN MODEL
IBindingFactory
bindingFactory
=
BindingDirectory
.
getFactory
(
SynthModel
.
class
);
IUnmarshallingContext
mctx
=
bindingFactory
.
createUnmarshallingContext
();
mctx
.
setDocument
(
new
FileInputStream
(
skinFile
),
"UTF-8"
);
// pass resources directory in as user context so it can be used in SynthModel preSet
mctx
.
setUserContext
(
resourcesDir
);
SynthModel
model
=
(
SynthModel
)
mctx
.
unmarshalElement
();
// create and run generator
Generator
generator
=
new
Generator
(
full
,
buildDir
,
srcDir
,
packagePrefix
,
lafName
,
model
);
generator
.
generate
();
}
catch
(
Exception
e
)
{
System
.
err
.
println
(
"Error loading skin and generating java src:"
);
e
.
printStackTrace
();
}
JAXBContext
ctx
=
JAXBContext
.
newInstance
(
"build.tools.generatenimbus"
);
Unmarshaller
u
=
ctx
.
createUnmarshaller
();
SynthModel
model
=
(
SynthModel
)
u
.
unmarshal
(
skinFile
);
Generator
.
init
(
full
,
buildDir
,
packagePrefix
,
lafName
,
model
);
Generator
.
getInstance
().
generate
();
}
}
...
...
@@ -152,8 +129,8 @@ public class Generator {
* @param lafName The name of the laf, such as MyLAF.
* @param model The actual SynthModel to base these generated files on.
*/
p
ublic
Generator
(
boolean
full
,
File
buildDir
,
File
srcDir
,
String
packageNamePrefix
,
String
lafName
,
SynthModel
model
)
{
p
rivate
Generator
(
boolean
full
,
File
buildDir
,
String
packageNamePrefix
,
String
lafName
,
SynthModel
model
)
{
this
.
full
=
full
;
//validate the input variables
if
(
packageNamePrefix
==
null
)
{
...
...
@@ -162,9 +139,6 @@ public class Generator {
if
(
buildDir
==
null
)
{
throw
new
IllegalArgumentException
(
"You must specify the build directory"
);
}
if
(
srcDir
==
null
)
{
throw
new
IllegalArgumentException
(
"You must specify the source directory"
);
}
if
(
model
==
null
)
{
throw
new
IllegalArgumentException
(
"You must specify the SynthModel"
);
}
...
...
@@ -183,8 +157,6 @@ public class Generator {
//org.mypackage.mylaf subdirectories)
buildPackageRoot
=
new
File
(
buildDir
,
packageNamePrefix
.
replaceAll
(
"\\."
,
"\\/"
));
buildPackageRoot
.
mkdirs
();
srcPackageRoot
=
new
File
(
srcDir
,
packageNamePrefix
.
replaceAll
(
"\\."
,
"\\/"
));
srcPackageRoot
.
mkdirs
();
//save the variables
this
.
packageNamePrefix
=
packageNamePrefix
;
...
...
@@ -192,98 +164,104 @@ public class Generator {
this
.
model
=
model
;
}
public
void
generate
()
{
//Generate the one-time files. If these files already exist, skip the
//ones that exist and create the missing ones. Register warnings for the
//already existing files.
//TODO Skip existing files, send warnings, etc.
if
(
full
)
{
try
{
//create the LookAndFeel file
String
template
=
read
(
"resources/LookAndFeel.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
srcPackageRoot
,
lafName
+
"LookAndFeel.java"
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
//create the painters and such.
regenerate
();
public
static
void
init
(
boolean
full
,
File
buildDir
,
String
packageNamePrefix
,
String
lafName
,
SynthModel
model
)
{
instance
=
new
Generator
(
full
,
buildDir
,
packageNamePrefix
,
lafName
,
model
);
model
.
initStyles
();
}
public
void
regenerate
()
{
try
{
if
(
full
)
{
//first, create the AbstractRegionPainter.java file.
String
template
=
read
(
"resources/AbstractRegionPainter.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"AbstractRegionPainter.java"
));
//write out BlendingMode.java
template
=
read
(
"resources/BlendingMode.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"BlendingMode.java"
));
//create the SynthPainterImpl class
template
=
read
(
"resources/SynthPainterImpl.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"SynthPainterImpl.java"
));
public
static
Generator
getInstance
()
{
return
instance
;
}
//create the IconImpl class
template
=
read
(
"resources/IconImpl.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
lafName
+
"Icon.java"
));
public
static
Map
<
String
,
String
>
getVariables
()
{
return
new
HashMap
<
String
,
String
>(
instance
.
variables
);
}
//create the StyleImpl class
template
=
read
(
"resources/StyleImpl.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
lafName
+
"Style.java"
));
public
void
generate
()
{
if
(
full
)
{
//create the LookAndFeel file
writeSrcFileImpl
(
"LookAndFeel"
,
variables
,
lafName
+
"LookAndFeel"
);
//write out Effect.java
template
=
read
(
"resources/Effect.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"Effect.java"
));
writeSrcFileImpl
(
"AbstractRegionPainter"
,
variables
);
writeSrcFileImpl
(
"BlendingMode"
,
variables
);
writeSrcFileImpl
(
"SynthPainterImpl"
,
variables
);
writeSrcFileImpl
(
"IconImpl"
,
variables
,
lafName
+
"Icon.java"
);
writeSrcFileImpl
(
"StyleImpl"
,
variables
,
lafName
+
"Style.java"
);
writeSrcFileImpl
(
"Effect"
,
variables
);
writeSrcFileImpl
(
"EffectUtils"
,
variables
);
writeSrcFileImpl
(
"ShadowEffect"
,
variables
);
writeSrcFileImpl
(
"DropShadowEffect"
,
variables
);
writeSrcFileImpl
(
"InnerShadowEffect"
,
variables
);
writeSrcFileImpl
(
"InnerGlowEffect"
,
variables
);
writeSrcFileImpl
(
"OuterGlowEffect"
,
variables
);
writeSrcFileImpl
(
"State"
,
variables
);
writeSrcFileImpl
(
"ImageCache"
,
variables
);
writeSrcFileImpl
(
"ImageScalingHelper"
,
variables
);
}
//next, populate the first set of ui defaults based on what is in the
//various palettes of the synth model
StringBuilder
defBuffer
=
new
StringBuilder
();
StringBuilder
styleBuffer
=
new
StringBuilder
();
model
.
write
(
defBuffer
,
styleBuffer
,
packageNamePrefix
);
//write out EffectUtils.java
template
=
read
(
"resources/EffectUtils.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"EffectUtils.java"
));
Map
<
String
,
String
>
vars
=
getVariables
();
vars
.
put
(
"UI_DEFAULT_INIT"
,
defBuffer
.
toString
());
vars
.
put
(
"STYLE_INIT"
,
styleBuffer
.
toString
());
writeSrcFile
(
"Defaults"
,
vars
,
lafName
+
"Defaults"
);
}
//write out ShadowEffect.java
template
=
read
(
"resources/ShadowEffect.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"ShadowEffect.java"
));
private
void
writeSrcFileImpl
(
String
name
,
Map
<
String
,
String
>
variables
)
{
writeSrcFileImpl
(
name
,
variables
,
name
);
}
//write out DropShadowEffect.java
template
=
read
(
"resources/DropShadowEffect.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"DropShadowEffect.java"
));
private
void
writeSrcFileImpl
(
String
templateName
,
Map
<
String
,
String
>
variables
,
String
outputName
)
{
PrintWriter
out
=
null
;
try
{
InputStream
stream
=
getClass
().
getResourceAsStream
(
"resources/"
+
templateName
+
".template"
);
TemplateReader
in
=
new
TemplateReader
(
variables
,
stream
);
//write out InnerShadowEffect.java
template
=
read
(
"resources/InnerShadowEffect.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"InnerShadowEffect.java"
));
out
=
new
PrintWriter
(
new
File
(
buildPackageRoot
,
outputName
+
".java"
));
String
line
=
in
.
readLine
();
while
(
line
!=
null
)
{
out
.
println
(
line
);
line
=
in
.
readLine
();
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"IOException in writer"
,
e
);
}
finally
{
if
(
out
!=
null
)
out
.
close
();
}
}
//write out InnerGlowEffect.java
template
=
read
(
"resources/InnerGlowEffect.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"InnerGlowEffect.java"
));
public
static
void
writeSrcFile
(
String
templateName
,
Map
<
String
,
String
>
variables
,
String
outputName
)
{
instance
.
writeSrcFileImpl
(
templateName
,
variables
,
outputName
);
}
//write out OuterGlowEffect.java
template
=
read
(
"resources/OuterGlowEffect.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"OuterGlowEffect.java"
));
/** A BufferedReader implementation that automatically performs
* string replacements as needed.
*/
private
static
final
class
TemplateReader
extends
BufferedReader
{
private
Map
<
String
,
String
>
variables
;
//write out State.java
template
=
read
(
"resources/State.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"State.java"
));
TemplateReader
(
Map
<
String
,
String
>
variables
,
InputStream
template
)
{
super
(
new
InputStreamReader
(
template
));
this
.
variables
=
variables
;
}
template
=
read
(
"resources/ImageCache.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"ImageCache.java"
));
@Override
public
String
readLine
()
throws
IOException
{
return
substituteVariables
(
super
.
readLine
());
}
template
=
read
(
"resources/ImageScalingHelper.template"
);
writeSrcFile
(
template
,
variables
,
new
File
(
buildPackageRoot
,
"ImageScalingHelper.java"
));
private
String
substituteVariables
(
String
input
)
{
if
(
input
==
null
)
return
null
;
for
(
Map
.
Entry
<
String
,
String
>
variable
:
variables
.
entrySet
())
{
input
=
input
.
replace
(
"${"
+
variable
.
getKey
()
+
"}"
,
variable
.
getValue
());
}
//next, populate the first set of ui defaults based on what is in the
//various palettes of the synth model
StringBuilder
uiDefaultInit
=
new
StringBuilder
();
StringBuilder
styleInit
=
new
StringBuilder
();
DefaultsGenerator
.
generateDefaults
(
uiDefaultInit
,
styleInit
,
model
,
variables
,
packageNamePrefix
,
buildPackageRoot
);
variables
.
put
(
"UI_DEFAULT_INIT"
,
uiDefaultInit
.
toString
());
variables
.
put
(
"STYLE_INIT"
,
styleInit
.
toString
());
writeSrcFile
(
read
(
"resources/Defaults.template"
),
variables
,
new
File
(
buildPackageRoot
,
lafName
+
"Defaults.java"
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
input
;
}
}
}
make/tools/s
wing-nimbus/classes/org/jdesktop/swingx/designer/effects/OuterGlowEffect
.java
→
make/tools/s
rc/build/tools/generatenimbus/ObjectFactory
.java
浏览文件 @
04a8b4d8
...
...
@@ -22,34 +22,41 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.swingx.designer.effects
;
import
org.jdesktop.swingx.designer.paint.Matte
;
package
build.tools.generatenimbus
;
import
javax.xml.bind.annotation.XmlRegistry
;
import
javax.swing.UIDefaults
;
import
java.awt.Color
;
/**
* OuterGlowEffect
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the test package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
* @author Created by Jasper Potts (Jun 21, 2007)
*/
public
class
OuterGlowEffect
extends
DropShadowEffect
{
protected
OuterGlowEffect
()
{
distance
=
0
;
}
@XmlRegistry
public
class
ObjectFactory
{
public
OuterGlowEffect
(
UIDefaults
uiDefaults
)
{
color
=
new
Matte
(
new
Color
(
255
,
255
,
211
),
uiDefaults
);
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: test
*
*/
public
ObjectFactory
()
{
}
/**
*
Get the display name for this effect
*
Create an instance of {@link SynthModel }
*
* @return The user displayable name
*/
public
S
tring
getDisplayName
()
{
return
"Outer Glow"
;
public
S
ynthModel
createSynthModel
()
{
return
new
SynthModel
()
;
}
}
make/tools/src/build/tools/generatenimbus/Paint.java
0 → 100644
浏览文件 @
04a8b4d8
/*
* Copyright 2002-2007 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
build.tools.generatenimbus
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
public
abstract
class
Paint
{
}
class
Matte
extends
Paint
{
@XmlAttribute
private
int
red
;
@XmlAttribute
private
int
green
;
@XmlAttribute
private
int
blue
;
@XmlAttribute
private
int
alpha
;
@XmlAttribute
private
String
uiDefaultParentName
=
null
;
@XmlAttribute
private
float
hueOffset
=
0
;
@XmlAttribute
private
float
saturationOffset
=
0
;
@XmlAttribute
private
float
brightnessOffset
=
0
;
@XmlAttribute
private
int
alphaOffset
=
0
;
@XmlAttribute
private
String
componentPropertyName
=
null
;
public
String
getComponentPropertyName
()
{
return
componentPropertyName
;
}
@XmlAttribute
private
boolean
uiResource
=
true
;
public
boolean
isAbsolute
()
{
return
uiDefaultParentName
==
null
;
}
public
String
getDeclaration
()
{
if
(
isAbsolute
())
{
return
String
.
format
(
"new Color(%d, %d, %d, %d)"
,
red
,
green
,
blue
,
alpha
);
}
else
{
return
String
.
format
(
"decodeColor(\"%s\", %sf, %sf, %sf, %d)"
,
uiDefaultParentName
,
String
.
valueOf
(
hueOffset
),
String
.
valueOf
(
saturationOffset
),
String
.
valueOf
(
brightnessOffset
),
alphaOffset
);
}
}
public
String
write
()
{
if
(
isAbsolute
())
{
return
String
.
format
(
"%s, %s, %s, %s"
,
red
,
green
,
blue
,
alpha
);
}
else
{
String
s
=
String
.
format
(
"\"%s\", %sf, %sf, %sf, %d"
,
uiDefaultParentName
,
String
.
valueOf
(
hueOffset
),
String
.
valueOf
(
saturationOffset
),
String
.
valueOf
(
brightnessOffset
),
alphaOffset
);
if
(!
uiResource
)
{
s
+=
", false"
;
}
return
s
;
}
}
public
ComponentColor
createComponentColor
(
String
variableName
)
{
return
new
ComponentColor
(
componentPropertyName
,
variableName
,
saturationOffset
,
brightnessOffset
,
alphaOffset
);
}
}
class
ComponentColor
{
private
String
propertyName
;
private
String
defaultColorVariableName
;
private
float
saturationOffset
=
0
,
brightnessOffset
=
0
;
private
int
alphaOffset
=
0
;
ComponentColor
(
String
propertyName
,
String
defaultColorVariableName
,
float
saturationOffset
,
float
brightnessOffset
,
int
alphaOffset
)
{
this
.
propertyName
=
propertyName
;
this
.
defaultColorVariableName
=
defaultColorVariableName
;
this
.
saturationOffset
=
saturationOffset
;
this
.
brightnessOffset
=
brightnessOffset
;
this
.
alphaOffset
=
alphaOffset
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
{
return
true
;
}
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
{
return
false
;
}
ComponentColor
c
=
(
ComponentColor
)
o
;
if
(
alphaOffset
!=
c
.
alphaOffset
)
{
return
false
;
}
if
(
Float
.
compare
(
saturationOffset
,
c
.
saturationOffset
)
!=
0
)
{
return
false
;
}
if
(
Float
.
compare
(
brightnessOffset
,
c
.
brightnessOffset
)
!=
0
)
{
return
false
;
}
if
(
defaultColorVariableName
!=
null
?
!
defaultColorVariableName
.
equals
(
c
.
defaultColorVariableName
)
:
c
.
defaultColorVariableName
!=
null
)
{
return
false
;
}
if
(
propertyName
!=
null
?
!
propertyName
.
equals
(
c
.
propertyName
)
:
c
.
propertyName
!=
null
)
{
return
false
;
}
return
true
;
}
@Override
public
int
hashCode
()
{
int
hash
=
5
;
hash
=
61
*
hash
+
(
this
.
propertyName
!=
null
?
this
.
propertyName
.
hashCode
()
:
0
);
hash
=
61
*
hash
+
(
this
.
defaultColorVariableName
!=
null
?
this
.
defaultColorVariableName
.
hashCode
()
:
0
);
hash
=
61
*
hash
+
Float
.
floatToIntBits
(
this
.
saturationOffset
);
hash
=
61
*
hash
+
Float
.
floatToIntBits
(
this
.
brightnessOffset
);
hash
=
61
*
hash
+
this
.
alphaOffset
;
return
hash
;
}
public
void
write
(
StringBuilder
sb
)
{
sb
.
append
(
" getComponentColor(c, \""
).
append
(
propertyName
).
append
(
"\", "
).
append
(
defaultColorVariableName
).
append
(
", "
).
append
(
saturationOffset
).
append
(
"f, "
).
append
(
brightnessOffset
).
append
(
"f, "
).
append
(
alphaOffset
);
}
}
class
GradientStop
{
@XmlAttribute
private
float
position
;
public
float
getPosition
()
{
return
position
;
}
@XmlAttribute
private
float
midpoint
;
public
float
getMidpoint
()
{
return
midpoint
;
}
@XmlElement
private
Matte
matte
;
public
Matte
getColor
()
{
return
matte
;
}
}
class
AbstractGradient
extends
Paint
{
public
static
enum
CycleMethod
{
NO_CYCLE
,
REFLECT
,
REPEAT
}
@XmlElement
(
name
=
"stop"
)
private
ArrayList
<
GradientStop
>
stops
;
public
List
<
GradientStop
>
getStops
()
{
return
stops
;
}
}
class
Gradient
extends
AbstractGradient
{
}
class
RadialGradient
extends
AbstractGradient
{
}
make/tools/s
wing-nimbus/classes/org/jdesktop/synthdesigner/generator
/PainterGenerator.java
→
make/tools/s
rc/build/tools/generatenimbus
/PainterGenerator.java
浏览文件 @
04a8b4d8
...
...
@@ -22,49 +22,15 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.synthdesigner.generator
;
import
org.jdesktop.swingx.designer.BezierControlPoint
;
import
org.jdesktop.swingx.designer.Canvas
;
import
org.jdesktop.swingx.designer.EllipseShape
;
import
org.jdesktop.swingx.designer.Layer
;
import
org.jdesktop.swingx.designer.PaintedShape
;
import
org.jdesktop.swingx.designer.PathShape
;
import
org.jdesktop.swingx.designer.RectangleShape
;
import
org.jdesktop.swingx.designer.SimpleShape
;
import
org.jdesktop.swingx.designer.TemplateLayer
;
import
org.jdesktop.swingx.designer.paint.Gradient
;
import
org.jdesktop.swingx.designer.paint.Matte
;
import
org.jdesktop.swingx.designer.paint.PaintModel
;
import
org.jdesktop.swingx.designer.paint.RadialGradient
;
import
org.jdesktop.swingx.designer.paint.GradientStop
;
import
org.jdesktop.swingx.designer.paint.AbstractGradient
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
GeneratorUtils
.
makePretty
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
GeneratorUtils
.
toClassName
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
GeneratorUtils
.
toConstantName
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
TemplateWriter
.
read
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
TemplateWriter
.
writeSrcFile
;
import
org.jdesktop.synthdesigner.synthmodel.UIIconRegion
;
import
org.jdesktop.synthdesigner.synthmodel.UIRegion
;
import
org.jdesktop.synthdesigner.synthmodel.UIState
;
import
java.awt.*
;
package
build.tools.generatenimbus
;
import
java.awt.geom.Point2D
;
import
java.beans.Beans
;
import
java.io.File
;
import
java.io.IOException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.InvocationTargetException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
javax.swing.JComponent
;
import
javax.swing.SwingUtilities
;
import
javax.swing.JList
;
import
javax.swing.JTable
;
import
javax.swing.text.JTextComponent
;
/**
* PainterGenerator - Class for generating Painter class java source from a Canvas
...
...
@@ -91,22 +57,6 @@ import javax.swing.text.JTextComponent;
* @author Jasper Potts
*/
public
class
PainterGenerator
{
private
static
String
painterImplTemplate
;
private
static
String
getPainterImplTemplate
()
{
if
(
painterImplTemplate
==
null
)
{
//load the painter template file into an in-memory string to improve performance
//when generating a lot of classes
try
{
painterImplTemplate
=
read
(
"resources/PainterImpl.template"
);
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"Failed to read template files."
);
throw
new
RuntimeException
(
e
);
}
}
return
painterImplTemplate
;
}
//a handful of counters, incremented whenever the associated object type is encounted.
//These counters form the basis of the field and method suffixes.
//These are all 1 based, because I felt like it :-)
...
...
@@ -170,10 +120,8 @@ public class PainterGenerator {
private
void
generate
(
UIRegion
r
)
{
for
(
UIState
state
:
r
.
getBackgroundStates
())
{
System
.
out
.
println
(
"------>"
+
state
.
getName
());
Canvas
canvas
=
state
.
getCanvas
();
String
type
=
r
instanceof
UIIconRegion
?
((
UIIconRegion
)
r
).
getKey
()
:
"Background"
;
String
type
=
(
r
instanceof
UIIconRegion
?
r
.
getKey
()
:
"Background"
)
;
generate
(
state
,
canvas
,
type
);
}
for
(
UIState
state
:
r
.
getForegroundStates
())
{
...
...
@@ -203,13 +151,7 @@ public class PainterGenerator {
.
append
(
" extendedCacheKeys = new Object[] {\n"
);
for
(
int
i
=
0
;
i
<
entry
.
getValue
().
size
();
i
++)
{
ComponentColor
cc
=
entry
.
getValue
().
get
(
i
);
getExtendedCacheKeysCode
.
append
(
" getComponentColor(c, \""
)
.
append
(
cc
.
propertyName
).
append
(
"\", "
)
.
append
(
cc
.
defaultColorVariableName
).
append
(
", "
)
.
append
(
cc
.
saturationOffset
).
append
(
"f, "
)
.
append
(
cc
.
brightnessOffset
).
append
(
"f, "
)
.
append
(
cc
.
alphaOffset
);
cc
.
write
(
getExtendedCacheKeysCode
);
if
(
i
+
1
<
entry
.
getValue
().
size
())
{
getExtendedCacheKeysCode
.
append
(
"),\n"
);
}
else
{
...
...
@@ -228,9 +170,9 @@ public class PainterGenerator {
//type is background, foreground, border, upArrowIcon, etc.
private
void
generate
(
UIState
state
,
Canvas
canvas
,
String
type
)
{
String
states
=
UIState
.
keysToString
(
state
.
getStateKeys
()
);
String
stateType
=
t
oConstantName
(
type
+
"_"
+
states
);
String
paintMethodName
=
"paint"
+
type
+
t
oClassName
(
states
);
String
states
=
state
.
getStateKeys
(
);
String
stateType
=
Utils
.
statesT
oConstantName
(
type
+
"_"
+
states
);
String
paintMethodName
=
"paint"
+
type
+
Utils
.
statesT
oClassName
(
states
);
//create new array for component colors for this state
componentColors
=
new
ArrayList
<
ComponentColor
>();
...
...
@@ -257,171 +199,166 @@ public class PainterGenerator {
Layer
[]
layers
=
canvas
.
getLayers
().
toArray
(
new
Layer
[
0
]);
for
(
int
index
=
layers
.
length
-
1
;
index
>=
0
;
index
--)
{
Layer
layer
=
layers
[
index
];
if
(
layer
instanceof
TemplateLayer
)
{
continue
;
}
//shapes must be painted in reverse order
List
<
S
impleS
hape
>
shapes
=
layer
.
getShapes
();
List
<
Shape
>
shapes
=
layer
.
getShapes
();
for
(
int
i
=
shapes
.
size
()-
1
;
i
>=
0
;
i
--)
{
SimpleShape
s
=
shapes
.
get
(
i
);
if
(
s
instanceof
PaintedShape
)
{
PaintedShape
shape
=
(
PaintedShape
)
s
;
PaintModel
paint
=
shape
.
getPaintModel
();
/*
We attempt to write the minimal number of bytecodes as possible when
generating code. Due to the inherit complexities in determining what
is extraneous, we use the following system:
We first generate the code for the shape. Then, we check to see if
this shape has already been generated. If so, then we defer to an
existing method. If not, then we will create a new methods, stick
the code in it, and refer to that method.
*/
String
shapeMethodName
=
null
;
// will contain the name of the method which creates the shape
String
shapeVariable
=
null
;
// will be one of rect, roundRect, ellipse, or path.
String
shapeMethodBody
=
null
;
if
(
shape
instanceof
RectangleShape
)
{
RectangleShape
rshape
=
(
RectangleShape
)
shape
;
float
x1
=
encode
((
float
)
rshape
.
getX1
(),
a
,
b
,
width
);
float
y1
=
encode
((
float
)
rshape
.
getY1
(),
c
,
d
,
height
);
float
x2
=
encode
((
float
)
rshape
.
getX2
(),
a
,
b
,
width
);
float
y2
=
encode
((
float
)
rshape
.
getY2
(),
c
,
d
,
height
);
if
(
rshape
.
isRounded
())
{
//it is a rounded rectangle
float
rounding
=
(
float
)
rshape
.
getRounding
();
shapeMethodBody
=
" roundRect.setRoundRect("
+
writeDecodeX
(
x1
)
+
", //x\n"
+
" "
+
writeDecodeY
(
y1
)
+
", //y\n"
+
" "
+
writeDecodeX
(
x2
)
+
" - "
+
writeDecodeX
(
x1
)
+
", //width\n"
+
" "
+
writeDecodeY
(
y2
)
+
" - "
+
writeDecodeY
(
y1
)
+
", //height\n"
+
" "
+
rounding
+
"f, "
+
rounding
+
"f); //rounding"
;
shapeVariable
=
"roundRect"
;
}
else
{
shapeMethodBody
=
" rect.setRect("
+
writeDecodeX
(
x1
)
+
", //x\n"
+
" "
+
writeDecodeY
(
y1
)
+
", //y\n"
+
" "
+
writeDecodeX
(
x2
)
+
" - "
+
writeDecodeX
(
x1
)
+
", //width\n"
+
" "
+
writeDecodeY
(
y2
)
+
" - "
+
writeDecodeY
(
y1
)
+
"); //height"
;
shapeVariable
=
"rect"
;
}
}
else
if
(
shape
instanceof
EllipseShape
)
{
EllipseShape
eshape
=
(
EllipseShape
)
shape
;
float
x1
=
encode
((
float
)
eshape
.
getX1
(),
a
,
b
,
width
);
float
y1
=
encode
((
float
)
eshape
.
getY1
(),
c
,
d
,
height
);
float
x2
=
encode
((
float
)
eshape
.
getX2
(),
a
,
b
,
width
);
float
y2
=
encode
((
float
)
eshape
.
getY2
(),
c
,
d
,
height
);
Shape
shape
=
shapes
.
get
(
i
);
Paint
paint
=
shape
.
getPaint
();
/*
We attempt to write the minimal number of bytecodes as possible when
generating code. Due to the inherit complexities in determining what
is extraneous, we use the following system:
We first generate the code for the shape. Then, we check to see if
this shape has already been generated. If so, then we defer to an
existing method. If not, then we will create a new methods, stick
the code in it, and refer to that method.
*/
String
shapeMethodName
=
null
;
// will contain the name of the method which creates the shape
String
shapeVariable
=
null
;
// will be one of rect, roundRect, ellipse, or path.
String
shapeMethodBody
=
null
;
if
(
shape
instanceof
Rectangle
)
{
Rectangle
rshape
=
(
Rectangle
)
shape
;
float
x1
=
encode
((
float
)
rshape
.
getX1
(),
a
,
b
,
width
);
float
y1
=
encode
((
float
)
rshape
.
getY1
(),
c
,
d
,
height
);
float
x2
=
encode
((
float
)
rshape
.
getX2
(),
a
,
b
,
width
);
float
y2
=
encode
((
float
)
rshape
.
getY2
(),
c
,
d
,
height
);
if
(
rshape
.
isRounded
())
{
//it is a rounded rectangle
float
rounding
=
(
float
)
rshape
.
getRounding
();
shapeMethodBody
=
" ellipse.setFrame("
+
" roundRect.setRoundRect("
+
writeDecodeX
(
x1
)
+
", //x\n"
+
" "
+
writeDecodeY
(
y1
)
+
", //y\n"
+
" "
+
writeDecodeX
(
x2
)
+
" - "
+
writeDecodeX
(
x1
)
+
", //width\n"
+
" "
+
writeDecodeY
(
y2
)
+
" - "
+
writeDecodeY
(
y1
)
+
", //height\n"
+
" "
+
rounding
+
"f, "
+
rounding
+
"f); //rounding"
;
shapeVariable
=
"roundRect"
;
}
else
{
shapeMethodBody
=
" rect.setRect("
+
writeDecodeX
(
x1
)
+
", //x\n"
+
" "
+
writeDecodeY
(
y1
)
+
", //y\n"
+
" "
+
writeDecodeX
(
x2
)
+
" - "
+
writeDecodeX
(
x1
)
+
", //width\n"
+
" "
+
writeDecodeY
(
y2
)
+
" - "
+
writeDecodeY
(
y1
)
+
"); //height"
;
shapeVariable
=
"ellipse"
;
}
else
if
(
shape
instanceof
PathShape
)
{
PathShape
pshape
=
(
PathShape
)
shape
;
List
<
BezierControlPoint
>
controlPoints
=
pshape
.
getBezierControlPoints
();
BezierControlPoint
first
,
last
;
first
=
last
=
controlPoints
.
get
(
0
);
StringBuilder
buffer
=
new
StringBuilder
();
buffer
.
append
(
" path.reset();\n"
);
buffer
.
append
(
" path.moveTo("
+
writeDecodeX
(
encode
((
float
)
first
.
getX
(),
a
,
b
,
width
))
+
", "
+
writeDecodeY
(
encode
((
float
)
first
.
getY
(),
c
,
d
,
height
))
+
");\n"
);
for
(
int
j
=
1
;
j
<
controlPoints
.
size
();
j
++)
{
BezierControlPoint
cp
=
controlPoints
.
get
(
j
);
if
(
last
.
getCp2
().
isSharp
()
&&
cp
.
getCp1
().
isSharp
())
{
float
x
=
encode
((
float
)
cp
.
getX
(),
a
,
b
,
width
);
float
y
=
encode
((
float
)
cp
.
getY
(),
c
,
d
,
height
);
buffer
.
append
(
" path.lineTo("
+
writeDecodeX
(
x
)
+
", "
+
writeDecodeY
(
y
)
+
");\n"
);
}
else
{
float
x1
=
encode
((
float
)
last
.
getX
(),
a
,
b
,
width
);
float
y1
=
encode
((
float
)
last
.
getY
(),
c
,
d
,
height
);
float
x2
=
encode
((
float
)
cp
.
getX
(),
a
,
b
,
width
);
float
y2
=
encode
((
float
)
cp
.
getY
(),
c
,
d
,
height
);
buffer
.
append
(
" path.curveTo("
+
writeDecodeBezierX
(
x1
,
last
.
getX
(),
last
.
getCp2X
())
+
", "
+
writeDecodeBezierY
(
y1
,
last
.
getY
(),
last
.
getCp2Y
())
+
", "
+
writeDecodeBezierX
(
x2
,
cp
.
getX
(),
cp
.
getCp1X
())
+
", "
+
writeDecodeBezierY
(
y2
,
cp
.
getY
(),
cp
.
getCp1Y
())
+
", "
+
writeDecodeX
(
x2
)
+
", "
+
writeDecodeY
(
y2
)
+
");\n"
);
}
last
=
cp
;
}
if
(
last
.
getCp2
().
isSharp
()
&&
first
.
getCp1
().
isSharp
())
{
float
x
=
encode
((
float
)
first
.
getX
(),
a
,
b
,
width
);
float
y
=
encode
((
float
)
first
.
getY
(),
c
,
d
,
height
);
shapeVariable
=
"rect"
;
}
}
else
if
(
shape
instanceof
Ellipse
)
{
Ellipse
eshape
=
(
Ellipse
)
shape
;
float
x1
=
encode
((
float
)
eshape
.
getX1
(),
a
,
b
,
width
);
float
y1
=
encode
((
float
)
eshape
.
getY1
(),
c
,
d
,
height
);
float
x2
=
encode
((
float
)
eshape
.
getX2
(),
a
,
b
,
width
);
float
y2
=
encode
((
float
)
eshape
.
getY2
(),
c
,
d
,
height
);
shapeMethodBody
=
" ellipse.setFrame("
+
writeDecodeX
(
x1
)
+
", //x\n"
+
" "
+
writeDecodeY
(
y1
)
+
", //y\n"
+
" "
+
writeDecodeX
(
x2
)
+
" - "
+
writeDecodeX
(
x1
)
+
", //width\n"
+
" "
+
writeDecodeY
(
y2
)
+
" - "
+
writeDecodeY
(
y1
)
+
"); //height"
;
shapeVariable
=
"ellipse"
;
}
else
if
(
shape
instanceof
Path
)
{
Path
pshape
=
(
Path
)
shape
;
List
<
Point
>
controlPoints
=
pshape
.
getControlPoints
();
Point
first
,
last
;
first
=
last
=
controlPoints
.
get
(
0
);
StringBuilder
buffer
=
new
StringBuilder
();
buffer
.
append
(
" path.reset();\n"
);
buffer
.
append
(
" path.moveTo("
+
writeDecodeX
(
encode
((
float
)
first
.
getX
(),
a
,
b
,
width
))
+
", "
+
writeDecodeY
(
encode
((
float
)
first
.
getY
(),
c
,
d
,
height
))
+
");\n"
);
for
(
int
j
=
1
;
j
<
controlPoints
.
size
();
j
++)
{
Point
cp
=
controlPoints
.
get
(
j
);
if
(
last
.
isP2Sharp
()
&&
cp
.
isP1Sharp
())
{
float
x
=
encode
((
float
)
cp
.
getX
(),
a
,
b
,
width
);
float
y
=
encode
((
float
)
cp
.
getY
(),
c
,
d
,
height
);
buffer
.
append
(
" path.lineTo("
+
writeDecodeX
(
x
)
+
", "
+
writeDecodeY
(
y
)
+
");\n"
);
}
else
{
float
x1
=
encode
((
float
)
last
.
getX
(),
a
,
b
,
width
);
float
y1
=
encode
((
float
)
last
.
getY
(),
c
,
d
,
height
);
float
x2
=
encode
((
float
)
first
.
getX
(),
a
,
b
,
width
);
float
y2
=
encode
((
float
)
first
.
getY
(),
c
,
d
,
height
);
float
x2
=
encode
((
float
)
cp
.
getX
(),
a
,
b
,
width
);
float
y2
=
encode
((
float
)
cp
.
getY
(),
c
,
d
,
height
);
buffer
.
append
(
" path.curveTo("
+
writeDecodeBezierX
(
x1
,
last
.
getX
(),
last
.
getCp2X
())
+
", "
+
writeDecodeBezierY
(
y1
,
last
.
getY
(),
last
.
getCp2Y
())
+
", "
+
writeDecodeBezierX
(
x2
,
first
.
getX
(),
first
.
getCp1X
())
+
", "
+
writeDecodeBezierY
(
y2
,
first
.
getY
(),
first
.
getCp1Y
())
+
", "
+
writeDecodeBezierX
(
x2
,
cp
.
getX
(),
cp
.
getCp1X
())
+
", "
+
writeDecodeBezierY
(
y2
,
cp
.
getY
(),
cp
.
getCp1Y
())
+
", "
+
writeDecodeX
(
x2
)
+
", "
+
writeDecodeY
(
y2
)
+
");\n"
);
}
buffer
.
append
(
" path.closePath();"
);
shapeMethodBody
=
buffer
.
toString
();
shapeVariable
=
"path"
;
last
=
cp
;
}
if
(
last
.
isP2Sharp
()
&&
first
.
isP1Sharp
())
{
float
x
=
encode
((
float
)
first
.
getX
(),
a
,
b
,
width
);
float
y
=
encode
((
float
)
first
.
getY
(),
c
,
d
,
height
);
buffer
.
append
(
" path.lineTo("
+
writeDecodeX
(
x
)
+
", "
+
writeDecodeY
(
y
)
+
");\n"
);
}
else
{
throw
new
RuntimeException
(
"Cannot happen unless a new Shape has been defined"
);
float
x1
=
encode
((
float
)
last
.
getX
(),
a
,
b
,
width
);
float
y1
=
encode
((
float
)
last
.
getY
(),
c
,
d
,
height
);
float
x2
=
encode
((
float
)
first
.
getX
(),
a
,
b
,
width
);
float
y2
=
encode
((
float
)
first
.
getY
(),
c
,
d
,
height
);
buffer
.
append
(
" path.curveTo("
+
writeDecodeBezierX
(
x1
,
last
.
getX
(),
last
.
getCp2X
())
+
", "
+
writeDecodeBezierY
(
y1
,
last
.
getY
(),
last
.
getCp2Y
())
+
", "
+
writeDecodeBezierX
(
x2
,
first
.
getX
(),
first
.
getCp1X
())
+
", "
+
writeDecodeBezierY
(
y2
,
first
.
getY
(),
first
.
getCp1Y
())
+
", "
+
writeDecodeX
(
x2
)
+
", "
+
writeDecodeY
(
y2
)
+
");\n"
);
}
buffer
.
append
(
" path.closePath();"
);
shapeMethodBody
=
buffer
.
toString
();
shapeVariable
=
"path"
;
}
else
{
throw
new
RuntimeException
(
"Cannot happen unless a new Shape has been defined"
);
}
//now that we have the shape defined in shapeMethodBody, and a shapeVariable name,
//look to see if such a body has been previously defined.
shapeMethodName
=
methods
.
get
(
shapeMethodBody
);
String
returnType
=
null
;
if
(
shapeMethodName
==
null
)
{
if
(
"rect"
.
equals
(
shapeVariable
))
{
shapeMethodName
=
"decodeRect"
+
rectCounter
++;
returnType
=
"Rectangle2D"
;
}
else
if
(
"roundRect"
.
equals
(
shapeVariable
))
{
shapeMethodName
=
"decodeRoundRect"
+
roundRectCounter
++;
returnType
=
"RoundRectangle2D"
;
}
else
if
(
"ellipse"
.
equals
(
shapeVariable
))
{
shapeMethodName
=
"decodeEllipse"
+
ellipseCounter
++;
returnType
=
"Ellipse2D"
;
}
else
{
shapeMethodName
=
"decodePath"
+
pathCounter
++;
returnType
=
"Path2D"
;
}
methods
.
put
(
shapeMethodBody
,
shapeMethodName
);
//since the method wasn't previously defined, time to define it
shapesCode
.
append
(
" private "
).
append
(
returnType
).
append
(
" "
).
append
(
shapeMethodName
).
append
(
"() {\n"
);
shapesCode
.
append
(
shapeMethodBody
);
shapesCode
.
append
(
"\n"
);
shapesCode
.
append
(
" return "
+
shapeVariable
+
";\n"
);
shapesCode
.
append
(
" }\n\n"
);
//now that we have the shape defined in shapeMethodBody, and a shapeVariable name,
//look to see if such a body has been previously defined.
shapeMethodName
=
methods
.
get
(
shapeMethodBody
);
String
returnType
=
null
;
if
(
shapeMethodName
==
null
)
{
if
(
"rect"
.
equals
(
shapeVariable
))
{
shapeMethodName
=
"decodeRect"
+
rectCounter
++;
returnType
=
"Rectangle2D"
;
}
else
if
(
"roundRect"
.
equals
(
shapeVariable
))
{
shapeMethodName
=
"decodeRoundRect"
+
roundRectCounter
++;
returnType
=
"RoundRectangle2D"
;
}
else
if
(
"ellipse"
.
equals
(
shapeVariable
))
{
shapeMethodName
=
"decodeEllipse"
+
ellipseCounter
++;
returnType
=
"Ellipse2D"
;
}
else
{
shapeMethodName
=
"decodePath"
+
pathCounter
++;
returnType
=
"Path2D"
;
}
methods
.
put
(
shapeMethodBody
,
shapeMethodName
);
//since the method wasn't previously defined, time to define it
shapesCode
.
append
(
" private "
).
append
(
returnType
).
append
(
" "
).
append
(
shapeMethodName
).
append
(
"() {\n"
);
shapesCode
.
append
(
shapeMethodBody
);
shapesCode
.
append
(
"\n"
);
shapesCode
.
append
(
" return "
+
shapeVariable
+
";\n"
);
shapesCode
.
append
(
" }\n\n"
);
}
//now that the method has been defined, I can go on and decode the
//paint. After the paint is decoded, I can write the g.fill() method call,
//using the result of the shapeMethodName. Yay!
//now that the method has been defined, I can go on and decode the
//paint. After the paint is decoded, I can write the g.fill() method call,
//using the result of the shapeMethodName. Yay!
// if (shapeVariable != null) {
//first, calculate the bounds of the shape being painted and store in variables
paintingCode
.
append
(
" "
).
append
(
shapeVariable
).
append
(
" = "
).
append
(
shapeMethodName
).
append
(
"();\n"
);
if
(
paint
instanceof
Matte
)
{
String
colorVariable
=
encodeMatte
((
Matte
)
paint
);
paintingCode
.
append
(
" g.setPaint("
).
append
(
colorVariable
).
append
(
");\n"
);
}
else
if
(
paint
instanceof
Gradient
)
{
String
gradientMethodName
=
encodeGradient
(
shape
,
(
Gradient
)
paint
);
paintingCode
.
append
(
" g.setPaint("
).
append
(
gradientMethodName
).
append
(
"("
).
append
(
shapeVariable
).
append
(
"));\n"
);
}
else
if
(
paint
instanceof
RadialGradient
)
{
String
radialMethodName
=
encodeRadial
(
shape
,
(
RadialGradient
)
paint
);
paintingCode
.
append
(
" g.setPaint("
).
append
(
radialMethodName
).
append
(
"("
).
append
(
shapeVariable
).
append
(
"));\n"
);
}
paintingCode
.
append
(
" g.fill("
).
append
(
shapeVariable
).
append
(
");\n"
);
//first, calculate the bounds of the shape being painted and store in variables
paintingCode
.
append
(
" "
).
append
(
shapeVariable
).
append
(
" = "
).
append
(
shapeMethodName
).
append
(
"();\n"
);
if
(
paint
instanceof
Matte
)
{
String
colorVariable
=
encodeMatte
((
Matte
)
paint
);
paintingCode
.
append
(
" g.setPaint("
).
append
(
colorVariable
).
append
(
");\n"
);
}
else
if
(
paint
instanceof
Gradient
)
{
String
gradientMethodName
=
encodeGradient
(
shape
,
(
Gradient
)
paint
);
paintingCode
.
append
(
" g.setPaint("
).
append
(
gradientMethodName
).
append
(
"("
).
append
(
shapeVariable
).
append
(
"));\n"
);
}
else
if
(
paint
instanceof
RadialGradient
)
{
String
radialMethodName
=
encodeRadial
(
shape
,
(
RadialGradient
)
paint
);
paintingCode
.
append
(
" g.setPaint("
).
append
(
radialMethodName
).
append
(
"("
).
append
(
shapeVariable
).
append
(
"));\n"
);
}
paintingCode
.
append
(
" g.fill("
).
append
(
shapeVariable
).
append
(
");\n"
);
}
}
...
...
@@ -434,8 +371,33 @@ public class PainterGenerator {
}
}
private
float
encode
(
float
x
,
float
a
,
float
b
,
float
width
)
{
return
ObjectCodeConvertors
.
encode
(
x
,
a
,
b
,
width
);
private
float
encode
(
float
x
,
float
a
,
float
b
,
float
w
)
{
float
r
=
0
;
if
(
x
<
a
)
{
r
=
(
x
/
a
);
}
else
if
(
x
>
b
)
{
r
=
2
+
((
x
-
b
)
/
(
w
-
b
));
}
else
if
(
x
==
a
&&
x
==
b
)
{
return
1.5f
;
}
else
{
r
=
1
+
((
x
-
a
)
/
(
b
-
a
));
}
if
(
Float
.
isNaN
(
r
))
{
System
.
err
.
println
(
"[Error] Encountered NaN: encode("
+
x
+
", "
+
a
+
", "
+
b
+
", "
+
w
+
")"
);
return
0
;
}
else
if
(
Float
.
isInfinite
(
r
))
{
System
.
err
.
println
(
"[Error] Encountered Infinity: encode("
+
x
+
", "
+
a
+
", "
+
b
+
", "
+
w
+
")"
);
return
0
;
}
else
if
(
r
<
0
)
{
System
.
err
.
println
(
"[Error] encoded value was less than 0: encode("
+
x
+
", "
+
a
+
", "
+
b
+
", "
+
w
+
")"
);
return
0
;
}
else
if
(
r
>
3
)
{
System
.
err
.
println
(
"[Error] encoded value was greater than 3: encode("
+
x
+
", "
+
a
+
", "
+
b
+
", "
+
w
+
")"
);
return
3
;
}
else
{
return
r
;
}
}
private
String
writeDecodeX
(
float
encodedX
)
{
...
...
@@ -469,30 +431,17 @@ public class PainterGenerator {
}
private
String
encodeMatte
(
Matte
m
)
{
String
declaration
=
null
;
if
(
m
.
isAbsolute
())
{
Color
c
=
m
.
getColor
();
declaration
=
ObjectCodeConvertors
.
convert
(
c
);
}
else
{
declaration
=
"decodeColor(\""
+
m
.
getUiDefaultParentName
()
+
"\", "
+
m
.
getHueOffset
()
+
"f, "
+
m
.
getSaturationOffset
()
+
"f, "
+
m
.
getBrightnessOffset
()
+
"f, "
+
m
.
getAlphaOffset
()
+
")"
;
}
String
declaration
=
m
.
getDeclaration
();
String
variableName
=
colors
.
get
(
declaration
);
if
(
variableName
==
null
)
{
variableName
=
"color"
+
colorCounter
++;
colors
.
put
(
declaration
,
variableName
);
colorCode
.
append
(
" private Color "
).
append
(
variableName
).
append
(
" = "
);
colorCode
.
append
(
declaration
).
append
(
";\n"
);
colorCode
.
append
(
String
.
format
(
" private Color %s = %s;\n"
,
variableName
,
declaration
)
);
}
// handle component colors
if
(
m
.
getComponentPropertyName
()
!=
null
)
{
ComponentColor
cc
=
new
ComponentColor
(
m
.
getComponentPropertyName
(),
variableName
,
m
.
getSaturationOffset
(),
m
.
getBrightnessOffset
(),
m
.
getAlphaOffset
());
ComponentColor
cc
=
m
.
createComponentColor
(
variableName
);
int
index
=
componentColors
.
indexOf
(
cc
);
if
(
index
==
-
1
)
{
index
=
componentColors
.
size
();
...
...
@@ -504,20 +453,7 @@ public class PainterGenerator {
}
}
private
String
encodeColor
(
Color
c
)
{
String
declaration
=
ObjectCodeConvertors
.
convert
(
c
);
String
variableName
=
colors
.
get
(
declaration
);
if
(
variableName
==
null
)
{
variableName
=
"color"
+
colorCounter
++;
colors
.
put
(
declaration
,
variableName
);
colorCode
.
append
(
" private Color "
).
append
(
variableName
).
append
(
" = "
);
colorCode
.
append
(
declaration
).
append
(
";\n"
);
}
return
variableName
;
}
private
String
encodeGradient
(
PaintedShape
ps
,
Gradient
g
)
{
private
String
encodeGradient
(
Shape
ps
,
Gradient
g
)
{
StringBuilder
b
=
new
StringBuilder
();
float
x1
=
(
float
)
ps
.
getPaintX1
();
float
y1
=
(
float
)
ps
.
getPaintY1
();
...
...
@@ -633,7 +569,7 @@ public class PainterGenerator {
b
.
append
(
"}"
);
}
private
String
encodeRadial
(
Painted
Shape
ps
,
RadialGradient
g
)
{
private
String
encodeRadial
(
Shape
ps
,
RadialGradient
g
)
{
float
centerX1
=
(
float
)
ps
.
getPaintX1
();
float
centerY1
=
(
float
)
ps
.
getPaintY1
();
float
x2
=
(
float
)
ps
.
getPaintX2
();
...
...
@@ -669,15 +605,14 @@ public class PainterGenerator {
}
//note that this method is not thread-safe. In fact, none of this class is.
static
void
writePainter
(
UIRegion
r
,
Map
<
String
,
String
>
variables
,
File
painterPackageRoot
,
String
prefix
)
throws
IOException
{
public
static
void
writePainter
(
UIRegion
r
,
String
painterName
)
{
//Need only write out the stuff for this region, don't need to worry about subregions
//since this method will be called for each of those (and they go in their own file, anyway).
//The only subregion that we compound into this is the one for icons.
String
painterName
=
makePretty
(
prefix
)
+
"Painter"
;
PainterGenerator
gen
=
new
PainterGenerator
(
r
);
System
.
out
.
println
(
"Generating source file: "
+
painterName
+
".java"
);
System
.
out
.
println
(
gen
.
stateTypeCode
.
toString
());
Map
<
String
,
String
>
variables
=
Generator
.
getVariables
();
variables
.
put
(
"PAINTER_NAME"
,
painterName
);
variables
.
put
(
"STATIC_DECL"
,
gen
.
stateTypeCode
.
toString
());
variables
.
put
(
"COLORS_DECL"
,
gen
.
colorCode
.
toString
());
...
...
@@ -687,72 +622,6 @@ public class PainterGenerator {
variables
.
put
(
"SHAPES_DECL"
,
gen
.
shapesCode
.
toString
());
variables
.
put
(
"GRADIENTS_DECL"
,
gen
.
gradientsCode
.
toString
());
writeSrcFile
(
getPainterImplTemplate
(),
variables
,
new
File
(
painterPackageRoot
,
painterName
+
".java"
));
variables
.
remove
(
"PAINTER_NAME"
);
variables
.
remove
(
"STATIC_DECL"
);
variables
.
remove
(
"COLORS_DECL"
);
variables
.
remove
(
"DO_PAINT_SWITCH_BODY"
);
variables
.
remove
(
"PAINTING_DECL"
);
variables
.
remove
(
"SHAPES_DECL"
);
variables
.
remove
(
"GRADIENTS_DECL"
);
}
/**
* Represents the usage of a color from a component within a painter. That
* is, a painter can use colors from the component when it paints. This
* class represents the usage of such a color, containing a reference to
* the name of the property that contains the color, and the various
* derivation offsets to apply to that color.
*/
private
static
class
ComponentColor
{
public
String
propertyName
;
public
String
defaultColorVariableName
;
private
float
saturationOffset
=
0
,
brightnessOffset
=
0
;
private
int
alphaOffset
=
0
;
private
ComponentColor
(
String
propertyName
,
String
defaultColorVariableName
,
float
saturationOffset
,
float
brightnessOffset
,
int
alphaOffset
)
{
this
.
propertyName
=
propertyName
;
this
.
defaultColorVariableName
=
defaultColorVariableName
;
this
.
saturationOffset
=
saturationOffset
;
this
.
brightnessOffset
=
brightnessOffset
;
this
.
alphaOffset
=
alphaOffset
;
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
ComponentColor
c
=
(
ComponentColor
)
o
;
if
(
alphaOffset
!=
c
.
alphaOffset
)
return
false
;
if
(
Float
.
compare
(
saturationOffset
,
c
.
saturationOffset
)
!=
0
)
return
false
;
if
(
Float
.
compare
(
brightnessOffset
,
c
.
brightnessOffset
)
!=
0
)
return
false
;
if
(
defaultColorVariableName
!=
null
?
!
defaultColorVariableName
.
equals
(
c
.
defaultColorVariableName
)
:
c
.
defaultColorVariableName
!=
null
)
return
false
;
if
(
propertyName
!=
null
?
!
propertyName
.
equals
(
c
.
propertyName
)
:
c
.
propertyName
!=
null
)
return
false
;
return
true
;
}
@Override
public
int
hashCode
()
{
int
hash
=
5
;
hash
=
61
*
hash
+
(
this
.
propertyName
!=
null
?
this
.
propertyName
.
hashCode
()
:
0
);
hash
=
61
*
hash
+
(
this
.
defaultColorVariableName
!=
null
?
this
.
defaultColorVariableName
.
hashCode
()
:
0
);
hash
=
61
*
hash
+
Float
.
floatToIntBits
(
this
.
saturationOffset
);
hash
=
61
*
hash
+
Float
.
floatToIntBits
(
this
.
brightnessOffset
);
hash
=
61
*
hash
+
this
.
alphaOffset
;
return
hash
;
}
Generator
.
writeSrcFile
(
"PainterImpl"
,
variables
,
painterName
);
}
}
make/tools/src/build/tools/generatenimbus/Shape.java
0 → 100644
浏览文件 @
04a8b4d8
/*
* Copyright 2002-2007 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
build.tools.generatenimbus
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlElementWrapper
;
import
javax.xml.bind.annotation.XmlElements
;
public
abstract
class
Shape
{
@XmlElement
private
PaintPoints
paintPoints
;
public
double
getPaintX1
()
{
return
paintPoints
.
x1
;
}
public
double
getPaintX2
()
{
return
paintPoints
.
x2
;
}
public
double
getPaintY1
()
{
return
paintPoints
.
y1
;
}
public
double
getPaintY2
()
{
return
paintPoints
.
y2
;
}
@XmlElements
({
@XmlElement
(
name
=
"matte"
,
type
=
Matte
.
class
),
@XmlElement
(
name
=
"gradient"
,
type
=
Gradient
.
class
),
@XmlElement
(
name
=
"radialGradient"
,
type
=
RadialGradient
.
class
)
})
private
Paint
paint
;
public
Paint
getPaint
()
{
return
paint
;
}
static
class
PaintPoints
{
@XmlAttribute
double
x1
;
@XmlAttribute
double
y1
;
@XmlAttribute
double
x2
;
@XmlAttribute
double
y2
;
}
}
class
Point
{
@XmlAttribute
private
double
x
;
public
double
getX
()
{
return
x
;
}
@XmlAttribute
private
double
y
;
public
double
getY
()
{
return
y
;
}
@XmlAttribute
(
name
=
"cp1x"
)
private
double
cp1x
;
public
double
getCp1X
()
{
return
cp1x
;
}
@XmlAttribute
(
name
=
"cp1y"
)
private
double
cp1y
;
public
double
getCp1Y
()
{
return
cp1y
;
}
@XmlAttribute
(
name
=
"cp2x"
)
private
double
cp2x
;
public
double
getCp2X
()
{
return
cp2x
;
}
@XmlAttribute
(
name
=
"cp2y"
)
private
double
cp2y
;
public
double
getCp2Y
()
{
return
cp2y
;
}
public
boolean
isP1Sharp
()
{
return
cp1x
==
x
&&
cp1y
==
y
;
}
public
boolean
isP2Sharp
()
{
return
cp2x
==
x
&&
cp2y
==
y
;
}
}
class
Path
extends
Shape
{
@XmlElement
(
name
=
"point"
)
@XmlElementWrapper
(
name
=
"points"
)
private
List
<
Point
>
controlPoints
=
new
ArrayList
<
Point
>();
public
List
<
Point
>
getControlPoints
()
{
return
controlPoints
;
}
}
class
Rectangle
extends
Shape
{
@XmlAttribute
private
double
x1
;
public
double
getX1
()
{
return
x1
;
}
@XmlAttribute
private
double
x2
;
public
double
getX2
()
{
return
x2
;
}
@XmlAttribute
private
double
y1
;
public
double
getY1
()
{
return
y1
;
}
@XmlAttribute
private
double
y2
;
public
double
getY2
()
{
return
y2
;
}
@XmlAttribute
public
double
getRounding
()
{
double
rounding
=
Math
.
abs
(
roundingX
-
x1
)
*
2
;
return
rounding
>
2
?
rounding
:
0
;
}
public
void
setRounding
(
double
rounding
)
{
if
(
rounding
>
0
&&
rounding
<
2
)
{
rounding
=
0
;
}
roundingX
=
rounding
/
2
d
+
x1
;
}
private
double
roundingX
;
public
boolean
isRounded
()
{
return
getRounding
()
>
0
;
}
}
class
Ellipse
extends
Shape
{
@XmlAttribute
private
double
x1
;
public
double
getX1
()
{
return
x1
;
}
@XmlAttribute
private
double
x2
;
public
double
getX2
()
{
return
x2
;
}
@XmlAttribute
private
double
y1
;
public
double
getY1
()
{
return
y1
;
}
@XmlAttribute
private
double
y2
;
public
double
getY2
()
{
return
y2
;
}
}
make/tools/src/build/tools/generatenimbus/SynthModel.java
0 → 100644
浏览文件 @
04a8b4d8
/*
* Copyright 2002-2007 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
build.tools.generatenimbus
;
import
java.awt.Font
;
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.xml.bind.annotation.*
;
@XmlRootElement
(
name
=
"synthModel"
)
public
class
SynthModel
{
@XmlElement
private
UIStyle
style
;
@XmlElement
(
name
=
"uiColor"
)
@XmlElementWrapper
(
name
=
"colors"
)
private
ArrayList
<
UIColor
>
colors
;
@XmlElement
(
name
=
"uiFont"
)
@XmlElementWrapper
(
name
=
"fonts"
)
private
ArrayList
<
UIFont
>
fonts
;
@XmlElement
(
name
=
"uiComponent"
)
@XmlElementWrapper
(
name
=
"components"
)
private
ArrayList
<
UIComponent
>
components
;
public
void
initStyles
()
{
for
(
UIComponent
c:
components
)
{
c
.
initStyles
(
this
.
style
);
}
}
public
void
write
(
StringBuilder
defBuffer
,
StringBuilder
styleBuffer
,
String
packageName
)
{
defBuffer
.
append
(
" //Color palette\n"
);
for
(
UIColor
c:
colors
)
defBuffer
.
append
(
c
.
write
());
defBuffer
.
append
(
'\n'
);
defBuffer
.
append
(
" //Font palette\n"
);
defBuffer
.
append
(
" d.put(\"defaultFont\", new FontUIResource(defaultFont));\n"
);
for
(
UIFont
f:
fonts
)
defBuffer
.
append
(
f
.
write
());
defBuffer
.
append
(
'\n'
);
defBuffer
.
append
(
" //Border palette\n"
);
defBuffer
.
append
(
'\n'
);
defBuffer
.
append
(
" //The global style definition\n"
);
defBuffer
.
append
(
style
.
write
(
""
));
defBuffer
.
append
(
'\n'
);
for
(
UIComponent
c:
components
)
{
String
prefix
=
Utils
.
escape
(
c
.
getKey
());
defBuffer
.
append
(
" //Initialize "
).
append
(
prefix
).
append
(
"\n"
);
c
.
write
(
defBuffer
,
styleBuffer
,
c
,
prefix
,
packageName
);
defBuffer
.
append
(
'\n'
);
}
}
}
class
Typeface
{
public
enum
DeriveStyle
{
Default
,
Off
,
On
;
@Override
public
String
toString
()
{
switch
(
this
)
{
default
:
return
"null"
;
case
On:
return
"true"
;
case
Off:
return
"false"
;
}
}
}
@XmlAttribute
private
String
uiDefaultParentName
;
@XmlAttribute
(
name
=
"family"
)
private
String
name
;
@XmlAttribute
private
int
size
;
@XmlAttribute
private
DeriveStyle
bold
=
DeriveStyle
.
Default
;
@XmlAttribute
private
DeriveStyle
italic
=
DeriveStyle
.
Default
;
@XmlAttribute
private
float
sizeOffset
=
1
f
;
public
boolean
isAbsolute
()
{
return
uiDefaultParentName
==
null
;
}
public
String
write
()
{
if
(
isAbsolute
())
{
int
style
=
Font
.
PLAIN
;
if
(
bold
==
DeriveStyle
.
On
)
{
style
=
style
|
Font
.
BOLD
;
}
if
(
italic
==
DeriveStyle
.
On
)
{
style
=
style
|
Font
.
ITALIC
;
}
return
String
.
format
(
"new javax.swing.plaf.FontUIResource(\"%s\", %d, %d)"
,
name
,
style
,
size
);
}
else
{
return
String
.
format
(
"new DerivedFont(\"%s\", %sf, %s, %s)"
,
uiDefaultParentName
,
String
.
valueOf
(
sizeOffset
),
bold
,
italic
);
}
}
}
class
Border
{
enum
BorderType
{
@XmlEnumValue
(
"empty"
)
EMPTY
,
@XmlEnumValue
(
"painter"
)
PAINTER
}
@XmlAttribute
private
BorderType
type
;
@XmlAttribute
private
String
painter
;
@XmlAttribute
private
int
top
;
@XmlAttribute
private
int
left
;
@XmlAttribute
private
int
bottom
;
@XmlAttribute
private
int
right
;
public
String
write
()
{
switch
(
type
)
{
case
PAINTER:
return
String
.
format
(
"new PainterBorder(\"%s\", new Insets(%d, %d, %d, %d))"
,
painter
,
top
,
left
,
bottom
,
right
);
case
EMPTY:
return
String
.
format
(
"BorderFactory.createEmptyBorder(%d, %d, %d, %d)"
,
top
,
left
,
bottom
,
right
);
default
:
return
"### Look, here's an unknown border! $$$"
;
}
}
}
class
Insets
{
@XmlAttribute
int
top
;
@XmlAttribute
int
left
;
@XmlAttribute
int
bottom
;
@XmlAttribute
int
right
;
public
Insets
()
{
this
(
0
,
0
,
0
,
0
);
}
public
Insets
(
int
top
,
int
left
,
int
bottom
,
int
right
)
{
this
.
top
=
top
;
this
.
left
=
left
;
this
.
bottom
=
bottom
;
this
.
right
=
right
;
}
public
String
write
(
boolean
uiResource
)
{
String
uiSuffix
=
(
uiResource
?
"UIResource"
:
""
);
return
String
.
format
(
"new Insets%s(%d, %d, %d, %d)"
,
uiSuffix
,
top
,
left
,
bottom
,
right
);
}
}
class
Dimension
{
@XmlAttribute
int
width
;
@XmlAttribute
int
height
;
public
String
write
(
boolean
uiResource
)
{
String
uiSuffix
=
(
uiResource
?
"UIResource"
:
""
);
return
String
.
format
(
"new Dimension%s(%d, %d)"
,
uiSuffix
,
width
,
height
);
}
}
class
Canvas
{
@XmlElement
private
Dimension
size
;
public
Dimension
getSize
()
{
return
size
;
}
@XmlElement
(
name
=
"layer"
)
private
List
<
Layer
>
layers
;
public
List
<
Layer
>
getLayers
()
{
return
layers
;
}
@XmlElement
private
Insets
stretchingInsets
=
null
;
public
Insets
getStretchingInsets
()
{
return
stretchingInsets
;
}
public
boolean
isBlank
()
{
return
layers
.
size
()
==
0
||
(
layers
.
size
()
==
1
&&
layers
.
get
(
0
).
isEmpty
());
}
}
class
Layer
{
/** List of shapes in this layer, first shape is painted on top */
@XmlElements
({
@XmlElement
(
name
=
"ellipse"
,
type
=
Ellipse
.
class
),
@XmlElement
(
name
=
"path"
,
type
=
Path
.
class
),
@XmlElement
(
name
=
"rectangle"
,
type
=
Rectangle
.
class
)
})
@XmlElementWrapper
(
name
=
"shapes"
)
private
List
<
Shape
>
shapes
=
new
ArrayList
<
Shape
>();
public
List
<
Shape
>
getShapes
()
{
return
shapes
;
}
public
boolean
isEmpty
()
{
return
shapes
.
isEmpty
();
}
}
make/tools/s
wing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIProperty
.java
→
make/tools/s
rc/build/tools/generatenimbus/UIDefault
.java
浏览文件 @
04a8b4d8
/*
* Copyright 200
5-2006
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 200
2-2007
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
...
...
@@ -22,64 +22,105 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.synthdesigner.synthmodel
;
import
org.jdesktop.beans.AbstractBean
;
package
build.tools.generatenimbus
;
/**
* UIProperty
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIProperty
extends
AbstractBean
{
public
static
enum
PropertyType
{
BOOLEAN
,
INT
,
FLOAT
,
DOUBLE
,
STRING
,
FONT
,
COLOR
,
INSETS
,
DIMENSION
,
BORDER
}
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
private
String
name
;
private
PropertyType
typ
e
;
private
Object
value
;
public
class
UIDefault
<
T
>
{
@XmlAttribute
private
String
nam
e
;
private
T
value
;
protected
UIProperty
()
{
public
String
getName
()
{
return
name
;
}
public
UIProperty
(
String
name
,
PropertyType
type
,
Object
value
)
{
this
.
name
=
name
;
this
.
type
=
type
;
public
T
getValue
()
{
return
value
;
}
public
void
setValue
(
T
value
)
{
this
.
value
=
value
;
}
}
// =================================================================================================================
// Bean Methods
class
UIColor
extends
UIDefault
<
Matte
>
{
public
String
getName
()
{
return
name
;
@XmlElement
public
void
setMatte
(
Matte
m
)
{
setValue
(
m
);
}
public
void
setName
(
String
name
)
{
String
old
=
getName
();
this
.
name
=
name
;
firePropertyChange
(
"name"
,
old
,
getName
());
public
String
write
()
{
return
String
.
format
(
" addColor(d, \"%s\", %s);\n"
,
getName
(),
getValue
().
write
());
}
}
public
PropertyType
getType
()
{
return
type
;
class
UIFont
extends
UIDefault
<
Typeface
>
{
@XmlElement
public
void
setTypeface
(
Typeface
t
)
{
setValue
(
t
);
}
public
void
setType
(
PropertyType
type
)
{
PropertyType
old
=
getType
();
this
.
type
=
type
;
firePropertyChange
(
"type"
,
old
,
getType
());
public
String
write
()
{
return
String
.
format
(
" d.put(\"%s\", %s);\n"
,
getName
(),
getValue
().
write
());
}
}
public
Object
getValue
()
{
return
value
;
class
UIProperty
extends
UIDefault
<
String
>
{
public
static
enum
PropertyType
{
BOOLEAN
,
INT
,
FLOAT
,
DOUBLE
,
STRING
,
FONT
,
COLOR
,
INSETS
,
DIMENSION
,
BORDER
}
@XmlAttribute
private
PropertyType
type
;
public
void
setValue
(
Object
value
)
{
Object
old
=
getValue
();
this
.
value
=
value
;
firePropertyChange
(
"value"
,
old
,
getValue
());
@XmlElement
private
Border
border
;
@XmlElement
private
Dimension
dimension
;
@XmlElement
private
Insets
insets
;
@XmlElement
private
Matte
matte
;
@XmlElement
private
Typeface
typeface
;
@XmlAttribute
@Override
public
void
setValue
(
String
value
)
{
super
.
setValue
(
value
);
}
public
String
write
(
String
prefix
)
{
switch
(
type
)
{
case
BOOLEAN:
return
String
.
format
(
" d.put(\"%s%s\", Boolean.%s);\n"
,
prefix
,
getName
(),
getValue
().
toUpperCase
());
///autobox
case
STRING:
return
String
.
format
(
" d.put(\"%s%s\", \"%s\");\n"
,
prefix
,
getName
(),
getValue
());
case
INT:
return
String
.
format
(
" d.put(\"%s%s\", new Integer(%s));\n"
,
prefix
,
getName
(),
getValue
());
case
FLOAT:
return
String
.
format
(
" d.put(\"%s%s\", new Float(%sf));\n"
,
prefix
,
getName
(),
getValue
());
case
DOUBLE:
return
String
.
format
(
" d.put(\"%s%s\", new Double(%s));\n"
,
prefix
,
getName
(),
getValue
());
case
COLOR:
return
String
.
format
(
" addColor(d, \"%s%s\", %s);\n"
,
prefix
,
getName
(),
matte
.
write
());
case
FONT:
return
String
.
format
(
" d.put(\"%s%s\", %s);\n"
,
prefix
,
getName
(),
typeface
.
write
());
case
INSETS:
return
String
.
format
(
" d.put(\"%s%s\", %s);\n"
,
prefix
,
getName
(),
insets
.
write
(
true
));
case
DIMENSION:
return
String
.
format
(
" d.put(\"%s%s\", new DimensionUIResource(%d, %d));\n"
,
prefix
,
getName
(),
dimension
.
width
,
dimension
.
height
);
case
BORDER:
return
String
.
format
(
" d.put(\"%s%s\", new BorderUIResource(%s));\n"
,
prefix
,
getName
(),
border
.
write
());
default
:
return
"### Look, something's wrong with UIProperty.write() $$$"
;
}
}
}
make/tools/src/build/tools/generatenimbus/UIStyle.java
0 → 100644
浏览文件 @
04a8b4d8
/*
* Copyright 2002-2007 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
build.tools.generatenimbus
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
javax.xml.bind.annotation.XmlAttribute
;
import
javax.xml.bind.annotation.XmlElement
;
import
javax.xml.bind.annotation.XmlElementWrapper
;
import
javax.xml.bind.annotation.XmlElements
;
class
UIStyle
{
public
static
enum
CacheMode
{
NO_CACHING
,
FIXED_SIZES
,
NINE_SQUARE_SCALE
}
@XmlElement
private
UIColor
textForeground
=
null
;
@XmlElement
(
name
=
"inherit-textForeground"
)
private
boolean
textForegroundInherited
=
true
;
@XmlElement
private
UIColor
textBackground
=
null
;
@XmlElement
(
name
=
"inherit-textBackground"
)
private
boolean
textBackgroundInherited
=
true
;
@XmlElement
private
UIColor
background
=
null
;
@XmlElement
(
name
=
"inherit-background"
)
private
boolean
backgroundInherited
=
true
;
@XmlElement
private
boolean
cacheSettingsInherited
=
true
;
@XmlElement
CacheMode
cacheMode
=
CacheMode
.
FIXED_SIZES
;
@XmlElement
String
maxHozCachedImgScaling
=
"1.0"
;
@XmlElement
String
maxVertCachedImgScaling
=
"1.0"
;
@XmlElement
(
name
=
"uiProperty"
)
@XmlElementWrapper
(
name
=
"uiproperties"
)
private
List
<
UIProperty
>
uiProperties
=
new
ArrayList
<
UIProperty
>();
private
UIStyle
parentStyle
=
null
;
public
void
setParentStyle
(
UIStyle
parentStyle
)
{
this
.
parentStyle
=
parentStyle
;
}
public
CacheMode
getCacheMode
()
{
if
(
cacheSettingsInherited
)
{
return
(
parentStyle
==
null
?
CacheMode
.
FIXED_SIZES
:
parentStyle
.
getCacheMode
());
}
else
{
return
cacheMode
;
}
}
public
String
getMaxHozCachedImgScaling
()
{
if
(
cacheSettingsInherited
)
{
return
(
parentStyle
==
null
?
"1.0"
:
parentStyle
.
getMaxHozCachedImgScaling
());
}
else
{
return
maxHozCachedImgScaling
;
}
}
public
String
getMaxVertCachedImgScaling
()
{
if
(
cacheSettingsInherited
)
{
return
(
parentStyle
==
null
?
"1.0"
:
parentStyle
.
getMaxVertCachedImgScaling
());
}
else
{
return
maxVertCachedImgScaling
;
}
}
public
String
write
(
String
prefix
)
{
StringBuilder
sb
=
new
StringBuilder
();
if
(!
textForegroundInherited
)
{
sb
.
append
(
String
.
format
(
" addColor(d, \"%s%s\", %s);\n"
,
prefix
,
"textForeground"
,
textForeground
.
getValue
().
write
()));
}
if
(!
textBackgroundInherited
)
{
sb
.
append
(
String
.
format
(
" addColor(d, \"%s%s\", %s);\n"
,
prefix
,
"textBackground"
,
textBackground
.
getValue
().
write
()));
}
if
(!
backgroundInherited
)
{
sb
.
append
(
String
.
format
(
" addColor(d, \"%s%s\", %s);\n"
,
prefix
,
"background"
,
background
.
getValue
().
write
()));
}
for
(
UIProperty
property
:
uiProperties
)
{
sb
.
append
(
property
.
write
(
prefix
));
}
return
sb
.
toString
();
}
}
class
UIRegion
{
@XmlAttribute
protected
String
name
;
@XmlAttribute
protected
String
key
;
@XmlAttribute
private
boolean
opaque
=
false
;
@XmlElement
private
Insets
contentMargins
=
new
Insets
(
0
,
0
,
0
,
0
);
@XmlElement
(
name
=
"state"
)
@XmlElementWrapper
(
name
=
"backgroundStates"
)
protected
List
<
UIState
>
backgroundStates
=
new
ArrayList
<
UIState
>();
public
List
<
UIState
>
getBackgroundStates
()
{
return
backgroundStates
;
}
@XmlElement
(
name
=
"state"
)
@XmlElementWrapper
(
name
=
"foregroundStates"
)
protected
List
<
UIState
>
foregroundStates
=
new
ArrayList
<
UIState
>();
public
List
<
UIState
>
getForegroundStates
()
{
return
foregroundStates
;
}
@XmlElement
(
name
=
"state"
)
@XmlElementWrapper
(
name
=
"borderStates"
)
protected
List
<
UIState
>
borderStates
=
new
ArrayList
<
UIState
>();
public
List
<
UIState
>
getBorderStates
()
{
return
borderStates
;
}
@XmlElement
private
UIStyle
style
=
new
UIStyle
();
@XmlElements
({
@XmlElement
(
name
=
"region"
,
type
=
UIRegion
.
class
),
@XmlElement
(
name
=
"uiComponent"
,
type
=
UIComponent
.
class
),
@XmlElement
(
name
=
"uiIconRegion"
,
type
=
UIIconRegion
.
class
)
})
@XmlElementWrapper
(
name
=
"regions"
)
private
List
<
UIRegion
>
subRegions
=
new
ArrayList
<
UIRegion
>();
public
List
<
UIRegion
>
getSubRegions
()
{
return
subRegions
;
}
protected
void
initStyles
(
UIStyle
parentStyle
)
{
style
.
setParentStyle
(
parentStyle
);
for
(
UIState
state:
backgroundStates
)
{
state
.
getStyle
().
setParentStyle
(
this
.
style
);
}
for
(
UIState
state:
foregroundStates
)
{
state
.
getStyle
().
setParentStyle
(
this
.
style
);
}
for
(
UIState
state:
borderStates
)
{
state
.
getStyle
().
setParentStyle
(
this
.
style
);
}
for
(
UIRegion
region:
subRegions
)
{
region
.
initStyles
(
this
.
style
);
}
}
public
String
getKey
()
{
return
key
==
null
||
""
.
equals
(
key
)
?
name
:
key
;
}
private
boolean
hasCanvas
()
{
for
(
UIState
s
:
backgroundStates
)
{
if
(
s
.
hasCanvas
())
return
true
;
}
for
(
UIState
s
:
borderStates
)
{
if
(
s
.
hasCanvas
())
return
true
;
}
for
(
UIState
s
:
foregroundStates
)
{
if
(
s
.
hasCanvas
())
return
true
;
}
for
(
UIRegion
r:
subRegions
)
{
if
(
r
.
hasCanvas
())
return
true
;
}
return
false
;
}
public
void
write
(
StringBuilder
sb
,
StringBuilder
styleBuffer
,
UIComponent
comp
,
String
prefix
,
String
pkg
)
{
// write content margins
sb
.
append
(
String
.
format
(
" d.put(\"%s.contentMargins\", %s);\n"
,
prefix
,
contentMargins
.
write
(
true
)));
// write opaque if true
if
(
opaque
)
{
sb
.
append
(
String
.
format
(
" d.put(\"%s.opaque\", Boolean.TRUE);\n"
,
prefix
));
}
// register component with LAF
String
regionCode
=
"Region."
+
Utils
.
regionNameToCaps
(
name
);
styleBuffer
.
append
(
String
.
format
(
" register(%s, \"%s\");\n"
,
regionCode
,
prefix
));
//write the State, if necessary
StringBuffer
regString
=
new
StringBuffer
();
List
<
UIStateType
>
types
=
comp
.
getStateTypes
();
if
(
types
!=
null
&&
types
.
size
()
>
0
)
{
for
(
UIStateType
type
:
types
)
{
regString
.
append
(
type
.
getKey
());
regString
.
append
(
","
);
}
//remove the last ","
regString
.
deleteCharAt
(
regString
.
length
()
-
1
);
}
if
(!
regString
.
equals
(
"Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Default"
)
&&
types
.
size
()
>
0
)
{
//there were either custom states, or the normal states were in a custom order
//so go ahead and write out prefix.State
sb
.
append
(
String
.
format
(
" d.put(\"%s.States\", \"%s\");\n"
,
prefix
,
regString
));
}
// write out any custom states, if necessary
for
(
UIStateType
type
:
types
)
{
String
synthState
=
type
.
getKey
();
if
(!
"Enabled"
.
equals
(
synthState
)
&&
!
"MouseOver"
.
equals
(
synthState
)
&&
!
"Pressed"
.
equals
(
synthState
)
&&
!
"Disabled"
.
equals
(
synthState
)
&&
!
"Focused"
.
equals
(
synthState
)
&&
!
"Selected"
.
equals
(
synthState
)
&&
!
"Default"
.
equals
(
synthState
))
{
//what we have here, gentlemen, is a bona-fide custom state.
//if the type is not one of the standard types, then construct a name for
//the new type, and write out a new subclass of State.
String
className
=
Utils
.
normalize
(
prefix
)
+
synthState
+
"State"
;
sb
.
append
(
String
.
format
(
" d.put(\"%s.%s\", new %s());\n"
,
prefix
,
synthState
,
className
));
String
body
=
type
.
getCodeSnippet
();
Map
<
String
,
String
>
variables
=
Generator
.
getVariables
();
variables
.
put
(
"STATE_NAME"
,
className
);
variables
.
put
(
"STATE_KEY"
,
synthState
);
variables
.
put
(
"BODY"
,
body
);
Generator
.
writeSrcFile
(
"StateImpl"
,
variables
,
className
);
}
}
// write style
sb
.
append
(
style
.
write
(
prefix
+
'.'
));
String
fileName
=
Utils
.
normalize
(
prefix
)
+
"Painter"
;
boolean
hasCanvas
=
hasCanvas
();
if
(
hasCanvas
)
{
PainterGenerator
.
writePainter
(
this
,
fileName
);
}
// write states ui defaults
for
(
UIState
state
:
backgroundStates
)
{
state
.
write
(
sb
,
prefix
,
pkg
,
fileName
,
"background"
);
}
for
(
UIState
state
:
foregroundStates
)
{
state
.
write
(
sb
,
prefix
,
pkg
,
fileName
,
"foreground"
);
}
for
(
UIState
state
:
borderStates
)
{
state
.
write
(
sb
,
prefix
,
pkg
,
fileName
,
"border"
);
}
// handle sub regions
for
(
UIRegion
subreg
:
subRegions
)
{
String
p
=
prefix
;
if
(!
(
subreg
instanceof
UIIconRegion
))
{
p
=
prefix
+
":"
+
Utils
.
escape
(
subreg
.
getKey
());
}
UIComponent
c
=
comp
;
if
(
subreg
instanceof
UIComponent
)
{
c
=
(
UIComponent
)
subreg
;
}
subreg
.
write
(
sb
,
styleBuffer
,
c
,
p
,
pkg
);
}
}
}
class
UIIconRegion
extends
UIRegion
{
@XmlAttribute
private
String
basicKey
;
@Override
public
void
write
(
StringBuilder
sb
,
StringBuilder
styleBuffer
,
UIComponent
comp
,
String
prefix
,
String
pkg
)
{
Dimension
size
=
null
;
String
fileNamePrefix
=
Utils
.
normalize
(
prefix
)
+
"Painter"
;
// write states ui defaults
for
(
UIState
state
:
backgroundStates
)
{
Canvas
canvas
=
state
.
getCanvas
();
if
(!
canvas
.
isBlank
())
{
state
.
write
(
sb
,
prefix
,
pkg
,
fileNamePrefix
,
getKey
());
size
=
canvas
.
getSize
();
}
}
if
(
size
!=
null
)
{
// Put SynthIconImpl wrapper in UiDefaults
String
k
=
(
basicKey
==
null
?
prefix
+
"."
+
getKey
()
:
basicKey
);
sb
.
append
(
String
.
format
(
" d.put(\"%s\", new NimbusIcon(\"%s\", \"%sPainter\", %d, %d));\n"
,
k
,
prefix
,
getKey
(),
size
.
width
,
size
.
height
));
}
}
}
class
UIComponent
extends
UIRegion
{
@XmlAttribute
private
String
componentName
;
@XmlElement
(
name
=
"stateType"
)
@XmlElementWrapper
(
name
=
"stateTypes"
)
private
List
<
UIStateType
>
stateTypes
=
new
ArrayList
<
UIStateType
>();
public
List
<
UIStateType
>
getStateTypes
()
{
return
stateTypes
;
}
@Override
public
String
getKey
()
{
if
(
key
==
null
||
""
.
equals
(
key
))
{
if
(
componentName
==
null
||
""
.
equals
(
componentName
))
{
return
name
;
}
else
{
return
"\""
+
componentName
+
"\""
;
}
}
else
{
return
key
;
}
}
}
class
UIState
{
@XmlAttribute
private
String
stateKeys
;
public
String
getStateKeys
()
{
return
stateKeys
;
}
/** Indicates whether to invert the meaning of the 9-square stretching insets */
@XmlAttribute
private
boolean
inverted
;
/** A cached string representing the list of stateKeys deliminated with "+" */
private
String
cachedName
=
null
;
@XmlElement
private
Canvas
canvas
;
public
Canvas
getCanvas
()
{
return
canvas
;
}
@XmlElement
private
UIStyle
style
;
public
UIStyle
getStyle
()
{
return
style
;
}
public
boolean
hasCanvas
()
{
return
!
canvas
.
isBlank
();
}
public
static
List
<
String
>
stringToKeys
(
String
keysString
)
{
return
Arrays
.
asList
(
keysString
.
split
(
"\\+"
));
}
public
String
getName
()
{
if
(
cachedName
==
null
)
{
StringBuilder
buf
=
new
StringBuilder
();
List
<
String
>
keys
=
stringToKeys
(
stateKeys
);
Collections
.
sort
(
keys
);
for
(
Iterator
<
String
>
iter
=
keys
.
iterator
();
iter
.
hasNext
();)
{
buf
.
append
(
iter
.
next
());
if
(
iter
.
hasNext
())
{
buf
.
append
(
'+'
);
}
}
cachedName
=
buf
.
toString
();
}
return
cachedName
;
}
public
void
write
(
StringBuilder
sb
,
String
prefix
,
String
pkg
,
String
fileNamePrefix
,
String
painterPrefix
)
{
String
statePrefix
=
prefix
+
"["
+
getName
()
+
"]"
;
// write state style
sb
.
append
(
style
.
write
(
statePrefix
+
'.'
));
// write painter
if
(
hasCanvas
())
{
writeLazyPainter
(
sb
,
statePrefix
,
pkg
,
fileNamePrefix
,
painterPrefix
);
}
}
private
void
writeLazyPainter
(
StringBuilder
sb
,
String
statePrefix
,
String
packageNamePrefix
,
String
fileNamePrefix
,
String
painterPrefix
)
{
String
cacheModeString
=
"AbstractRegionPainter.PaintContext.CacheMode."
+
style
.
getCacheMode
();
String
stateConstant
=
Utils
.
statesToConstantName
(
painterPrefix
+
"_"
+
stateKeys
);
sb
.
append
(
String
.
format
(
" d.put(\"%s.%sPainter\", new LazyPainter(\"%s.%s\", %s.%s, %s, %s, %b, %s, %s, %s));\n"
,
statePrefix
,
painterPrefix
,
packageNamePrefix
,
fileNamePrefix
,
fileNamePrefix
,
stateConstant
,
canvas
.
getStretchingInsets
().
write
(
false
),
canvas
.
getSize
().
write
(
false
),
inverted
,
cacheModeString
,
Utils
.
formatDouble
(
style
.
getMaxHozCachedImgScaling
()),
Utils
.
formatDouble
(
style
.
getMaxVertCachedImgScaling
())));
}
}
class
UIStateType
{
@XmlAttribute
private
String
key
;
public
String
getKey
()
{
return
key
;
}
@XmlElement
private
String
codeSnippet
;
public
String
getCodeSnippet
()
{
return
codeSnippet
;
}
}
make/tools/s
wing-nimbus/classes/org/jdesktop/synthdesigner/generator/Generator
Utils.java
→
make/tools/s
rc/build/tools/generatenimbus/
Utils.java
浏览文件 @
04a8b4d8
...
...
@@ -22,158 +22,61 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.synthdesigner.generator
;
import
javax.swing.plaf.synth.Region
;
import
javax.swing.plaf.synth.SynthConstants
;
/**
* GeneratorUtils
*
* @author Richard Bair
* @author Jasper Potts
*/
class
GeneratorUtils
{
private
GeneratorUtils
()
{}
package
build.tools.generatenimbus
;
/**
* Given a synth state, create the appropriate name as it would be used for a ui default key.
* <p/>
* For example:
* <p/>
* enabled enabled+over enabled+over+selected
*/
static
String
toUIDefaultKey
(
int
state
)
{
StringBuffer
buffer
=
new
StringBuffer
();
if
((
state
&
SynthConstants
.
DEFAULT
)
==
SynthConstants
.
DEFAULT
)
{
buffer
.
append
(
"default"
);
}
if
((
state
&
SynthConstants
.
DISABLED
)
==
SynthConstants
.
DISABLED
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
"+"
);
buffer
.
append
(
"disabled"
);
}
if
((
state
&
SynthConstants
.
ENABLED
)
==
SynthConstants
.
ENABLED
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
"+"
);
buffer
.
append
(
"enabled"
);
}
if
((
state
&
SynthConstants
.
FOCUSED
)
==
SynthConstants
.
FOCUSED
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
"+"
);
buffer
.
append
(
"focused"
);
}
if
((
state
&
SynthConstants
.
MOUSE_OVER
)
==
SynthConstants
.
MOUSE_OVER
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
"+"
);
buffer
.
append
(
"over"
);
}
if
((
state
&
SynthConstants
.
PRESSED
)
==
SynthConstants
.
PRESSED
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
"+"
);
buffer
.
append
(
"down"
);
}
if
((
state
&
SynthConstants
.
SELECTED
)
==
SynthConstants
.
SELECTED
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
"+"
);
buffer
.
append
(
"selected"
);
}
return
buffer
.
toString
();
}
import
java.util.ArrayList
;
import
java.util.List
;
import
javax.swing.plaf.synth.Region
;
//takes a states string of the form Enabled+Foo+Bar.
//removes any whitespace. Replaces the + signs with And.
static
String
toClassName
(
String
states
)
{
String
s
=
states
.
replace
(
" "
,
""
);
s
=
states
.
replace
(
"+"
,
"And"
);
return
s
;
}
public
class
Utils
{
//takes a states string of the form Enabled+Foo+Bar.
//removes any whitespace. Replaces the + signs with _.
//capitalizes the whole lot
static
String
toConstantName
(
String
states
)
{
String
s
=
states
.
replace
(
" "
,
""
);
s
=
states
.
replace
(
"+"
,
"_"
);
return
s
.
toUpperCase
();
public
static
String
escape
(
String
s
)
{
return
s
.
replace
(
"\""
,
"\\\""
);
}
/**
* Given a string "s" of the form:
*
* A.\"A.a\".B
*
* Make it such that:
*
* AAAB
*
* For example, ComboBox.\"ComboBox.arrowButton\" would become
* ComboBoxComboBoxArrowButton
*
* @param s
* @return
*/
static
String
makePretty
(
String
s
)
{
public
static
String
normalize
(
String
s
)
{
char
[]
src
=
s
.
toCharArray
();
char
[]
dst
=
new
char
[
src
.
length
];
int
dstIndex
=
0
;
for
(
int
i
=
0
;
i
<
src
.
length
;
i
++)
{
//if the src char is a period and there is a following character,
//make sure the character is capitalized.
if
((
src
[
i
]
==
'.'
||
src
[
i
]
==
':'
)
&&
i
<
src
.
length
-
1
)
{
src
[
i
+
1
]
=
Character
.
toUpperCase
(
src
[
i
+
1
]);
continue
;
}
//if the src char is one that is to be removed, skip it.
if
(
src
[
i
]
==
'.'
||
src
[
i
]
==
':'
||
src
[
i
]
==
'\\'
||
src
[
i
]
==
'"'
)
{
continue
;
StringBuilder
buf
=
new
StringBuilder
();
List
<
String
>
parts
=
new
ArrayList
<
String
>();
boolean
capitalize
=
false
;
for
(
int
i
=
0
;
i
<
src
.
length
;
i
++)
{
switch
(
src
[
i
])
{
case
'\\'
:
case
'"'
:
break
;
case
'.'
:
capitalize
=
true
;
break
;
case
':'
:
parts
.
add
(
buf
.
toString
());
buf
.
delete
(
0
,
buf
.
length
());
capitalize
=
true
;
break
;
default
:
buf
.
append
(
capitalize
?
Character
.
toUpperCase
(
src
[
i
])
:
src
[
i
]);
capitalize
=
false
;
break
;
}
//copy over the current char.
dst
[
dstIndex
++]
=
src
[
i
];
}
//at this point, dstIndex is 1 greater than the last valid index position in dst
//or in other words it represents the count.
return
new
String
(
dst
,
0
,
dstIndex
);
}
parts
.
add
(
buf
.
toString
());
/**
* Encodes the given synth state as if it were specified in java code, such as
* <p/>
* SynthConstants.ENABLED | SynthConstants.MOUSE_OVER
*/
static
String
toJavaList
(
int
state
)
{
StringBuffer
buffer
=
new
StringBuffer
();
if
((
state
&
SynthConstants
.
DEFAULT
)
==
SynthConstants
.
DEFAULT
)
{
buffer
.
append
(
"SynthConstants.DEFAULT"
);
}
if
((
state
&
SynthConstants
.
DISABLED
)
==
SynthConstants
.
DISABLED
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
" | "
);
buffer
.
append
(
"SynthConstants.DISABLED"
);
}
if
((
state
&
SynthConstants
.
ENABLED
)
==
SynthConstants
.
ENABLED
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
" | "
);
buffer
.
append
(
"SynthConstants.ENABLED"
);
}
if
((
state
&
SynthConstants
.
FOCUSED
)
==
SynthConstants
.
FOCUSED
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
" | "
);
buffer
.
append
(
"SynthConstants.FOCUSED"
);
}
if
((
state
&
SynthConstants
.
MOUSE_OVER
)
==
SynthConstants
.
MOUSE_OVER
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
" | "
);
buffer
.
append
(
"SynthConstants.MOUSE_OVER"
);
}
if
((
state
&
SynthConstants
.
PRESSED
)
==
SynthConstants
.
PRESSED
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
" | "
);
buffer
.
append
(
"SynthConstants.PRESSED"
);
}
if
((
state
&
SynthConstants
.
SELECTED
)
==
SynthConstants
.
SELECTED
)
{
if
(
buffer
.
length
()
>
0
)
buffer
.
append
(
" | "
);
buffer
.
append
(
"SynthConstants.SELECTED"
);
// Try to optimize long class names by omitting repeating prefixes, e.g.
// SliderTrackPainter.java instead of SliderSliderTrackPainter.java
String
result
=
parts
.
get
(
0
);
for
(
int
i
=
1
;
i
<
parts
.
size
();
i
++)
{
String
part
=
parts
.
get
(
i
);
if
(
part
.
startsWith
(
result
))
{
result
=
part
;
}
else
{
result
+=
part
;
}
}
return
buffer
.
toString
()
;
return
result
;
}
/**
* Checks the given region name to discover if it is one of the standard synth regions. If so, return the name in
* caps and such. Otherwise, return a big fat null.
* <p/>
* I have to do this because, unfortunately, synth's Region doesn't implement equals.
*/
static
String
getRegionNameCaps
(
String
regionName
)
{
public
static
String
regionNameToCaps
(
String
regionName
)
{
if
(
Region
.
ARROW_BUTTON
.
getName
().
equals
(
regionName
))
{
return
"ARROW_BUTTON"
;
}
else
if
(
Region
.
BUTTON
.
getName
().
equals
(
regionName
))
{
...
...
@@ -289,7 +192,24 @@ class GeneratorUtils {
}
else
if
(
Region
.
VIEWPORT
.
getName
().
equals
(
regionName
))
{
return
"VIEWPORT"
;
}
System
.
err
.
println
(
"[Info] Couldn't find a Region for "
+
regionName
);
return
null
;
throw
new
RuntimeException
(
"Bad Region name "
+
regionName
);
}
public
static
String
statesToConstantName
(
String
states
)
{
String
s
=
states
.
replace
(
" "
,
""
);
s
=
states
.
replace
(
"+"
,
"_"
);
return
s
.
toUpperCase
();
}
//takes a states string of the form Enabled+Foo+Bar.
//removes any whitespace. Replaces the + signs with And.
public
static
String
statesToClassName
(
String
states
)
{
String
s
=
states
.
replace
(
" "
,
""
);
s
=
states
.
replace
(
"+"
,
"And"
);
return
s
;
}
public
static
String
formatDouble
(
String
doubleValue
)
{
return
doubleValue
.
replace
(
"INF"
,
"Double.POSITIVE_INFINITY"
);
}
}
make/tools/swing-nimbus/Makefile
已删除
100644 → 0
浏览文件 @
feb1bd83
#
# Copyright 1998-2005 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.
#
#
# Makefile for building the Nimbus generator
#
BUILDDIR
=
../..
PACKAGE
=
org.jdesktop.synthdesigner.generator
PRODUCT
=
tools
PROGRAM
=
nimbus_generator
include
$(BUILDDIR)/common/Defs.gmk
BUILDTOOL_SOURCE_ROOT
=
classes
BUILDTOOL_MAIN
=
$(PKGDIR)
/Generator.java
#
# Files
#
MAIN_CLASS_FILE
=
$(BUILDTOOLCLASSDIR)
/
$(BUILDTOOL_MAIN:%.java=%.class)
SOURCE_FILES
=
$(
shell
$(FIND)
$(BUILDTOOL_SOURCE_ROOT)
-name
'*.java'
-print
)
TEMPLATE_FILES
=
$(SHARE_SRC)
/classes/javax/swing/plaf/nimbus/Defaults.template
\
$(SHARE_SRC)
/classes/javax/swing/plaf/nimbus/PainterImpl.template
\
$(SHARE_SRC)
/classes/javax/swing/plaf/nimbus/StateImpl.template
TEMPLATE_DEST
=
$(BUILDTOOLCLASSDIR)
/org/jdesktop/synthdesigner/generator/resources
JIBX_FILES
=
$(BUILDTOOL_SOURCE_ROOT)
/org/jdesktop/swingx/designer/Designer.jibx.xml
\
$(BUILDTOOL_SOURCE_ROOT)
/org/jdesktop/synthdesigner/synthmodel/SynthModel.jibx.xml
JIBX_LIBS_CP
=
$(JIBX_LIBS_PATH)
/bcel.jar
$(CLASSPATH_SEPARATOR)$(JIBX_LIBS_PATH)
/xpp3.jar
$(CLASSPATH_SEPARATOR)$(JIBX_LIBS_PATH)
/jibx-bind.jar
$(CLASSPATH_SEPARATOR)$(JIBX_LIBS_PATH)
/jibx-run.jar
JIBX_LIBS_LIST
=
$(
subst
$(CLASSPATH_SEPARATOR)
, ,
$(JIBX_LIBS_CP)
)
#
# Rules
#
include
$(BUILDDIR)/common/BuildToolJar.gmk
$(MAIN_CLASS_FILE)
:
$(SOURCE_FILES) $(JIBX_LIBS_LIST)
@
$(MKDIR)
-p
$(BUILDTOOLCLASSDIR)
$(BOOT_JAVAC_CMD)
-classpath
"
$(JIBX_LIBS_CP)
"
\
-d
$(BUILDTOOLCLASSDIR)
-sourcepath
$(BUILDTOOL_SOURCE_ROOT)
\
$(SOURCE_FILES)
$(TEMPLATE_DEST)
:
$(TEMPLATE_FILES)
$(MKDIR)
-p
$(TEMPLATE_DEST)
$(RM)
$(TEMPLATE_DEST)
/
*
.template
$(CP)
$(TEMPLATE_FILES)
$(TEMPLATE_DEST)
$(BUILDTOOL_MANIFEST_FILE)
:
$(MAIN_CLASS_FILE)
$(ECHO)
"Main-Class:
$(BUILTTOOL_MAINCLASS)
"
>
$@
$(ECHO)
"Class-Path:
$
(JIBX_LIBS_LIST:
$(JIBX_LIBS_PATH)
/%=%)"
>>
$@
$(CP)
$(JIBX_LIBS_LIST)
$(BUILDTOOLJARDIR)
$(BUILDTOOL_JAR_FILE)
:
$(MAIN_CLASS_FILE) $(TEMPLATE_DEST)
\
$(JIBX_FILES) $(BUILDTOOL_MANIFEST_FILE)
@
$
(
prep-target
)
$(BOOT_JAVA_CMD)
\
-classpath
"
$(JIBX_LIBS_CP)$(CLASSPATH_SEPARATOR)$(BUILDTOOLCLASSDIR)
"
\
org.jibx.binding.Compile
$(JIBX_FILES)
$(BOOT_JAR_CMD)
cfm
$@
$(BUILDTOOL_MANIFEST_FILE)
\
-C
$(BUILDTOOLCLASSDIR)
org
\
$(BOOT_JAR_JFLAGS)
||
$(RM)
$@
@
$
(
java-vm-cleanup
)
clean clobber
::
$(RM)
-r
$(TEMPLATE_DEST)
make/tools/swing-nimbus/classes/org/jdesktop/beans/AbstractBean.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.beans
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.beans.PropertyChangeSupport
;
import
java.beans.PropertyVetoException
;
import
java.beans.VetoableChangeListener
;
import
java.beans.VetoableChangeSupport
;
/**
* <p>A convenience class from which to extend all non-visual AbstractBeans. It
* manages the PropertyChange notification system, making it relatively trivial
* to add support for property change events in getters/setters.</p>
*
* <p>A non-visual java bean is a Java class that conforms to the AbstractBean
* patterns to allow visual manipulation of the bean's properties and event
* handlers at design-time.</p>
*
* <p>Here is a simple example bean that contains one property, foo, and the
* proper pattern for implementing property change notification:
* <pre><code>
* public class ABean extends AbstractBean {
* private String foo;
*
* public void setFoo(String newFoo) {
* String old = getFoo();
* this.foo = newFoo;
* firePropertyChange("foo", old, getFoo());
* }
*
* public String getFoo() {
* return foo;
* }
* }
* </code></pre></p>
*
* <p>You will notice that "getFoo()" is used in the setFoo method rather than
* accessing "foo" directly for the gets. This is done intentionally so that if
* a subclass overrides getFoo() to return, for instance, a constant value the
* property change notification system will continue to work properly.</p>
*
* <p>The firePropertyChange method takes into account the old value and the new
* value. Only if the two differ will it fire a property change event. So you can
* be assured from the above code fragment that a property change event will only
* occur if old is indeed different from getFoo()</p>
*
* <p><code>AbstractBean</code> also supports {@link VetoablePropertyChange} events.
* These events are similar to <code>PropertyChange</code> events, except a special
* exception can be used to veto changing the property. For example, perhaps the
* property is changing from "fred" to "red", but a listener deems that "red" is
* unexceptable. In this case, the listener can fire a veto exception and the property must
* remain "fred". For example:
* <pre><code>
* public class ABean extends AbstractBean {
* private String foo;
*
* public void setFoo(String newFoo) throws PropertyVetoException {
* String old = getFoo();
* this.foo = newFoo;
* fireVetoableChange("foo", old, getFoo());
* }
*
* public String getFoo() {
* return foo;
* }
* }
*
* public class Tester {
* public static void main(String... args) {
* try {
* ABean a = new ABean();
* a.setFoo("fred");
* a.addVetoableChangeListener(new VetoableChangeListener() {
* public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
* if ("red".equals(evt.getNewValue()) {
* throw new PropertyVetoException("Cannot be red!", evt);
* }
* }
* }
* a.setFoo("red");
* } catch (Exception e) {
* e.printStackTrace(); // this will be executed
* }
* }
* }
* </code></pre></p>
*
* @status REVIEWED
* @author rbair
*/
public
abstract
class
AbstractBean
{
/**
* Helper class that manages all the property change notification machinery.
* PropertyChangeSupport cannot be extended directly because it requires
* a bean in the constructor, and the "this" argument is not valid until
* after super construction. Hence, delegation instead of extension
*/
private
transient
PropertyChangeSupport
pcs
;
/**
* Helper class that manages all the veto property change notification machinery.
*/
private
transient
VetoableChangeSupport
vcs
;
/** Creates a new instance of AbstractBean */
protected
AbstractBean
()
{
pcs
=
new
PropertyChangeSupport
(
this
);
vcs
=
new
VetoableChangeSupport
(
this
);
}
/**
* Creates a new instance of AbstractBean, using the supplied PropertyChangeSupport and
* VetoableChangeSupport delegates. Neither of these may be null.
*/
protected
AbstractBean
(
PropertyChangeSupport
pcs
,
VetoableChangeSupport
vcs
)
{
if
(
pcs
==
null
)
{
throw
new
NullPointerException
(
"PropertyChangeSupport must not be null"
);
}
if
(
vcs
==
null
)
{
throw
new
NullPointerException
(
"VetoableChangeSupport must not be null"
);
}
this
.
pcs
=
pcs
;
this
.
vcs
=
vcs
;
}
/**
* Add a PropertyChangeListener to the listener list.
* The listener is registered for all properties.
* The same listener object may be added more than once, and will be called
* as many times as it is added.
* If <code>listener</code> is null, no exception is thrown and no action
* is taken.
*
* @param listener The PropertyChangeListener to be added
*/
public
final
void
addPropertyChangeListener
(
PropertyChangeListener
listener
)
{
pcs
.
addPropertyChangeListener
(
listener
);
}
/**
* Remove a PropertyChangeListener from the listener list.
* This removes a PropertyChangeListener that was registered
* for all properties.
* If <code>listener</code> was added more than once to the same event
* source, it will be notified one less time after being removed.
* If <code>listener</code> is null, or was never added, no exception is
* thrown and no action is taken.
*
* @param listener The PropertyChangeListener to be removed
*/
public
final
void
removePropertyChangeListener
(
PropertyChangeListener
listener
)
{
pcs
.
removePropertyChangeListener
(
listener
);
}
/**
* Returns an array of all the listeners that were added to the
* PropertyChangeSupport object with addPropertyChangeListener().
* <p>
* If some listeners have been added with a named property, then
* the returned array will be a mixture of PropertyChangeListeners
* and <code>PropertyChangeListenerProxy</code>s. If the calling
* method is interested in distinguishing the listeners then it must
* test each element to see if it's a
* <code>PropertyChangeListenerProxy</code>, perform the cast, and examine
* the parameter.
*
* <pre>
* PropertyChangeListener[] listeners = bean.getPropertyChangeListeners();
* for (int i = 0; i < listeners.length; i++) {
* if (listeners[i] instanceof PropertyChangeListenerProxy) {
* PropertyChangeListenerProxy proxy =
* (PropertyChangeListenerProxy)listeners[i];
* if (proxy.getPropertyName().equals("foo")) {
* // proxy is a PropertyChangeListener which was associated
* // with the property named "foo"
* }
* }
* }
*</pre>
*
* @see java.beans.PropertyChangeListenerProxy
* @return all of the <code>PropertyChangeListeners</code> added or an
* empty array if no listeners have been added
*/
public
final
PropertyChangeListener
[]
getPropertyChangeListeners
()
{
return
pcs
.
getPropertyChangeListeners
();
}
/**
* Add a PropertyChangeListener for a specific property. The listener
* will be invoked only when a call on firePropertyChange names that
* specific property.
* The same listener object may be added more than once. For each
* property, the listener will be invoked the number of times it was added
* for that property.
* If <code>propertyName</code> or <code>listener</code> is null, no
* exception is thrown and no action is taken.
*
* @param propertyName The name of the property to listen on.
* @param listener The PropertyChangeListener to be added
*/
public
final
void
addPropertyChangeListener
(
String
propertyName
,
PropertyChangeListener
listener
)
{
pcs
.
addPropertyChangeListener
(
propertyName
,
listener
);
}
/**
* Remove a PropertyChangeListener for a specific property.
* If <code>listener</code> was added more than once to the same event
* source for the specified property, it will be notified one less time
* after being removed.
* If <code>propertyName</code> is null, no exception is thrown and no
* action is taken.
* If <code>listener</code> is null, or was never added for the specified
* property, no exception is thrown and no action is taken.
*
* @param propertyName The name of the property that was listened on.
* @param listener The PropertyChangeListener to be removed
*/
public
final
void
removePropertyChangeListener
(
String
propertyName
,
PropertyChangeListener
listener
)
{
pcs
.
removePropertyChangeListener
(
propertyName
,
listener
);
}
/**
* Returns an array of all the listeners which have been associated
* with the named property.
*
* @param propertyName The name of the property being listened to
* @return all of the <code>PropertyChangeListeners</code> associated with
* the named property. If no such listeners have been added,
* or if <code>propertyName</code> is null, an empty array is
* returned.
*/
public
final
PropertyChangeListener
[]
getPropertyChangeListeners
(
String
propertyName
)
{
return
pcs
.
getPropertyChangeListeners
(
propertyName
);
}
/**
* Report a bound property update to any registered listeners.
* No event is fired if old and new are equal and non-null.
*
* <p>
* This is merely a convenience wrapper around the more general
* firePropertyChange method that takes {@code
* PropertyChangeEvent} value.
*
* @param propertyName The programmatic name of the property
* that was changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
*/
protected
final
void
firePropertyChange
(
String
propertyName
,
Object
oldValue
,
Object
newValue
)
{
pcs
.
firePropertyChange
(
propertyName
,
oldValue
,
newValue
);
}
/**
* Fire an existing PropertyChangeEvent to any registered listeners.
* No event is fired if the given event's old and new values are
* equal and non-null.
* @param evt The PropertyChangeEvent object.
*/
protected
final
void
firePropertyChange
(
PropertyChangeEvent
evt
)
{
pcs
.
firePropertyChange
(
evt
);
}
/**
* Report a bound indexed property update to any registered
* listeners.
* <p>
* No event is fired if old and new values are equal
* and non-null.
*
* <p>
* This is merely a convenience wrapper around the more general
* firePropertyChange method that takes {@code PropertyChangeEvent} value.
*
* @param propertyName The programmatic name of the property that
* was changed.
* @param index index of the property element that was changed.
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
*/
protected
final
void
fireIndexedPropertyChange
(
String
propertyName
,
int
index
,
Object
oldValue
,
Object
newValue
)
{
pcs
.
fireIndexedPropertyChange
(
propertyName
,
index
,
oldValue
,
newValue
);
}
/**
* Check if there are any listeners for a specific property, including
* those registered on all properties. If <code>propertyName</code>
* is null, only check for listeners registered on all properties.
*
* @param propertyName the property name.
* @return true if there are one or more listeners for the given property
*/
protected
final
boolean
hasPropertyChangeListeners
(
String
propertyName
)
{
return
pcs
.
hasListeners
(
propertyName
);
}
/**
* Check if there are any listeners for a specific property, including
* those registered on all properties. If <code>propertyName</code>
* is null, only check for listeners registered on all properties.
*
* @param propertyName the property name.
* @return true if there are one or more listeners for the given property
*/
protected
final
boolean
hasVetoableChangeListeners
(
String
propertyName
)
{
return
vcs
.
hasListeners
(
propertyName
);
}
/**
* Add a VetoableListener to the listener list.
* The listener is registered for all properties.
* The same listener object may be added more than once, and will be called
* as many times as it is added.
* If <code>listener</code> is null, no exception is thrown and no action
* is taken.
*
* @param listener The VetoableChangeListener to be added
*/
public
final
void
addVetoableChangeListener
(
VetoableChangeListener
listener
)
{
vcs
.
addVetoableChangeListener
(
listener
);
}
/**
* Remove a VetoableChangeListener from the listener list.
* This removes a VetoableChangeListener that was registered
* for all properties.
* If <code>listener</code> was added more than once to the same event
* source, it will be notified one less time after being removed.
* If <code>listener</code> is null, or was never added, no exception is
* thrown and no action is taken.
*
* @param listener The VetoableChangeListener to be removed
*/
public
final
void
removeVetoableChangeListener
(
VetoableChangeListener
listener
)
{
vcs
.
removeVetoableChangeListener
(
listener
);
}
/**
* Returns the list of VetoableChangeListeners. If named vetoable change listeners
* were added, then VetoableChangeListenerProxy wrappers will returned
* <p>
* @return List of VetoableChangeListeners and VetoableChangeListenerProxys
* if named property change listeners were added.
*/
public
final
VetoableChangeListener
[]
getVetoableChangeListeners
(){
return
vcs
.
getVetoableChangeListeners
();
}
/**
* Add a VetoableChangeListener for a specific property. The listener
* will be invoked only when a call on fireVetoableChange names that
* specific property.
* The same listener object may be added more than once. For each
* property, the listener will be invoked the number of times it was added
* for that property.
* If <code>propertyName</code> or <code>listener</code> is null, no
* exception is thrown and no action is taken.
*
* @param propertyName The name of the property to listen on.
* @param listener The VetoableChangeListener to be added
*/
public
final
void
addVetoableChangeListener
(
String
propertyName
,
VetoableChangeListener
listener
)
{
vcs
.
addVetoableChangeListener
(
propertyName
,
listener
);
}
/**
* Remove a VetoableChangeListener for a specific property.
* If <code>listener</code> was added more than once to the same event
* source for the specified property, it will be notified one less time
* after being removed.
* If <code>propertyName</code> is null, no exception is thrown and no
* action is taken.
* If <code>listener</code> is null, or was never added for the specified
* property, no exception is thrown and no action is taken.
*
* @param propertyName The name of the property that was listened on.
* @param listener The VetoableChangeListener to be removed
*/
public
final
void
removeVetoableChangeListener
(
String
propertyName
,
VetoableChangeListener
listener
)
{
vcs
.
removeVetoableChangeListener
(
propertyName
,
listener
);
}
/**
* Returns an array of all the listeners which have been associated
* with the named property.
*
* @param propertyName The name of the property being listened to
* @return all the <code>VetoableChangeListeners</code> associated with
* the named property. If no such listeners have been added,
* or if <code>propertyName</code> is null, an empty array is
* returned.
*/
public
final
VetoableChangeListener
[]
getVetoableChangeListeners
(
String
propertyName
)
{
return
vcs
.
getVetoableChangeListeners
(
propertyName
);
}
/**
* Report a vetoable property update to any registered listeners. If
* anyone vetos the change, then fire a new event reverting everyone to
* the old value and then rethrow the PropertyVetoException.
* <p>
* No event is fired if old and new are equal and non-null.
*
* @param propertyName The programmatic name of the property
* that is about to change..
* @param oldValue The old value of the property.
* @param newValue The new value of the property.
* @exception PropertyVetoException if the recipient wishes the property
* change to be rolled back.
*/
protected
final
void
fireVetoableChange
(
String
propertyName
,
Object
oldValue
,
Object
newValue
)
throws
PropertyVetoException
{
vcs
.
fireVetoableChange
(
propertyName
,
oldValue
,
newValue
);
}
/**
* Fire a vetoable property update to any registered listeners. If
* anyone vetos the change, then fire a new event reverting everyone to
* the old value and then rethrow the PropertyVetoException.
* <p>
* No event is fired if old and new are equal and non-null.
*
* @param evt The PropertyChangeEvent to be fired.
* @exception PropertyVetoException if the recipient wishes the property
* change to be rolled back.
*/
protected
final
void
fireVetoableChange
(
PropertyChangeEvent
evt
)
throws
PropertyVetoException
{
vcs
.
fireVetoableChange
(
evt
);
}
/**
* @inheritDoc
*/
public
Object
clone
()
throws
CloneNotSupportedException
{
AbstractBean
result
=
(
AbstractBean
)
super
.
clone
();
result
.
pcs
=
new
PropertyChangeSupport
(
result
);
result
.
vcs
=
new
VetoableChangeSupport
(
result
);
return
result
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/BezierControlPoint.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
java.awt.BasicStroke
;
import
java.awt.Graphics2D
;
import
java.awt.Shape
;
import
java.awt.geom.Ellipse2D
;
import
java.awt.geom.GeneralPath
;
import
java.awt.geom.Line2D
;
import
java.awt.geom.Point2D
;
import
java.awt.geom.Rectangle2D
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
* BezierControlPoint
*
* @author Created by Jasper Potts (May 29, 2007)
*/
public
class
BezierControlPoint
extends
ControlPoint
{
private
HandleControlPoint
cp1
=
new
HandleControlPoint
();
private
HandleControlPoint
cp2
=
new
HandleControlPoint
();
private
transient
boolean
makingChange
=
false
;
private
transient
PropertyChangeListener
cpListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
// if (!makingChange) {
// makingChange = true;
// if (evt.getSource() == cp1) {
// double angle = Math.tan((cp1.getY() - getY())/(cp1.getX() - getX()));
// double cp2len = Math.sqrt(
// Math.pow(cp2.getX() - getX(),2) +
// Math.pow(cp2.getY() - getY(),2)
// );
// double offsetX = cp2len * Math.sin(angle);
// double offsetY = cp2len * Math.cos(angle);
// cp2.setPosition(getX() - offsetX, getY() - offsetY);
// } else {
// double angle = Math.tan((cp2.getY() - getY())/(cp2.getX() - getX()));
// double cp1len = Math.sqrt(
// Math.pow(cp1.getX() - getX(),2) +
// Math.pow(cp1.getY() - getY(),2)
// );
// double offsetX = cp1len * Math.sin(angle);
// double offsetY = cp1len * Math.cos(angle);
// cp1.setPosition(getX() - offsetX, getY() - offsetY);
// }
//// if (evt.getSource() == cp1) {
//// double offsetX = cp1.getX() - getX();
//// double offsetY = cp1.getY() - getY();
//// cp2.setPosition(getX() - offsetX, getY() - offsetY);
//// } else {
//// double offsetX = cp2.getX() - getX();
//// double offsetY = cp2.getY() - getY();
//// cp1.setPosition(getX() - offsetX, getY() - offsetY);
//// }
// makingChange = false;
// firePropertyChange("cp1", null, cp1);
// firePropertyChange("cp2", null, cp1);
// }
firePropertyChange
(
"shape"
,
null
,
getShape
());
}
};
public
BezierControlPoint
()
{
cp1
.
addPropertyChangeListener
(
cpListener
);
cp2
.
addPropertyChangeListener
(
cpListener
);
}
public
BezierControlPoint
(
double
x
,
double
y
)
{
super
(
x
,
y
);
cp1
.
addPropertyChangeListener
(
cpListener
);
cp2
.
addPropertyChangeListener
(
cpListener
);
cp1
.
setPosition
(
x
,
y
);
cp2
.
setPosition
(
x
,
y
);
}
public
boolean
isSharpCorner
()
{
return
(
cp1
.
getX
()
==
x
.
getValue
())
&&
(
cp1
.
getY
()
==
y
.
getValue
())
&&
(
cp2
.
getX
()
==
x
.
getValue
())
&&
(
cp2
.
getY
()
==
y
.
getValue
());
}
public
void
flip
(
int
width
,
int
height
){
makingChange
=
true
;
if
(
width
>
0
){
x
.
setValue
(
width
-
x
.
getValue
());
cp1
.
x
.
setValue
(
width
-
cp1
.
x
.
getValue
());
cp2
.
x
.
setValue
(
width
-
cp2
.
x
.
getValue
());
}
if
(
height
>
0
){
y
.
setValue
(
height
-
y
.
getValue
());
cp1
.
y
.
setValue
(
height
-
cp1
.
y
.
getValue
());
cp2
.
y
.
setValue
(
height
-
cp2
.
y
.
getValue
());
}
makingChange
=
false
;
}
public
void
convertToSharpCorner
()
{
cp1
.
setPosition
(
x
.
getValue
(),
y
.
getValue
());
cp2
.
setPosition
(
x
.
getValue
(),
y
.
getValue
());
}
public
List
<
ControlPoint
>
getControlPoints
()
{
if
(
isSharpCorner
())
{
return
Collections
.
emptyList
();
}
else
{
List
<
ControlPoint
>
points
=
new
ArrayList
<
ControlPoint
>();
points
.
add
(
cp1
);
points
.
add
(
cp2
);
return
points
;
}
}
public
HandleControlPoint
getCp1
()
{
return
cp1
;
}
public
HandleControlPoint
getCp2
()
{
return
cp2
;
}
public
void
paintControls
(
Graphics2D
g2
,
double
pixelSize
,
boolean
paintControlLines
)
{
g2
.
setStroke
(
new
BasicStroke
((
float
)
pixelSize
));
// paint control line
g2
.
setColor
(
GraphicsHelper
.
BEZIER_CONTROL_LINE
);
g2
.
draw
(
new
Line2D
.
Double
(
cp1
.
getX
(),
cp1
.
getY
(),
getX
(),
getY
()));
g2
.
draw
(
new
Line2D
.
Double
(
getX
(),
getY
(),
cp2
.
getX
(),
cp2
.
getY
()));
// paint this control point
Shape
s
;
if
(
isSharpCorner
())
{
double
size
=
pixelSize
*
4
d
;
GeneralPath
path
=
new
GeneralPath
();
path
.
moveTo
(
getX
()
-
size
,
getY
());
path
.
lineTo
(
getX
(),
getY
()
+
size
);
path
.
lineTo
(
getX
()
+
size
,
getY
());
path
.
lineTo
(
getX
(),
getY
()
-
size
);
path
.
closePath
();
s
=
path
;
}
else
{
double
size
=
pixelSize
*
3
d
;
s
=
new
Ellipse2D
.
Double
(
getX
()
-
size
,
getY
()
-
size
,
size
*
2
,
size
*
2
);
}
g2
.
setColor
(
GraphicsHelper
.
BEZIER_CONTROL_POINT_FILL
);
g2
.
fill
(
s
);
g2
.
setColor
(
GraphicsHelper
.
BEZIER_CONTROL_POINT_LINE
);
g2
.
draw
(
s
);
// paint child control points
if
(!
isSharpCorner
())
{
cp1
.
paintControls
(
g2
,
pixelSize
,
true
);
cp2
.
paintControls
(
g2
,
pixelSize
,
true
);
}
}
public
void
move
(
double
moveX
,
double
moveY
,
boolean
snapPixels
)
{
makingChange
=
true
;
super
.
move
(
moveX
,
moveY
,
snapPixels
);
cp1
.
move
(
moveX
,
moveY
,
snapPixels
);
cp2
.
move
(
moveX
,
moveY
,
snapPixels
);
makingChange
=
false
;
}
public
double
getCp1X
()
{
return
cp1
.
getX
();
}
public
void
setCp1X
(
double
v
)
{
cp1
.
setX
(
v
);
}
public
double
getCp1Y
()
{
return
cp1
.
getY
();
}
public
void
setCp1Y
(
double
v
)
{
cp1
.
setY
(
v
);
}
public
double
getCp2X
()
{
return
cp2
.
getX
();
}
public
void
setCp2X
(
double
v
)
{
cp2
.
setX
(
v
);
}
public
double
getCp2Y
()
{
return
cp2
.
getY
();
}
public
void
setCp2Y
(
double
v
)
{
cp2
.
setY
(
v
);
}
// =================================================================================================================
// Bezier handle control point
public
class
HandleControlPoint
extends
ControlPoint
{
public
void
paintControls
(
Graphics2D
g2
,
double
pixelSize
,
boolean
paintControlLines
)
{
if
(!
isSharp
()){
double
size
=
pixelSize
*
3
d
;
Shape
s
=
new
Ellipse2D
.
Double
(
getX
()
-
size
,
getY
()
-
size
,
size
*
2
,
size
*
2
);
g2
.
setColor
(
GraphicsHelper
.
BEZIER_CONTROL_POINT_FILL
);
g2
.
fill
(
s
);
g2
.
setColor
(
GraphicsHelper
.
BEZIER_CONTROL_POINT_LINE
);
g2
.
draw
(
s
);
g2
.
draw
(
new
Rectangle2D
.
Double
(
getX
()
-
(
pixelSize
/
2
),
getY
()
-
(
pixelSize
/
2
),
pixelSize
,
pixelSize
));
}
}
public
boolean
isHit
(
Point2D
p
,
double
pixelSize
)
{
return
!
isSharp
()
&&
super
.
isHit
(
p
,
pixelSize
);
}
/**
* Is the line controled by this handle in or out of the parent BezierControlPoint sharp.
*
* @return <code>true</code> If this is the exact same point as the parent BezierControlPoint.
*/
public
boolean
isSharp
(){
return
x
.
getValue
()
==
BezierControlPoint
.
this
.
x
.
getValue
()
&&
y
.
getValue
()
==
BezierControlPoint
.
this
.
y
.
getValue
();
}
public
void
convertToSharp
(){
setPosition
(
BezierControlPoint
.
this
.
x
.
getValue
(),
BezierControlPoint
.
this
.
y
.
getValue
());
}
public
BezierControlPoint
getParentControlPoint
(){
return
BezierControlPoint
.
this
;
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/BlendingMode.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
/**
* BlendingMode - Enum of composite blending modes, setup to match photoshop as closely as possible
*
* @author Created by Jasper Potts (May 31, 2007)
*/
public
enum
BlendingMode
{
NORMAL
,
// DISSOLVE, missing
// -----------------------------
DARKEN
,
MULTIPLY
,
COLOR_BURN
,
LINEAR_BURN
,
// (SUBTRACT)
// -----------------------------
LIGHTEN
,
SCREEN
,
COLOR_DODGE
,
LINEAR_DODGE
,
// (ADD)
// -----------------------------
OVERLAY
,
SOFT_LIGHT
,
HARD_LIGHT
,
VIVID_LIGHT
,
// (HEAT) is close
LINEAR_LIGHT
,
// (GLOW) is close
//PIN_LIGHT, missing
//HARD_MIX, missing
// -----------------------------
DIFFERENCE
,
EXCLUSION
,
// -----------------------------
HUE
,
// nowhere close
SATURATION
,
COLOR
,
LUMINOSITY
,
// close but not exact
//LIGHTER_COLOR, missing
//DARKER_COLOR, missing
;
// =================================================================================================================
// Helper methods for creating Blending Mode Combo Box
public
static
final
Object
[]
BLENDING_MODES
=
new
Object
[]{
BlendingMode
.
NORMAL
,
// DISSOLVE, missing
"-"
,
BlendingMode
.
DARKEN
,
BlendingMode
.
MULTIPLY
,
BlendingMode
.
COLOR_BURN
,
BlendingMode
.
LINEAR_BURN
,
// (SUBTRACT)
"-"
,
BlendingMode
.
LIGHTEN
,
BlendingMode
.
SCREEN
,
BlendingMode
.
COLOR_DODGE
,
BlendingMode
.
LINEAR_DODGE
,
// (ADD)
"-"
,
BlendingMode
.
OVERLAY
,
BlendingMode
.
SOFT_LIGHT
,
BlendingMode
.
HARD_LIGHT
,
BlendingMode
.
VIVID_LIGHT
,
// (HEAT) is close
BlendingMode
.
LINEAR_LIGHT
,
// (GLOW) is close
//PIN_LIGHT, missing
//HARD_MIX, missing
"-"
,
BlendingMode
.
DIFFERENCE
,
BlendingMode
.
EXCLUSION
,
"-"
,
BlendingMode
.
HUE
,
// nowhere close
BlendingMode
.
SATURATION
,
BlendingMode
.
COLOR
,
BlendingMode
.
LUMINOSITY
,
// close but not exact
};
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/Canvas.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
org.jdesktop.beans.AbstractBean
;
import
org.jdesktop.swingx.designer.utils.HasResources
;
import
org.jdesktop.swingx.designer.utils.HasUIDefaults
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
javax.swing.UIDefaults
;
import
java.awt.AlphaComposite
;
import
java.awt.Dimension
;
import
java.awt.Graphics2D
;
import
java.awt.Insets
;
import
java.awt.RenderingHints
;
import
java.awt.image.BufferedImage
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
/**
* ComponentRegion
*
* @author Created by Jasper Potts (May 22, 2007)
*/
public
class
Canvas
extends
AbstractBean
implements
LayerContainer
,
HasUIDefaults
,
HasResources
{
private
Dimension
size
;
/** list of all layers in the canvas, the first layer is painted on top */
private
List
<
Layer
>
layers
;
private
int
nextLayerNameIndex
=
1
;
private
BufferedImage
buffer
;
private
boolean
isValid
=
false
;
private
Insets
stretchingInsets
=
null
;
private
Layer
workingLayer
=
null
;
private
PropertyChangeListener
layersPropertyChangeListener
;
private
UIDefaults
canvasUIDefaults
=
null
;
private
transient
File
resourcesDir
;
private
transient
File
imagesDir
;
private
transient
File
templatesDir
;
// =================================================================================================================
// Constructor
/** Private constructor for JIBX */
protected
Canvas
()
{
layersPropertyChangeListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
isValid
=
false
;
// pass on layer change
int
index
=
layers
.
indexOf
((
Layer
)
evt
.
getSource
());
if
(
index
!=
-
1
)
{
firePropertyChange
(
"layers["
+
index
+
"]."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
}
};
}
public
Canvas
(
int
width
,
int
height
)
{
this
();
stretchingInsets
=
new
Insets
(
1
,
1
,
1
,
1
);
layers
=
new
ArrayList
<
Layer
>();
setSize
(
new
Dimension
(
width
,
height
));
addLayer
(
new
Layer
());
}
// =================================================================================================================
// JIBX Methods
/**
* Called by JIBX before all fields have been set
*
* @param context The JIBX Unmarshalling Context
*/
private
void
preSet
(
IUnmarshallingContext
context
)
{
canvasUIDefaults
=
(
UIDefaults
)
context
.
getUserContext
();
}
// =================================================================================================================
// Bean Methods
/**
* Get the UIDefaults for this canvas. The UIDefaults is used to store default pallet of colors, fonts etc.
*
* @return Canvas UIDefaults
*/
public
UIDefaults
getUiDefaults
()
{
return
canvasUIDefaults
;
}
/**
* Set the UIDefaults for this canvas. The UIDefaults is used to store default pallet of colors, fonts etc.
*
* @param canvasUIDefaults Canvas UIDefaults
*/
public
void
setUiDefaults
(
UIDefaults
canvasUIDefaults
)
{
this
.
canvasUIDefaults
=
canvasUIDefaults
;
}
/**
* Get the current working layer, is is the layer that new shapes will be drawn into
*
* @return The current working layer, may be null if there is no working layer
*/
public
Layer
getWorkingLayer
()
{
return
workingLayer
;
}
/**
* Set the current working layer, is is the layer that new shapes will be drawn into
*
* @param workingLayer the new working layer, must be a child of this canvas
*/
public
void
setWorkingLayer
(
Layer
workingLayer
)
{
Layer
old
=
getWorkingLayer
();
this
.
workingLayer
=
workingLayer
;
firePropertyChange
(
"workingLayer"
,
old
,
getWorkingLayer
());
}
public
int
getNextLayerNameIndex
()
{
return
nextLayerNameIndex
++;
}
public
Dimension
getSize
()
{
return
size
;
}
public
void
setSize
(
Dimension
size
)
{
Dimension
old
=
getSize
();
this
.
size
=
size
;
buffer
=
new
BufferedImage
(
this
.
size
.
width
,
this
.
size
.
height
,
BufferedImage
.
TYPE_INT_ARGB
);
isValid
=
false
;
firePropertyChange
(
"size"
,
old
,
getSize
());
}
public
Insets
getStretchingInsets
()
{
return
stretchingInsets
;
}
public
void
setStretchingInsets
(
Insets
stretchingInsets
)
{
Insets
old
=
getStretchingInsets
();
this
.
stretchingInsets
=
stretchingInsets
;
firePropertyChange
(
"stretchingInsets"
,
old
,
getStretchingInsets
());
}
public
BufferedImage
getRenderedImage
()
{
if
(!
isValid
)
{
Graphics2D
g2
=
buffer
.
createGraphics
();
// clear
g2
.
setComposite
(
AlphaComposite
.
Clear
);
g2
.
fillRect
(
0
,
0
,
buffer
.
getWidth
(),
buffer
.
getHeight
());
// paint
g2
.
setRenderingHint
(
RenderingHints
.
KEY_ANTIALIASING
,
RenderingHints
.
VALUE_ANTIALIAS_ON
);
g2
.
setComposite
(
AlphaComposite
.
SrcOver
);
for
(
int
i
=
layers
.
size
()
-
1
;
i
>=
0
;
i
--)
{
layers
.
get
(
i
).
paint
(
g2
,
1
);
}
g2
.
dispose
();
}
return
buffer
;
}
/**
* @return true if this Canvas has not been edited.
* <p/>
* TODO Currently this is not a bound property, but should be. That is, when the Canvas becomes edited
* (usually due to the Layer having a shape added to it), then a property change event should be fired.
*/
public
boolean
isBlank
()
{
return
layers
.
size
()
==
0
||
(
layers
.
size
()
==
1
&&
layers
.
get
(
0
).
isEmpty
());
}
public
File
getResourcesDir
()
{
return
resourcesDir
;
}
public
void
setResourcesDir
(
File
resourcesDir
)
{
File
old
=
getResourcesDir
();
this
.
resourcesDir
=
resourcesDir
;
firePropertyChange
(
"resourcesDir"
,
old
,
getResourcesDir
());
}
public
File
getImagesDir
()
{
return
imagesDir
;
}
public
void
setImagesDir
(
File
imagesDir
)
{
File
old
=
getImagesDir
();
this
.
imagesDir
=
imagesDir
;
firePropertyChange
(
"imagesDir"
,
old
,
getImagesDir
());
}
public
File
getTemplatesDir
()
{
return
templatesDir
;
}
public
void
setTemplatesDir
(
File
templatesDir
)
{
File
old
=
getTemplatesDir
();
this
.
templatesDir
=
templatesDir
;
firePropertyChange
(
"templatesDir"
,
old
,
getTemplatesDir
());
}
// =================================================================================================================
// LayerContainer Methods
public
LayerContainer
getParent
()
{
// we are root so null
return
null
;
}
public
void
addLayerToBottom
(
Layer
layer
)
{
layers
.
add
(
layer
);
layer
.
setParent
(
this
);
layer
.
addPropertyChangeListener
(
layersPropertyChangeListener
);
// no single layer changes so fire all changed event
firePropertyChange
(
"layers"
,
null
,
layers
);
}
public
void
addLayer
(
int
i
,
Layer
layer
)
{
layers
.
add
(
i
,
layer
);
layer
.
setParent
(
this
);
layer
.
addPropertyChangeListener
(
layersPropertyChangeListener
);
// no single layer changes so fire all changed event
firePropertyChange
(
"layers"
,
null
,
layers
);
}
public
void
addLayer
(
Layer
layer
)
{
layers
.
add
(
0
,
layer
);
layer
.
setParent
(
this
);
layer
.
addPropertyChangeListener
(
layersPropertyChangeListener
);
// no single layer changes so fire all changed event
firePropertyChange
(
"layers"
,
null
,
layers
);
}
public
Layer
getLayer
(
int
index
)
{
return
layers
.
get
(
index
);
}
public
int
getLayerCount
()
{
return
layers
.
size
();
}
public
Iterator
<
Layer
>
getLayerIterator
()
{
return
Collections
.
unmodifiableList
(
layers
).
iterator
();
}
public
Collection
<
Layer
>
getLayers
()
{
return
Collections
.
unmodifiableList
(
layers
);
}
public
int
indexOfLayer
(
Layer
layer
)
{
return
layers
.
indexOf
(
layer
);
}
public
void
removeLayer
(
Layer
layer
)
{
int
index
=
layers
.
indexOf
(
layer
);
if
(
index
!=
-
1
)
{
layers
.
remove
(
layer
);
layer
.
removePropertyChangeListener
(
layersPropertyChangeListener
);
fireIndexedPropertyChange
(
"layers"
,
index
,
layer
,
null
);
}
}
public
Dimension
getRootSize
()
{
return
getSize
();
}
// =================================================================================================================
// JIBX Helper Methods
/** Called by JIBX after "layers" has been filled so we can set parents and listeners */
private
void
setupLayers
()
{
for
(
Layer
layer
:
layers
)
{
layer
.
setParent
(
this
);
layer
.
addPropertyChangeListener
(
layersPropertyChangeListener
);
}
// no single layer changes so fire all changed event
firePropertyChange
(
"layers"
,
null
,
layers
);
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/ControlPoint.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
java.awt.BasicStroke
;
import
java.awt.Color
;
import
java.awt.Graphics2D
;
import
java.awt.Shape
;
import
java.awt.geom.Point2D
;
import
java.awt.geom.Rectangle2D
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.util.Collections
;
import
java.util.List
;
/**
* ControlPoint
*
* @author Created by Jasper Potts (May 24, 2007)
*/
public
class
ControlPoint
extends
SimpleShape
{
protected
Color
fillColor
;
protected
Color
lineColor
;
protected
DoubleBean
x
,
y
;
public
ControlPoint
()
{
this
(
new
DoubleBean
(),
new
DoubleBean
());
}
public
ControlPoint
(
Color
fillColor
,
Color
lineColor
)
{
this
(
new
DoubleBean
(),
new
DoubleBean
(),
fillColor
,
lineColor
);
}
public
ControlPoint
(
double
x
,
double
y
)
{
this
(
new
DoubleBean
(
x
),
new
DoubleBean
(
y
));
}
public
ControlPoint
(
DoubleBean
x
,
DoubleBean
y
)
{
this
(
x
,
y
,
GraphicsHelper
.
CONTROL_POINT_FILL
,
GraphicsHelper
.
CONTROL_POINT_LINE
);
}
public
ControlPoint
(
DoubleBean
x
,
DoubleBean
y
,
Color
fillColor
,
Color
lineColor
)
{
this
.
x
=
x
;
this
.
y
=
y
;
this
.
fillColor
=
fillColor
;
this
.
lineColor
=
lineColor
;
x
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"position"
,
new
Point2D
.
Double
((
Double
)
evt
.
getOldValue
(),
getY
()),
getPosition
());
}
});
y
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"position"
,
new
Point2D
.
Double
(
getX
(),
(
Double
)
evt
.
getOldValue
()),
getPosition
());
}
});
}
public
double
getX
()
{
return
x
.
getValue
();
}
public
double
getY
()
{
return
y
.
getValue
();
}
public
void
setX
(
double
x
)
{
this
.
x
.
setValue
(
x
);
}
public
void
setY
(
double
y
)
{
this
.
y
.
setValue
(
y
);
}
public
void
setPosition
(
Point2D
position
)
{
x
.
setValue
(
position
.
getX
());
y
.
setValue
(
position
.
getY
());
}
public
void
setPosition
(
double
x
,
double
y
)
{
setPosition
(
new
Point2D
.
Double
(
x
,
y
));
}
public
Point2D
getPosition
()
{
return
new
Point2D
.
Double
(
getX
(),
getY
());
}
public
Rectangle2D
getBounds
(
double
pixelSize
)
{
double
size
=
pixelSize
*
4
d
;
return
new
Rectangle2D
.
Double
(
getX
()
-
size
,
getY
()
-
size
,
size
*
2
,
size
*
2
);
}
public
boolean
isHit
(
Point2D
p
,
double
pixelSize
)
{
return
getBounds
(
pixelSize
).
contains
(
p
);
}
public
Shape
getShape
()
{
return
getBounds
(
0
);
}
public
void
paint
(
Graphics2D
g2
,
double
pixelSize
)
{
}
public
void
paintControls
(
Graphics2D
g2
,
double
pixelSize
,
boolean
paintControlLines
)
{
g2
.
setStroke
(
new
BasicStroke
((
float
)
pixelSize
));
Shape
s
=
getBounds
(
pixelSize
);
g2
.
setColor
(
fillColor
);
g2
.
fill
(
s
);
g2
.
setColor
(
lineColor
);
g2
.
draw
(
s
);
}
public
List
<
ControlPoint
>
getControlPoints
()
{
return
Collections
.
emptyList
();
}
public
void
move
(
double
moveX
,
double
moveY
,
boolean
snapPixels
)
{
if
(
snapPixels
)
{
setPosition
(
Math
.
round
(
x
.
getValue
()
+
moveX
),
Math
.
round
(
y
.
getValue
()
+
moveY
));
}
else
{
setPosition
(
x
.
getValue
()
+
moveX
,
y
.
getValue
()
+
moveY
);
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/Designer.jibx.xml
已删除
100644 → 0
浏览文件 @
feb1bd83
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 only, as
published by the Free Software Foundation. Sun designates this
particular file as subject to the "Classpath" exception as provided
by Sun in the LICENSE file that accompanied this code.
This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
version 2 for more details (a copy is included in the LICENSE file that
accompanied this code).
You should have received a copy of the GNU General Public License version
2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
CA 95054 USA or visit www.sun.com if you need additional information or
have any questions.
-->
<!DOCTYPE binding SYSTEM "http://jibx.sourceforge.net">
<binding>
<!-- == PAINTS =========================================================================================== -->
<mapping
class=
"java.awt.Color"
marshaller=
"org.jdesktop.swingx.designer.jibxhelpers.ColorMapper"
unmarshaller=
"org.jdesktop.swingx.designer.jibxhelpers.ColorMapper"
/>
<mapping
name=
"matte"
class=
"org.jdesktop.swingx.designer.paint.Matte"
post-set=
"postSet"
>
<value
name=
"red"
field=
"red"
style=
"attribute"
/>
<value
name=
"green"
field=
"green"
style=
"attribute"
/>
<value
name=
"blue"
field=
"blue"
style=
"attribute"
/>
<value
name=
"alpha"
field=
"alpha"
style=
"attribute"
/>
<value
name=
"uiDefaultParentName"
field=
"uiDefaultParentName"
style=
"attribute"
usage=
"optional"
/>
<value
name=
"componentPropertyName"
field=
"componentPropertyName"
style=
"attribute"
usage=
"optional"
/>
<value
name=
"hueOffset"
field=
"hueOffset"
style=
"attribute"
/>
<value
name=
"saturationOffset"
field=
"saturationOffset"
style=
"attribute"
/>
<value
name=
"brightnessOffset"
field=
"brightnessOffset"
style=
"attribute"
/>
<value
name=
"alphaOffset"
field=
"alphaOffset"
style=
"attribute"
/>
<value
name=
"uiResource"
field=
"uiResource"
style=
"attribute"
usage=
"optional"
default=
"true"
/>
</mapping>
<mapping
class=
"org.jdesktop.swingx.designer.paint.AbstractGradient"
abstract=
"true"
>
<value
name=
"cycleMethod"
field=
"cycleMethod"
style=
"attribute"
/>
<collection
field=
"stops"
set-method=
"setStops"
pre-set=
"clear"
create-type=
"java.util.ArrayList"
>
<structure
name=
"stop"
type=
"org.jdesktop.swingx.designer.paint.GradientStop"
>
<value
name=
"position"
field=
"position"
style=
"attribute"
/>
<value
name=
"midpoint"
field=
"midpoint"
style=
"attribute"
/>
<structure
field=
"color"
set-method=
"setColor"
/>
</structure>
</collection>
</mapping>
<mapping
name=
"gradient"
class=
"org.jdesktop.swingx.designer.paint.Gradient"
extends=
"org.jdesktop.swingx.designer.paint.AbstractGradient"
>
<structure
map-as=
"org.jdesktop.swingx.designer.paint.AbstractGradient"
/>
</mapping>
<mapping
name=
"radialGradient"
class=
"org.jdesktop.swingx.designer.paint.RadialGradient"
extends=
"org.jdesktop.swingx.designer.paint.AbstractGradient"
>
<structure
map-as=
"org.jdesktop.swingx.designer.paint.AbstractGradient"
/>
</mapping>
<!-- == SHAPES =========================================================================================== -->
<mapping
class=
"org.jdesktop.swingx.designer.SimpleShape"
abstract=
"true"
>
<!--protected AffineTransform transform = new AffineTransform();-->
</mapping>
<mapping
class=
"org.jdesktop.swingx.designer.PaintedShape"
abstract=
"true"
extends=
"org.jdesktop.swingx.designer.SimpleShape"
>
<structure
map-as=
"org.jdesktop.swingx.designer.SimpleShape"
/>
<structure
field=
"paint"
/>
<structure
name=
"paintPoints"
>
<value
name=
"x1"
get-method=
"getPaintX1"
set-method=
"setPaintX1"
style=
"attribute"
/>
<value
name=
"y1"
get-method=
"getPaintY1"
set-method=
"setPaintY1"
style=
"attribute"
/>
<value
name=
"x2"
get-method=
"getPaintX2"
set-method=
"setPaintX2"
style=
"attribute"
/>
<value
name=
"y2"
get-method=
"getPaintY2"
set-method=
"setPaintY2"
style=
"attribute"
/>
</structure>
</mapping>
<mapping
name=
"rectangle"
class=
"org.jdesktop.swingx.designer.RectangleShape"
extends=
"org.jdesktop.swingx.designer.PaintedShape"
>
<structure
map-as=
"org.jdesktop.swingx.designer.PaintedShape"
/>
<value
name=
"x1"
get-method=
"getX1"
set-method=
"setX1"
style=
"attribute"
/>
<value
name=
"x2"
get-method=
"getX2"
set-method=
"setX2"
style=
"attribute"
/>
<value
name=
"y1"
get-method=
"getY1"
set-method=
"setY1"
style=
"attribute"
/>
<value
name=
"y2"
get-method=
"getY2"
set-method=
"setY2"
style=
"attribute"
/>
<value
name=
"rounding"
get-method=
"getRounding"
set-method=
"setRounding"
style=
"attribute"
/>
</mapping>
<mapping
name=
"ellipse"
class=
"org.jdesktop.swingx.designer.EllipseShape"
extends=
"org.jdesktop.swingx.designer.PaintedShape"
>
<structure
map-as=
"org.jdesktop.swingx.designer.PaintedShape"
/>
<value
name=
"x1"
get-method=
"getX1"
set-method=
"setX1"
style=
"attribute"
/>
<value
name=
"x2"
get-method=
"getX2"
set-method=
"setX2"
style=
"attribute"
/>
<value
name=
"y1"
get-method=
"getY1"
set-method=
"setY1"
style=
"attribute"
/>
<value
name=
"y2"
get-method=
"getY2"
set-method=
"setY2"
style=
"attribute"
/>
</mapping>
<mapping
name=
"path"
class=
"org.jdesktop.swingx.designer.PathShape"
extends=
"org.jdesktop.swingx.designer.PaintedShape"
>
<structure
map-as=
"org.jdesktop.swingx.designer.PaintedShape"
/>
<collection
name=
"points"
get-method=
"getBezierControlPoints"
set-method=
"setControlPoints"
create-type=
"java.util.ArrayList"
>
<structure
name=
"point"
type=
"org.jdesktop.swingx.designer.BezierControlPoint"
>
<value
name=
"x"
get-method=
"getX"
set-method=
"setX"
style=
"attribute"
/>
<value
name=
"y"
get-method=
"getY"
set-method=
"setY"
style=
"attribute"
/>
<value
name=
"cp1x"
get-method=
"getCp1X"
set-method=
"setCp1X"
style=
"attribute"
/>
<value
name=
"cp1y"
get-method=
"getCp1Y"
set-method=
"setCp1Y"
style=
"attribute"
/>
<value
name=
"cp2x"
get-method=
"getCp2X"
set-method=
"setCp2X"
style=
"attribute"
/>
<value
name=
"cp2y"
get-method=
"getCp2Y"
set-method=
"setCp2Y"
style=
"attribute"
/>
</structure>
</collection>
</mapping>
<!-- == EFFECTS =========================================================================================== -->
<mapping
class=
"org.jdesktop.swingx.designer.effects.ShadowEffect"
abstract=
"true"
>
<structure
field=
"color"
/>
<value
name=
"blendingMode"
field=
"blendingMode"
style=
"attribute"
/>
<value
name=
"opacity"
field=
"opacity"
style=
"attribute"
/>
<value
name=
"angle"
field=
"angle"
style=
"attribute"
/>
<value
name=
"distance"
field=
"distance"
style=
"attribute"
/>
<value
name=
"spread"
field=
"spread"
style=
"attribute"
/>
<value
name=
"size"
field=
"size"
style=
"attribute"
/>
</mapping>
<mapping
name=
"dropShadow"
class=
"org.jdesktop.swingx.designer.effects.DropShadowEffect"
extends=
"org.jdesktop.swingx.designer.effects.ShadowEffect"
>
<structure
map-as=
"org.jdesktop.swingx.designer.effects.ShadowEffect"
/>
</mapping>
<mapping
name=
"innerShadow"
class=
"org.jdesktop.swingx.designer.effects.InnerShadowEffect"
extends=
"org.jdesktop.swingx.designer.effects.ShadowEffect"
>
<structure
map-as=
"org.jdesktop.swingx.designer.effects.ShadowEffect"
/>
</mapping>
<mapping
name=
"innerGlow"
class=
"org.jdesktop.swingx.designer.effects.InnerGlowEffect"
extends=
"org.jdesktop.swingx.designer.effects.ShadowEffect"
>
<structure
map-as=
"org.jdesktop.swingx.designer.effects.ShadowEffect"
/>
</mapping>
<mapping
name=
"outerGlow"
class=
"org.jdesktop.swingx.designer.effects.OuterGlowEffect"
extends=
"org.jdesktop.swingx.designer.effects.ShadowEffect"
>
<structure
map-as=
"org.jdesktop.swingx.designer.effects.ShadowEffect"
/>
</mapping>
<!-- == TEMPLATE LAYER ================================================================================== -->
<mapping
name=
"templateLayer"
class=
"org.jdesktop.swingx.designer.TemplateLayer"
extends=
"org.jdesktop.swingx.designer.Layer"
post-set=
"postInit"
>
<structure
map-as=
"org.jdesktop.swingx.designer.Layer"
/>
<value
name=
"fileName"
field=
"fileName"
style=
"attribute"
/>
</mapping>
<!-- == LAYER =========================================================================================== -->
<mapping
name=
"layer"
class=
"org.jdesktop.swingx.designer.Layer"
extends=
"org.jdesktop.swingx.designer.SimpleShape"
post-set=
"postInit"
>
<structure
map-as=
"org.jdesktop.swingx.designer.SimpleShape"
/>
<value
name=
"name"
field=
"name"
style=
"attribute"
/>
<value
name=
"type"
field=
"type"
style=
"attribute"
default=
"standard"
/>
<value
name=
"opacity"
field=
"opacity"
/>
<value
name=
"fillOpacity"
field=
"fillOpacity"
/>
<value
name=
"blendingMode"
field=
"blendingMode"
/>
<value
name=
"locked"
field=
"locked"
/>
<value
name=
"visible"
field=
"visible"
/>
<structure
name=
"shapes"
>
<collection
field=
"shapes"
create-type=
"java.util.ArrayList"
/>
</structure>
<structure
name=
"effects"
>
<collection
field=
"effects"
create-type=
"java.util.ArrayList"
/>
</structure>
</mapping>
<!-- == CANVAS =========================================================================================== -->
<mapping
name=
"canvas"
class=
"org.jdesktop.swingx.designer.Canvas"
pre-set=
"preSet"
post-set=
"setupLayers"
>
<structure
name=
"size"
get-method=
"getSize"
set-method=
"setSize"
marshaller=
"org.jdesktop.swingx.designer.jibxhelpers.DimensionMapper"
unmarshaller=
"org.jdesktop.swingx.designer.jibxhelpers.DimensionMapper"
/>
<value
name=
"nextLayerNameIndex"
field=
"nextLayerNameIndex"
/>
<structure
name=
"stretchingInsets"
field=
"stretchingInsets"
marshaller=
"org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"
unmarshaller=
"org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"
/>
<collection
field=
"layers"
create-type=
"java.util.ArrayList"
/>
</mapping>
</binding>
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/EllipseShape.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.geom.Ellipse2D
;
import
java.awt.geom.Point2D
;
import
java.awt.geom.Rectangle2D
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* EllipseShape
*
* @author Created by Jasper Potts (May 22, 2007)
*/
public
class
EllipseShape
extends
PaintedShape
{
private
DoubleBean
x1
=
new
DoubleBean
();
private
DoubleBean
x2
=
new
DoubleBean
();
private
DoubleBean
y1
=
new
DoubleBean
();
private
DoubleBean
y2
=
new
DoubleBean
();
private
ControlPoint
tl
=
new
ControlPoint
(
x1
,
y1
);
private
ControlPoint
tr
=
new
ControlPoint
(
x2
,
y1
);
private
ControlPoint
bl
=
new
ControlPoint
(
x1
,
y2
);
private
ControlPoint
br
=
new
ControlPoint
(
x2
,
y2
);
// =================================================================================================================
// Constructors
/** private noargs constructor for JIBX */
private
EllipseShape
()
{
this
(
null
);
}
public
EllipseShape
(
UIDefaults
canvasUiDefaults
)
{
super
(
canvasUiDefaults
);
PropertyChangeListener
listener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"bounds"
,
null
,
getBounds
(
0
));
}
};
x1
.
addPropertyChangeListener
(
listener
);
y1
.
addPropertyChangeListener
(
listener
);
x2
.
addPropertyChangeListener
(
listener
);
y2
.
addPropertyChangeListener
(
listener
);
}
public
EllipseShape
(
double
x
,
double
y
,
double
w
,
double
h
)
{
this
();
x1
.
setValue
(
x
);
y1
.
setValue
(
y
);
x2
.
setValue
(
x
+
w
);
y2
.
setValue
(
y
+
h
);
}
public
Rectangle2D
getBounds
(
double
pixelSize
)
{
double
left
=
Math
.
min
(
x1
.
getValue
(),
x2
.
getValue
());
double
right
=
Math
.
max
(
x1
.
getValue
(),
x2
.
getValue
());
double
top
=
Math
.
min
(
y1
.
getValue
(),
y2
.
getValue
());
double
bottom
=
Math
.
max
(
y1
.
getValue
(),
y2
.
getValue
());
return
new
Rectangle2D
.
Double
(
left
,
top
,
right
-
left
,
bottom
-
top
);
}
public
Ellipse2D
getShape
()
{
double
left
=
Math
.
min
(
x1
.
getValue
(),
x2
.
getValue
());
double
right
=
Math
.
max
(
x1
.
getValue
(),
x2
.
getValue
());
double
top
=
Math
.
min
(
y1
.
getValue
(),
y2
.
getValue
());
double
bottom
=
Math
.
max
(
y1
.
getValue
(),
y2
.
getValue
());
return
new
Ellipse2D
.
Double
(
left
,
top
,
right
-
left
,
bottom
-
top
);
}
public
boolean
isHit
(
Point2D
p
,
double
pixelSize
)
{
return
getBounds
(
pixelSize
).
contains
(
p
);
}
public
void
paint
(
Graphics2D
g2
,
double
pixelSize
)
{
g2
.
setPaint
(
getPaint
());
g2
.
fill
(
getShape
());
}
public
void
setFrame
(
double
x1
,
double
y1
,
double
x2
,
double
y2
)
{
this
.
x1
.
setValue
(
x1
);
this
.
y1
.
setValue
(
y1
);
this
.
x2
.
setValue
(
x2
);
this
.
y2
.
setValue
(
y2
);
}
@Override
public
String
toString
()
{
Rectangle2D
bounds
=
getBounds
(
0
);
return
"ELLIPSE { x="
+
bounds
.
getX
()
+
", y="
+
bounds
.
getY
()
+
", w="
+
bounds
.
getWidth
()
+
", h="
+
bounds
.
getHeight
()
+
" }"
;
}
public
List
<
ControlPoint
>
getControlPoints
()
{
List
<
ControlPoint
>
points
=
new
ArrayList
<
ControlPoint
>();
points
.
addAll
(
super
.
getControlPoints
());
points
.
add
(
tl
);
points
.
add
(
tr
);
points
.
add
(
bl
);
points
.
add
(
br
);
return
points
;
}
public
void
paintControls
(
Graphics2D
g2
,
double
pixelSize
,
boolean
paintControlLines
)
{
if
(
paintControlLines
)
{
g2
.
setStroke
(
new
BasicStroke
((
float
)
pixelSize
));
g2
.
setColor
(
GraphicsHelper
.
CONTROL_LINE
);
g2
.
draw
(
getShape
());
}
tl
.
paintControls
(
g2
,
pixelSize
,
true
);
tr
.
paintControls
(
g2
,
pixelSize
,
true
);
bl
.
paintControls
(
g2
,
pixelSize
,
true
);
br
.
paintControls
(
g2
,
pixelSize
,
true
);
// super.paintControls(g2, pixelSize, paintControlLines);
}
public
void
move
(
double
moveX
,
double
moveY
,
boolean
snapPixels
)
{
if
(
snapPixels
)
{
x1
.
setValue
(
Math
.
round
(
x1
.
getValue
()
+
moveX
));
x2
.
setValue
(
Math
.
round
(
x2
.
getValue
()
+
moveX
));
y1
.
setValue
(
Math
.
round
(
y1
.
getValue
()
+
moveY
));
y2
.
setValue
(
Math
.
round
(
y2
.
getValue
()
+
moveY
));
}
else
{
x1
.
setValue
(
x1
.
getValue
()
+
moveX
);
x2
.
setValue
(
x2
.
getValue
()
+
moveX
);
y1
.
setValue
(
y1
.
getValue
()
+
moveY
);
y2
.
setValue
(
y2
.
getValue
()
+
moveY
);
}
}
public
double
getX1
()
{
return
x1
.
getValue
();
}
public
void
setX1
(
double
x1
)
{
this
.
x1
.
setValue
(
x1
);
}
public
double
getX2
()
{
return
x2
.
getValue
();
}
public
void
setX2
(
double
x2
)
{
this
.
x2
.
setValue
(
x2
);
}
public
double
getY1
()
{
return
y1
.
getValue
();
}
public
void
setY1
(
double
y1
)
{
this
.
y1
.
setValue
(
y1
);
}
public
double
getY2
()
{
return
y2
.
getValue
();
}
public
void
setY2
(
double
y2
)
{
this
.
y2
.
setValue
(
y2
);
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/GraphicsHelper.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
java.awt.Color
;
/**
* GraphicsHelper
*
* @author Created by Jasper Potts (May 29, 2007)
*/
public
class
GraphicsHelper
{
public
static
final
Color
FILL_LINE
=
Color
.
BLUE
;
public
static
final
Color
FILL_CP_LINE
=
Color
.
BLUE
;
public
static
final
Color
FILL_CP_FILL
=
Color
.
WHITE
;
public
static
final
Color
CONTROL_LINE
=
Color
.
RED
;
public
static
final
Color
CONTROL_POINT_LINE
=
Color
.
RED
;
public
static
final
Color
CONTROL_POINT_FILL
=
Color
.
WHITE
;
public
static
final
Color
BEZIER_CONTROL_POINT_LINE
=
CONTROL_POINT_LINE
;
public
static
final
Color
BEZIER_CONTROL_POINT_FILL
=
CONTROL_POINT_FILL
;
public
static
final
Color
BEZIER_CONTROL_LINE
=
Color
.
DARK_GRAY
;
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/Layer.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
org.jdesktop.swingx.designer.effects.Effect
;
import
java.awt.Dimension
;
import
java.awt.Graphics2D
;
import
java.awt.Shape
;
import
java.awt.geom.Point2D
;
import
java.awt.geom.Rectangle2D
;
import
java.awt.image.BufferedImage
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
/**
* Layer
*
* @author Created by Jasper Potts (May 22, 2007)
*/
public
class
Layer
extends
SimpleShape
implements
Iterable
<
SimpleShape
>,
LayerContainer
{
public
static
enum
LayerType
{
standard
,
template
}
private
String
name
;
protected
LayerType
type
=
LayerType
.
standard
;
/** List of shapes in this layer, first shape is painted on top */
private
List
<
SimpleShape
>
shapes
=
new
ArrayList
<
SimpleShape
>();
private
List
<
Effect
>
effects
=
new
ArrayList
<
Effect
>();
private
double
opacity
=
1
;
private
double
fillOpacity
=
1
;
private
BlendingMode
blendingMode
=
BlendingMode
.
NORMAL
;
private
boolean
locked
=
false
;
private
boolean
visible
=
true
;
private
PropertyChangeListener
shapeChangeListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
int
index
=
shapes
.
indexOf
((
SimpleShape
)
evt
.
getSource
());
firePropertyChange
(
"shapes["
+
index
+
"]."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
};
private
PropertyChangeListener
effectChangeListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
int
index
=
effects
.
indexOf
((
Effect
)
evt
.
getSource
());
System
.
out
.
println
(
"Layer.propertyChange EFFECT PROPERTY CHANGED "
+
evt
.
getSource
()
+
" -- "
+
evt
.
getPropertyName
());
firePropertyChange
(
"effects["
+
index
+
"]."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
};
private
BufferedImage
buffer
=
null
;
// =================================================================================================================
// Constructors
public
Layer
()
{
}
public
Layer
(
String
name
)
{
this
();
this
.
name
=
name
;
}
/** Called by JIBX after populating this layer so we can add listeners to children */
protected
void
postInit
()
{
for
(
SimpleShape
shape
:
shapes
)
{
shape
.
addPropertyChangeListener
(
shapeChangeListener
);
shape
.
setParent
(
this
);
}
for
(
Effect
effect
:
effects
)
{
effect
.
addPropertyChangeListener
(
effectChangeListener
);
}
}
// =================================================================================================================
// Bean Methods
public
LayerType
getType
()
{
return
type
;
}
public
boolean
isLocked
()
{
return
locked
;
}
public
void
setLocked
(
boolean
locked
)
{
boolean
old
=
isLocked
();
this
.
locked
=
locked
;
firePropertyChange
(
"locked"
,
old
,
isLocked
());
}
public
boolean
isVisible
()
{
return
visible
;
}
public
void
setVisible
(
boolean
visible
)
{
boolean
old
=
isVisible
();
this
.
visible
=
visible
;
firePropertyChange
(
"visible"
,
old
,
isVisible
());
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
String
old
=
getName
();
this
.
name
=
name
;
firePropertyChange
(
"name"
,
old
,
getName
());
}
public
void
setParent
(
LayerContainer
parent
)
{
super
.
setParent
(
parent
);
// generate a name if null
if
(
name
==
null
)
{
Canvas
c
=
null
;
LayerContainer
p
=
parent
;
while
(
true
)
{
if
(
p
instanceof
Canvas
)
{
c
=
(
Canvas
)
p
;
break
;
}
else
if
(
p
==
null
)
{
break
;
}
p
=
p
.
getParent
();
}
if
(
c
!=
null
)
{
setName
(
"Layer "
+
c
.
getNextLayerNameIndex
());
}
}
}
/**
* Add shape to top of layer so it paints above all other shapes
*
* @param shape The shape to add
*/
public
void
add
(
SimpleShape
shape
)
{
shapes
.
add
(
0
,
shape
);
shape
.
setParent
(
this
);
shape
.
addPropertyChangeListener
(
shapeChangeListener
);
fireIndexedPropertyChange
(
"shapes"
,
0
,
null
,
shape
);
}
public
void
remove
(
SimpleShape
shape
)
{
int
index
=
shapes
.
indexOf
(
shape
);
if
(
index
!=
-
1
)
{
shapes
.
remove
(
shape
);
shape
.
setParent
(
null
);
fireIndexedPropertyChange
(
"shapes"
,
index
,
shape
,
null
);
}
}
/**
* Returns an unmodifianle iterator over a set of elements of type SimpleShape.
*
* @return an Iterator.
*/
public
Iterator
<
SimpleShape
>
iterator
()
{
return
Collections
.
unmodifiableList
(
shapes
).
iterator
();
}
public
List
<
Effect
>
getEffects
()
{
return
Collections
.
unmodifiableList
(
effects
);
}
public
void
addEffect
(
Effect
effect
)
{
int
index
=
effects
.
size
();
effects
.
add
(
effect
);
effect
.
addPropertyChangeListener
(
effectChangeListener
);
fireIndexedPropertyChange
(
"effects"
,
index
,
null
,
effects
);
}
public
void
removeEffect
(
Effect
effect
)
{
int
index
=
effects
.
indexOf
(
effect
);
if
(
index
!=
-
1
)
{
effects
.
remove
(
effect
);
effect
.
removePropertyChangeListener
(
effectChangeListener
);
fireIndexedPropertyChange
(
"effects"
,
index
,
effect
,
null
);
}
}
public
double
getOpacity
()
{
return
opacity
;
}
public
void
setOpacity
(
double
opacity
)
{
if
(
opacity
<
0
||
opacity
>
1
)
return
;
double
old
=
getOpacity
();
this
.
opacity
=
opacity
;
firePropertyChange
(
"opacity"
,
old
,
getOpacity
());
}
public
double
getFillOpacity
()
{
return
fillOpacity
;
}
public
void
setFillOpacity
(
double
fillOpacity
)
{
if
(
fillOpacity
<
0
||
fillOpacity
>
1
)
return
;
double
old
=
getFillOpacity
();
this
.
fillOpacity
=
fillOpacity
;
firePropertyChange
(
"fillOpacity"
,
old
,
getFillOpacity
());
}
public
BlendingMode
getBlendingMode
()
{
return
blendingMode
;
}
public
void
setBlendingMode
(
BlendingMode
blendingMode
)
{
BlendingMode
old
=
getBlendingMode
();
this
.
blendingMode
=
blendingMode
;
firePropertyChange
(
"blendingMode"
,
old
,
getBlendingMode
());
}
// =================================================================================================================
// Layer Methods
/**
* Get the parent canvas that contains this layer
*
* @return Parant canvas, or null if the layer is not in a canvas
*/
public
Canvas
getCanvas
()
{
LayerContainer
lc
=
this
;
while
(
lc
!=
null
)
{
if
(
lc
instanceof
Canvas
)
return
(
Canvas
)
lc
;
lc
=
lc
.
getParent
();
}
return
null
;
}
public
List
<
SimpleShape
>
getShapes
()
{
return
new
ArrayList
<
SimpleShape
>(
shapes
);
}
public
List
<
SimpleShape
>
getIntersectingShapes
(
Point2D
p
,
double
pixelSize
)
{
if
(
isLocked
()
||
!
isVisible
())
return
Collections
.
emptyList
();
List
<
SimpleShape
>
intersectingShapes
=
new
ArrayList
<
SimpleShape
>();
for
(
SimpleShape
shape
:
shapes
)
{
if
(
shape
instanceof
Layer
)
{
intersectingShapes
.
addAll
(((
Layer
)
shape
).
getIntersectingShapes
(
p
,
pixelSize
));
}
else
{
if
(
shape
.
isHit
(
p
,
pixelSize
))
intersectingShapes
.
add
(
shape
);
}
}
return
intersectingShapes
;
}
public
List
<
SimpleShape
>
getIntersectingShapes
(
Rectangle2D
rect
,
double
pixelSize
)
{
if
(
isLocked
()
||
!
isVisible
())
return
Collections
.
emptyList
();
List
<
SimpleShape
>
intersectingShapes
=
new
ArrayList
<
SimpleShape
>();
for
(
SimpleShape
shape
:
shapes
)
{
if
(
shape
instanceof
Layer
)
{
intersectingShapes
.
addAll
(((
Layer
)
shape
).
getIntersectingShapes
(
rect
,
pixelSize
));
}
else
{
if
(
shape
.
intersects
(
rect
,
pixelSize
))
intersectingShapes
.
add
(
shape
);
}
}
return
intersectingShapes
;
}
public
boolean
isEmpty
()
{
return
shapes
.
isEmpty
();
}
// =================================================================================================================
// SimpleShape Methods
public
Rectangle2D
getBounds
(
double
pixelSize
)
{
Rectangle2D
.
Double
rect
=
new
Rectangle2D
.
Double
();
for
(
SimpleShape
shape
:
shapes
)
{
rect
.
add
(
shape
.
getBounds
(
pixelSize
));
}
return
rect
;
}
public
Shape
getShape
()
{
return
getBounds
(
0
);
}
public
boolean
isHit
(
Point2D
p
,
double
pixelSize
)
{
if
(
isLocked
()
||
!
isVisible
())
return
false
;
for
(
SimpleShape
shape
:
shapes
)
{
if
(
shape
.
isHit
(
p
,
pixelSize
))
return
true
;
}
return
false
;
}
public
boolean
intersects
(
Rectangle2D
rect
,
double
pixelSize
)
{
if
(
isLocked
()
||
!
isVisible
())
return
false
;
for
(
SimpleShape
shape
:
shapes
)
{
if
(
shape
.
intersects
(
rect
,
pixelSize
))
return
true
;
}
return
false
;
}
public
List
<
ControlPoint
>
getControlPoints
()
{
return
Collections
.
emptyList
();
}
public
void
paint
(
Graphics2D
g2
,
double
pixelSize
)
{
}
public
void
paintControls
(
Graphics2D
g2
,
double
pixelSize
,
boolean
paintControlLines
)
{
}
public
String
toString
()
{
return
getName
();
}
// =================================================================================================================
// LayerContainer Methods
public
void
addLayer
(
int
i
,
Layer
layer
)
{
// get existing layer at index i
Layer
existingLayer
=
getLayer
(
i
);
if
(
existingLayer
==
null
)
{
addLayer
(
layer
);
}
else
{
int
index
=
indexOfLayer
(
existingLayer
);
shapes
.
add
(
index
,
layer
);
layer
.
setParent
(
this
);
layer
.
addPropertyChangeListener
(
shapeChangeListener
);
fireIndexedPropertyChange
(
"layers"
,
index
,
null
,
layer
);
}
}
public
void
addLayer
(
Layer
layer
)
{
shapes
.
add
(
layer
);
layer
.
setParent
(
this
);
layer
.
addPropertyChangeListener
(
shapeChangeListener
);
int
index
=
indexOfLayer
(
layer
);
fireIndexedPropertyChange
(
"layers"
,
index
,
null
,
layer
);
}
public
Layer
getLayer
(
int
index
)
{
int
i
=
-
1
;
for
(
SimpleShape
shape
:
shapes
)
{
if
(
shape
instanceof
Layer
)
i
++;
if
(
i
==
index
)
return
(
Layer
)
shape
;
}
return
null
;
}
public
int
getLayerCount
()
{
int
count
=
0
;
for
(
SimpleShape
shape
:
shapes
)
{
if
(
shape
instanceof
Layer
)
count
++;
}
return
count
;
}
public
Collection
<
Layer
>
getLayers
()
{
List
<
Layer
>
layers
=
new
ArrayList
<
Layer
>();
for
(
SimpleShape
shape
:
shapes
)
{
if
(
shape
instanceof
Layer
)
layers
.
add
((
Layer
)
shape
);
}
return
Collections
.
unmodifiableList
(
layers
);
}
public
Iterator
<
Layer
>
getLayerIterator
()
{
return
new
Iterator
<
Layer
>()
{
private
int
index
=
0
;
public
boolean
hasNext
()
{
for
(
int
i
=
index
;
i
<
shapes
.
size
();
i
++)
{
if
(
shapes
.
get
(
i
)
instanceof
Layer
)
{
return
true
;
}
}
return
false
;
}
public
Layer
next
()
{
for
(;
index
<
shapes
.
size
();
index
++)
{
if
(
shapes
.
get
(
index
)
instanceof
Layer
)
{
Layer
nextLayer
=
(
Layer
)
shapes
.
get
(
index
);
index
++;
// increment index so we don't find the same one again
return
nextLayer
;
}
}
return
null
;
}
public
void
remove
()
{
throw
new
UnsupportedOperationException
();
}
};
}
public
int
indexOfLayer
(
Layer
layer
)
{
int
i
=
-
1
;
for
(
SimpleShape
s
:
shapes
)
{
if
(
s
instanceof
Layer
)
i
++;
if
(
s
==
layer
)
return
i
;
}
return
-
1
;
}
public
void
removeLayer
(
Layer
layer
)
{
int
index
=
indexOfLayer
(
layer
);
if
(
index
!=
-
1
)
{
shapes
.
remove
(
layer
);
layer
.
removePropertyChangeListener
(
shapeChangeListener
);
fireIndexedPropertyChange
(
"layers"
,
index
,
layer
,
null
);
}
}
public
Dimension
getRootSize
()
{
return
getParent
().
getRootSize
();
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/LayerContainer.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
java.awt.Dimension
;
import
java.beans.PropertyChangeListener
;
import
java.util.Collection
;
import
java.util.Iterator
;
/**
* LayerContainer
*
* @author Created by Jasper Potts (May 31, 2007)
*/
public
interface
LayerContainer
{
public
void
addPropertyChangeListener
(
PropertyChangeListener
listener
);
public
void
removePropertyChangeListener
(
PropertyChangeListener
listener
);
public
LayerContainer
getParent
();
public
void
addLayer
(
Layer
layer
);
public
void
addLayer
(
int
i
,
Layer
layer
);
public
void
removeLayer
(
Layer
layer
);
public
int
getLayerCount
();
public
Layer
getLayer
(
int
index
);
public
int
indexOfLayer
(
Layer
layer
);
public
Iterator
<
Layer
>
getLayerIterator
();
public
Collection
<
Layer
>
getLayers
();
/**
* Get the size in pixels of the root of the layer tree, this is usualy a canvas
*
* @return The size of the whole layer tree
*/
public
Dimension
getRootSize
();
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/PaintedShape.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
org.jdesktop.swingx.designer.paint.Matte
;
import
org.jdesktop.swingx.designer.paint.PaintModel
;
import
javax.swing.UIDefaults
;
import
java.awt.BasicStroke
;
import
java.awt.Color
;
import
java.awt.GradientPaint
;
import
java.awt.Graphics2D
;
import
java.awt.LinearGradientPaint
;
import
java.awt.Paint
;
import
java.awt.RadialGradientPaint
;
import
java.awt.Shape
;
import
java.awt.geom.Ellipse2D
;
import
java.awt.geom.Line2D
;
import
java.awt.geom.Point2D
;
import
java.awt.geom.Rectangle2D
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
/**
* PaintedShape
*
* @author Created by Jasper Potts (May 22, 2007)
*/
public
abstract
class
PaintedShape
extends
SimpleShape
{
private
PaintModel
paint
;
// control points for paint control types
private
DoubleBean
px1
=
new
DoubleBean
(
0.25
);
private
DoubleBean
px2
=
new
DoubleBean
(
0.75
);
private
DoubleBean
py1
=
new
DoubleBean
(
0
);
private
DoubleBean
py2
=
new
DoubleBean
(
1
);
private
ControlPoint
ptl
=
new
PaintControlPoint
(
px1
,
py1
);
private
ControlPoint
ptr
=
new
PaintControlPoint
(
px2
,
py1
);
private
ControlPoint
pbl
=
new
PaintControlPoint
(
px1
,
py2
);
private
ControlPoint
pbr
=
new
PaintControlPoint
(
px2
,
py2
);
private
PropertyChangeListener
paintListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"paint."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
};
protected
PaintedShape
()
{
px1
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"x1"
,
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
});
py1
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"y1"
,
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
});
px2
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"x2"
,
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
});
py2
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"y2"
,
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
});
}
protected
PaintedShape
(
UIDefaults
canvasUiDefaults
)
{
this
();
setPaintModel
(
new
Matte
(
Color
.
ORANGE
,
canvasUiDefaults
));
}
public
PaintModel
getPaintModel
()
{
return
paint
;
}
public
void
setPaintModel
(
PaintModel
paint
)
{
PaintModel
old
=
getPaintModel
();
if
(
old
!=
null
)
old
.
removePropertyChangeListener
(
paintListener
);
this
.
paint
=
paint
;
this
.
paint
.
addPropertyChangeListener
(
paintListener
);
firePropertyChange
(
"paintModel"
,
old
,
getPaintModel
());
}
public
Paint
getPaint
()
{
Paint
p
=
getPaintModel
().
getPaint
();
if
(
p
instanceof
Color
)
{
return
p
;
}
//resize p as necessary to fit the bounds of this PaintedShape
Rectangle2D
bounds
=
getBounds
(
0
);
if
(
p
instanceof
LinearGradientPaint
)
{
LinearGradientPaint
lgp
=
(
LinearGradientPaint
)
p
;
return
new
LinearGradientPaint
(
convertLocalPoint
(
ptl
.
getPosition
(),
bounds
),
convertLocalPoint
(
pbr
.
getPosition
(),
bounds
),
lgp
.
getFractions
(),
lgp
.
getColors
());
}
else
if
(
p
instanceof
RadialGradientPaint
)
{
RadialGradientPaint
rgp
=
(
RadialGradientPaint
)
p
;
Point2D
outer
=
convertLocalPoint
(
ptl
.
getPosition
(),
bounds
);
Point2D
center
=
convertLocalPoint
(
pbr
.
getPosition
(),
bounds
);
double
deltaX
=
Math
.
abs
(
center
.
getX
()
-
outer
.
getX
());
double
deltaY
=
Math
.
abs
(
center
.
getY
()
-
outer
.
getY
());
float
radius
=
(
float
)
Math
.
sqrt
((
deltaX
*
deltaX
)
+
(
deltaY
*
deltaY
));
return
new
RadialGradientPaint
(
center
,
radius
,
rgp
.
getFractions
(),
rgp
.
getColors
());
}
else
{
return
p
;
}
}
public
List
<?
extends
ControlPoint
>
getControlPoints
()
{
switch
(
paint
.
getPaintControlType
())
{
case
control_line:
return
Arrays
.
asList
(
ptl
,
pbr
);
case
control_rect:
return
Arrays
.
asList
(
ptl
,
ptr
,
pbl
,
pbr
);
default
:
return
Collections
.
emptyList
();
}
}
public
void
paintFillControls
(
Graphics2D
g2
,
double
pixelSize
,
boolean
paintControlLines
)
{
switch
(
paint
.
getPaintControlType
())
{
case
control_line:
Point2D
p1
=
convertLocalPoint
(
ptl
.
getPosition
(),
PaintedShape
.
this
.
getBounds
(
0
));
Point2D
p2
=
convertLocalPoint
(
pbr
.
getPosition
(),
PaintedShape
.
this
.
getBounds
(
0
));
g2
.
setStroke
(
new
BasicStroke
((
float
)
pixelSize
));
g2
.
setColor
(
GraphicsHelper
.
FILL_LINE
);
g2
.
draw
(
new
Line2D
.
Double
(
p1
.
getX
(),
p1
.
getY
(),
p2
.
getX
(),
p2
.
getY
()));
ptl
.
paintControls
(
g2
,
pixelSize
,
true
);
pbr
.
paintControls
(
g2
,
pixelSize
,
true
);
break
;
case
control_rect:
g2
.
setStroke
(
new
BasicStroke
((
float
)
pixelSize
));
g2
.
setColor
(
GraphicsHelper
.
FILL_LINE
);
g2
.
draw
(
new
Rectangle2D
.
Double
(
px1
.
getValue
(),
py1
.
getValue
(),
px2
.
getValue
()
-
px1
.
getValue
(),
py2
.
getValue
()
-
py1
.
getValue
()));
ptl
.
paintControls
(
g2
,
pixelSize
,
true
);
ptr
.
paintControls
(
g2
,
pixelSize
,
true
);
pbl
.
paintControls
(
g2
,
pixelSize
,
true
);
pbr
.
paintControls
(
g2
,
pixelSize
,
true
);
break
;
}
}
public
void
move
(
double
moveX
,
double
moveY
,
boolean
snapPixels
)
{
for
(
ControlPoint
controlPoint
:
getControlPoints
())
{
if
(!(
controlPoint
instanceof
PaintControlPoint
))
controlPoint
.
move
(
moveX
,
moveY
,
snapPixels
);
}
}
public
double
getPaintX1
()
{
return
px1
.
getValue
();
}
public
void
setPaintX1
(
double
x1
)
{
this
.
px1
.
setValue
(
x1
);
}
public
double
getPaintX2
()
{
return
px2
.
getValue
();
}
public
void
setPaintX2
(
double
x2
)
{
this
.
px2
.
setValue
(
x2
);
}
public
double
getPaintY1
()
{
return
py1
.
getValue
();
}
public
void
setPaintY1
(
double
y1
)
{
this
.
py1
.
setValue
(
y1
);
}
public
double
getPaintY2
()
{
return
py2
.
getValue
();
}
public
void
setPaintY2
(
double
y2
)
{
this
.
py2
.
setValue
(
y2
);
}
// =================================================================================================================
// Private helper methods
private
Point2D
convertLocalPoint
(
Point2D
point
,
Rectangle2D
bounds
)
{
point
.
setLocation
(
bounds
.
getX
()
+
(
point
.
getX
()
*
bounds
.
getWidth
()),
bounds
.
getY
()
+
(
point
.
getY
()
*
bounds
.
getHeight
())
);
return
point
;
}
private
Point2D
convertScreenPoint
(
Point2D
point
,
Rectangle2D
bounds
)
{
return
new
Point2D
.
Double
(
(
point
.
getX
()
-
bounds
.
getX
())
/
bounds
.
getWidth
(),
(
point
.
getY
()
-
bounds
.
getY
())
/
bounds
.
getHeight
()
);
}
// =================================================================================================================
// Gradient ControlPoint
/**
* A Special ControlPoint thats internal values are in coordinates relative to the shapes bounds. With 0,0 being the
* top left of the shape and 1.0X == shape width and 1.0Y == shapes height.
*/
public
class
PaintControlPoint
extends
ControlPoint
{
public
PaintControlPoint
()
{
super
(
GraphicsHelper
.
FILL_CP_FILL
,
GraphicsHelper
.
FILL_CP_LINE
);
}
public
PaintControlPoint
(
DoubleBean
x
,
DoubleBean
y
)
{
super
(
x
,
y
,
GraphicsHelper
.
FILL_CP_FILL
,
GraphicsHelper
.
FILL_CP_LINE
);
}
public
void
paintControls
(
Graphics2D
g2
,
double
pixelSize
,
boolean
paintControlLines
)
{
Point2D
p
=
convertLocalPoint
(
getPosition
(),
PaintedShape
.
this
.
getBounds
(
0
));
g2
.
setStroke
(
new
BasicStroke
((
float
)
pixelSize
));
double
size
=
pixelSize
*
4
d
;
Shape
s
=
new
Ellipse2D
.
Double
(
p
.
getX
()
-
size
,
p
.
getY
()
-
size
,
size
*
2
,
size
*
2
);
g2
.
setPaint
(
new
GradientPaint
(
(
float
)
p
.
getX
(),
(
float
)
(
p
.
getY
()
-
size
),
Color
.
CYAN
,
(
float
)
p
.
getX
(),
(
float
)
(
p
.
getY
()
+
size
),
Color
.
WHITE
));
g2
.
fill
(
s
);
g2
.
setColor
(
GraphicsHelper
.
FILL_CP_LINE
);
g2
.
draw
(
s
);
}
public
void
move
(
double
moveX
,
double
moveY
,
boolean
snapPixels
)
{
Rectangle2D
bounds
=
PaintedShape
.
this
.
getBounds
(
0
);
moveX
=
moveX
/
bounds
.
getWidth
();
moveY
=
moveY
/
bounds
.
getHeight
();
if
(
snapPixels
)
{
// snap to neareast 0.5
double
newX
=
Math
.
round
((
x
.
getValue
()
+
moveX
)
*
2
d
)
/
2
d
;
double
newY
=
Math
.
round
((
y
.
getValue
()
+
moveY
)
*
2
d
)
/
2
d
;
setPosition
(
newX
,
newY
);
}
else
{
setPosition
(
x
.
getValue
()
+
moveX
,
y
.
getValue
()
+
moveY
);
}
}
public
Rectangle2D
getBounds
(
double
pixelSize
)
{
Point2D
p
=
convertLocalPoint
(
getPosition
(),
PaintedShape
.
this
.
getBounds
(
0
));
double
size
=
pixelSize
*
4
d
;
return
new
Rectangle2D
.
Double
(
p
.
getX
()
-
size
,
p
.
getY
()
-
size
,
size
*
2
,
size
*
2
);
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/PathShape.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.geom.GeneralPath
;
import
java.awt.geom.Point2D
;
import
java.awt.geom.Rectangle2D
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* PathShape
*
* @author Created by Jasper Potts (May 29, 2007)
*/
public
class
PathShape
extends
PaintedShape
{
private
Shape
cachedShape
=
null
;
private
List
<
BezierControlPoint
>
controlPoints
=
new
ArrayList
<
BezierControlPoint
>();
private
PropertyChangeListener
cpListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
rebuildShape
();
}
};
// =================================================================================================================
// Constructors
/** private noargs constructor for JIBX */
private
PathShape
()
{
this
(
null
);
}
public
PathShape
(
UIDefaults
canvasUiDefaults
)
{
super
(
canvasUiDefaults
);
}
public
BezierControlPoint
addPoint
(
double
x
,
double
y
)
{
BezierControlPoint
cp
=
new
BezierControlPoint
(
x
,
y
);
controlPoints
.
add
(
cp
);
cp
.
addPropertyChangeListener
(
cpListener
);
// update shape
rebuildShape
();
// return new control point
return
cp
;
}
public
Shape
getShape
()
{
if
(
cachedShape
==
null
)
{
rebuildShape
();
}
return
cachedShape
;
}
private
void
rebuildShape
()
{
GeneralPath
path
=
new
GeneralPath
();
BezierControlPoint
first
,
last
;
first
=
last
=
controlPoints
.
get
(
0
);
path
.
moveTo
((
float
)
first
.
getX
(),
(
float
)
first
.
getY
());
for
(
int
i
=
0
;
i
<
controlPoints
.
size
();
i
++)
{
BezierControlPoint
controlPoint
=
controlPoints
.
get
(
i
);
if
(
last
.
getCp2
().
isSharp
()
&&
controlPoint
.
getCp1
().
isSharp
())
{
path
.
lineTo
(
controlPoint
.
getX
(),
controlPoint
.
getY
());
}
else
{
path
.
curveTo
(
(
float
)
last
.
getCp2
().
getX
(),
(
float
)
last
.
getCp2
().
getY
(),
(
float
)
controlPoint
.
getCp1
().
getX
(),
(
float
)
controlPoint
.
getCp1
().
getY
(),
(
float
)
controlPoint
.
getX
(),
(
float
)
controlPoint
.
getY
()
);
}
last
=
controlPoint
;
}
// close path
if
(
last
.
getCp2
().
isSharp
()
&&
first
.
getCp1
().
isSharp
())
{
path
.
lineTo
(
first
.
getX
(),
first
.
getY
());
}
else
{
path
.
curveTo
(
(
float
)
last
.
getCp2
().
getX
(),
(
float
)
last
.
getCp2
().
getY
(),
(
float
)
first
.
getCp1
().
getX
(),
(
float
)
first
.
getCp1
().
getY
(),
(
float
)
first
.
getX
(),
(
float
)
first
.
getY
()
);
}
path
.
closePath
();
// fire change
cachedShape
=
path
;
firePropertyChange
(
"shape"
,
null
,
cachedShape
);
}
@Override
public
String
toString
()
{
String
p
=
"PATH {\n"
;
BezierControlPoint
first
,
last
;
first
=
last
=
controlPoints
.
get
(
0
);
p
+=
" path.moveTo("
+
first
.
getX
()
+
","
+
first
.
getY
()
+
");"
;
for
(
int
i
=
0
;
i
<
controlPoints
.
size
();
i
++)
{
BezierControlPoint
controlPoint
=
controlPoints
.
get
(
i
);
p
+=
" path.curveTo("
+
(
float
)
last
.
getCp2
().
getX
()
+
","
+
(
float
)
last
.
getCp2
().
getY
()
+
","
+
(
float
)
controlPoint
.
getCp1
().
getX
()
+
","
+
(
float
)
controlPoint
.
getCp1
().
getY
()
+
","
+
(
float
)
controlPoint
.
getX
()
+
","
+
(
float
)
controlPoint
.
getY
()
+
");\n"
;
last
=
controlPoint
;
}
// close path
p
+=
" path.curveTo("
+
(
float
)
last
.
getCp2
().
getX
()
+
","
+
(
float
)
last
.
getCp2
().
getY
()
+
","
+
(
float
)
first
.
getCp1
().
getX
()
+
","
+
(
float
)
first
.
getCp1
().
getY
()
+
","
+
(
float
)
first
.
getX
()
+
","
+
(
float
)
first
.
getY
()
+
");\n"
;
p
+=
"}\n"
;
return
p
;
}
// =================================================================================================================
// Shape Methods
public
Rectangle2D
getBounds
(
double
pixelSize
)
{
return
getShape
().
getBounds2D
();
}
public
List
<?
extends
ControlPoint
>
getControlPoints
()
{
List
<
ControlPoint
>
pts
=
new
ArrayList
<
ControlPoint
>();
for
(
BezierControlPoint
controlPoint
:
controlPoints
)
{
pts
.
add
(
controlPoint
);
}
for
(
ControlPoint
controlPoint
:
super
.
getControlPoints
())
{
pts
.
add
(
controlPoint
);
}
return
pts
;
}
public
void
setControlPoints
(
List
<
BezierControlPoint
>
controlPoints
)
{
List
<
BezierControlPoint
>
old
=
this
.
controlPoints
;
for
(
BezierControlPoint
cp
:
old
)
{
cp
.
removePropertyChangeListener
(
cpListener
);
}
this
.
controlPoints
=
controlPoints
;
for
(
BezierControlPoint
cp
:
this
.
controlPoints
)
{
cp
.
addPropertyChangeListener
(
cpListener
);
}
// update shape
rebuildShape
();
}
public
boolean
isHit
(
Point2D
p
,
double
pixelSize
)
{
return
getShape
().
contains
(
p
);
}
public
void
paint
(
Graphics2D
g2
,
double
pixelSize
)
{
g2
.
setPaint
(
getPaint
());
g2
.
fill
(
getShape
());
}
public
void
paintControls
(
Graphics2D
g2
,
double
pixelSize
,
boolean
paintControlLines
)
{
if
(
paintControlLines
)
{
g2
.
setStroke
(
new
BasicStroke
((
float
)
pixelSize
));
g2
.
setColor
(
GraphicsHelper
.
CONTROL_LINE
);
g2
.
draw
(
getShape
());
}
for
(
BezierControlPoint
controlPoint
:
controlPoints
)
{
if
(!
controlPoint
.
isSharpCorner
())
controlPoint
.
paintControls
(
g2
,
pixelSize
,
true
);
}
}
public
List
<
BezierControlPoint
>
getBezierControlPoints
()
{
return
controlPoints
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/RectangleShape.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.geom.Ellipse2D
;
import
java.awt.geom.Point2D
;
import
java.awt.geom.Rectangle2D
;
import
java.awt.geom.RoundRectangle2D
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* RectangleShape
*
* @author Created by Jasper Potts (May 22, 2007)
*/
public
class
RectangleShape
extends
PaintedShape
{
private
DoubleBean
x1
=
new
DoubleBean
();
private
DoubleBean
x2
=
new
DoubleBean
();
private
DoubleBean
y1
=
new
DoubleBean
();
private
DoubleBean
y2
=
new
DoubleBean
();
private
ControlPoint
tl
=
new
ControlPoint
(
x1
,
y1
);
private
ControlPoint
tr
=
new
ControlPoint
(
x2
,
y1
);
private
ControlPoint
bl
=
new
ControlPoint
(
x1
,
y2
);
private
ControlPoint
br
=
new
ControlPoint
(
x2
,
y2
);
private
DoubleBean
roundingX
=
new
DoubleBean
()
{
public
void
setValue
(
double
value
)
{
// contrain y = y1 and x is between x1+1 and (x2-x1)/2
boolean
x1isLess
=
x1
.
getValue
()
<
x2
.
getValue
();
double
min
=
x1isLess
?
x1
.
getValue
()
+
1
:
x1
.
getValue
()
-
1
;
double
max
=
x1isLess
?
x1
.
getValue
()
+
((
x2
.
getValue
()
-
x1
.
getValue
())
/
2
)
:
x2
.
getValue
()
+
((
x1
.
getValue
()
-
x2
.
getValue
())
/
2
);
double
newX
=
value
;
if
(
newX
<
min
)
newX
=
min
;
if
(
newX
>
max
)
newX
=
max
;
super
.
setValue
(
newX
);
}
};
private
ControlPoint
rounding
=
new
ControlPoint
(
roundingX
,
y1
)
{
public
void
paintControls
(
Graphics2D
g2
,
double
pixelSize
,
boolean
paintControlLines
)
{
double
size
=
pixelSize
*
3
d
;
Shape
s
=
new
Ellipse2D
.
Double
(
getX
()
-
size
,
getY
()
-
size
,
size
*
2
,
size
*
2
);
g2
.
setColor
(
GraphicsHelper
.
BEZIER_CONTROL_POINT_FILL
);
g2
.
fill
(
s
);
g2
.
setColor
(
GraphicsHelper
.
BEZIER_CONTROL_POINT_LINE
);
g2
.
draw
(
s
);
}
public
void
setPosition
(
Point2D
position
)
{
// only alow X to change
x
.
setValue
(
position
.
getX
());
}
};
// =================================================================================================================
// Constructors
/** private noargs constructor for JIBX */
private
RectangleShape
()
{
this
(
null
);
}
public
RectangleShape
(
UIDefaults
canvasUiDefaults
)
{
super
(
canvasUiDefaults
);
x1
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
// keep rounding point in sync
roundingX
.
setValue
(
roundingX
.
getValue
()
+
((
Double
)
evt
.
getNewValue
()
-
(
Double
)
evt
.
getOldValue
()));
firePropertyChange
(
"bounds"
,
null
,
getBounds
(
0
));
}
});
x2
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
// keep rounding point in sync
double
distanceFromX1
=
Math
.
abs
(
roundingX
.
getValue
()
-
x1
.
getValue
());
roundingX
.
setValue
(
(
x1
.
getValue
()
<
x2
.
getValue
())
?
x1
.
getValue
()
+
distanceFromX1
:
x1
.
getValue
()
-
distanceFromX1
);
firePropertyChange
(
"bounds"
,
null
,
getBounds
(
0
));
}
});
PropertyChangeListener
listener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"bounds"
,
null
,
getBounds
(
0
));
}
};
y1
.
addPropertyChangeListener
(
listener
);
y2
.
addPropertyChangeListener
(
listener
);
rounding
.
addPropertyChangeListener
(
listener
);
}
public
RectangleShape
(
double
x
,
double
y
,
double
w
,
double
h
)
{
this
();
x1
.
setValue
(
x
);
y1
.
setValue
(
y
);
x2
.
setValue
(
x
+
w
);
y2
.
setValue
(
y
+
h
);
}
public
Shape
getShape
()
{
double
rounding
=
getRounding
();
double
left
=
Math
.
min
(
x1
.
getValue
(),
x2
.
getValue
());
double
right
=
Math
.
max
(
x1
.
getValue
(),
x2
.
getValue
());
double
top
=
Math
.
min
(
y1
.
getValue
(),
y2
.
getValue
());
double
bottom
=
Math
.
max
(
y1
.
getValue
(),
y2
.
getValue
());
if
(
rounding
>
0
)
{
return
new
RoundRectangle2D
.
Double
(
left
,
top
,
right
-
left
,
bottom
-
top
,
rounding
,
rounding
);
}
else
{
return
new
Rectangle2D
.
Double
(
left
,
top
,
right
-
left
,
bottom
-
top
);
}
}
public
double
getRounding
()
{
double
rounding
=
Math
.
abs
(
roundingX
.
getValue
()
-
x1
.
getValue
())
*
2
;
return
rounding
>
2
?
rounding
:
0
;
}
public
void
setRounding
(
double
rounding
)
{
if
(
rounding
>
0
&&
rounding
<
2
)
rounding
=
0
;
roundingX
.
setValue
((
rounding
/
2
d
)
+
x1
.
getValue
());
}
public
boolean
isRounded
()
{
return
getRounding
()
>
0
;
}
public
double
getX1
()
{
return
x1
.
getValue
();
}
public
void
setX1
(
double
x1
)
{
this
.
x1
.
setValue
(
x1
);
}
public
double
getX2
()
{
return
x2
.
getValue
();
}
public
void
setX2
(
double
x2
)
{
this
.
x2
.
setValue
(
x2
);
}
public
double
getY1
()
{
return
y1
.
getValue
();
}
public
void
setY1
(
double
y1
)
{
this
.
y1
.
setValue
(
y1
);
}
public
double
getY2
()
{
return
y2
.
getValue
();
}
public
void
setY2
(
double
y2
)
{
this
.
y2
.
setValue
(
y2
);
}
// =================================================================================================================
// SimpleShape Methods
public
Rectangle2D
getBounds
(
double
pixelSize
)
{
double
left
=
Math
.
min
(
x1
.
getValue
(),
x2
.
getValue
());
double
right
=
Math
.
max
(
x1
.
getValue
(),
x2
.
getValue
());
double
top
=
Math
.
min
(
y1
.
getValue
(),
y2
.
getValue
());
double
bottom
=
Math
.
max
(
y1
.
getValue
(),
y2
.
getValue
());
return
new
Rectangle2D
.
Double
(
left
,
top
,
right
-
left
,
bottom
-
top
);
}
public
boolean
isHit
(
Point2D
p
,
double
pixelSize
)
{
return
getShape
().
contains
(
p
);
}
public
void
paint
(
Graphics2D
g2
,
double
pixelSize
)
{
g2
.
setPaint
(
getPaint
());
g2
.
fill
(
getShape
());
}
public
void
setFrame
(
double
x1
,
double
y1
,
double
x2
,
double
y2
)
{
this
.
x1
.
setValue
(
x1
);
this
.
y1
.
setValue
(
y1
);
this
.
x2
.
setValue
(
x2
);
this
.
y2
.
setValue
(
y2
);
}
@Override
public
String
toString
()
{
Rectangle2D
bounds
=
getBounds
(
0
);
if
(
isRounded
())
{
return
"ROUND RECT { x="
+
bounds
.
getX
()
+
", y="
+
bounds
.
getY
()
+
", w="
+
bounds
.
getWidth
()
+
", h="
+
bounds
.
getHeight
()
+
", rounding="
+
getRounding
()
+
" }"
;
}
else
{
return
"ROUND RECT { x="
+
bounds
.
getX
()
+
", y="
+
bounds
.
getY
()
+
", w="
+
bounds
.
getWidth
()
+
", h="
+
bounds
.
getHeight
()
+
" }"
;
}
}
public
List
<
ControlPoint
>
getControlPoints
()
{
List
<
ControlPoint
>
points
=
new
ArrayList
<
ControlPoint
>();
points
.
addAll
(
super
.
getControlPoints
());
points
.
add
(
tl
);
points
.
add
(
tr
);
points
.
add
(
bl
);
points
.
add
(
br
);
points
.
add
(
rounding
);
return
points
;
}
public
void
paintControls
(
Graphics2D
g2
,
double
pixelSize
,
boolean
paintControlLines
)
{
if
(
paintControlLines
)
{
g2
.
setStroke
(
new
BasicStroke
((
float
)
pixelSize
));
g2
.
setColor
(
GraphicsHelper
.
CONTROL_LINE
);
g2
.
draw
(
getShape
());
}
tl
.
paintControls
(
g2
,
pixelSize
,
true
);
tr
.
paintControls
(
g2
,
pixelSize
,
true
);
bl
.
paintControls
(
g2
,
pixelSize
,
true
);
br
.
paintControls
(
g2
,
pixelSize
,
true
);
rounding
.
paintControls
(
g2
,
pixelSize
,
true
);
}
public
void
move
(
double
moveX
,
double
moveY
,
boolean
snapPixels
)
{
if
(
snapPixels
)
{
x1
.
setValue
(
Math
.
round
(
x1
.
getValue
()
+
moveX
));
x2
.
setValue
(
Math
.
round
(
x2
.
getValue
()
+
moveX
));
y1
.
setValue
(
Math
.
round
(
y1
.
getValue
()
+
moveY
));
y2
.
setValue
(
Math
.
round
(
y2
.
getValue
()
+
moveY
));
}
else
{
x1
.
setValue
(
x1
.
getValue
()
+
moveX
);
x2
.
setValue
(
x2
.
getValue
()
+
moveX
);
y1
.
setValue
(
y1
.
getValue
()
+
moveY
);
y2
.
setValue
(
y2
.
getValue
()
+
moveY
);
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/SimpleShape.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
org.jdesktop.beans.AbstractBean
;
import
java.awt.Graphics2D
;
import
java.awt.Shape
;
import
java.awt.geom.AffineTransform
;
import
java.awt.geom.Point2D
;
import
java.awt.geom.Rectangle2D
;
import
java.util.List
;
/**
* SimpleShape
*
* @author Created by Jasper Potts (May 22, 2007)
*/
public
abstract
class
SimpleShape
extends
AbstractBean
{
protected
AffineTransform
transform
=
new
AffineTransform
();
protected
LayerContainer
parent
=
null
;
public
void
applyTransform
(
AffineTransform
t
)
{
transform
.
concatenate
(
t
);
}
public
abstract
Rectangle2D
getBounds
(
double
pixelSize
);
public
abstract
void
paint
(
Graphics2D
g2
,
double
pixelSize
);
public
abstract
boolean
isHit
(
Point2D
p
,
double
pixelSize
);
public
boolean
intersects
(
Rectangle2D
rect
,
double
pixelSize
)
{
return
getBounds
(
pixelSize
).
intersects
(
rect
);
}
public
abstract
List
<?
extends
ControlPoint
>
getControlPoints
();
public
abstract
void
paintControls
(
Graphics2D
g2
,
double
pixelSize
,
boolean
paintControlLines
);
public
void
move
(
double
moveX
,
double
moveY
,
boolean
snapPixels
)
{
for
(
ControlPoint
controlPoint
:
getControlPoints
())
{
controlPoint
.
move
(
moveX
,
moveY
,
snapPixels
);
}
}
public
LayerContainer
getParent
()
{
return
parent
;
}
public
void
setParent
(
LayerContainer
parent
)
{
LayerContainer
old
=
getParent
();
this
.
parent
=
parent
;
firePropertyChange
(
"parent"
,
old
,
getParent
());
}
public
abstract
Shape
getShape
();
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/TemplateLayer.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer
;
import
org.jdesktop.swingx.designer.effects.Effect
;
import
javax.imageio.ImageIO
;
import
javax.swing.JOptionPane
;
import
javax.swing.SwingUtilities
;
import
java.awt.Color
;
import
java.awt.FontMetrics
;
import
java.awt.Graphics2D
;
import
java.awt.GraphicsConfiguration
;
import
java.awt.Image
;
import
java.awt.geom.Rectangle2D
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
java.lang.ref.SoftReference
;
/**
* TemplateLayer
*
* @author Created by Jasper Potts (Jul 2, 2007)
*/
public
class
TemplateLayer
extends
Layer
{
private
String
fileName
;
private
transient
SoftReference
<
BufferedImage
>
imgRef
=
null
;
public
TemplateLayer
()
{
type
=
LayerType
.
template
;
}
public
TemplateLayer
(
String
fileName
,
BufferedImage
templateImage
)
{
super
(
"Template"
);
this
.
fileName
=
fileName
;
type
=
LayerType
.
template
;
if
(
templateImage
!=
null
)
{
imgRef
=
new
SoftReference
<
BufferedImage
>(
templateImage
);
}
}
// =================================================================================================================
// Methods
public
String
getName
()
{
return
super
.
getName
();
}
/**
* template layers are always locked
*
* @return <code>true</code>
*/
public
boolean
isLocked
()
{
return
true
;
}
public
void
add
(
SimpleShape
shape
)
{
throw
new
IllegalStateException
(
"Template layers can't contain shapes"
);
}
public
void
addEffect
(
Effect
effect
)
{
throw
new
IllegalStateException
(
"Template layers can't contain effects"
);
}
public
void
addLayer
(
int
i
,
Layer
layer
)
{
throw
new
IllegalStateException
(
"Template layers can't contain sub layers"
);
}
public
void
addLayer
(
Layer
layer
)
{
throw
new
IllegalStateException
(
"Template layers can't contain sub layers"
);
}
public
void
paint
(
Graphics2D
g2
,
double
pixelSize
)
{
if
(
isVisible
())
{
BufferedImage
img
=
getTemplateImage
();
if
(
img
!=
null
)
g2
.
drawImage
(
img
,
0
,
0
,
null
);
}
}
public
Image
getBuffer
(
GraphicsConfiguration
graphicsConfiguration
)
{
return
getTemplateImage
();
}
public
BufferedImage
getTemplateImage
()
{
BufferedImage
img
=
null
;
if
(
imgRef
==
null
||
(
img
=
imgRef
.
get
())
==
null
)
{
// can not access canvas
final
File
templateImgFile
=
new
File
(
getCanvas
().
getTemplatesDir
(),
fileName
);
System
.
out
.
println
(
"templateImgFile = "
+
templateImgFile
.
getAbsolutePath
());
System
.
out
.
println
(
"templateImgFile.exists = "
+
templateImgFile
.
exists
());
try
{
img
=
ImageIO
.
read
(
templateImgFile
);
imgRef
=
new
SoftReference
<
BufferedImage
>(
img
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
// create error image
img
=
new
BufferedImage
(
getCanvas
().
getSize
().
width
,
getCanvas
().
getSize
().
height
,
BufferedImage
.
TYPE_INT_RGB
);
Graphics2D
g2
=
img
.
createGraphics
();
g2
.
setColor
(
Color
.
RED
);
g2
.
fillRect
(
0
,
0
,
img
.
getWidth
(),
img
.
getHeight
());
g2
.
setColor
(
Color
.
WHITE
);
g2
.
setFont
(
g2
.
getFont
().
deriveFont
(
8
f
));
FontMetrics
fontMetrics
=
g2
.
getFontMetrics
();
Rectangle2D
stringBounds
=
fontMetrics
.
getStringBounds
(
"Missing Image"
,
g2
);
int
offsetX
=
(
int
)
((
img
.
getWidth
()
-
stringBounds
.
getWidth
())
/
2
d
);
int
offsetY
=
(
int
)
(((
img
.
getHeight
()
-
stringBounds
.
getHeight
())
/
2
d
)
-
stringBounds
.
getY
());
g2
.
drawString
(
"Missing Image"
,
offsetX
,
offsetY
);
g2
.
dispose
();
imgRef
=
new
SoftReference
<
BufferedImage
>(
img
);
}
}
return
img
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/DropShadowEffect.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.effects
;
import
org.jdesktop.swingx.designer.paint.Matte
;
import
javax.swing.UIDefaults
;
import
java.awt.Color
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.Raster
;
import
java.awt.image.WritableRaster
;
import
java.util.Arrays
;
/**
* DropShadowEffect
*
* @author Created by Jasper Potts (Jun 18, 2007)
*/
public
class
DropShadowEffect
extends
ShadowEffect
{
protected
DropShadowEffect
()
{}
;
public
DropShadowEffect
(
UIDefaults
uiDefaults
)
{
color
=
new
Matte
(
Color
.
BLACK
,
uiDefaults
);
}
// =================================================================================================================
// Effect Methods
/**
* Get the display name for this effect
*
* @return The user displayable name
*/
public
String
getDisplayName
()
{
return
"Drop Shadow"
;
}
/**
* Get the type of this effect, one of UNDER,BLENDED,OVER. UNDER means the result of apply effect should be painted
* under the src image. BLENDED means the result of apply sffect contains a modified src image so just it should be
* painted. OVER means the result of apply effect should be painted over the src image.
*
* @return The effect type
*/
public
EffectType
getEffectType
()
{
return
EffectType
.
UNDER
;
}
/**
* Apply the effect to the src image generating the result . The result image may or may not contain the source
* image depending on what the effect type is.
*
* @param src The source image for applying the effect to
* @param dst The dstination image to paint effect result into. If this is null then a new image will be created
* @param w The width of the src image to apply effect to, this allow the src and dst buffers to be bigger than
* the area the need effect applied to it
* @param h The height of the src image to apply effect to, this allow the src and dst buffers to be bigger than
* the area the need effect applied to it
* @return The result of appl
*/
public
BufferedImage
applyEffect
(
BufferedImage
src
,
BufferedImage
dst
,
int
w
,
int
h
)
{
// calculate offset
double
trangleAngle
=
Math
.
toRadians
(
angle
-
90
);
int
offsetX
=
(
int
)
(
Math
.
sin
(
trangleAngle
)
*
distance
);
int
offsetY
=
(
int
)
(
Math
.
cos
(
trangleAngle
)
*
distance
);
// clac expanded size
int
tmpOffX
=
offsetX
+
size
;
int
tmpOffY
=
offsetY
+
size
;
int
tmpW
=
w
+
offsetX
+
size
+
size
;
int
tmpH
=
h
+
offsetY
+
size
+
size
;
// create tmp buffers
int
[]
lineBuf
=
getTmpIntArray
(
w
);
byte
[]
tmpBuf1
=
getTmpByteArray1
(
tmpW
*
tmpH
);
Arrays
.
fill
(
tmpBuf1
,
(
byte
)
0x00
);
byte
[]
tmpBuf2
=
getTmpByteArray2
(
tmpW
*
tmpH
);
// extract src image alpha channel and inverse and offset
Raster
srcRaster
=
src
.
getRaster
();
for
(
int
y
=
0
;
y
<
h
;
y
++)
{
int
dy
=
(
y
+
tmpOffY
);
int
offset
=
dy
*
tmpW
;
srcRaster
.
getDataElements
(
0
,
y
,
w
,
1
,
lineBuf
);
for
(
int
x
=
0
;
x
<
w
;
x
++)
{
int
dx
=
x
+
tmpOffX
;
tmpBuf1
[
offset
+
dx
]
=
(
byte
)
((
lineBuf
[
x
]
&
0xFF000000
)
>>>
24
);
}
}
// blur
float
[]
kernel
=
EffectUtils
.
createGaussianKernel
(
size
);
EffectUtils
.
blur
(
tmpBuf1
,
tmpBuf2
,
tmpW
,
tmpH
,
kernel
,
size
);
// horizontal pass
EffectUtils
.
blur
(
tmpBuf2
,
tmpBuf1
,
tmpH
,
tmpW
,
kernel
,
size
);
// vertical pass
//rescale
float
spread
=
Math
.
min
(
1
/
(
1
-
(
0.01f
*
this
.
spread
)),
255
);
for
(
int
i
=
0
;
i
<
tmpBuf1
.
length
;
i
++)
{
int
val
=
(
int
)
(((
int
)
tmpBuf1
[
i
]
&
0xFF
)
*
spread
);
tmpBuf1
[
i
]
=
(
val
>
255
)
?
(
byte
)
0xFF
:
(
byte
)
val
;
}
// create color image with shadow color and greyscale image as alpha
if
(
dst
==
null
)
dst
=
new
BufferedImage
(
w
,
h
,
BufferedImage
.
TYPE_INT_ARGB
);
WritableRaster
shadowRaster
=
dst
.
getRaster
();
int
red
=
color
.
getRed
(),
green
=
color
.
getGreen
(),
blue
=
color
.
getBlue
();
for
(
int
y
=
0
;
y
<
h
;
y
++)
{
int
srcY
=
y
+
tmpOffY
;
int
shadowOffset
=
(
srcY
-
offsetY
)
*
tmpW
;
for
(
int
x
=
0
;
x
<
w
;
x
++)
{
int
srcX
=
x
+
tmpOffX
;
lineBuf
[
x
]
=
tmpBuf1
[
shadowOffset
+
(
srcX
-
offsetX
)]
<<
24
|
red
<<
16
|
green
<<
8
|
blue
;
}
shadowRaster
.
setDataElements
(
0
,
y
,
w
,
1
,
lineBuf
);
}
return
dst
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/Effect.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.effects
;
import
org.jdesktop.beans.AbstractBean
;
import
org.jdesktop.swingx.designer.BlendingMode
;
import
java.awt.image.BufferedImage
;
import
java.lang.ref.SoftReference
;
/**
* Effect
*
* @author Created by Jasper Potts (Jun 18, 2007)
*/
public
abstract
class
Effect
extends
AbstractBean
{
protected
boolean
visible
=
true
;
public
enum
EffectType
{
UNDER
,
BLENDED
,
OVER
}
public
boolean
isVisible
()
{
return
visible
;
}
public
void
setVisible
(
boolean
visible
)
{
boolean
old
=
isVisible
();
this
.
visible
=
visible
;
firePropertyChange
(
"visible"
,
old
,
isVisible
());
}
public
String
toString
()
{
return
getDisplayName
();
}
// =================================================================================================================
// Abstract Methods
/**
* Get the display name for this effect
*
* @return The user displayable name
*/
public
abstract
String
getDisplayName
();
/**
* Get the type of this effect, one of UNDER,BLENDED,OVER. UNDER means the result of apply effect should be painted
* under the src image. BLENDED means the result of apply sffect contains a modified src image so just it should be
* painted. OVER means the result of apply effect should be painted over the src image.
*
* @return The effect type
*/
public
abstract
EffectType
getEffectType
();
/**
* Get the blending mode to use to paint the result effected image if the EffectType is UNDER or OVER.
*
* @return The blending mode for the effect
*/
public
abstract
BlendingMode
getBlendingMode
();
/**
* Get the opacity to use to paint the result effected image if the EffectType is UNDER or OVER.
*
* @return The opactity for the effect, 0.0f -> 1.0f
*/
public
abstract
float
getOpacity
();
/**
* Apply the effect to the src image generating the result . The result image may or may not contain the source
* image depending on what the effect type is.
*
* @param src The source image for applying the effect to
* @param dst The dstination image to paint effect result into. If this is null then a new image will be created
* @param w The width of the src image to apply effect to, this allow the src and dst buffers to be bigger than
* the area the need effect applied to it
* @param h The height of the src image to apply effect to, this allow the src and dst buffers to be bigger than
* the area the need effect applied to it
* @return The result of appl
*/
public
abstract
BufferedImage
applyEffect
(
BufferedImage
src
,
BufferedImage
dst
,
int
w
,
int
h
);
// =================================================================================================================
// Static data cache
private
static
SoftReference
<
int
[]>
tmpIntArray
=
null
;
private
static
SoftReference
<
byte
[]>
tmpByteArray1
=
null
;
private
static
SoftReference
<
byte
[]>
tmpByteArray2
=
null
;
private
static
SoftReference
<
byte
[]>
tmpByteArray3
=
null
;
protected
static
int
[]
getTmpIntArray
(
int
size
)
{
int
[]
tmp
;
if
(
tmpIntArray
==
null
||
(
tmp
=
tmpIntArray
.
get
())
==
null
||
tmp
.
length
<
size
)
{
// create new array
tmp
=
new
int
[
size
];
tmpIntArray
=
new
SoftReference
<
int
[]>(
tmp
);
}
return
tmp
;
}
protected
static
byte
[]
getTmpByteArray1
(
int
size
)
{
byte
[]
tmp
;
if
(
tmpByteArray1
==
null
||
(
tmp
=
tmpByteArray1
.
get
())
==
null
||
tmp
.
length
<
size
)
{
// create new array
tmp
=
new
byte
[
size
];
tmpByteArray1
=
new
SoftReference
<
byte
[]>(
tmp
);
}
return
tmp
;
}
protected
static
byte
[]
getTmpByteArray2
(
int
size
)
{
byte
[]
tmp
;
if
(
tmpByteArray2
==
null
||
(
tmp
=
tmpByteArray2
.
get
())
==
null
||
tmp
.
length
<
size
)
{
// create new array
tmp
=
new
byte
[
size
];
tmpByteArray2
=
new
SoftReference
<
byte
[]>(
tmp
);
}
return
tmp
;
}
protected
static
byte
[]
getTmpByteArray3
(
int
size
)
{
byte
[]
tmp
;
if
(
tmpByteArray3
==
null
||
(
tmp
=
tmpByteArray3
.
get
())
==
null
||
tmp
.
length
<
size
)
{
// create new array
tmp
=
new
byte
[
size
];
tmpByteArray3
=
new
SoftReference
<
byte
[]>(
tmp
);
}
return
tmp
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/EffectUtils.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.effects
;
/**
* EffectUtils
*
* @author Created by Jasper Potts (Jun 18, 2007)
*/
public
class
EffectUtils
{
/**
* <p>Blurs the source pixels into the destination pixels. The force of the blur is specified by the radius which
* must be greater than 0.</p> <p>The source and destination pixels arrays are expected to be in the BYTE_GREY
* format.</p> <p>After this method is executed, dstPixels contains a transposed and filtered copy of
* srcPixels.</p>
*
* @param srcPixels the source pixels
* @param dstPixels the destination pixels
* @param width the width of the source picture
* @param height the height of the source picture
* @param kernel the kernel of the blur effect
* @param radius the radius of the blur effect
*/
public
static
void
blur
(
byte
[]
srcPixels
,
byte
[]
dstPixels
,
int
width
,
int
height
,
float
[]
kernel
,
int
radius
)
{
float
p
;
int
cp
;
for
(
int
y
=
0
;
y
<
height
;
y
++)
{
int
index
=
y
;
int
offset
=
y
*
width
;
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
p
=
0.0f
;
for
(
int
i
=
-
radius
;
i
<=
radius
;
i
++)
{
int
subOffset
=
x
+
i
;
if
(
subOffset
<
0
||
subOffset
>=
width
)
{
subOffset
=
(
x
+
width
)
%
width
;
}
int
pixel
=
srcPixels
[
offset
+
subOffset
]
&
0xFF
;
float
blurFactor
=
kernel
[
radius
+
i
];
p
+=
blurFactor
*
pixel
;
}
cp
=
(
int
)
(
p
+
0.5f
);
dstPixels
[
index
]
=
(
byte
)
(
cp
>
255
?
255
:
cp
);
index
+=
height
;
}
}
}
public
static
float
[]
createGaussianKernel
(
int
radius
)
{
if
(
radius
<
1
)
{
throw
new
IllegalArgumentException
(
"Radius must be >= 1"
);
}
float
[]
data
=
new
float
[
radius
*
2
+
1
];
float
sigma
=
radius
/
3.0f
;
float
twoSigmaSquare
=
2.0f
*
sigma
*
sigma
;
float
sigmaRoot
=
(
float
)
Math
.
sqrt
(
twoSigmaSquare
*
Math
.
PI
);
float
total
=
0.0f
;
for
(
int
i
=
-
radius
;
i
<=
radius
;
i
++)
{
float
distance
=
i
*
i
;
int
index
=
i
+
radius
;
data
[
index
]
=
(
float
)
Math
.
exp
(-
distance
/
twoSigmaSquare
)
/
sigmaRoot
;
total
+=
data
[
index
];
}
for
(
int
i
=
0
;
i
<
data
.
length
;
i
++)
{
data
[
i
]
/=
total
;
}
return
data
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/EffectUtilsTemp.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.effects
;
import
java.awt.Composite
;
import
java.awt.CompositeContext
;
import
java.awt.Graphics2D
;
import
java.awt.RenderingHints
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.ColorModel
;
import
java.awt.image.Raster
;
import
java.awt.image.WritableRaster
;
/**
* EffectUtilsTemp - effect utils methods that are not being used for now but we might want later
*
* @author Created by Jasper Potts (Jun 18, 2007)
*/
public
class
EffectUtilsTemp
{
/**
* Extract the alpha channel of a image into new greyscale buffered image
*
* @param src Must but INT_ARGB buffered image
* @return new TYPE_BYTE_GRAY image of just the alpha channel
*/
public
static
BufferedImage
extractAlpha
(
BufferedImage
src
)
{
int
w
=
src
.
getWidth
();
int
h
=
src
.
getHeight
();
// extract image alpha channel as greyscale image
final
BufferedImage
greyImg
=
new
BufferedImage
(
w
,
h
,
BufferedImage
.
TYPE_BYTE_GRAY
);
Graphics2D
g2
=
greyImg
.
createGraphics
();
g2
.
setComposite
(
new
Composite
()
{
public
CompositeContext
createContext
(
ColorModel
srcColorModel
,
ColorModel
dstColorModel
,
RenderingHints
hints
)
{
return
new
CompositeContext
()
{
public
void
dispose
()
{}
public
void
compose
(
Raster
src
,
Raster
dstIn
,
WritableRaster
dstOut
)
{
int
width
=
Math
.
min
(
src
.
getWidth
(),
dstIn
.
getWidth
());
int
height
=
Math
.
min
(
src
.
getHeight
(),
dstIn
.
getHeight
());
int
[]
srcPixels
=
new
int
[
width
];
byte
[]
dstPixels
=
new
byte
[
width
];
for
(
int
y
=
0
;
y
<
height
;
y
++)
{
src
.
getDataElements
(
0
,
y
,
width
,
1
,
srcPixels
);
for
(
int
x
=
0
;
x
<
width
;
x
++)
{
dstPixels
[
x
]
=
(
byte
)
((
srcPixels
[
x
]
&
0xFF000000
)
>>>
24
);
}
dstOut
.
setDataElements
(
0
,
y
,
width
,
1
,
dstPixels
);
}
}
};
}
});
g2
.
drawImage
(
src
,
0
,
0
,
null
);
g2
.
dispose
();
return
greyImg
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/InnerGlowEffect.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.effects
;
import
org.jdesktop.swingx.designer.paint.Matte
;
import
javax.swing.UIDefaults
;
import
java.awt.Color
;
/**
* InnerGlowEffect
*
* @author Created by Jasper Potts (Jun 21, 2007)
*/
public
class
InnerGlowEffect
extends
InnerShadowEffect
{
protected
InnerGlowEffect
()
{
distance
=
0
;
}
public
InnerGlowEffect
(
UIDefaults
uiDefaults
)
{
color
=
new
Matte
(
new
Color
(
255
,
255
,
211
),
uiDefaults
);
}
/**
* Get the display name for this effect
*
* @return The user displayable name
*/
public
String
getDisplayName
()
{
return
"Inner Glow"
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/InnerShadowEffect.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.effects
;
import
org.jdesktop.swingx.designer.paint.Matte
;
import
javax.swing.UIDefaults
;
import
java.awt.Color
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.Raster
;
import
java.awt.image.WritableRaster
;
import
java.util.Arrays
;
/**
* InnerShadowEffect
*
* @author Created by Jasper Potts (Jun 18, 2007)
*/
public
class
InnerShadowEffect
extends
ShadowEffect
{
protected
InnerShadowEffect
()
{}
;
public
InnerShadowEffect
(
UIDefaults
uiDefaults
)
{
color
=
new
Matte
(
Color
.
BLACK
,
uiDefaults
);
}
// =================================================================================================================
// Effect Methods
/**
* Get the display name for this effect
*
* @return The user displayable name
*/
public
String
getDisplayName
()
{
return
"Inner Shadow"
;
}
/**
* Get the type of this effect, one of UNDER,BLENDED,OVER. UNDER means the result of apply effect should be painted
* under the src image. BLENDED means the result of apply sffect contains a modified src image so just it should be
* painted. OVER means the result of apply effect should be painted over the src image.
*
* @return The effect type
*/
public
Effect
.
EffectType
getEffectType
()
{
return
Effect
.
EffectType
.
OVER
;
}
/**
* Apply the effect to the src image generating the result . The result image may or may not contain the source
* image depending on what the effect type is.
*
* @param src The source image for applying the effect to
* @param dst The dstination image to paint effect result into. If this is null then a new image will be created
* @param w The width of the src image to apply effect to, this allow the src and dst buffers to be bigger than
* the area the need effect applied to it
* @param h The height of the src image to apply effect to, this allow the src and dst buffers to be bigger than
* the area the need effect applied to it
* @return The result of appl
*/
public
BufferedImage
applyEffect
(
BufferedImage
src
,
BufferedImage
dst
,
int
w
,
int
h
)
{
// calculate offset
double
trangleAngle
=
Math
.
toRadians
(
angle
-
90
);
int
offsetX
=
(
int
)
(
Math
.
sin
(
trangleAngle
)
*
distance
);
int
offsetY
=
(
int
)
(
Math
.
cos
(
trangleAngle
)
*
distance
);
// clac expanded size
int
tmpOffX
=
offsetX
+
size
;
int
tmpOffY
=
offsetY
+
size
;
int
tmpW
=
w
+
offsetX
+
size
+
size
;
int
tmpH
=
h
+
offsetY
+
size
+
size
;
// create tmp buffers
int
[]
lineBuf
=
getTmpIntArray
(
w
);
byte
[]
srcAlphaBuf
=
getTmpByteArray1
(
tmpW
*
tmpH
);
Arrays
.
fill
(
srcAlphaBuf
,
(
byte
)
0xFF
);
byte
[]
tmpBuf1
=
getTmpByteArray2
(
tmpW
*
tmpH
);
byte
[]
tmpBuf2
=
getTmpByteArray3
(
tmpW
*
tmpH
);
// extract src image alpha channel and inverse and offset
Raster
srcRaster
=
src
.
getRaster
();
for
(
int
y
=
0
;
y
<
h
;
y
++)
{
int
dy
=
(
y
+
tmpOffY
);
int
offset
=
dy
*
tmpW
;
srcRaster
.
getDataElements
(
0
,
y
,
w
,
1
,
lineBuf
);
for
(
int
x
=
0
;
x
<
w
;
x
++)
{
int
dx
=
x
+
tmpOffX
;
srcAlphaBuf
[
offset
+
dx
]
=
(
byte
)
((
255
-
((
lineBuf
[
x
]
&
0xFF000000
)
>>>
24
))
&
0xFF
);
}
}
// blur
float
[]
kernel
=
EffectUtils
.
createGaussianKernel
(
size
*
2
);
EffectUtils
.
blur
(
srcAlphaBuf
,
tmpBuf2
,
tmpW
,
tmpH
,
kernel
,
size
*
2
);
// horizontal pass
EffectUtils
.
blur
(
tmpBuf2
,
tmpBuf1
,
tmpH
,
tmpW
,
kernel
,
size
*
2
);
// vertical pass
//rescale
float
spread
=
Math
.
min
(
1
/
(
1
-
(
0.01f
*
this
.
spread
)),
255
);
for
(
int
i
=
0
;
i
<
tmpBuf1
.
length
;
i
++)
{
int
val
=
(
int
)
(((
int
)
tmpBuf1
[
i
]
&
0xFF
)
*
spread
);
tmpBuf1
[
i
]
=
(
val
>
255
)
?
(
byte
)
0xFF
:
(
byte
)
val
;
}
// create color image with shadow color and greyscale image as alpha
if
(
dst
==
null
)
dst
=
new
BufferedImage
(
w
,
h
,
BufferedImage
.
TYPE_INT_ARGB
);
WritableRaster
shadowRaster
=
dst
.
getRaster
();
int
red
=
color
.
getRed
(),
green
=
color
.
getGreen
(),
blue
=
color
.
getBlue
();
for
(
int
y
=
0
;
y
<
h
;
y
++)
{
int
srcY
=
y
+
tmpOffY
;
int
offset
=
srcY
*
tmpW
;
int
shadowOffset
=
(
srcY
-
offsetY
)
*
tmpW
;
for
(
int
x
=
0
;
x
<
w
;
x
++)
{
int
srcX
=
x
+
tmpOffX
;
int
origianlAlphaVal
=
255
-
((
int
)
srcAlphaBuf
[
offset
+
srcX
]
&
0xFF
);
int
shadowVal
=
(
int
)
tmpBuf1
[
shadowOffset
+
(
srcX
-
offsetX
)]
&
0xFF
;
int
alphaVal
=
Math
.
min
(
origianlAlphaVal
,
shadowVal
);
lineBuf
[
x
]
=
((
byte
)
alphaVal
&
0xFF
)
<<
24
|
red
<<
16
|
green
<<
8
|
blue
;
}
shadowRaster
.
setDataElements
(
0
,
y
,
w
,
1
,
lineBuf
);
}
return
dst
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/effects/ShadowEffect.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.effects
;
import
org.jdesktop.swingx.designer.BlendingMode
;
import
org.jdesktop.swingx.designer.paint.Matte
;
import
javax.swing.UIDefaults
;
import
java.awt.Color
;
/**
* ShadowEffect - base class with all the standard properties for shadow effects
*
* @author Created by Jasper Potts (Jun 18, 2007)
*/
public
abstract
class
ShadowEffect
extends
Effect
{
protected
Matte
color
;
protected
BlendingMode
blendingMode
=
BlendingMode
.
NORMAL
;
/** Opacity a float 0-1 for percentage */
protected
float
opacity
=
0.75f
;
/** Angle in degrees between 0-360 */
protected
int
angle
=
135
;
/** Distance in pixels */
protected
int
distance
=
5
;
/** The shadow spread between 0-100 % */
protected
int
spread
=
0
;
/** Size in pixels */
protected
int
size
=
5
;
protected
ShadowEffect
()
{}
;
public
ShadowEffect
(
UIDefaults
uiDefaults
)
{
color
=
new
Matte
(
Color
.
BLACK
,
uiDefaults
);
}
// =================================================================================================================
// Bean methods
public
Matte
getColor
()
{
return
color
;
}
public
void
setColor
(
Matte
color
)
{
Matte
old
=
getColor
();
this
.
color
=
color
;
firePropertyChange
(
"color"
,
old
,
getColor
());
}
public
BlendingMode
getBlendingMode
()
{
return
blendingMode
;
}
public
void
setBlendingMode
(
BlendingMode
blendingMode
)
{
BlendingMode
old
=
getBlendingMode
();
this
.
blendingMode
=
blendingMode
;
firePropertyChange
(
"blendingMode"
,
old
,
getBlendingMode
());
}
public
float
getOpacity
()
{
return
opacity
;
}
public
void
setOpacity
(
float
opacity
)
{
float
old
=
getOpacity
();
this
.
opacity
=
opacity
;
firePropertyChange
(
"opacity"
,
old
,
getOpacity
());
}
public
int
getAngle
()
{
return
angle
;
}
public
void
setAngle
(
int
angle
)
{
int
old
=
getAngle
();
this
.
angle
=
angle
;
firePropertyChange
(
"angle"
,
old
,
getAngle
());
}
public
int
getDistance
()
{
return
distance
;
}
public
void
setDistance
(
int
distance
)
{
int
old
=
getDistance
();
this
.
distance
=
distance
;
firePropertyChange
(
"distance"
,
old
,
getDistance
());
}
public
int
getSpread
()
{
return
spread
;
}
public
void
setSpread
(
int
spread
)
{
int
old
=
getSpread
();
this
.
spread
=
spread
;
firePropertyChange
(
"spread"
,
old
,
getSpread
());
}
public
int
getSize
()
{
return
size
;
}
public
void
setSize
(
int
size
)
{
int
old
=
getSize
();
this
.
size
=
size
;
firePropertyChange
(
"size"
,
old
,
getSize
());
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/font/Typeface.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.font
;
import
java.awt.Font
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
javax.swing.UIDefaults
;
import
org.jdesktop.beans.AbstractBean
;
import
org.jdesktop.swingx.designer.utils.HasUIDefaults
;
import
org.jibx.runtime.IUnmarshallingContext
;
/**
* I don't think the name is technically correct (ie: a typeface is not a font),
* but I wanted something besides "font" so, here it is.
*
* This is a mutable font, much like Matte is a mutable color. Also like Matte,
* Typeface can be derived.
*
* @author rbair
*/
public
class
Typeface
extends
AbstractBean
{
//specifies whether to derive bold, or italic.
//Default means, get my value from my parent.
//Off means, leave bold/italic off.
//On means, make bold/italic on.
public
enum
DeriveStyle
{
Default
,
Off
,
On
}
private
String
uiDefaultParentName
;
/** This is a local UIDefaults that contains all the UIDefaults in the Model. */
private
transient
UIDefaults
uiDefaults
=
new
UIDefaults
();
private
PropertyChangeListener
uiDefaultsChangeListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
if
(
uiDefaultParentName
!=
null
&&
uiDefaultParentName
.
equals
(
evt
.
getPropertyName
()))
{
updateFontFromOffsets
();
}
}
};
/**
* The name of the font. If uiDefaultParentName is specified, then this name
* will be set to be equal to the name of the parent font.
*/
private
String
name
;
/**
* The size of the font. If uiDefaultParentName is set, then this value is
* updated to reflect the size of the parent font * the sizeOffset.
*/
private
int
size
;
//this field is not publically accessible. Rather, it is updated based on
//"bold" and "italic" as necessary.
private
int
style
=
Font
.
PLAIN
;
private
DeriveStyle
bold
=
DeriveStyle
.
Default
;
private
DeriveStyle
italic
=
DeriveStyle
.
Default
;
/**
* The size offset. Only used if uiDefaultParentName is specified. This offset
* will be multiplied with the parent font's size to determine the size of this
* typeface. The offset is specified as a percentage, either positive or negative.
*
* The reason a percentage was used, was so that things would look correctly
* when scaled, such as with high DPI situations.
*/
private
float
sizeOffset
;
/**
* Create a new Typeface. Note that, without specifying the uiDefaults,
* you cannot have font derivation. Thus, this constructor should never
* be called, except for the XML binding stuff.
*/
public
Typeface
()
{
}
/**
* Creates a new Typeface.
*
* @param f The font from which to get the font name, size, and style to use
* to initialize this typeface. Note that this font is not used as a parent
* font for derivation purposes. Rather, it is used as a source from which to
* copy initial settings.
*
* @param uiDefaults The uiDefaults to use for font derivation purposes.
* When the uiDefaultParentName is specified, then this Typeface will inspect
* the given UIDefaults for that parent <em>font</em>. Note that the UIDefaults
* should be populated with a font, and not with a typeface.
*/
public
Typeface
(
Font
f
,
UIDefaults
uiDefaults
)
{
if
(
f
!=
null
)
{
this
.
name
=
f
.
getName
();
this
.
size
=
f
.
getSize
();
this
.
style
=
f
.
getStyle
();
}
setUiDefaults
(
uiDefaults
);
}
// =================================================================================================================
// JIBX Methods
/**
* Called by JIBX after all fields have been set
*
* @param context The JIBX Unmarshalling Context
*/
protected
void
postSet
(
IUnmarshallingContext
context
)
{
// walk up till we get synth model
for
(
int
i
=
0
;
i
<
context
.
getStackDepth
();
i
++)
{
if
(
context
.
getStackObject
(
i
)
instanceof
HasUIDefaults
)
{
UIDefaults
uiDefaults
=
((
HasUIDefaults
)
context
.
getStackObject
(
i
)).
getUiDefaults
();
if
(
uiDefaults
!=
null
)
{
setUiDefaults
(
uiDefaults
);
break
;
}
}
}
}
// =================================================================================================================
// Typeface methods
/**
* Is the Typeface an absolute Font not derived from a parent ui default
*
* @return <code>true</code> if this is a absolute not uidefault derived font
*/
public
boolean
isAbsolute
()
{
return
uiDefaultParentName
==
null
;
}
/**
* Set all properties of this Typeface to be the same as <code>src</code> and fire all the change events
*
* @param src the Typeface to copy properties from
*/
public
void
copy
(
Typeface
src
)
{
// keep old values
Font
oldFont
=
getFont
();
String
oldParentName
=
uiDefaultParentName
;
String
oldName
=
name
;
int
oldSize
=
size
;
float
oldSizeOffset
=
sizeOffset
;
DeriveStyle
oldBold
=
bold
,
oldItalic
=
italic
;
style
=
src
.
style
;
//Note, I don't just call the setters here, because I want to make
//sure the "font" PCE is only fired once, at the end.
name
=
src
.
name
;
firePropertyChange
(
"name"
,
oldName
,
name
);
size
=
src
.
size
;
firePropertyChange
(
"size"
,
oldSize
,
size
);
bold
=
src
.
bold
;
firePropertyChange
(
"bold"
,
oldBold
,
bold
);
italic
=
src
.
italic
;
firePropertyChange
(
"italic"
,
oldItalic
,
italic
);
sizeOffset
=
src
.
sizeOffset
;
firePropertyChange
(
"sizeOffset"
,
oldSizeOffset
,
sizeOffset
);
uiDefaultParentName
=
src
.
uiDefaultParentName
;
firePropertyChange
(
"uiDefaultParentName"
,
oldParentName
,
uiDefaultParentName
);
setUiDefaults
(
src
.
uiDefaults
);
firePropertyChange
(
"font"
,
oldFont
,
getFont
());
}
// =================================================================================================================
// Bean Methods
/**
* Get the local UIDefaults that contains all the UIDefaults in the Model.
*
* @return The UIDefaults for the model that contains this Typeface, can be null if this Typeface is not part of a bigger
* model
*/
public
UIDefaults
getUiDefaults
()
{
return
uiDefaults
;
}
/**
* Set the local UIDefaults that contains all the UIDefaults in the Model.
*
* @param uiDefaults The UIDefaults for the model that contains this Typeface, can be null if this Typeface is not part of
* a bigger model
*/
public
void
setUiDefaults
(
UIDefaults
uiDefaults
)
{
if
(
uiDefaults
!=
this
.
uiDefaults
)
{
UIDefaults
old
=
getUiDefaults
();
if
(
old
!=
null
)
old
.
removePropertyChangeListener
(
uiDefaultsChangeListener
);
this
.
uiDefaults
=
uiDefaults
;
if
(
uiDefaults
!=
null
)
this
.
uiDefaults
.
addPropertyChangeListener
(
uiDefaultsChangeListener
);
firePropertyChange
(
"uiDefaults"
,
old
,
getUiDefaults
());
}
}
/**
* Get the name if the uidefault font that is the parent that this Typeface is derived from. If null then this is a
* absolute font.
*
* @return Parent font ui default name
*/
public
String
getUiDefaultParentName
()
{
return
uiDefaultParentName
;
}
/**
* Set the name if the uidefault font that is the parent that this Typeface is derived from. If null then this is a
* absolute font.
*
* @param uiDefaultParentName Parent font ui default name
*/
public
void
setUiDefaultParentName
(
String
uiDefaultParentName
)
{
String
old
=
getUiDefaultParentName
();
this
.
uiDefaultParentName
=
uiDefaultParentName
;
firePropertyChange
(
"uiDefaultParentName"
,
old
,
getUiDefaultParentName
());
if
(
isAbsolute
())
{
// reset offsets
float
oldSizeOffset
=
sizeOffset
;
sizeOffset
=
0
;
firePropertyChange
(
"sizeOffset"
,
oldSizeOffset
,
sizeOffset
);
}
else
{
updateFontFromOffsets
();
}
}
/**
* @return Gets the name of the font
*/
public
final
String
getName
()
{
return
name
;
}
/**
* Sets the name of the font. This method call <em>only</em> works if
* <code>isAbsolute</code> returns true. Otherwise, it is ignored.
* @param name the name of the font
*/
public
void
setName
(
String
name
)
{
if
(
isAbsolute
())
{
String
old
=
this
.
name
;
Font
oldF
=
getFont
();
this
.
name
=
name
;
firePropertyChange
(
"name"
,
old
,
this
.
name
);
firePropertyChange
(
"font"
,
oldF
,
getFont
());
}
}
/**
* @return gets the size of the font.
*/
public
final
int
getSize
()
{
return
size
;
}
/**
* <p>Sets the size of the font. THis method call will work whether
* <code>isAbsolute</code> returns true or false. If this is an absolute
* typeface, then the size is set directly. Otherwise, if this is a
* derived typeface, then the sizeOffset will be updated to reflect the
* proper offset based on this size, and the size of the parent font.</p>
*
* <p>For example, if the parent font's size was 12, and the sizeOffset was
* -2 (thus yielding as size on this typeface of 10), and you call setSize
* passing in "14" as the size, then the sizeOffset will be updated to be
* equal to "2".</p>
*
* @param size the new size for this typeface.
*/
public
void
setSize
(
int
size
)
{
int
old
=
this
.
size
;
Font
oldF
=
getFont
();
this
.
size
=
size
;
firePropertyChange
(
"size"
,
old
,
this
.
size
);
firePropertyChange
(
"font"
,
oldF
,
getFont
());
updateOffsetsFromFont
();
}
/**
* @return the size offset
*/
public
final
float
getSizeOffset
()
{
return
sizeOffset
;
}
/**
* Sets the percentage by which the size of this font should be different
* from its parent font. This property is kept in synch with the size property.
*
* @param sizeOffset the size offset. May be any float. The value "1" means,
* 100%. -1 means "-100%". 2 means "200%", and so on.
*/
public
void
setSizeOffset
(
float
sizeOffset
)
{
float
old
=
this
.
sizeOffset
;
Font
oldF
=
getFont
();
this
.
sizeOffset
=
sizeOffset
;
firePropertyChange
(
"sizeOffset"
,
old
,
this
.
sizeOffset
);
firePropertyChange
(
"font"
,
oldF
,
getFont
());
updateFontFromOffsets
();
}
public
DeriveStyle
getBold
()
{
return
bold
;
}
public
void
setBold
(
DeriveStyle
bold
)
{
DeriveStyle
old
=
this
.
bold
;
this
.
bold
=
bold
==
null
?
DeriveStyle
.
Default
:
bold
;
firePropertyChange
(
"bold"
,
old
,
this
.
bold
);
updateFontFromOffsets
();
}
public
DeriveStyle
getItalic
()
{
return
italic
;
}
public
void
setItalic
(
DeriveStyle
italic
)
{
DeriveStyle
old
=
this
.
italic
;
this
.
italic
=
italic
==
null
?
DeriveStyle
.
Default
:
italic
;
firePropertyChange
(
"italic"
,
old
,
this
.
italic
);
updateFontFromOffsets
();
}
/**
* @return whether or not the font represented by this typeface is supported
* on this operating system platform.
*/
public
boolean
isFontSupported
()
{
return
true
;
//Font.getFont(name) != null;
}
/**
* @return Gets the font associated with this Typeface. If font derivation is
* being used, then the Font returned is the result of that derivation.
*/
public
Font
getFont
()
{
return
new
Font
(
name
,
style
,
size
);
}
/**
* Sets the font from which this Typeface should extract the font name, style,
* and size. If font derivation is being used, then the font name will be ignored,
* the style will be used (and always override the parent font), and the size
* will be set and the sizeOffset updated appropriately.
*
* @param f the Font
*/
public
void
setFont
(
Font
f
)
{
Font
oldFont
=
getFont
();
String
oldName
=
name
;
int
oldSize
=
size
;
DeriveStyle
oldBold
=
bold
,
oldItalic
=
italic
;
name
=
f
.
getName
();
size
=
f
.
getSize
();
style
=
f
.
getStyle
();
updateOffsetsFromFont
();
firePropertyChange
(
"name"
,
oldName
,
name
);
firePropertyChange
(
"size"
,
oldSize
,
size
);
firePropertyChange
(
"bold"
,
oldBold
,
bold
);
firePropertyChange
(
"italic"
,
oldItalic
,
italic
);
firePropertyChange
(
"font"
,
oldFont
,
getFont
());
}
/**
* @inheritDoc
*
* @return A formatted string representing this Typeface. This String should
* not be considered public API, as it may change in a future release.
*/
@Override
public
String
toString
()
{
Font
f
=
getFont
();
String
strStyle
;
if
(
f
.
isBold
())
{
strStyle
=
f
.
isItalic
()
?
"bolditalic"
:
"bold"
;
}
else
{
strStyle
=
f
.
isItalic
()
?
"italic"
:
"plain"
;
}
if
(
isAbsolute
())
{
return
Typeface
.
class
.
getName
()
+
"[name="
+
name
+
", size="
+
size
+
", style="
+
strStyle
+
"]"
;
}
else
{
return
Typeface
.
class
.
getName
()
+
"[base="
+
uiDefaultParentName
+
", name="
+
name
+
", size="
+
size
+
"(offset "
+
sizeOffset
+
")"
+
", style="
+
strStyle
+
"]"
;
}
}
@Override
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
Typeface
typeface
=
(
Typeface
)
o
;
if
(!
typeface
.
name
.
equals
(
name
))
return
false
;
if
(
size
!=
typeface
.
size
)
return
false
;
if
(
bold
!=
typeface
.
bold
)
return
false
;
if
(
italic
!=
typeface
.
italic
)
return
false
;
if
(
sizeOffset
!=
typeface
.
sizeOffset
)
return
false
;
if
(
uiDefaultParentName
!=
null
?
!
uiDefaultParentName
.
equals
(
typeface
.
uiDefaultParentName
)
:
typeface
.
uiDefaultParentName
!=
null
)
return
false
;
return
true
;
}
@Override
public
int
hashCode
()
{
int
result
;
result
=
name
.
hashCode
();
result
=
31
*
result
+
size
;
result
=
31
*
result
+
bold
.
ordinal
();
result
=
31
*
result
+
italic
.
ordinal
();
result
=
31
*
result
+
(
int
)(
sizeOffset
*
100
);
result
=
31
*
result
+
(
uiDefaultParentName
!=
null
?
uiDefaultParentName
.
hashCode
()
:
0
);
return
result
;
}
@Override
public
Typeface
clone
()
{
Typeface
clone
=
new
Typeface
();
clone
.
name
=
name
;
clone
.
size
=
size
;
clone
.
style
=
style
;
clone
.
bold
=
bold
;
clone
.
italic
=
italic
;
clone
.
sizeOffset
=
sizeOffset
;
clone
.
uiDefaultParentName
=
uiDefaultParentName
;
clone
.
setUiDefaults
(
uiDefaults
);
return
clone
;
}
// =================================================================================================================
// Private Helper Methods
private
void
updateOffsetsFromFont
()
{
if
(!
isAbsolute
())
{
float
oldSizeOffset
=
sizeOffset
;
Font
parentFont
=
uiDefaults
.
getFont
(
uiDefaultParentName
);
if
(
parentFont
!=
null
)
{
float
s
=
size
;
float
p
=
parentFont
.
getSize
();
sizeOffset
=
(
s
/
p
)
-
1
f
;
firePropertyChange
(
"sizeOffset"
,
oldSizeOffset
,
sizeOffset
);
}
}
}
private
void
updateFontFromOffsets
()
{
if
(!
isAbsolute
())
{
Font
oldFont
=
getFont
();
// get parent font data
Font
parentFont
=
uiDefaults
.
getFont
(
uiDefaultParentName
);
if
(
parentFont
!=
null
)
{
String
oldName
=
name
;
int
oldSize
=
size
;
name
=
parentFont
.
getName
();
size
=
Math
.
round
(
parentFont
.
getSize
()
*
(
1
f
+
sizeOffset
));
boolean
isBold
=
(
bold
==
DeriveStyle
.
Default
&&
parentFont
.
isBold
())
||
bold
==
DeriveStyle
.
On
;
boolean
isItalic
=
(
italic
==
DeriveStyle
.
Default
&&
parentFont
.
isItalic
())
||
italic
==
DeriveStyle
.
On
;
style
=
Font
.
PLAIN
;
if
(
isBold
)
style
=
style
|
Font
.
BOLD
;
if
(
isItalic
)
style
=
style
|
Font
.
ITALIC
;
// update fire events
firePropertyChange
(
"name"
,
oldName
,
name
);
firePropertyChange
(
"size"
,
oldSize
,
size
);
firePropertyChange
(
"font"
,
oldFont
,
getFont
());
}
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/CanvasMapper.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.jibxhelpers
;
import
org.jdesktop.swingx.designer.Canvas
;
import
org.jdesktop.swingx.designer.utils.HasPath
;
import
org.jdesktop.swingx.designer.utils.HasResources
;
import
org.jdesktop.swingx.designer.utils.HasUIDefaults
;
import
org.jibx.runtime.BindingDirectory
;
import
org.jibx.runtime.IBindingFactory
;
import
org.jibx.runtime.IMarshallable
;
import
org.jibx.runtime.IMarshaller
;
import
org.jibx.runtime.IMarshallingContext
;
import
org.jibx.runtime.IUnmarshaller
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
org.jibx.runtime.JiBXException
;
import
org.jibx.runtime.impl.MarshallingContext
;
import
org.jibx.runtime.impl.UnmarshallingContext
;
import
javax.swing.UIDefaults
;
import
java.io.File
;
/**
* CanvasMapper
*
* @author Created by Jasper Potts (Jun 12, 2007)
*/
public
class
CanvasMapper
implements
IMarshaller
,
IUnmarshaller
{
private
static
final
String
ELEMENT_NAME
=
"canvas"
;
private
IBindingFactory
bindingFactory
;
public
CanvasMapper
()
{
try
{
bindingFactory
=
BindingDirectory
.
getFactory
(
Canvas
.
class
);
}
catch
(
JiBXException
e
)
{
e
.
printStackTrace
();
}
}
public
boolean
isExtension
(
int
i
)
{
return
false
;
}
public
boolean
isPresent
(
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
return
iUnmarshallingContext
.
isAt
(
null
,
ELEMENT_NAME
);
}
public
void
marshal
(
Object
object
,
IMarshallingContext
iMarshallingContext
)
throws
JiBXException
{
if
(!(
object
instanceof
Canvas
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
if
(!(
iMarshallingContext
instanceof
MarshallingContext
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
{
// version found, create marshaller for the associated binding
// IBindingFactory bindingFactory = BindingDirectory.getFactory(object.getClass());
MarshallingContext
context
=
(
MarshallingContext
)
bindingFactory
.
createMarshallingContext
();
// configure marshaller for writing document
context
.
setXmlWriter
(
iMarshallingContext
.
getXmlWriter
());
// output object as document
((
IMarshallable
)
object
).
marshal
(
context
);
}
}
public
Object
unmarshal
(
Object
object
,
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
// make sure we're at the appropriate start tag
UnmarshallingContext
ctx
=
(
UnmarshallingContext
)
iUnmarshallingContext
;
if
(!
ctx
.
isAt
(
null
,
ELEMENT_NAME
))
{
ctx
.
throwStartTagNameError
(
null
,
ELEMENT_NAME
);
}
// IBindingFactory bindingFactory = BindingDirectory.getFactory(Canvas.class);
UnmarshallingContext
uctx
=
(
UnmarshallingContext
)
bindingFactory
.
createUnmarshallingContext
();
uctx
.
setFromContext
(
ctx
);
// get the uiDefaults from SynthModel and set them as user context
UIDefaults
uiDefaults
=
((
HasUIDefaults
)
ctx
.
getStackObject
(
ctx
.
getStackDepth
()
-
1
)).
getUiDefaults
();
uctx
.
setUserContext
(
uiDefaults
);
// get has resources
HasResources
hasResources
=
(
HasResources
)
ctx
.
getStackObject
(
ctx
.
getStackDepth
()
-
1
);
// get path
HasPath
hasPath
=
null
;
for
(
int
i
=
0
;
i
<
ctx
.
getStackDepth
();
i
++)
{
if
(
ctx
.
getStackObject
(
i
)
instanceof
HasPath
)
{
hasPath
=
(
HasPath
)
ctx
.
getStackObject
(
i
);
break
;
}
}
// Unmarshal the Canvas
Canvas
canvas
=
(
Canvas
)
uctx
.
unmarshalElement
();
// set canvas's ui defaults
canvas
.
setUiDefaults
(
uiDefaults
);
// get canvas path
String
canvasPath
=
hasPath
.
getPath
();
// calc and set resources
canvas
.
setResourcesDir
(
new
File
(
hasResources
.
getResourcesDir
(),
canvasPath
));
canvas
.
setTemplatesDir
(
new
File
(
hasResources
.
getTemplatesDir
(),
canvasPath
));
canvas
.
setImagesDir
(
new
File
(
hasResources
.
getImagesDir
(),
canvasPath
));
// return canvas
return
canvas
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/ColorMapper.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.jibxhelpers
;
import
org.jibx.runtime.IMarshaller
;
import
org.jibx.runtime.IMarshallingContext
;
import
org.jibx.runtime.IUnmarshaller
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
org.jibx.runtime.JiBXException
;
import
org.jibx.runtime.impl.MarshallingContext
;
import
org.jibx.runtime.impl.UnmarshallingContext
;
import
java.awt.Color
;
/**
* ColorMapper
*
* @author Created by Jasper Potts (Jun 8, 2007)
*/
public
class
ColorMapper
implements
IMarshaller
,
IUnmarshaller
{
private
static
final
String
ELEMENT_NAME
=
"color"
;
private
static
final
String
RED_NAME
=
"red"
;
private
static
final
String
GREEN_NAME
=
"green"
;
private
static
final
String
BLUE_NAME
=
"blue"
;
private
static
final
String
ALPHA_NAME
=
"alpha"
;
public
boolean
isExtension
(
int
i
)
{
return
false
;
}
public
boolean
isPresent
(
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
return
iUnmarshallingContext
.
isAt
(
null
,
ELEMENT_NAME
);
}
public
void
marshal
(
Object
object
,
IMarshallingContext
iMarshallingContext
)
throws
JiBXException
{
if
(!(
object
instanceof
Color
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
if
(!(
iMarshallingContext
instanceof
MarshallingContext
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
{
MarshallingContext
ctx
=
(
MarshallingContext
)
iMarshallingContext
;
Color
color
=
(
Color
)
object
;
ctx
.
startTagAttributes
(
0
,
ELEMENT_NAME
).
attribute
(
0
,
RED_NAME
,
color
.
getRed
()).
attribute
(
0
,
GREEN_NAME
,
color
.
getGreen
()).
attribute
(
0
,
BLUE_NAME
,
color
.
getBlue
()).
attribute
(
0
,
ALPHA_NAME
,
color
.
getAlpha
()).
closeStartEmpty
();
}
}
public
Object
unmarshal
(
Object
object
,
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
// make sure we're at the appropriate start tag
UnmarshallingContext
ctx
=
(
UnmarshallingContext
)
iUnmarshallingContext
;
if
(!
ctx
.
isAt
(
null
,
ELEMENT_NAME
))
{
ctx
.
throwStartTagNameError
(
null
,
ELEMENT_NAME
);
}
// get values
int
red
=
ctx
.
attributeInt
(
null
,
RED_NAME
,
0
);
int
green
=
ctx
.
attributeInt
(
null
,
GREEN_NAME
,
0
);
int
blue
=
ctx
.
attributeInt
(
null
,
BLUE_NAME
,
0
);
int
alpha
=
ctx
.
attributeInt
(
null
,
ALPHA_NAME
,
0
);
ctx
.
parsePastEndTag
(
null
,
ELEMENT_NAME
);
// create
return
new
Color
(
red
,
green
,
blue
,
alpha
);
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/DimensionMapper.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.jibxhelpers
;
import
org.jibx.runtime.IAliasable
;
import
org.jibx.runtime.IMarshaller
;
import
org.jibx.runtime.IMarshallingContext
;
import
org.jibx.runtime.IUnmarshaller
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
org.jibx.runtime.JiBXException
;
import
org.jibx.runtime.impl.MarshallingContext
;
import
org.jibx.runtime.impl.UnmarshallingContext
;
import
java.awt.Dimension
;
/**
* DimensionMapper
*
* @author Created by Jasper Potts (Jun 12, 2007)
*/
public
class
DimensionMapper
implements
IMarshaller
,
IUnmarshaller
,
IAliasable
{
private
static
final
String
ELEMENT_NAME
=
"dimension"
;
private
static
final
String
WIDTH_NAME
=
"width"
;
private
static
final
String
HEIGHT_NAME
=
"height"
;
private
String
uri
;
private
int
index
;
private
String
name
;
public
DimensionMapper
()
{
uri
=
null
;
index
=
0
;
name
=
ELEMENT_NAME
;
}
public
DimensionMapper
(
String
uri
,
int
index
,
String
name
)
{
this
.
uri
=
uri
;
this
.
index
=
index
;
this
.
name
=
name
;
}
public
boolean
isExtension
(
int
i
)
{
return
false
;
}
public
boolean
isPresent
(
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
return
iUnmarshallingContext
.
isAt
(
uri
,
ELEMENT_NAME
);
}
public
void
marshal
(
Object
object
,
IMarshallingContext
iMarshallingContext
)
throws
JiBXException
{
if
(!(
object
instanceof
Dimension
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
if
(!(
iMarshallingContext
instanceof
MarshallingContext
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
{
MarshallingContext
ctx
=
(
MarshallingContext
)
iMarshallingContext
;
Dimension
dimension
=
(
Dimension
)
object
;
ctx
.
startTagAttributes
(
index
,
name
).
attribute
(
index
,
WIDTH_NAME
,
dimension
.
width
).
attribute
(
index
,
HEIGHT_NAME
,
dimension
.
height
).
closeStartEmpty
();
}
}
public
Object
unmarshal
(
Object
object
,
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
// make sure we're at the appropriate start tag
UnmarshallingContext
ctx
=
(
UnmarshallingContext
)
iUnmarshallingContext
;
if
(!
ctx
.
isAt
(
uri
,
name
))
{
ctx
.
throwStartTagNameError
(
uri
,
name
);
}
// get values
int
width
=
ctx
.
attributeInt
(
uri
,
WIDTH_NAME
,
index
);
int
height
=
ctx
.
attributeInt
(
uri
,
HEIGHT_NAME
,
index
);
// state finished parsing
ctx
.
parsePastEndTag
(
uri
,
name
);
// create
return
new
Dimension
(
width
,
height
);
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/jibxhelpers/InsetsMapper.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.jibxhelpers
;
import
org.jibx.runtime.IAliasable
;
import
org.jibx.runtime.IMarshaller
;
import
org.jibx.runtime.IMarshallingContext
;
import
org.jibx.runtime.IUnmarshaller
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
org.jibx.runtime.JiBXException
;
import
org.jibx.runtime.impl.MarshallingContext
;
import
org.jibx.runtime.impl.UnmarshallingContext
;
import
java.awt.Insets
;
/**
* InsetsMapper
*
* @author Created by Jasper Potts (Jun 8, 2007)
*/
public
class
InsetsMapper
implements
IMarshaller
,
IUnmarshaller
,
IAliasable
{
private
static
final
String
ELEMENT_NAME
=
"insets"
;
private
static
final
String
TOP_NAME
=
"top"
;
private
static
final
String
BOTTOM_NAME
=
"bottom"
;
private
static
final
String
LEFT_NAME
=
"left"
;
private
static
final
String
RIGHT_NAME
=
"right"
;
private
String
uri
;
private
int
index
;
private
String
name
;
public
InsetsMapper
()
{
uri
=
null
;
index
=
0
;
name
=
ELEMENT_NAME
;
}
public
InsetsMapper
(
String
uri
,
int
index
,
String
name
)
{
this
.
uri
=
uri
;
this
.
index
=
index
;
this
.
name
=
name
;
// System.out.println("InsetsMapper.CONSTRCUTED with uri="+uri+" index="+index+" name="+name);
}
public
boolean
isExtension
(
int
i
)
{
return
false
;
}
public
boolean
isPresent
(
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
return
iUnmarshallingContext
.
isAt
(
uri
,
ELEMENT_NAME
);
}
public
void
marshal
(
Object
object
,
IMarshallingContext
iMarshallingContext
)
throws
JiBXException
{
if
(!(
object
instanceof
Insets
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
if
(!(
iMarshallingContext
instanceof
MarshallingContext
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
{
// System.out.println("InsetsMapper.marshal name="+name);
MarshallingContext
ctx
=
(
MarshallingContext
)
iMarshallingContext
;
Insets
insets
=
(
Insets
)
object
;
ctx
.
startTagAttributes
(
index
,
name
).
attribute
(
index
,
TOP_NAME
,
insets
.
top
).
attribute
(
index
,
BOTTOM_NAME
,
insets
.
bottom
).
attribute
(
index
,
LEFT_NAME
,
insets
.
left
).
attribute
(
index
,
RIGHT_NAME
,
insets
.
right
).
closeStartEmpty
();
}
}
public
Object
unmarshal
(
Object
object
,
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
// make sure we're at the appropriate start tag
UnmarshallingContext
ctx
=
(
UnmarshallingContext
)
iUnmarshallingContext
;
if
(!
ctx
.
isAt
(
uri
,
name
))
{
// System.out.println("InsetsMapper.unmarshal name="+name+" uri="+uri+" currentNode="+ctx.getName());
ctx
.
throwStartTagNameError
(
uri
,
name
);
}
else
{
// System.out.println("InsetsMapper.unmarshal name="+name+" uri="+uri+" currentNode="+ctx.getName());
}
// get values
int
top
=
ctx
.
attributeInt
(
uri
,
TOP_NAME
,
index
);
int
bottom
=
ctx
.
attributeInt
(
uri
,
BOTTOM_NAME
,
index
);
int
left
=
ctx
.
attributeInt
(
uri
,
LEFT_NAME
,
index
);
int
right
=
ctx
.
attributeInt
(
uri
,
RIGHT_NAME
,
index
);
// create new hashmap if needed
Insets
insets
=
(
Insets
)
object
;
if
(
insets
==
null
)
{
insets
=
new
Insets
(
top
,
left
,
bottom
,
right
);
}
else
{
insets
.
set
(
top
,
left
,
bottom
,
right
);
}
ctx
.
parsePastEndTag
(
uri
,
name
);
return
insets
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/AbstractGradient.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.paint
;
import
java.awt.Color
;
import
java.awt.MultipleGradientPaint.CycleMethod
;
import
java.awt.Paint
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
/** @author rbair */
public
abstract
class
AbstractGradient
extends
PaintModel
{
private
final
Comparator
<
GradientStop
>
sorter
=
new
Comparator
<
GradientStop
>()
{
public
int
compare
(
GradientStop
s1
,
GradientStop
s2
)
{
//since a float value may be -.001 or .001, and since casting
//this to an int will round off to 0, I have to do a more direct
//comparison
float
v
=
s1
.
getPosition
()
-
s2
.
getPosition
();
if
(
v
<
0
)
return
-
1
;
else
if
(
v
==
0
)
return
0
;
else
return
1
;
}
};
private
PropertyChangeListener
stopListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
if
(
evt
.
getPropertyName
().
equals
(
"position"
))
{
if
(
stops
.
contains
((
GradientStop
)
evt
.
getSource
()))
{
resortModel
(
true
);
}
else
{
System
.
err
.
println
(
"[WARNING] The position of an orphaned stop was changed."
);
}
}
else
{
firePropertyChange
(
"paint"
,
null
,
getPaint
());
}
}
};
private
List
<
GradientStop
>
stops
=
new
ArrayList
<
GradientStop
>();
private
List
<
GradientStop
>
unmodifiable
;
private
CycleMethod
cycleMethod
;
protected
AbstractGradient
()
{
unmodifiable
=
Collections
.
unmodifiableList
(
stops
);
cycleMethod
=
CycleMethod
.
NO_CYCLE
;
setStops
(
new
GradientStop
(
0
,
new
Matte
(
Color
.
BLUE
,
null
)),
new
GradientStop
(
1
,
new
Matte
(
Color
.
WHITE
,
null
)));
}
/**
* Copy stops and cycleMethod from src to dst
*
* @param dst The gradient to update to same stops and cycle method as this gradient
*/
protected
void
copyTo
(
AbstractGradient
dst
)
{
dst
.
stops
.
clear
();
List
<
GradientStop
>
stops
=
new
ArrayList
<
GradientStop
>();
for
(
GradientStop
stop
:
this
.
stops
)
{
stops
.
add
(
stop
.
clone
());
}
dst
.
setStops
(
stops
);
dst
.
cycleMethod
=
this
.
cycleMethod
;
}
public
PaintControlType
getPaintControlType
()
{
return
PaintControlType
.
control_line
;
}
public
void
setCycleMethod
(
CycleMethod
method
)
{
CycleMethod
old
=
cycleMethod
;
Paint
oldp
=
getPaint
();
cycleMethod
=
method
==
null
?
CycleMethod
.
NO_CYCLE
:
method
;
firePropertyChange
(
"cycleMethod"
,
old
,
cycleMethod
);
firePropertyChange
(
"paint"
,
oldp
,
getPaint
());
}
public
final
CycleMethod
getCycleMethod
()
{
return
cycleMethod
;
}
public
void
setStops
(
GradientStop
...
stops
)
{
if
(
stops
==
null
||
stops
.
length
<
1
)
{
throw
new
IllegalArgumentException
(
"Must have more than one stop"
);
}
List
<
GradientStop
>
old
=
new
ArrayList
<
GradientStop
>(
this
.
stops
);
for
(
GradientStop
stop
:
old
)
{
stop
.
removePropertyChangeListener
(
stopListener
);
}
Paint
oldp
=
getPaint
();
this
.
stops
.
clear
();
Collections
.
addAll
(
this
.
stops
,
stops
);
for
(
GradientStop
stop
:
this
.
stops
)
{
stop
.
addPropertyChangeListener
(
stopListener
);
}
resortModel
(
false
);
firePropertyChange
(
"stops"
,
old
,
getStops
());
firePropertyChange
(
"paint"
,
oldp
,
getPaint
());
}
public
final
void
setStops
(
List
<
GradientStop
>
stops
)
{
setStops
(
stops
==
null
?
null
:
stops
.
toArray
(
new
GradientStop
[
0
]));
}
public
final
List
<
GradientStop
>
getStops
()
{
return
unmodifiable
;
}
private
void
resortModel
(
boolean
fireEvent
)
{
Collections
.
sort
(
this
.
stops
,
sorter
);
if
(
fireEvent
)
{
Paint
oldp
=
getPaint
();
firePropertyChange
(
"stops"
,
null
,
getStops
());
firePropertyChange
(
"paint"
,
oldp
,
getPaint
());
}
}
//adds a new stop, and interoplates the proper color to use based on
//its position
public
GradientStop
addStop
(
float
position
)
{
GradientStop
prevStop
=
null
;
GradientStop
nextStop
=
null
;
for
(
GradientStop
stop
:
stops
)
{
if
(
stop
.
getPosition
()
<=
position
)
{
prevStop
=
stop
;
}
else
if
(
stop
.
getPosition
()
>=
position
)
{
nextStop
=
stop
;
}
}
Matte
c
=
null
;
if
(
prevStop
!=
null
&&
nextStop
!=
null
)
{
//interpolate the value of c
c
=
interpolate
(
prevStop
.
getColor
(),
nextStop
.
getColor
(),
position
/
(
nextStop
.
getPosition
()
-
prevStop
.
getPosition
()));
}
else
if
(
prevStop
!=
null
)
{
c
=
prevStop
.
getColor
().
clone
();
}
else
if
(
nextStop
!=
null
)
{
c
=
nextStop
.
getColor
().
clone
();
}
return
addStop
(
position
,
c
);
}
public
GradientStop
addStop
(
float
position
,
Matte
color
)
{
GradientStop
s
=
new
GradientStop
(
position
,
color
);
s
.
addPropertyChangeListener
(
stopListener
);
List
<
GradientStop
>
old
=
new
ArrayList
<
GradientStop
>(
stops
);
Paint
oldp
=
getPaint
();
stops
.
add
(
s
);
resortModel
(
false
);
firePropertyChange
(
"stops"
,
old
,
getStops
());
firePropertyChange
(
"paint"
,
oldp
,
getPaint
());
return
s
;
}
public
GradientStop
removeStop
(
GradientStop
s
)
{
List
<
GradientStop
>
old
=
new
ArrayList
<
GradientStop
>(
stops
);
Paint
oldp
=
getPaint
();
stops
.
remove
(
s
);
s
.
removePropertyChangeListener
(
stopListener
);
resortModel
(
false
);
firePropertyChange
(
"stops"
,
old
,
getStops
());
firePropertyChange
(
"paint"
,
oldp
,
getPaint
());
return
s
;
}
@Override
public
Paint
getPaint
()
{
if
(
stops
.
size
()
==
0
)
{
return
null
;
}
//there are stops.size() number of main stops. Between each is
//a fractional stop. Thus, there are:
//stops.size() + stops.size() - 1
//number of fractions and colors.
float
[]
fractions
=
new
float
[
stops
.
size
()
+
stops
.
size
()
-
1
];
Matte
[]
colors
=
new
Matte
[
fractions
.
length
];
//for each stop, create the stop and it's associated fraction
int
index
=
0
;
// the index into fractions and colors
for
(
int
i
=
0
;
i
<
stops
.
size
();
i
++)
{
GradientStop
s
=
stops
.
get
(
i
);
//copy over the stop's data
colors
[
index
]
=
s
.
getColor
();
fractions
[
index
]
=
s
.
getPosition
();
//If this isn't the last stop, then add in the fraction
if
(
index
<
fractions
.
length
-
1
)
{
float
f1
=
s
.
getPosition
();
float
f2
=
stops
.
get
(
i
+
1
).
getPosition
();
index
++;
fractions
[
index
]
=
f1
+
(
f2
-
f1
)
*
s
.
getMidpoint
();
colors
[
index
]
=
interpolate
(
colors
[
index
-
1
],
stops
.
get
(
i
+
1
).
getColor
(),
.
5
f
);
}
index
++;
}
for
(
int
i
=
1
;
i
<
fractions
.
length
;
i
++)
{
//to avoid an error with LinearGradientPaint where two fractions
//are identical, bump up the fraction value by a miniscule amount
//if it is identical to the previous one
//NOTE: The <= is critical because the previous value may already
//have been bumped up
if
(
fractions
[
i
]
<=
fractions
[
i
-
1
])
{
fractions
[
i
]
=
fractions
[
i
-
1
]
+
.
000001
f
;
}
}
//another boundary condition where multiple stops are all at the end. The
//previous loop bumped all but one of these past 1.0, which is bad.
//so remove any fractions (and their colors!) that are beyond 1.0
int
outOfBoundsIndex
=
-
1
;
for
(
int
i
=
0
;
i
<
fractions
.
length
;
i
++)
{
if
(
fractions
[
i
]
>
1
)
{
outOfBoundsIndex
=
i
;
break
;
}
}
if
(
outOfBoundsIndex
>=
0
)
{
float
[]
f
=
fractions
;
Matte
[]
c
=
colors
;
fractions
=
new
float
[
outOfBoundsIndex
];
colors
=
new
Matte
[
outOfBoundsIndex
];
System
.
arraycopy
(
f
,
0
,
fractions
,
0
,
outOfBoundsIndex
);
System
.
arraycopy
(
c
,
0
,
colors
,
0
,
outOfBoundsIndex
);
}
return
createPaint
(
fractions
,
colors
,
cycleMethod
);
}
protected
abstract
Paint
createPaint
(
float
[]
fractions
,
Matte
[]
colors
,
CycleMethod
method
);
protected
static
Matte
interpolate
(
Matte
v0
,
Matte
v1
,
float
fraction
)
{
return
new
Matte
(
interpolate
(
v0
.
getColor
(),
v1
.
getColor
(),
fraction
),
v0
.
getUiDefaults
());
}
protected
static
Color
interpolate
(
Color
v0
,
Color
v1
,
float
fraction
)
{
int
r
=
v0
.
getRed
()
+
(
int
)
((
v1
.
getRed
()
-
v0
.
getRed
())
*
fraction
+
0.5f
);
int
g
=
v0
.
getGreen
()
+
(
int
)
((
v1
.
getGreen
()
-
v0
.
getGreen
())
*
fraction
+
0.5f
);
int
b
=
v0
.
getBlue
()
+
(
int
)
((
v1
.
getBlue
()
-
v0
.
getBlue
())
*
fraction
+
0.5f
);
int
a
=
v0
.
getAlpha
()
+
(
int
)
((
v1
.
getAlpha
()
-
v0
.
getAlpha
())
*
fraction
+
0.5f
);
return
new
Color
(
r
,
g
,
b
,
a
);
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/Gradient.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.paint
;
import
java.awt.Color
;
import
java.awt.LinearGradientPaint
;
import
java.awt.MultipleGradientPaint.CycleMethod
;
import
java.awt.Paint
;
/**
* Represents a GradientPaint or LinearGradientPaint.
*
* @author rbair
*/
public
class
Gradient
extends
AbstractGradient
implements
Cloneable
{
protected
Paint
createPaint
(
float
[]
fractions
,
Matte
[]
mattes
,
CycleMethod
method
)
{
Color
[]
colors
=
new
Color
[
mattes
.
length
];
for
(
int
i
=
0
;
i
<
colors
.
length
;
i
++)
{
colors
[
i
]
=
mattes
[
i
].
getColor
();
}
return
new
LinearGradientPaint
(
0
,
0
,
1
,
0
,
fractions
,
colors
,
method
);
}
@Override
public
Gradient
clone
()
{
Gradient
gradient
=
new
Gradient
();
copyTo
(
gradient
);
return
gradient
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/GradientStop.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.paint
;
import
org.jdesktop.beans.AbstractBean
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
/** Each stop is defined linearly, at positions between 0 and 1. */
public
final
class
GradientStop
extends
AbstractBean
implements
Cloneable
{
private
float
position
;
private
Matte
color
;
private
PropertyChangeListener
matteListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"color"
,
null
,
color
);
}
};
/**
* The midpoint to the right of the stop. Must be 0 <= midpoint <= 1. The midpoint value of the last Stop is
* ignored.
*/
private
float
midpoint
;
public
GradientStop
()
{}
public
GradientStop
(
float
position
,
Matte
color
)
{
if
(
color
==
null
)
{
throw
new
IllegalArgumentException
(
"Color must not be null"
);
}
this
.
position
=
clamp
(
0
,
1
,
position
);
this
.
color
=
color
;
this
.
midpoint
=
.
5
f
;
if
(
this
.
color
!=
null
)
{
this
.
color
.
addPropertyChangeListener
(
"color"
,
matteListener
);
}
}
public
GradientStop
clone
()
{
GradientStop
clone
=
new
GradientStop
(
this
.
position
,
this
.
color
.
clone
());
clone
.
midpoint
=
midpoint
;
return
clone
;
}
public
final
float
getPosition
()
{
return
position
;
}
public
final
void
setPosition
(
float
position
)
{
float
old
=
this
.
position
;
this
.
position
=
clamp
(
0
,
1
,
position
);
firePropertyChange
(
"position"
,
old
,
this
.
position
);
}
public
final
Matte
getColor
()
{
return
color
;
}
public
final
void
setColor
(
Matte
c
)
{
if
(
c
==
null
)
throw
new
IllegalArgumentException
(
"Color must not be null"
);
Matte
old
=
this
.
color
;
if
(
old
!=
null
)
old
.
removePropertyChangeListener
(
matteListener
);
this
.
color
=
c
;
if
(
this
.
color
!=
null
)
this
.
color
.
addPropertyChangeListener
(
matteListener
);
firePropertyChange
(
"color"
,
old
,
c
);
}
public
final
void
setOpacity
(
int
opacity
)
{
int
old
=
getOpacity
();
color
.
setAlpha
(
opacity
);
firePropertyChange
(
"opacity"
,
old
,
getOpacity
());
}
public
final
int
getOpacity
()
{
return
color
.
getAlpha
();
}
public
final
float
getMidpoint
()
{
return
midpoint
;
}
public
final
void
setMidpoint
(
float
midpoint
)
{
float
old
=
this
.
midpoint
;
this
.
midpoint
=
clamp
(
0
,
1
,
midpoint
);
firePropertyChange
(
"midpoint"
,
old
,
this
.
midpoint
);
}
private
float
clamp
(
float
lo
,
float
hi
,
float
value
)
{
if
(
value
<
lo
)
{
return
lo
;
}
else
if
(
value
>
hi
)
{
return
hi
;
}
else
{
return
value
;
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/Matte.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.paint
;
import
org.jdesktop.swingx.designer.utils.HasUIDefaults
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
javax.swing.UIDefaults
;
import
java.awt.Color
;
import
java.awt.Paint
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
/**
* Representing a single uniform color. Basically, it represents the java.awt.Color. It can either be absolute or
* derived from a UIDefault color.
*
* @author rbair & jasper potts
*/
public
class
Matte
extends
PaintModel
implements
HasUIDefaults
{
private
float
[]
tmpf1
=
new
float
[
3
];
private
float
[]
tmpf2
=
new
float
[
3
];
private
int
red
;
private
int
green
;
private
int
blue
;
private
int
alpha
;
private
Color
cached
=
null
;
/**
* The name of the ui default key to derive this color from.
*/
private
String
uiDefaultParentName
=
null
;
/**
* The name of the bean property, or client property, on this component
* from which to extract a color used for painting. So for example the color
* used in a painter could be the background of the component.
*/
private
String
componentPropertyName
=
null
;
private
float
hueOffset
=
0
,
saturationOffset
=
0
,
brightnessOffset
=
0
;
private
int
alphaOffset
=
0
;
/**
* When true this color will become a UIResource in the UIManager defaults
* table. If false, then it will not be a UIResource. This is sometimes
* required, such as with colors installed on renderers.
*/
private
boolean
uiResource
=
true
;
/** This is a local UIDefaults that contains all the UIDefaults in the Model. */
private
transient
UIDefaults
uiDefaults
=
new
UIDefaults
();
private
PropertyChangeListener
uiDefaultsChangeListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
if
(
uiDefaultParentName
!=
null
&&
uiDefaultParentName
.
equals
(
evt
.
getPropertyName
()))
{
updateARGBFromOffsets
();
}
}
};
// =================================================================================================================
// Constructors
/** propected constructor for JIBX */
protected
Matte
()
{}
public
Matte
(
Color
c
,
UIDefaults
uiDefaults
)
{
if
(
c
!=
null
)
{
this
.
red
=
c
.
getRed
();
this
.
green
=
c
.
getGreen
();
this
.
blue
=
c
.
getBlue
();
this
.
alpha
=
c
.
getAlpha
();
}
setUiDefaults
(
uiDefaults
);
}
// =================================================================================================================
// JIBX Methods
/**
* Called by JIBX after all fields have been set
*
* @param context The JIBX Unmarshalling Context
*/
protected
void
postSet
(
IUnmarshallingContext
context
)
{
// walk up till we get synth model
for
(
int
i
=
0
;
i
<
context
.
getStackDepth
();
i
++)
{
if
(
context
.
getStackObject
(
i
)
instanceof
HasUIDefaults
)
{
UIDefaults
uiDefaults
=
((
HasUIDefaults
)
context
.
getStackObject
(
i
)).
getUiDefaults
();
if
(
uiDefaults
!=
null
)
{
setUiDefaults
(
uiDefaults
);
break
;
}
}
}
}
// =================================================================================================================
// Matte methods
/**
* Is the matte an absolute color ot derived from a parent ui default
*
* @return <code>true</code> if this is a absolute not uidefault derived color
*/
public
boolean
isAbsolute
()
{
return
uiDefaultParentName
==
null
;
}
/**
* Set all properties of this matte to be the same as <code>srcMatte</code> and fire all the change events
*
* @param srcMatte the matte to copy properties from
*/
public
void
copy
(
Matte
srcMatte
)
{
// keep old values
Color
oldColor
=
getColor
();
String
oldParentName
=
uiDefaultParentName
;
String
oldComponentPropertyName
=
componentPropertyName
;
boolean
oldUiResource
=
uiResource
;
int
oldR
=
red
,
oldG
=
green
,
oldB
=
blue
,
oldA
=
alpha
;
float
oldH
=
hueOffset
,
oldS
=
saturationOffset
,
oldBr
=
brightnessOffset
;
// set properties
if
(
uiResource
!=
srcMatte
.
uiResource
)
{
uiResource
=
srcMatte
.
uiResource
;
firePropertyChange
(
"uiResource"
,
oldUiResource
,
isUiResource
());
}
if
(
red
!=
srcMatte
.
red
)
{
red
=
srcMatte
.
red
;
firePropertyChange
(
"red"
,
oldR
,
getRed
());
}
if
(
green
!=
srcMatte
.
green
)
{
green
=
srcMatte
.
green
;
firePropertyChange
(
"green"
,
oldG
,
getGreen
());
}
if
(
blue
!=
srcMatte
.
blue
)
{
blue
=
srcMatte
.
blue
;
firePropertyChange
(
"blue"
,
oldB
,
getBlue
());
}
if
(
alpha
!=
srcMatte
.
alpha
)
{
alpha
=
srcMatte
.
alpha
;
firePropertyChange
(
"alpha"
,
oldA
,
getAlpha
());
}
if
(
hueOffset
!=
srcMatte
.
hueOffset
)
{
hueOffset
=
srcMatte
.
hueOffset
;
firePropertyChange
(
"hueOffset"
,
oldH
,
getHueOffset
());
}
if
(
saturationOffset
!=
srcMatte
.
saturationOffset
)
{
saturationOffset
=
srcMatte
.
saturationOffset
;
firePropertyChange
(
"saturationOffset"
,
oldS
,
getSaturationOffset
());
}
if
(
brightnessOffset
!=
srcMatte
.
brightnessOffset
)
{
brightnessOffset
=
srcMatte
.
brightnessOffset
;
firePropertyChange
(
"brightnessOffset"
,
oldBr
,
getBrightnessOffset
());
}
if
(
alphaOffset
!=
srcMatte
.
alphaOffset
)
{
alphaOffset
=
srcMatte
.
alphaOffset
;
firePropertyChange
(
"alphaOffset"
,
oldA
,
getAlphaOffset
());
}
if
(
uiDefaultParentName
!=
srcMatte
.
uiDefaultParentName
)
{
uiDefaultParentName
=
srcMatte
.
uiDefaultParentName
;
firePropertyChange
(
"uiDefaultParentName"
,
oldParentName
,
getUiDefaultParentName
());
}
if
(
componentPropertyName
!=
srcMatte
.
componentPropertyName
)
{
componentPropertyName
=
srcMatte
.
componentPropertyName
;
firePropertyChange
(
"componentPropertyName"
,
oldComponentPropertyName
,
getComponentPropertyName
());
}
if
(
uiDefaults
!=
srcMatte
.
uiDefaults
)
{
setUiDefaults
(
srcMatte
.
uiDefaults
);
}
if
(!
oldColor
.
equals
(
srcMatte
.
getColor
()))
{
firePropertyChange
(
"paint"
,
oldColor
,
getColor
());
firePropertyChange
(
"color"
,
oldColor
,
getColor
());
fireHSBChange
(
oldR
,
oldG
,
oldB
);
}
}
// =================================================================================================================
// PaintModel methods
public
PaintControlType
getPaintControlType
()
{
return
PaintControlType
.
none
;
}
// =================================================================================================================
// Bean Methods
/**
* Get the local UIDefaults that contains all the UIDefaults in the Model.
*
* @return The UIDefaults for the model that contains this Matte, can be null if this Matte is not part of a bigger
* model
*/
public
UIDefaults
getUiDefaults
()
{
return
uiDefaults
;
}
/**
* Set the local UIDefaults that contains all the UIDefaults in the Model.
*
* @param uiDefaults The UIDefaults for the model that contains this Matte, can be null if this Matte is not part of
* a bigger model
*/
public
void
setUiDefaults
(
UIDefaults
uiDefaults
)
{
if
(
uiDefaults
!=
this
.
uiDefaults
)
{
UIDefaults
old
=
getUiDefaults
();
if
(
old
!=
null
)
old
.
removePropertyChangeListener
(
uiDefaultsChangeListener
);
this
.
uiDefaults
=
uiDefaults
;
if
(
uiDefaults
!=
null
)
this
.
uiDefaults
.
addPropertyChangeListener
(
uiDefaultsChangeListener
);
firePropertyChange
(
"uiDefaults"
,
old
,
getUiDefaults
());
}
}
/**
* Get the name if the uidefault color that is the parent that this matte is derived from. If null then this is a
* absolute color.
*
* @return Parent color ui default name
*/
public
String
getUiDefaultParentName
()
{
return
uiDefaultParentName
;
}
/**
* Set the name if the uidefault color that is the parent that this matte is derived from. If null then this is a
* absolute color.
*
* @param uiDefaultParentName Parent color ui default name
*/
public
void
setUiDefaultParentName
(
String
uiDefaultParentName
)
{
String
old
=
getUiDefaultParentName
();
this
.
uiDefaultParentName
=
uiDefaultParentName
;
firePropertyChange
(
"uiDefaultParentName"
,
old
,
getUiDefaultParentName
());
if
(
isAbsolute
())
{
// reset offsets
float
oldH
=
hueOffset
,
oldS
=
saturationOffset
,
oldB
=
brightnessOffset
;
int
oldA
=
alphaOffset
;
hueOffset
=
0
;
saturationOffset
=
0
;
brightnessOffset
=
0
;
alphaOffset
=
0
;
firePropertyChange
(
"hueOffset"
,
oldH
,
getHueOffset
());
firePropertyChange
(
"saturationOffset"
,
oldS
,
getSaturationOffset
());
firePropertyChange
(
"brightnessOffset"
,
oldB
,
getBrightnessOffset
());
firePropertyChange
(
"alphaOffset"
,
oldA
,
getAlphaOffset
());
}
updateARGBFromOffsets
();
}
/**
* Sets the property to use for extracting the color for whatever component
* is passed to the painter. Can be a key in client properties. Can be null.
* @param name
*/
public
void
setComponentPropertyName
(
String
name
)
{
String
old
=
componentPropertyName
;
firePropertyChange
(
"componentPropertyName"
,
old
,
componentPropertyName
=
name
);
}
/**
* Gets the name of the bean property, or client property, on this component
* from which to extract a color used for painting. So for example the color
* used in a painter could be the background of the component.
*
* @return
*/
public
String
getComponentPropertyName
()
{
return
componentPropertyName
;
}
/**
* Sets whether this color should be represented as a UIResource in UIDefaults
* @param b true if the color should be a ui resource
*/
public
void
setUiResource
(
boolean
b
)
{
boolean
old
=
uiResource
;
firePropertyChange
(
"uiResource"
,
old
,
uiResource
=
b
);
}
/**
* When false this color will become a non-UIResource in the UIManager defaults
* table. This is sometimes required to force swing to use the given color,
* such as with renderers.
* @return false if the color should not be a uiresource
*/
public
boolean
isUiResource
()
{
return
uiResource
;
}
public
float
getHueOffset
()
{
return
hueOffset
;
}
public
void
setHueOffset
(
float
hueOffset
)
{
float
old
=
getHueOffset
();
this
.
hueOffset
=
hueOffset
;
firePropertyChange
(
"hueOffset"
,
old
,
getHueOffset
());
updateARGBFromOffsets
();
}
public
float
getSaturationOffset
()
{
return
saturationOffset
;
}
public
void
setSaturationOffset
(
float
satOffset
)
{
float
old
=
getSaturationOffset
();
this
.
saturationOffset
=
satOffset
;
firePropertyChange
(
"saturationOffset"
,
old
,
getSaturationOffset
());
updateARGBFromOffsets
();
}
public
float
getBrightnessOffset
()
{
return
brightnessOffset
;
}
public
void
setBrightnessOffset
(
float
brightOffset
)
{
float
old
=
getBrightnessOffset
();
this
.
brightnessOffset
=
brightOffset
;
firePropertyChange
(
"brightnessOffset"
,
old
,
getBrightnessOffset
());
updateARGBFromOffsets
();
}
public
int
getAlphaOffset
()
{
return
alphaOffset
;
}
public
void
setAlphaOffset
(
int
alphaOffset
)
{
int
old
=
getAlphaOffset
();
this
.
alphaOffset
=
alphaOffset
;
firePropertyChange
(
"alphaOffset"
,
old
,
alphaOffset
);
updateARGBFromOffsets
();
}
public
void
setRed
(
int
red
)
{
red
=
clamp
(
red
);
if
(
this
.
red
!=
red
)
{
Color
old
=
getColor
();
int
oldr
=
this
.
red
;
this
.
red
=
red
;
firePropertyChange
(
"paint"
,
old
,
getColor
());
firePropertyChange
(
"color"
,
old
,
getColor
());
firePropertyChange
(
"red"
,
oldr
,
red
);
fireHSBChange
(
oldr
,
green
,
blue
);
updateOffsetsFromARGB
();
}
}
public
final
int
getRed
()
{
return
red
;
}
public
void
setGreen
(
int
green
)
{
green
=
clamp
(
green
);
if
(
this
.
green
!=
green
)
{
Color
old
=
getColor
();
int
oldg
=
this
.
green
;
this
.
green
=
green
;
firePropertyChange
(
"paint"
,
old
,
getColor
());
firePropertyChange
(
"color"
,
old
,
getColor
());
firePropertyChange
(
"green"
,
oldg
,
green
);
fireHSBChange
(
red
,
oldg
,
blue
);
updateOffsetsFromARGB
();
}
}
public
final
int
getGreen
()
{
return
green
;
}
public
void
setBlue
(
int
blue
)
{
blue
=
clamp
(
blue
);
if
(
this
.
blue
!=
blue
)
{
Color
old
=
getColor
();
int
oldb
=
this
.
blue
;
this
.
blue
=
blue
;
firePropertyChange
(
"paint"
,
old
,
getColor
());
firePropertyChange
(
"color"
,
old
,
getColor
());
firePropertyChange
(
"blue"
,
oldb
,
blue
);
fireHSBChange
(
red
,
green
,
oldb
);
updateOffsetsFromARGB
();
}
}
public
final
int
getBlue
()
{
return
blue
;
}
public
void
setAlpha
(
int
alpha
)
{
alpha
=
clamp
(
alpha
);
if
(
this
.
alpha
!=
alpha
)
{
int
old
=
getAlpha
();
this
.
alpha
=
alpha
;
firePropertyChange
(
"alpha"
,
old
,
alpha
);
firePropertyChange
(
"paint"
,
old
,
getColor
());
firePropertyChange
(
"color"
,
old
,
getColor
());
updateOffsetsFromARGB
();
}
}
public
final
int
getAlpha
()
{
return
alpha
;
}
public
Color
getColor
()
{
if
(
cached
==
null
||
red
!=
cached
.
getRed
()
||
green
!=
cached
.
getGreen
()
||
blue
!=
cached
.
getBlue
()
||
alpha
!=
cached
.
getAlpha
())
{
cached
=
new
Color
(
red
,
green
,
blue
,
alpha
);
}
return
cached
;
}
public
void
setColor
(
Color
c
)
{
setColor
(
c
,
false
);
}
public
void
setColor
(
Color
c
,
boolean
dontSetAlpha
)
{
Color
oldColor
=
getColor
();
int
oldR
=
red
,
oldG
=
green
,
oldB
=
blue
,
oldA
=
alpha
;
cached
=
c
;
red
=
c
.
getRed
();
green
=
c
.
getGreen
();
blue
=
c
.
getBlue
();
if
(!
dontSetAlpha
)
alpha
=
c
.
getAlpha
();
updateOffsetsFromARGB
();
firePropertyChange
(
"red"
,
oldR
,
getRed
());
firePropertyChange
(
"green"
,
oldG
,
getGreen
());
firePropertyChange
(
"blue"
,
oldB
,
getBlue
());
fireHSBChange
(
oldR
,
oldG
,
oldB
);
if
(!
dontSetAlpha
)
firePropertyChange
(
"alpha"
,
oldA
,
getAlpha
());
firePropertyChange
(
"paint"
,
oldColor
,
getColor
());
firePropertyChange
(
"color"
,
oldColor
,
getColor
());
}
@Override
public
Paint
getPaint
()
{
return
getColor
();
}
@Override
public
String
toString
()
{
if
(
isAbsolute
())
{
return
Matte
.
class
.
getName
()
+
"[r="
+
red
+
", g="
+
green
+
", b="
+
blue
+
", a="
+
alpha
+
"]"
;
}
else
{
return
Matte
.
class
.
getName
()
+
"[base="
+
uiDefaultParentName
+
", H+"
+
hueOffset
+
", S+"
+
saturationOffset
+
", B+"
+
brightnessOffset
+
", A+"
+
alphaOffset
+
"]"
;
}
}
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
Matte
matte
=
(
Matte
)
o
;
if
(
alpha
!=
matte
.
alpha
)
return
false
;
if
(
alphaOffset
!=
matte
.
alphaOffset
)
return
false
;
if
(
Float
.
compare
(
matte
.
alpha
,
alpha
)
!=
0
)
return
false
;
if
(
blue
!=
matte
.
blue
)
return
false
;
if
(
Float
.
compare
(
matte
.
brightnessOffset
,
brightnessOffset
)
!=
0
)
return
false
;
if
(
green
!=
matte
.
green
)
return
false
;
if
(
Float
.
compare
(
matte
.
hueOffset
,
hueOffset
)
!=
0
)
return
false
;
if
(
red
!=
matte
.
red
)
return
false
;
if
(
uiResource
!=
matte
.
uiResource
)
return
false
;
if
(
Float
.
compare
(
matte
.
saturationOffset
,
saturationOffset
)
!=
0
)
return
false
;
if
(
componentPropertyName
!=
null
?
!
componentPropertyName
.
equals
(
componentPropertyName
)
:
matte
.
componentPropertyName
!=
null
)
return
false
;
if
(
uiDefaultParentName
!=
null
?
!
uiDefaultParentName
.
equals
(
matte
.
uiDefaultParentName
)
:
matte
.
uiDefaultParentName
!=
null
)
return
false
;
return
true
;
}
public
int
hashCode
()
{
int
result
;
result
=
red
;
result
=
31
*
result
+
green
;
result
=
31
*
result
+
blue
;
result
=
31
*
result
+
alpha
;
result
=
31
*
result
+
(
uiDefaultParentName
!=
null
?
uiDefaultParentName
.
hashCode
()
:
0
);
result
=
31
*
result
+
(
componentPropertyName
!=
null
?
componentPropertyName
.
hashCode
()
:
0
);
result
=
31
*
result
+
hueOffset
!=
+
0.0f
?
Float
.
floatToIntBits
(
hueOffset
)
:
0
;
result
=
31
*
result
+
saturationOffset
!=
+
0.0f
?
Float
.
floatToIntBits
(
saturationOffset
)
:
0
;
result
=
31
*
result
+
brightnessOffset
!=
+
0.0f
?
Float
.
floatToIntBits
(
brightnessOffset
)
:
0
;
result
=
31
*
result
+
(
uiResource
?
1
:
0
);
return
result
;
}
@Override
public
Matte
clone
()
{
Matte
m
=
new
Matte
();
m
.
red
=
red
;
m
.
green
=
green
;
m
.
blue
=
blue
;
m
.
alpha
=
alpha
;
m
.
brightnessOffset
=
brightnessOffset
;
m
.
hueOffset
=
hueOffset
;
m
.
saturationOffset
=
saturationOffset
;
m
.
alphaOffset
=
alphaOffset
;
m
.
uiDefaultParentName
=
uiDefaultParentName
;
m
.
componentPropertyName
=
componentPropertyName
;
m
.
uiResource
=
uiResource
;
m
.
setUiDefaults
(
uiDefaults
);
return
m
;
}
// =================================================================================================================
// Private Helper Methods
private
void
updateOffsetsFromARGB
()
{
if
(!
isAbsolute
())
{
tmpf1
=
Color
.
RGBtoHSB
(
red
,
green
,
blue
,
tmpf1
);
Color
parentColor
=
uiDefaults
.
getColor
(
uiDefaultParentName
);
tmpf2
=
Color
.
RGBtoHSB
(
parentColor
.
getRed
(),
parentColor
.
getGreen
(),
parentColor
.
getBlue
(),
tmpf2
);
// update offset properties and fire events
float
oldH
=
hueOffset
,
oldS
=
saturationOffset
,
oldB
=
brightnessOffset
;
int
oldA
=
alphaOffset
;
hueOffset
=
tmpf1
[
0
]
-
tmpf2
[
0
];
saturationOffset
=
tmpf1
[
1
]
-
tmpf2
[
1
];
brightnessOffset
=
tmpf1
[
2
]
-
tmpf2
[
2
];
alphaOffset
=
alpha
-
parentColor
.
getAlpha
();
firePropertyChange
(
"hueOffset"
,
oldH
,
getHueOffset
());
firePropertyChange
(
"saturationOffset"
,
oldS
,
getSaturationOffset
());
firePropertyChange
(
"brightnessOffset"
,
oldB
,
getBrightnessOffset
());
firePropertyChange
(
"alphaOffset"
,
oldA
,
getAlphaOffset
());
}
}
private
void
updateARGBFromOffsets
()
{
if
(!
isAbsolute
())
{
Color
oldColor
=
getColor
();
// get parent color HSB
Color
parentColor
=
uiDefaults
.
getColor
(
uiDefaultParentName
);
tmpf1
=
Color
.
RGBtoHSB
(
parentColor
.
getRed
(),
parentColor
.
getGreen
(),
parentColor
.
getBlue
(),
tmpf1
);
// apply offsets
tmpf1
[
0
]
=
clamp
(
tmpf1
[
0
]
+
hueOffset
);
tmpf1
[
1
]
=
clamp
(
tmpf1
[
1
]
+
saturationOffset
);
tmpf1
[
2
]
=
clamp
(
tmpf1
[
2
]
+
brightnessOffset
);
int
oldA
=
getAlpha
();
alpha
=
clamp
(
parentColor
.
getAlpha
()
+
alphaOffset
);
updateRGB
(
tmpf1
);
// update fire events
firePropertyChange
(
"alpha"
,
oldA
,
getAlpha
());
firePropertyChange
(
"paint"
,
oldColor
,
getColor
());
firePropertyChange
(
"color"
,
oldColor
,
getColor
());
}
}
private
void
updateRGB
(
float
[]
hsb
)
{
int
oldR
=
red
,
oldG
=
green
,
oldB
=
blue
;
int
rgb
=
Color
.
HSBtoRGB
(
hsb
[
0
],
hsb
[
1
],
hsb
[
2
]);
red
=
(
rgb
>>
16
)
&
0xFF
;
green
=
(
rgb
>>
8
)
&
0xFF
;
blue
=
rgb
&
0xFF
;
firePropertyChange
(
"red"
,
oldR
,
getRed
());
firePropertyChange
(
"green"
,
oldG
,
getGreen
());
firePropertyChange
(
"blue"
,
oldB
,
getBlue
());
}
private
void
fireHSBChange
(
int
oldR
,
int
oldG
,
int
oldB
)
{
tmpf1
=
Color
.
RGBtoHSB
(
oldR
,
oldG
,
oldB
,
tmpf1
);
tmpf2
=
Color
.
RGBtoHSB
(
red
,
green
,
blue
,
tmpf2
);
firePropertyChange
(
"hue"
,
tmpf1
[
0
],
tmpf2
[
0
]);
firePropertyChange
(
"saturation"
,
tmpf1
[
1
],
tmpf2
[
1
]);
firePropertyChange
(
"brightness"
,
tmpf1
[
2
],
tmpf2
[
2
]);
}
private
float
clamp
(
float
value
)
{
if
(
value
<
0
)
{
value
=
0
;
}
else
if
(
value
>
1
)
{
value
=
1
;
}
return
value
;
}
private
int
clamp
(
int
value
)
{
if
(
value
<
0
)
{
value
=
0
;
}
else
if
(
value
>
255
)
{
value
=
255
;
}
return
value
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/PaintModel.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.paint
;
import
org.jdesktop.beans.AbstractBean
;
import
java.awt.Paint
;
/**
* I'd have just called it Paint, but sadly, that name was already taken, and would have been too confusing.
* <p/>
* Whenever size or position values are required (for example with Texture or Gradient), they are specified in the unit
* square: that is, between 0 and 1 inclusive. They can then later be scaled as necessary by any painting code.
*
* @author rbair
*/
public
abstract
class
PaintModel
extends
AbstractBean
implements
Cloneable
{
public
static
enum
PaintControlType
{
none
,
control_line
,
control_rect
}
protected
PaintModel
()
{
}
/**
* @return an instance of Paint that is represented by this PaintModel. This is often not a reversable operation,
* and hence there is no "setPaint" method. Rather, tweaking the exposed properties of the PaintModel fires,
* when necessary, property change events for the "paint" property, and results in different values returned
* from this method.
*/
public
abstract
Paint
getPaint
();
/**
* Get the type of controls for this paint model
*
* @return The type of paint controls, one of PaintControlType.none, PaintControlType.control_line or
* PaintControlType.control_rect
*/
public
abstract
PaintControlType
getPaintControlType
();
public
abstract
PaintModel
clone
();
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasPath.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.utils
;
/**
* HasPath - interface for model nodes that can provide there path in the tree
*
* @author Created by Jasper Potts (Jul 2, 2007)
*/
public
interface
HasPath
{
public
String
getPath
();
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasResources.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.utils
;
import
java.io.File
;
/**
* HasResources - interface for model nodes that have resources
*
* @author Created by Jasper Potts (Jul 2, 2007)
*/
public
interface
HasResources
{
public
File
getResourcesDir
();
public
File
getImagesDir
();
public
File
getTemplatesDir
();
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/utils/HasUIDefaults.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.swingx.designer.utils
;
import
javax.swing.UIDefaults
;
/**
* HasUIDefaults - A tagging interface for any class that has UIDefaults
*
* @author Created by Jasper Potts (Jun 22, 2007)
*/
public
interface
HasUIDefaults
{
public
UIDefaults
getUiDefaults
();
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/DefaultsGenerator.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.synthdesigner.generator
;
import
org.jdesktop.swingx.designer.Canvas
;
import
org.jdesktop.swingx.designer.font.Typeface
;
import
org.jdesktop.swingx.designer.paint.Matte
;
import
org.jdesktop.swingx.designer.paint.PaintModel
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
GeneratorUtils
.
makePretty
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
GeneratorUtils
.
toConstantName
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
ObjectCodeConvertors
.
convert
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
TemplateWriter
.
read
;
import
static
org
.
jdesktop
.
synthdesigner
.
generator
.
TemplateWriter
.
writeSrcFile
;
import
org.jdesktop.synthdesigner.synthmodel.SynthModel
;
import
org.jdesktop.synthdesigner.synthmodel.UIComponent
;
import
org.jdesktop.synthdesigner.synthmodel.UIFont
;
import
org.jdesktop.synthdesigner.synthmodel.UIIconRegion
;
import
org.jdesktop.synthdesigner.synthmodel.UIPaint
;
import
org.jdesktop.synthdesigner.synthmodel.UIProperty
;
import
org.jdesktop.synthdesigner.synthmodel.UIRegion
;
import
org.jdesktop.synthdesigner.synthmodel.UIState
;
import
org.jdesktop.synthdesigner.synthmodel.UIStateType
;
import
org.jdesktop.synthdesigner.synthmodel.UIStyle
;
import
javax.swing.border.BevelBorder
;
import
javax.swing.border.Border
;
import
javax.swing.border.CompoundBorder
;
import
javax.swing.border.EmptyBorder
;
import
javax.swing.border.EtchedBorder
;
import
javax.swing.border.LineBorder
;
import
javax.swing.border.MatteBorder
;
import
java.awt.Dimension
;
import
java.awt.Font
;
import
java.awt.Insets
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.Map
;
import
org.jdesktop.synthdesigner.synthmodel.PainterBorder
;
/**
* DefaultsGenerator
* <p/>
* There are two main sets of defaults that must be configured. The first is
* the actual UI defaults tree. The second is a map of components + regions, which
* are used to decide what SynthStyle to use.
*
* @author Jasper Potts
* @author Richard Bair
*/
public
class
DefaultsGenerator
{
private
static
String
stateTypeImplTemplate
;
private
static
String
getStateTypeTemplate
()
{
if
(
stateTypeImplTemplate
==
null
)
{
//load the painter template file into an in-memory string to improve performance
//when generating a lot of classes
try
{
stateTypeImplTemplate
=
read
(
"resources/StateImpl.template"
);
}
catch
(
IOException
e
)
{
System
.
err
.
println
(
"Failed to read template files."
);
throw
new
RuntimeException
(
e
);
}
}
return
stateTypeImplTemplate
;
}
/**
* Generate the defaults file and all painter files for a SynthModel. This method
* is the main entry point, called by the Generator class.
*
* @param uiDefaultInit The buffer to write ui default put methods of the form <code>d.put("activeCaption", new
* ColorUIResource(123, 45, 200));</code>
* @param styleInit The buffer to write out code to generate Synth Style populating the styles map <code>m
* = new HashMap<Key, LazyStyle>()</code>
* @param model The Synth Model we are writing out defaults class for
* @param variables The variables map pre populated with "PACKAGE" and "LAF_NAME"
* @param packageNamePrefix The package name associated with this synth look and feel. For example,
* org.mypackage.mylaf
* @param painterPackageRoot The directory to write painters out to
*/
public
static
void
generateDefaults
(
StringBuilder
uiDefaultInit
,
StringBuilder
styleInit
,
SynthModel
model
,
Map
<
String
,
String
>
variables
,
String
packageNamePrefix
,
File
painterPackageRoot
)
{
// write color palette
uiDefaultInit
.
append
(
" //Color palette\n"
);
writeColorPalette
(
uiDefaultInit
,
model
.
getColorPalette
());
uiDefaultInit
.
append
(
"\n"
);
// write fonts palette
uiDefaultInit
.
append
(
" //Font palette\n"
);
uiDefaultInit
.
append
(
" d.put(\"defaultFont\", new FontUIResource(defaultFont));\n"
);
writeFontPalette
(
uiDefaultInit
,
model
.
getFontPalette
());
uiDefaultInit
.
append
(
"\n"
);
// TODO: Other palettes
uiDefaultInit
.
append
(
" //Border palette\n"
);
uiDefaultInit
.
append
(
"\n"
);
// write global style
uiDefaultInit
.
append
(
" //The global style definition\n"
);
writeStyle
(
model
.
getStyle
(),
uiDefaultInit
,
""
);
uiDefaultInit
.
append
(
"\n"
);
// write components
for
(
UIComponent
c
:
model
.
getComponents
())
{
String
prefix
=
escape
(
c
.
getKey
());
uiDefaultInit
.
append
(
" //Initialize "
).
append
(
prefix
)
.
append
(
"\n"
);
writeRegion
(
c
,
c
,
prefix
,
uiDefaultInit
,
styleInit
,
variables
,
packageNamePrefix
,
painterPackageRoot
);
uiDefaultInit
.
append
(
"\n"
);
}
}
private
static
void
writeColorPalette
(
StringBuilder
uiDefaultInit
,
List
<
UIPaint
>
colors
)
{
for
(
UIPaint
color
:
colors
)
{
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
color
.
getName
())
.
append
(
"\","
)
.
append
(
convertPaint
(
color
.
getValue
()))
.
append
(
");\n"
);
}
}
private
static
void
writeFontPalette
(
StringBuilder
uiDefaultInit
,
List
<
UIFont
>
fonts
)
{
for
(
UIFont
font
:
fonts
)
{
// We have no way of doing CSS style font lists yet so will just
// just the first font
if
(!
font
.
getFonts
().
isEmpty
()){
Typeface
t
=
font
.
getFonts
().
get
(
0
);
if
(
t
.
isAbsolute
()){
Font
f
=
t
.
getFont
();
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
font
.
getName
())
.
append
(
"\", new javax.swing.plaf.FontUIResource(\""
)
.
append
(
f
.
getName
())
.
append
(
"\", "
)
.
append
(
f
.
getStyle
())
.
append
(
", "
)
.
append
(
f
.
getSize
())
.
append
(
"));\n"
);
}
else
{
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
font
.
getName
())
.
append
(
"\", new DerivedFont(\""
)
.
append
(
t
.
getUiDefaultParentName
())
.
append
(
"\", "
)
.
append
(
t
.
getSizeOffset
())
.
append
(
"f, "
);
switch
(
t
.
getBold
()){
case
Default:
uiDefaultInit
.
append
(
"null"
);
break
;
case
On:
uiDefaultInit
.
append
(
"true"
);
break
;
case
Off:
uiDefaultInit
.
append
(
"false"
);
break
;
}
uiDefaultInit
.
append
(
", "
);
switch
(
t
.
getItalic
()){
case
Default:
uiDefaultInit
.
append
(
"null"
);
break
;
case
On:
uiDefaultInit
.
append
(
"true"
);
break
;
case
Off:
uiDefaultInit
.
append
(
"false"
);
break
;
}
uiDefaultInit
.
append
(
"));\n"
);
}
}
}
}
/**
* Write out the UIDefaults entries for a style
*
* @param style The style to write defaults entries for
* @param uiDefaultInit The buffer to write ui default put methods of the form <code>d.put("activeCaption", new
* ColorUIResource(123, 45, 200));</code>
* @param prefix The prefix for the style property names, for the model path where the style is from, should
* end with a "."
*/
private
static
void
writeStyle
(
UIStyle
style
,
StringBuilder
uiDefaultInit
,
String
prefix
)
{
if
(!
style
.
isTextForegroundInherited
())
writeMatte
(
prefix
+
"textForeground"
,
style
.
getTextForeground
(),
uiDefaultInit
);
if
(!
style
.
isTextBackgroundInherited
())
writeMatte
(
prefix
+
"textBackground"
,
style
.
getTextBackground
(),
uiDefaultInit
);
if
(!
style
.
isBackgroundInherited
())
writeMatte
(
prefix
+
"background"
,
style
.
getBackground
(),
uiDefaultInit
);
if
(!
style
.
isFontInherited
())
writeTypeFace
(
prefix
+
"font"
,
style
.
getFont
(),
uiDefaultInit
);
for
(
UIProperty
property
:
style
.
getUiProperties
())
{
switch
(
property
.
getType
())
{
case
BOOLEAN:
Boolean
b
=
((
Boolean
)
property
.
getValue
());
if
(
b
!=
null
)
{
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
property
.
getName
())
.
append
(
"\", "
)
.
append
(
b
?
"Boolean.TRUE"
:
"Boolean.FALSE"
)
.
append
(
");\n"
);
}
break
;
case
STRING:
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
property
.
getName
())
.
append
(
"\", \""
)
.
append
(
property
.
getValue
().
toString
())
.
append
(
"\");\n"
);
break
;
case
INT:
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
property
.
getName
())
.
append
(
"\", new Integer("
)
.
append
(((
Integer
)
property
.
getValue
()).
intValue
())
.
append
(
"));\n"
);
break
;
case
FLOAT:
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
property
.
getName
())
.
append
(
"\", new Float("
)
.
append
(((
Float
)
property
.
getValue
()).
floatValue
())
.
append
(
"f));\n"
);
break
;
case
DOUBLE:
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
property
.
getName
())
.
append
(
"\", new Double("
)
.
append
(((
Double
)
property
.
getValue
()).
doubleValue
())
.
append
(
"));\n"
);
break
;
case
COLOR:
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
property
.
getName
())
.
append
(
"\", "
)
.
append
(
convertPaint
((
Matte
)
property
.
getValue
()))
.
append
(
");\n"
);
break
;
case
FONT:
writeTypeFace
(
prefix
.
replace
(
"\""
,
"\\\""
)
+
property
.
getName
(),
(
Typeface
)
property
.
getValue
(),
uiDefaultInit
);
break
;
case
INSETS:
Insets
i
=
(
Insets
)
property
.
getValue
();
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
property
.
getName
())
.
append
(
"\", new InsetsUIResource("
)
.
append
(
i
.
top
).
append
(
", "
).
append
(
i
.
left
).
append
(
", "
).
append
(
i
.
bottom
).
append
(
", "
)
.
append
(
i
.
right
)
.
append
(
"));\n"
);
break
;
case
DIMENSION:
Dimension
d
=
(
Dimension
)
property
.
getValue
();
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
property
.
getName
())
.
append
(
"\", new DimensionUIResource("
)
.
append
(
d
.
width
).
append
(
", "
).
append
(
d
.
height
)
.
append
(
"));\n"
);
break
;
case
BORDER:
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
property
.
getName
())
.
append
(
"\", new BorderUIResource("
);
uiDefaultInit
.
append
(
convertBorder
(
(
Border
)
property
.
getValue
()));
uiDefaultInit
.
append
(
"));\n"
);
break
;
}
}
}
private
static
void
writeMatte
(
String
propertyName
,
Matte
matte
,
StringBuilder
uiDefaultInit
)
{
if
(
matte
==
null
)
System
.
err
.
println
(
"Error matte is NULL for ["
+
propertyName
+
"]"
);
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
propertyName
)
.
append
(
"\", "
)
.
append
(
convertPaint
(
matte
))
.
append
(
");\n"
);
}
private
static
void
writeTypeFace
(
String
propertyName
,
Typeface
typeface
,
StringBuilder
uiDefaultInit
)
{
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
propertyName
)
.
append
(
"\", new DerivedFont(\""
)
.
append
(
typeface
.
getUiDefaultParentName
())
.
append
(
"\", "
)
.
append
(
typeface
.
getSizeOffset
())
.
append
(
"f, "
);
switch
(
typeface
.
getBold
())
{
case
Default:
uiDefaultInit
.
append
(
"null,"
);
break
;
case
Off:
uiDefaultInit
.
append
(
"Boolean.FALSE,"
);
break
;
case
On:
uiDefaultInit
.
append
(
"Boolean.TRUE,"
);
break
;
}
switch
(
typeface
.
getItalic
())
{
case
Default:
uiDefaultInit
.
append
(
"null"
);
break
;
case
Off:
uiDefaultInit
.
append
(
"Boolean.FALSE"
);
break
;
case
On:
uiDefaultInit
.
append
(
"Boolean.TRUE"
);
break
;
}
uiDefaultInit
.
append
(
"));\n"
);
}
/**
* Write out code for a Component or Region
*
* @param comp This may be the same as the region <code>reg</code> or is the parent component
* containing the region
* @param region The region we are writing out
* @param prefix This is dot sperated path of component and sub regions to and including the region
* <code>reg</code> of the form [Comp].[Region]......[Region] path
* @param uiDefaultInit This is for inserting into org.mypackage.mylaf.MyDefaults#getDefaults() method
* @param styleInit This is for inserting into org.mypackage.mylaf.MyDefaults#initialize() method
* @param variables The variables map pre populated with "PACKAGE" and "LAF_NAME"
* @param packageNamePrefix The package name associated with this synth look and feel. For example,
* org.mypackage.mylaf
* @param painterPackageRoot The directory to write painters out to
*/
private
static
void
writeRegion
(
UIComponent
comp
,
UIRegion
region
,
String
prefix
,
StringBuilder
uiDefaultInit
,
StringBuilder
styleInit
,
Map
<
String
,
String
>
variables
,
String
packageNamePrefix
,
File
painterPackageRoot
)
{
// register component with LAF
String
regionCode
=
GeneratorUtils
.
getRegionNameCaps
(
region
.
getName
());
if
(
regionCode
==
null
)
{
throw
new
IllegalStateException
(
"We were asked to encode a region we know nothing about: "
+
region
.
getName
());
}
else
{
regionCode
=
"Region."
+
regionCode
;
}
//construct the list of States that accompany this registration.
StringBuffer
regString
=
new
StringBuffer
();
//like: Enabled,Disabled,Foo,Default,Etc
List
<
UIStateType
>
types
=
comp
.
getStateTypes
();
//state types are only defined on the UIComponent level
if
(
types
!=
null
&&
types
.
size
()
>
0
)
{
for
(
UIStateType
type
:
types
)
{
regString
.
append
(
type
.
getKey
());
regString
.
append
(
","
);
}
//remove the last ","
regString
.
deleteCharAt
(
regString
.
length
()-
1
);
}
styleInit
.
append
(
" register("
)
.
append
(
regionCode
)
.
append
(
", \""
)
.
append
(
prefix
);
styleInit
.
append
(
"\""
);
styleInit
.
append
(
");\n"
);
// write content margins
Insets
i
=
(
Insets
)
region
.
getContentMargins
();
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
".contentMargins"
)
.
append
(
"\", new InsetsUIResource("
)
.
append
(
i
.
top
).
append
(
", "
).
append
(
i
.
left
).
append
(
", "
).
append
(
i
.
bottom
).
append
(
", "
).
append
(
i
.
right
)
.
append
(
"));\n"
);
// write opaque if true
if
(
region
instanceof
UIComponent
&&
((
UIComponent
)
region
).
isOpaque
())
{
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
".opaque"
)
.
append
(
"\", Boolean.TRUE);\n"
);
}
//write the State, if necessary
if
(!
regString
.
equals
(
"Enabled,MouseOver,Pressed,Disabled,Focused,Selected,Default"
)
&&
types
.
size
()
>
0
)
{
//there were either custom states, or the normal states were in a custom order
//so go ahead and write out prefix.State
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
".States"
)
.
append
(
"\", \""
)
.
append
(
regString
)
.
append
(
"\");\n"
);
}
//write out any custom states, if necessary
for
(
UIStateType
type
:
types
)
{
String
synthState
=
type
.
getKey
();
if
(!
"Enabled"
.
equals
(
synthState
)
&&
!
"MouseOver"
.
equals
(
synthState
)
&&
!
"Pressed"
.
equals
(
synthState
)
&&
!
"Disabled"
.
equals
(
synthState
)
&&
!
"Focused"
.
equals
(
synthState
)
&&
!
"Selected"
.
equals
(
synthState
)
&&
!
"Default"
.
equals
(
synthState
))
{
//what we have here, gentlemen, is a bona-fide custom state.
try
{
//if the type is not one of the standard types, then construct a name for
//the new type, and write out a new subclass of State.
java
.
lang
.
String
className
=
makePretty
(
prefix
)
+
synthState
+
"State"
;
java
.
lang
.
String
body
=
type
.
getCodeSnippet
();
variables
.
put
(
"STATE_NAME"
,
className
);
variables
.
put
(
"STATE_KEY"
,
synthState
);
variables
.
put
(
"BODY"
,
body
);
writeSrcFile
(
getStateTypeTemplate
(),
variables
,
new
java
.
io
.
File
(
painterPackageRoot
,
className
+
".java"
));
variables
.
remove
(
"STATE_NAME"
);
variables
.
remove
(
"STATE_KEY"
);
variables
.
remove
(
"BODY"
);
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
prefix
)
.
append
(
"."
)
.
append
(
synthState
)
.
append
(
"\", new "
)
.
append
(
className
)
.
append
(
"());\n"
);
}
catch
(
IOException
ex
)
{
ex
.
printStackTrace
();
}
}
}
// write region style
writeStyle
(
region
.
getStyle
(),
uiDefaultInit
,
prefix
+
"."
);
try
{
boolean
hasCanvas
=
hasCanvas
(
region
);
if
(
hasCanvas
)
{
PainterGenerator
.
writePainter
(
region
,
variables
,
painterPackageRoot
,
prefix
);
}
String
fileNamePrefix
=
makePretty
(
prefix
)
+
"Painter"
;
// write states ui defaults
for
(
UIState
state
:
region
.
getBackgroundStates
())
{
String
statePrefix
=
prefix
+
"["
+
state
.
getName
()
+
"]"
;
// write state style
writeStyle
(
state
.
getStyle
(),
uiDefaultInit
,
statePrefix
+
"."
);
// write painter
if
(
hasCanvas
)
{
writeLazyPainter
(
state
,
uiDefaultInit
,
statePrefix
,
packageNamePrefix
,
fileNamePrefix
,
"background"
);
}
}
for
(
UIState
state
:
region
.
getForegroundStates
())
{
String
statePrefix
=
prefix
+
"["
+
state
.
getName
()
+
"]"
;
// write state style
writeStyle
(
state
.
getStyle
(),
uiDefaultInit
,
statePrefix
+
"."
);
// write painter
if
(
hasCanvas
)
{
writeLazyPainter
(
state
,
uiDefaultInit
,
statePrefix
,
packageNamePrefix
,
fileNamePrefix
,
"foreground"
);
}
}
for
(
UIState
state
:
region
.
getBorderStates
())
{
String
statePrefix
=
prefix
+
"["
+
state
.
getName
()
+
"]"
;
// write state style
writeStyle
(
state
.
getStyle
(),
uiDefaultInit
,
statePrefix
+
"."
);
// write painter
if
(
hasCanvas
)
{
writeLazyPainter
(
state
,
uiDefaultInit
,
statePrefix
,
packageNamePrefix
,
fileNamePrefix
,
"border"
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
// handle sub regions
for
(
UIRegion
subRegion
:
region
.
getSubRegions
())
{
String
subregionName
=
prefix
+
":"
+
escape
(
subRegion
.
getKey
());
if
(
subRegion
instanceof
UIIconRegion
)
{
writeIconRegion
(
comp
,
(
UIIconRegion
)
subRegion
,
prefix
,
uiDefaultInit
,
variables
,
packageNamePrefix
,
painterPackageRoot
);
}
else
if
(
subRegion
instanceof
UIComponent
)
{
// inner named component
UIComponent
subComponent
=
(
UIComponent
)
subRegion
;
writeRegion
(
subComponent
,
subRegion
,
subregionName
,
uiDefaultInit
,
styleInit
,
variables
,
packageNamePrefix
,
painterPackageRoot
);
}
else
{
writeRegion
(
comp
,
subRegion
,
subregionName
,
uiDefaultInit
,
styleInit
,
variables
,
packageNamePrefix
,
painterPackageRoot
);
}
}
}
private
static
void
writeLazyPainter
(
UIState
state
,
StringBuilder
uiDefaultInit
,
String
statePrefix
,
String
packageNamePrefix
,
String
fileNamePrefix
,
String
painterSuffix
)
{
Canvas
canvas
=
state
.
getCanvas
();
if
(!
canvas
.
isBlank
())
{
Insets
si
=
canvas
.
getStretchingInsets
();
boolean
inverted
=
state
.
isInverted
();
UIStyle
.
CacheMode
cache
=
state
.
getStyle
().
getCacheMode
();
String
cacheModeString
=
null
;
switch
(
cache
)
{
case
NO_CACHING:
cacheModeString
=
"AbstractRegionPainter.PaintContext.CacheMode.NO_CACHING"
;
break
;
case
FIXED_SIZES:
cacheModeString
=
"AbstractRegionPainter.PaintContext.CacheMode.FIXED_SIZES"
;
break
;
case
NINE_SQUARE_SCALE:
cacheModeString
=
"AbstractRegionPainter.PaintContext.CacheMode.NINE_SQUARE_SCALE"
;
break
;
}
double
maxH
=
state
.
getStyle
().
getMaxHozCachedImgScaling
();
double
maxV
=
state
.
getStyle
().
getMaxVertCachedImgScaling
();
String
stateConstant
=
toConstantName
(
painterSuffix
+
"_"
+
UIState
.
keysToString
(
state
.
getStateKeys
()));
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
statePrefix
)
.
append
(
"."
).
append
(
painterSuffix
).
append
(
"Painter\", new LazyPainter(\""
)
.
append
(
packageNamePrefix
).
append
(
"."
).
append
(
fileNamePrefix
)
.
append
(
"\", "
)
.
append
(
fileNamePrefix
).
append
(
"."
).
append
(
stateConstant
).
append
(
", "
)
.
append
(
convert
(
si
)).
append
(
", "
)
.
append
(
convert
(
canvas
.
getSize
())).
append
(
", "
)
.
append
(
inverted
).
append
(
", "
)
.
append
(
cacheModeString
).
append
(
", "
)
.
append
(
maxH
==
Double
.
POSITIVE_INFINITY
?
"Double.POSITIVE_INFINITY"
:
maxH
).
append
(
", "
)
.
append
(
maxV
==
Double
.
POSITIVE_INFINITY
?
"Double.POSITIVE_INFINITY"
:
maxV
).
append
(
"));\n"
);
}
}
/**
* Write out code for a IconRegion
*
* @param comp This may be the same as the region <code>region</code> or is the parent component
* containing the region
* @param region The region we are writing out
* @param prefix This is [Comp][Region]......[Region] path
* @param key The key for this icon.
* @param uiDefaultInit This is for inserting into org.mypackage.mylaf.MyDefaults#getDefaults() method
* @param variables The variables map pre populated with "PACKAGE" and "LAF_NAME"
* @param packageNamePrefix The package name associated with this synth look and feel. For example,
* org.mypackage.mylaf
* @param painterPackageRoot The directory to write painters out to
*/
private
static
void
writeIconRegion
(
UIComponent
comp
,
UIIconRegion
region
,
String
prefix
,
StringBuilder
uiDefaultInit
,
Map
<
String
,
String
>
variables
,
String
packageNamePrefix
,
File
painterPackageRoot
)
{
Dimension
size
=
null
;
String
fileNamePrefix
=
makePretty
(
prefix
)
+
"Painter"
;
// write states ui defaults
for
(
UIState
state
:
region
.
getBackgroundStates
())
{
// TODO: Handle Background,Foreground and Borders States Lists? Actually not sure that IconRegions need support borders or foregrounds
Canvas
canvas
=
state
.
getCanvas
();
if
(!
canvas
.
isBlank
())
{
String
statePrefix
=
prefix
+
"["
+
state
.
getName
()
+
"]"
;
// Put Painter in UiDefaults
writeLazyPainter
(
state
,
uiDefaultInit
,
statePrefix
,
packageNamePrefix
,
fileNamePrefix
,
region
.
getKey
());
size
=
canvas
.
getSize
();
}
}
if
(
size
!=
null
)
{
// Put SynthIconImpl wrapper in UiDefaults
String
key
=
region
.
getBasicKey
()
==
null
?
prefix
+
"."
+
region
.
getKey
()
:
region
.
getBasicKey
();
uiDefaultInit
.
append
(
" d.put(\""
)
.
append
(
key
)
.
append
(
"\", new NimbusIcon(\""
)
//TODO should this be wrapped in an IconUIResource?
.
append
(
prefix
)
.
append
(
"\", \""
)
.
append
(
region
.
getKey
())
.
append
(
"Painter"
)
.
append
(
"\", "
)
.
append
(
size
.
width
)
.
append
(
", "
)
.
append
(
size
.
height
)
.
append
(
"));\n"
);
}
// handle sub regions
if
(
region
.
getSubRegions
().
length
>
0
)
{
// there is no meaning to a sub region inside a IconRegion
throw
new
IllegalStateException
(
"You can not have sub regions inside UiIconRegions. \""
+
comp
.
getSubRegions
()[
0
].
getName
()
+
"\" is inside \""
+
prefix
.
substring
(
0
,
prefix
.
length
()
-
1
)
+
"\""
);
}
}
/**
* Utility method for escaping all double quotes with backslash double-quote.
*/
private
static
String
escape
(
String
s
)
{
return
s
.
replace
(
"\""
,
"\\\""
);
}
private
static
String
convertPaint
(
PaintModel
paint
){
if
(
paint
instanceof
Matte
){
Matte
matte
=
(
Matte
)
paint
;
if
(
matte
.
isAbsolute
()){
String
colorParams
=
convert
(
matte
.
getColor
());
if
(
matte
.
isUiResource
())
{
return
"new ColorUIResource("
+
colorParams
+
")"
;
}
else
{
return
colorParams
;
}
}
else
{
String
s
=
"getDerivedColor(\""
+
matte
.
getUiDefaultParentName
()+
"\","
+
matte
.
getHueOffset
()+
"f,"
+
matte
.
getSaturationOffset
()+
"f,"
+
matte
.
getBrightnessOffset
()+
"f,"
+
matte
.
getAlphaOffset
();
if
(
matte
.
isUiResource
())
{
return
s
+
")"
;
}
else
{
return
s
+
",false)"
;
}
}
}
else
{
//TODO: What about gradients etc here?
System
.
err
.
println
(
"Error: Could not write paint in "
+
"DefaultsGenerator as it was not a Matte. = "
+
paint
.
getClass
().
getName
());
return
""
;
}
}
private
static
String
convertBorder
(
Border
val
)
{
StringBuilder
uiDefaultInit
=
new
StringBuilder
();
Insets
i
;
if
(
val
instanceof
PainterBorder
)
{
PainterBorder
pb
=
(
PainterBorder
)
val
;
i
=
pb
.
getBorderInsets
();
uiDefaultInit
.
append
(
"new PainterBorder(\""
)
.
append
(
pb
.
getPainterName
())
.
append
(
"\", new Insets("
)
.
append
(
i
.
top
).
append
(
", "
)
.
append
(
i
.
left
).
append
(
", "
)
.
append
(
i
.
bottom
).
append
(
", "
)
.
append
(
i
.
right
)
.
append
(
"))"
);
}
else
if
(
val
instanceof
EmptyBorder
)
{
i
=
((
EmptyBorder
)
val
).
getBorderInsets
();
uiDefaultInit
.
append
(
"BorderFactory.createEmptyBorder("
)
.
append
(
i
.
top
).
append
(
", "
)
.
append
(
i
.
left
).
append
(
", "
)
.
append
(
i
.
bottom
).
append
(
", "
)
.
append
(
i
.
right
)
.
append
(
")"
);
}
else
if
(
val
instanceof
LineBorder
)
{
LineBorder
border
=
(
LineBorder
)
val
;
uiDefaultInit
.
append
(
"BorderFactory.createLineBorder("
)
.
append
(
convert
(
border
.
getLineColor
()))
.
append
(
","
)
.
append
(
border
.
getThickness
())
.
append
(
")"
);
}
else
if
(
val
instanceof
EtchedBorder
)
{
EtchedBorder
border
=
(
EtchedBorder
)
val
;
uiDefaultInit
.
append
(
"BorderFactory.createEtchedBorder("
)
.
append
(
border
.
getEtchType
())
.
append
(
","
)
.
append
(
convert
(
border
.
getHighlightColor
()))
.
append
(
","
)
.
append
(
convert
(
border
.
getShadowColor
()))
.
append
(
")"
);
}
else
if
(
val
instanceof
BevelBorder
)
{
BevelBorder
border
=
(
BevelBorder
)
val
;
uiDefaultInit
.
append
(
"BorderFactory.createEtchedBorder("
)
.
append
(
border
.
getBevelType
())
.
append
(
","
)
.
append
(
convert
(
border
.
getHighlightOuterColor
()))
.
append
(
","
)
.
append
(
convert
(
border
.
getHighlightInnerColor
()))
.
append
(
","
)
.
append
(
convert
(
border
.
getShadowOuterColor
()))
.
append
(
","
)
.
append
(
convert
(
border
.
getShadowInnerColor
()))
.
append
(
")"
);
}
else
if
(
val
instanceof
MatteBorder
)
{
MatteBorder
border
=
(
MatteBorder
)
val
;
i
=
border
.
getBorderInsets
();
uiDefaultInit
.
append
(
"BorderFactory.createEmptyBorder("
)
.
append
(
i
.
top
).
append
(
", "
)
.
append
(
i
.
left
).
append
(
", "
)
.
append
(
i
.
bottom
).
append
(
", "
)
.
append
(
i
.
right
).
append
(
", "
)
.
append
(
convert
(
border
.
getMatteColor
()))
.
append
(
")"
);
}
else
if
(
val
instanceof
CompoundBorder
)
{
CompoundBorder
border
=
(
CompoundBorder
)
val
;
uiDefaultInit
.
append
(
"BorderFactory.createEmptyBorder("
)
.
append
(
convertBorder
(
border
.
getOutsideBorder
()))
.
append
(
","
)
.
append
(
convertBorder
(
border
.
getInsideBorder
()))
.
append
(
")"
);
}
return
uiDefaultInit
.
toString
();
}
private
static
boolean
hasCanvas
(
UIRegion
region
)
{
for
(
UIState
s
:
region
.
getBackgroundStates
())
{
if
(!
s
.
getCanvas
().
isBlank
())
return
true
;
}
for
(
UIState
s
:
region
.
getBorderStates
())
{
if
(!
s
.
getCanvas
().
isBlank
())
return
true
;
}
for
(
UIState
s
:
region
.
getForegroundStates
())
{
if
(!
s
.
getCanvas
().
isBlank
())
return
true
;
}
for
(
UIRegion
subregion
:
region
.
getSubRegions
())
{
if
(
hasCanvas
(
subregion
))
return
true
;
}
return
false
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/ObjectCodeConvertors.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.synthdesigner.generator
;
import
java.awt.*
;
/**
* ObjectCodeConvertors
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
ObjectCodeConvertors
{
static
java
.
math
.
MathContext
ctx
=
new
java
.
math
.
MathContext
(
3
);
/**
* Given a value (x), encode it such that 0 -> 1 is to the left of a, 1 -> 2 is between a and b, and 2 -> 3
* is to the right of b.
*
* @param w width in the case of the x axis, height in the case of the y axis.
*/
static
float
encode
(
float
x
,
float
a
,
float
b
,
float
w
)
{
float
r
=
0
;
if
(
x
<
a
)
{
r
=
(
x
/
a
);
}
else
if
(
x
>
b
)
{
r
=
2
+
((
x
-
b
)
/
(
w
-
b
));
}
else
if
(
x
==
a
&&
x
==
b
)
{
return
1.5f
;
}
else
{
r
=
1
+
((
x
-
a
)
/
(
b
-
a
));
}
if
(
Float
.
isNaN
(
r
))
{
System
.
err
.
println
(
"[Error] Encountered NaN: encode("
+
x
+
", "
+
a
+
", "
+
b
+
", "
+
w
+
")"
);
return
0
;
}
else
if
(
Float
.
isInfinite
(
r
))
{
System
.
err
.
println
(
"[Error] Encountered Infinity: encode("
+
x
+
", "
+
a
+
", "
+
b
+
", "
+
w
+
")"
);
return
0
;
}
else
if
(
r
<
0
)
{
System
.
err
.
println
(
"[Error] encoded value was less than 0: encode("
+
x
+
", "
+
a
+
", "
+
b
+
", "
+
w
+
")"
);
return
0
;
}
else
if
(
r
>
3
)
{
System
.
err
.
println
(
"[Error] encoded value was greater than 3: encode("
+
x
+
", "
+
a
+
", "
+
b
+
", "
+
w
+
")"
);
return
3
;
}
else
{
//for prettyness sake (and since we aren't really going to miss
//any accuracy here) I'm rounding this to 3 decimal places
// return java.math.BigDecimal.valueOf(r).round(ctx).doubleValue();
return
r
;
}
}
static
String
convert
(
Paint
paint
)
{
//TODO need to support writing out other Paints, such as gradients
if
(
paint
instanceof
Color
)
{
return
convert
((
Color
)
paint
);
}
else
{
System
.
err
.
println
(
"[WARNING] Unable to encode a paint in the encode(Paint) method: "
+
paint
);
return
"null"
;
}
}
/**
* Given a Color, write out the java code required to create a new Color.
*
* @param color The color to convert
* @return String of the code for the color
*/
static
String
convert
(
Color
color
)
{
return
"new Color("
+
color
.
getRed
()
+
", "
+
color
.
getGreen
()
+
", "
+
color
.
getBlue
()
+
", "
+
color
.
getAlpha
()
+
")"
;
}
static
String
convert
(
Insets
i
)
{
return
"new Insets("
+
i
.
top
+
", "
+
i
.
left
+
", "
+
i
.
bottom
+
", "
+
i
.
right
+
")"
;
}
static
String
convert
(
Dimension
d
)
{
return
"new Dimension("
+
d
.
width
+
", "
+
d
.
height
+
")"
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/generator/TemplateWriter.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.synthdesigner.generator
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.PrintWriter
;
import
java.io.StringReader
;
import
java.util.Map
;
/**
* TemplateWriter - Class for writing Java Source files using a src template and variable subsitution
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
TemplateWriter
{
/**
* Write a Java source file by taking a template file and applying variable substitution and writing to the output
* file.
*
* @param template The template to use
* @param variables Map of the variable names and values to substitute in the template
* @param output The file to write to
* @throws IOException If there was a problem writing the Java source file
*/
static
void
writeSrcFile
(
String
template
,
Map
<
String
,
String
>
variables
,
File
output
)
throws
IOException
{
TemplateReader
in
=
new
TemplateReader
(
variables
,
template
);
PrintWriter
out
=
new
PrintWriter
(
new
FileWriter
(
output
));
String
line
=
in
.
readLine
();
while
(
line
!=
null
)
{
out
.
println
(
line
);
line
=
in
.
readLine
();
}
out
.
close
();
}
/**
* Read a template file into a string
*
* @param name The template file path relative to Generator class
* @return The contents of the template file as string
* @throws IOException If there was a problem reading the template file
*/
static
String
read
(
String
name
)
throws
IOException
{
InputStream
in
=
Generator
.
class
.
getResourceAsStream
(
name
);
if
(
in
==
null
)
throw
new
IOException
(
"Could not find template ["
+
name
+
"] relative to class ["
+
Generator
.
class
.
getName
()+
"]"
);
byte
[]
data
=
new
byte
[
4096
];
int
length
=
-
1
;
StringBuilder
buffer
=
new
StringBuilder
();
while
((
length
=
in
.
read
(
data
))
!=
-
1
)
{
buffer
.
append
(
new
String
(
data
,
0
,
length
));
}
return
buffer
.
toString
();
}
/** A BufferedReader implementation that automatically performs string replacements as needed. */
private
static
final
class
TemplateReader
extends
BufferedReader
{
private
Map
<
String
,
String
>
variables
;
TemplateReader
(
Map
<
String
,
String
>
variables
,
String
template
)
{
super
(
new
StringReader
(
template
));
this
.
variables
=
variables
;
}
/**
* @return a line of text from the template but with variables substituted. Other methods will return the text
* sans substitution. Call this method.
* @throws java.io.IOException
*/
public
String
readLine
()
throws
IOException
{
return
substituteVariables
(
super
.
readLine
());
}
private
String
substituteVariables
(
String
input
)
{
if
(
input
==
null
)
return
null
;
for
(
Map
.
Entry
<
String
,
String
>
variable
:
variables
.
entrySet
())
{
input
=
input
.
replace
(
"${"
+
variable
.
getKey
()
+
"}"
,
variable
.
getValue
());
}
return
input
;
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/HasUIStyle.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.synthdesigner.synthmodel
;
/**
* HasUIStyle - A marker interface for all classes that have a UIStyle
*
* @author Richard Bair
* @author Jasper Potts
*/
public
interface
HasUIStyle
{
public
UIStyle
getStyle
();
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/PainterBorder.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.synthdesigner.synthmodel
;
import
javax.swing.border.EmptyBorder
;
/**
* Represents a border that refers to a Painter to do it's work. This border
* doesn't actually render -- it is just used as part of the model.
*
* @author Richard Bair
*/
public
class
PainterBorder
extends
EmptyBorder
{
private
String
painterName
;
public
PainterBorder
(
String
painterName
,
int
top
,
int
left
,
int
bottom
,
int
right
)
{
super
(
top
,
left
,
bottom
,
right
);
this
.
painterName
=
painterName
;
}
public
String
getPainterName
()
{
return
painterName
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/SynthModel.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2002-2007 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
org.jdesktop.synthdesigner.synthmodel
;
import
org.jdesktop.beans.AbstractBean
;
import
org.jdesktop.swingx.designer.utils.HasResources
;
import
org.jdesktop.swingx.designer.utils.HasUIDefaults
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
javax.swing.JButton
;
import
javax.swing.JCheckBox
;
import
javax.swing.JCheckBoxMenuItem
;
import
javax.swing.JColorChooser
;
import
javax.swing.JComboBox
;
import
javax.swing.JDesktopPane
;
import
javax.swing.JEditorPane
;
import
javax.swing.JFileChooser
;
import
javax.swing.JFormattedTextField
;
import
javax.swing.JInternalFrame
;
import
javax.swing.JLabel
;
import
javax.swing.JList
;
import
javax.swing.JMenu
;
import
javax.swing.JMenuBar
;
import
javax.swing.JMenuItem
;
import
javax.swing.JOptionPane
;
import
javax.swing.JPanel
;
import
javax.swing.JPasswordField
;
import
javax.swing.JPopupMenu
;
import
javax.swing.JProgressBar
;
import
javax.swing.JRadioButton
;
import
javax.swing.JRadioButtonMenuItem
;
import
javax.swing.JRootPane
;
import
javax.swing.JScrollBar
;
import
javax.swing.JScrollPane
;
import
javax.swing.JSeparator
;
import
javax.swing.JSlider
;
import
javax.swing.JSpinner
;
import
javax.swing.JSplitPane
;
import
javax.swing.JTabbedPane
;
import
javax.swing.JTable
;
import
javax.swing.JTextArea
;
import
javax.swing.JTextField
;
import
javax.swing.JTextPane
;
import
javax.swing.JToggleButton
;
import
javax.swing.JToolBar
;
import
javax.swing.JToolTip
;
import
javax.swing.JTree
;
import
javax.swing.JViewport
;
import
javax.swing.UIDefaults
;
import
javax.swing.plaf.basic.BasicLookAndFeel
;
import
javax.swing.plaf.metal.MetalLookAndFeel
;
import
static
javax
.
swing
.
plaf
.
synth
.
SynthConstants
.*;
import
javax.swing.table.JTableHeader
;
import
java.awt.Insets
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Models a Synth look and feel. Contains all of the colors, fonts, painters, states, etc that compose a synth look and
* feel.
* <p/>
* To model Synth properly, I need to both Model the way Synth works (with styles, and so forth) and the way a look and
* feel works (UIDefaults table, etc) since both of these are supported ways of doing things in Synth.
* <p/>
* One important (but non-visual) thing that needs to be configurable is the support for InputMaps per component. In
* Synth, an input map can be associated with the main Synth element, meaning it applies to everything. Or it can be
* associated with a single style. An Inputmap can have an id, and it can contain multiple key/action pairs (where
* actions are denoted by name).
* <p/>
* It looks like Regions can have InputMaps? Sounds fishy to me. I think only Components really have input maps.
* <p/>
* I would like some way of denoting special keys between mac and other platforms. For example, cut, copy, paste etc
* should be different. In general, the ctrl key and apple (meta) key are reversed from what is typically on windows.
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
SynthModel
extends
AbstractBean
implements
HasUIDefaults
,
HasUIStyle
,
HasResources
{
//I'm going to want:
//entries related to the Control color, and other colors of the Basic LAF
//entries related to fonts (standard fonts) used in the Basic LAF
//entries related to standard insets, borders, dimensions, icons
//entries related to component specific entries in the LAF
private
List
<
UIPaint
>
colors
;
private
List
<
UIFont
>
fonts
;
private
List
<
UIInsets
>
insets
;
private
List
<
UIBorder
>
borders
;
private
List
<
UIDimension
>
dimensions
;
private
List
<
UIIcon
>
icons
;
private
List
<
UIComponent
>
components
;
/**
* This is a local UIDefaults that contains all the UIDefaults in this synth model. It is kept uptodate by the
* indervidual UIDefaults nodes
*/
private
transient
UIDefaults
modelDefaults
=
new
UIDefaults
();
private
transient
UIStyle
globalStyle
=
new
UIStyle
();
private
transient
File
resourcesDir
;
private
transient
File
imagesDir
;
private
transient
File
templatesDir
;
/** Default constructor used by JIBX to create new empty SynthModel */
protected
SynthModel
()
{
this
(
false
);
}
public
SynthModel
(
boolean
populateWithDefaults
)
{
// create observable lists that fire changes on as property changes
colors
=
new
ArrayList
<
UIPaint
>();
fonts
=
new
ArrayList
<
UIFont
>();
insets
=
new
ArrayList
<
UIInsets
>();
borders
=
new
ArrayList
<
UIBorder
>();
dimensions
=
new
ArrayList
<
UIDimension
>();
icons
=
new
ArrayList
<
UIIcon
>();
components
=
new
ArrayList
<
UIComponent
>();
if
(
populateWithDefaults
)
{
//get the ui defaults from the SynthLookAndFeel. Using the UIDefaults table,
//pre initialize everything.
// SynthLookAndFeel synth = new SynthLookAndFeel();
BasicLookAndFeel
synth
=
new
MetalLookAndFeel
();
UIDefaults
defaults
=
synth
.
getDefaults
();
//pre-init the palettes
colors
.
add
(
new
UIColor
(
"desktop"
,
defaults
.
getColor
(
"desktop"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"activeCaption"
,
defaults
.
getColor
(
"activeCaption"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"activeCaptionText"
,
defaults
.
getColor
(
"activeCaptionText"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"activeCaptionBorder"
,
defaults
.
getColor
(
"activeCaptionBorder"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"inactiveCaption"
,
defaults
.
getColor
(
"inactiveCaption"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"inactiveCaptionText"
,
defaults
.
getColor
(
"inactiveCaptionText"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"inactiveCaptionBorder"
,
defaults
.
getColor
(
"inactiveCaptionBorder"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"window"
,
defaults
.
getColor
(
"window"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"windowBorder"
,
defaults
.
getColor
(
"windowBorder"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"windowText"
,
defaults
.
getColor
(
"windowText"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"menu"
,
defaults
.
getColor
(
"menu"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"menuText"
,
defaults
.
getColor
(
"menuText"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"text"
,
defaults
.
getColor
(
"text"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"textText"
,
defaults
.
getColor
(
"textText"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"textHighlight"
,
defaults
.
getColor
(
"textHighlight"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"textHighlightText"
,
defaults
.
getColor
(
"textHighlightText"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"textInactiveText"
,
defaults
.
getColor
(
"textInactiveText"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"control"
,
defaults
.
getColor
(
"control"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"controlText"
,
defaults
.
getColor
(
"controlText"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"controlHighlight"
,
defaults
.
getColor
(
"controlHighlight"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"controlLHighlight"
,
defaults
.
getColor
(
"controlLHighlight"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"controlShadow"
,
defaults
.
getColor
(
"controlShadow"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"controlDkShadow"
,
defaults
.
getColor
(
"controlDkShadow"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"scrollbar"
,
defaults
.
getColor
(
"scrollbar"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"info"
,
defaults
.
getColor
(
"info"
),
modelDefaults
));
colors
.
add
(
new
UIColor
(
"infoText"
,
defaults
.
getColor
(
"infoText"
),
modelDefaults
));
fonts
.
add
(
new
UIFont
(
"dialogPlain"
,
defaults
.
getFont
(
"Button.font"
),
modelDefaults
));
fonts
.
add
(
new
UIFont
(
"serifPlain"
,
defaults
.
getFont
(
"TextPane.font"
),
modelDefaults
));
fonts
.
add
(
new
UIFont
(
"sansSerifPlain"
,
defaults
.
getFont
(
"ToolTip.font"
),
modelDefaults
));
fonts
.
add
(
new
UIFont
(
"monospacedPlain"
,
defaults
.
getFont
(
"TextArea.font"
),
modelDefaults
));
fonts
.
add
(
new
UIFont
(
"dialogBold"
,
defaults
.
getFont
(
"InternalFrame.titleFont"
),
modelDefaults
));
insets
.
add
(
new
UIInsets
(
"zeroInsets"
,
new
Insets
(
0
,
0
,
0
,
0
)));
insets
.
add
(
new
UIInsets
(
"twoInsets"
,
new
Insets
(
2
,
2
,
2
,
2
)));
insets
.
add
(
new
UIInsets
(
"threeInsets"
,
new
Insets
(
3
,
3
,
3
,
3
)));
borders
.
add
(
new
UIBorder
(
"marginBorder"
,
defaults
.
getBorder
(
"MenuItem.border"
)));
borders
.
add
(
new
UIBorder
(
"etchedBorder"
,
defaults
.
getBorder
(
"TitledBorder.border"
)));
borders
.
add
(
new
UIBorder
(
"loweredBevelBorder"
,
defaults
.
getBorder
(
"Table.scrollPaneBorder"
)));
borders
.
add
(
new
UIBorder
(
"blackLineBorder"
,
defaults
.
getBorder
(
"ToolTip.border"
)));
//TODO have to deal with the special arrow button region
//pre-init the list of UI components
UIComponent
button
=
new
UIComponent
(
"Button"
,
JButton
.
class
.
getName
(),
"ButtonUI"
);
addStates
(
this
,
button
,
DEFAULT
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
button
);
UIComponent
toggleButton
=
new
UIComponent
(
"ToggleButton"
,
JToggleButton
.
class
.
getName
(),
"ToggleButtonUI"
);
addStates
(
this
,
toggleButton
,
DEFAULT
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
,
SELECTED
,
SELECTED
|
PRESSED
,
SELECTED
|
MOUSE_OVER
,
DISABLED
|
SELECTED
);
components
.
add
(
toggleButton
);
UIComponent
radioButton
=
new
UIComponent
(
"RadioButton"
,
JRadioButton
.
class
.
getName
(),
"RadioButtonUI"
);
addStates
(
this
,
radioButton
,
DEFAULT
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
,
SELECTED
,
SELECTED
|
PRESSED
,
SELECTED
|
MOUSE_OVER
,
DISABLED
|
SELECTED
);
components
.
add
(
radioButton
);
UIComponent
checkBox
=
new
UIComponent
(
"CheckBox"
,
JCheckBox
.
class
.
getName
(),
"CheckBoxUI"
);
addStates
(
this
,
checkBox
,
DEFAULT
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
,
SELECTED
,
SELECTED
|
PRESSED
,
SELECTED
|
MOUSE_OVER
,
DISABLED
|
SELECTED
);
components
.
add
(
checkBox
);
UIComponent
colorChooser
=
new
UIComponent
(
"ColorChooser"
,
JColorChooser
.
class
.
getName
(),
"ColorChooserUI"
);
addStates
(
this
,
colorChooser
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
colorChooser
);
UIComponent
comboBox
=
new
UIComponent
(
"ComboBox"
,
JComboBox
.
class
.
getName
(),
"ComboBoxUI"
);
addStates
(
this
,
comboBox
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
comboBox
);
UIComponent
fileChooser
=
new
UIComponent
(
"FileChooser"
,
JFileChooser
.
class
.
getName
(),
"FileChooserUI"
);
addStates
(
this
,
fileChooser
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
fileChooser
);
//not represented in Synth
// UIComponent fileView = new UIComponent ("FileView",
// list(DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
UIComponent
internalFrame
=
new
UIComponent
(
"InternalFrame"
,
JInternalFrame
.
class
.
getName
(),
"InternalFrameUI"
);
addStates
(
this
,
internalFrame
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
//has an internal frame title pane region
components
.
add
(
internalFrame
);
//TODO DesktopIcon ???
UIComponent
desktop
=
new
UIComponent
(
"Desktop"
,
JDesktopPane
.
class
.
getName
(),
"DesktopPaneUI"
);
addStates
(
this
,
desktop
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
desktop
);
UIComponent
label
=
new
UIComponent
(
"Label"
,
JLabel
.
class
.
getName
(),
"LabelUI"
);
addStates
(
this
,
label
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
label
);
UIComponent
list
=
new
UIComponent
(
"List"
,
JList
.
class
.
getName
(),
"ListUI"
);
addStates
(
this
,
list
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
list
);
UIComponent
menuBar
=
new
UIComponent
(
"MenuBar"
,
JMenuBar
.
class
.
getName
(),
"MenuBarUI"
);
addStates
(
this
,
menuBar
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
menuBar
);
UIComponent
menuItem
=
new
UIComponent
(
"MenuItem"
,
JMenuItem
.
class
.
getName
(),
"MenuItemUI"
);
addStates
(
this
,
menuItem
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
//has a menuItemAccelerator region
components
.
add
(
menuItem
);
UIComponent
radioButtonMenuItem
=
new
UIComponent
(
"RadioButtonMenuItem"
,
JRadioButtonMenuItem
.
class
.
getName
(),
"RadioButtonMenuItemUI"
);
addStates
(
this
,
radioButtonMenuItem
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
radioButtonMenuItem
);
UIComponent
checkBoxMenuItem
=
new
UIComponent
(
"CheckBoxMenuItem"
,
JCheckBoxMenuItem
.
class
.
getName
(),
"CheckBoxMenuItemUI"
);
addStates
(
this
,
checkBoxMenuItem
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
checkBoxMenuItem
);
UIComponent
menu
=
new
UIComponent
(
"Menu"
,
JMenu
.
class
.
getName
(),
"MenuUI"
);
addStates
(
this
,
menu
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
menu
);
UIComponent
popupMenu
=
new
UIComponent
(
"PopupMenu"
,
JPopupMenu
.
class
.
getName
(),
"PopupMenuUI"
);
addStates
(
this
,
popupMenu
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
//has a popupMenuSeparator region
components
.
add
(
popupMenu
);
UIComponent
optionPane
=
new
UIComponent
(
"OptionPane"
,
JOptionPane
.
class
.
getName
(),
"OptionPaneUI"
);
addStates
(
this
,
optionPane
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
optionPane
);
UIComponent
panel
=
new
UIComponent
(
"Panel"
,
JPanel
.
class
.
getName
(),
"PanelUI"
);
addStates
(
this
,
panel
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
panel
);
UIComponent
progressBar
=
new
UIComponent
(
"ProgressBar"
,
JProgressBar
.
class
.
getName
(),
"ProgressBarUI"
);
addStates
(
this
,
progressBar
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
progressBar
);
UIComponent
separator
=
new
UIComponent
(
"Separator"
,
JSeparator
.
class
.
getName
(),
"SeparatorUI"
);
addStates
(
this
,
separator
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
separator
);
UIRegion
scrollBarThumb
=
new
UIRegion
(
"ScrollBar.Thumb"
);
addStates
(
this
,
scrollBarThumb
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
UIRegion
scrollBarTrack
=
new
UIRegion
(
"ScrollBar.Track"
);
addStates
(
this
,
scrollBarTrack
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
UIComponent
scrollBar
=
new
UIComponent
(
"ScrollBar"
,
JScrollBar
.
class
.
getName
(),
"ScrollBarUI"
,
scrollBarThumb
,
scrollBarTrack
);
addStates
(
this
,
scrollBar
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
scrollBar
);
UIComponent
scrollPane
=
new
UIComponent
(
"ScrollPane"
,
JScrollPane
.
class
.
getName
(),
"ScrollPaneUI"
);
addStates
(
this
,
scrollPane
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
scrollPane
);
UIComponent
viewport
=
new
UIComponent
(
"Viewport"
,
JViewport
.
class
.
getName
(),
"ViewportUI"
);
addStates
(
this
,
viewport
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
viewport
);
UIComponent
slider
=
new
UIComponent
(
"Slider"
,
JSlider
.
class
.
getName
(),
"SliderUI"
);
addStates
(
this
,
slider
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
//has sliderThumb and sliderTrack sub regions
components
.
add
(
slider
);
UIComponent
spinner
=
new
UIComponent
(
"Spinner"
,
JSpinner
.
class
.
getName
(),
"SpinnerUI"
);
addStates
(
this
,
spinner
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
spinner
);
UIComponent
splitPane
=
new
UIComponent
(
"SplitPane"
,
JSplitPane
.
class
.
getName
(),
"SplitPaneUI"
);
addStates
(
this
,
splitPane
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
//has splitPaneDivider sub region
components
.
add
(
splitPane
);
UIComponent
tabbedPane
=
new
UIComponent
(
"TabbedPane"
,
JTabbedPane
.
class
.
getName
(),
"TabbedPaneUI"
);
addStates
(
this
,
tabbedPane
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
//has tabbedPaneContent and tabbedPaneTab and TabbedPaneTabArea sub regions
components
.
add
(
tabbedPane
);
UIComponent
table
=
new
UIComponent
(
"Table"
,
JTable
.
class
.
getName
(),
"TableUI"
);
addStates
(
this
,
table
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
table
);
UIComponent
tableHeader
=
new
UIComponent
(
"TableHeader"
,
JTableHeader
.
class
.
getName
(),
"TableHeaderUI"
);
addStates
(
this
,
tableHeader
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
tableHeader
);
UIComponent
textField
=
new
UIComponent
(
"TextField"
,
JTextField
.
class
.
getName
(),
"TextFieldUI"
);
addStates
(
this
,
textField
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
textField
);
UIComponent
formattedTextField
=
new
UIComponent
(
"FormattedTextField"
,
JFormattedTextField
.
class
.
getName
(),
"FormattedTextFieldUI"
);
addStates
(
this
,
formattedTextField
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
formattedTextField
);
UIComponent
passwordField
=
new
UIComponent
(
"PasswordField"
,
JPasswordField
.
class
.
getName
(),
"PasswordFieldUI"
);
addStates
(
this
,
passwordField
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
passwordField
);
UIComponent
textArea
=
new
UIComponent
(
"TextArea"
,
JTextArea
.
class
.
getName
(),
"TextAreaUI"
);
addStates
(
this
,
textArea
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
textArea
);
UIComponent
textPane
=
new
UIComponent
(
"TextPane"
,
JTextPane
.
class
.
getName
(),
"TextPaneUI"
);
addStates
(
this
,
textPane
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
textPane
);
UIComponent
editorPane
=
new
UIComponent
(
"EditorPane"
,
JEditorPane
.
class
.
getName
(),
"EditorPaneUI"
);
addStates
(
this
,
editorPane
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
editorPane
);
/*
* The only thing not represented in Synth as a region. I suppose we'll have
* to make it a CustomUIComponent
*/
// UIComponent titledBorder = new UIComponent ("TitledBorder",
// list(DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED);
UIComponent
toolBar
=
new
UIComponent
(
"ToolBar"
,
JToolBar
.
class
.
getName
(),
"ToolBarUI"
);
addStates
(
this
,
toolBar
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
//toolBarContent, toolBarDragWindow, toolBarSeparator sub regions
components
.
add
(
toolBar
);
UIComponent
toolTip
=
new
UIComponent
(
"ToolTip"
,
JToolTip
.
class
.
getName
(),
"ToolTipUI"
);
addStates
(
this
,
toolTip
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
toolTip
);
//tooltip manager
UIComponent
tree
=
new
UIComponent
(
"Tree"
,
JTree
.
class
.
getName
(),
"TreeUI"
);
addStates
(
this
,
tree
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
//treeCell sub region
components
.
add
(
tree
);
UIComponent
rootPane
=
new
UIComponent
(
"RootPane"
,
JRootPane
.
class
.
getName
(),
"RootPaneUI"
);
addStates
(
this
,
rootPane
,
DISABLED
,
ENABLED
,
FOCUSED
,
MOUSE_OVER
,
PRESSED
);
components
.
add
(
rootPane
);
}
}
public
List
<
UIPaint
>
getColorPalette
()
{
return
colors
;
}
public
List
<
UIFont
>
getFontPalette
()
{
return
fonts
;
}
public
List
<
UIInsets
>
getInsetPalette
()
{
return
insets
;
}
public
List
<
UIBorder
>
getBorderPalette
()
{
return
borders
;
}
public
List
<
UIDimension
>
getDimensionPalette
()
{
return
dimensions
;
}
public
List
<
UIIcon
>
getIconPalette
()
{
return
icons
;
}
public
List
<
UIComponent
>
getComponents
()
{
return
components
;
}
/**
* Get the local UIDefaults that contains all the UIDefaults in this synth model. It is kept uptodate by the
* indervidual UIDefaults nodes
*
* @return The UIDefaults for the synth model
*/
public
UIDefaults
getUiDefaults
()
{
return
modelDefaults
;
}
public
UIStyle
getStyle
()
{
return
globalStyle
;
}
// by default there are no painters assigned to the various states
private
static
void
addStates
(
SynthModel
model
,
UIRegion
parentRegion
,
int
...
states
)
{
for
(
int
state
:
states
)
{
List
<
String
>
stateList
=
new
ArrayList
<
String
>();
if
((
state
&
ENABLED
)
!=
0
)
{
stateList
.
add
(
UIStateType
.
ENABLED_KEY
);
}
if
((
state
&
MOUSE_OVER
)
!=
0
)
{
stateList
.
add
(
UIStateType
.
MOUSE_OVER_KEY
);
}
if
((
state
&
PRESSED
)
!=
0
)
{
stateList
.
add
(
UIStateType
.
PRESSED_KEY
);
}
if
((
state
&
DISABLED
)
!=
0
)
{
stateList
.
add
(
UIStateType
.
DISABLED_KEY
);
}
if
((
state
&
FOCUSED
)
!=
0
)
{
stateList
.
add
(
UIStateType
.
FOCUSED_KEY
);
}
if
((
state
&
SELECTED
)
!=
0
)
{
stateList
.
add
(
UIStateType
.
SELECTED_KEY
);
}
if
((
state
&
DEFAULT
)
!=
0
)
{
stateList
.
add
(
UIStateType
.
DEFAULT_KEY
);
}
parentRegion
.
addBackgroundState
(
new
UIState
(
model
,
parentRegion
,
stateList
.
toArray
(
new
String
[
stateList
.
size
()])));
}
}
public
File
getResourcesDir
()
{
return
resourcesDir
;
}
public
void
setResourcesDir
(
File
resourcesDir
)
{
System
.
out
.
println
(
"SynthModel.setResourcesDir("
+
resourcesDir
+
")"
);
File
old
=
getResourcesDir
();
this
.
resourcesDir
=
resourcesDir
;
firePropertyChange
(
"resourcesDir"
,
old
,
getResourcesDir
());
}
public
File
getImagesDir
()
{
return
imagesDir
;
}
public
void
setImagesDir
(
File
imagesDir
)
{
System
.
out
.
println
(
"SynthModel.setImagesDir("
+
imagesDir
+
")"
);
File
old
=
getImagesDir
();
this
.
imagesDir
=
imagesDir
;
firePropertyChange
(
"imagesDir"
,
old
,
getImagesDir
());
}
public
File
getTemplatesDir
()
{
return
templatesDir
;
}
public
void
setTemplatesDir
(
File
templatesDir
)
{
System
.
out
.
println
(
"SynthModel.setTemplatesDir("
+
templatesDir
+
")"
);
File
old
=
getTemplatesDir
();
this
.
templatesDir
=
templatesDir
;
firePropertyChange
(
"templatesDir"
,
old
,
getTemplatesDir
());
}
// =================================================================================================================
// JIBX Methods
public
void
preSet
(
IUnmarshallingContext
context
)
{
File
resourcesDir
=
(
File
)
context
.
getUserContext
();
this
.
resourcesDir
=
resourcesDir
;
this
.
imagesDir
=
new
File
(
resourcesDir
,
"images"
);
this
.
templatesDir
=
new
File
(
resourcesDir
,
"templates"
);
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/SynthModel.jibx.xml
已删除
100644 → 0
浏览文件 @
feb1bd83
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 1998-2004 Sun Microsystems, Inc. All Rights Reserved.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
This code is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 only, as
published by the Free Software Foundation. Sun designates this
particular file as subject to the "Classpath" exception as provided
by Sun in the LICENSE file that accompanied this code.
This code is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
version 2 for more details (a copy is included in the LICENSE file that
accompanied this code).
You should have received a copy of the GNU General Public License version
2 along with this work; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
CA 95054 USA or visit www.sun.com if you need additional information or
have any questions.
-->
<!DOCTYPE binding SYSTEM "http://jibx.sourceforge.net">
<binding>
<mapping
class=
"org.jdesktop.synthdesigner.synthmodel.UIDefault"
abstract=
"true"
post-set=
"postSet"
>
<value
name=
"name"
field=
"name"
style=
"attribute"
/>
</mapping>
<!-- == AWT TYPES =========================================================================================== -->
<mapping
class=
"java.awt.Color"
marshaller=
"org.jdesktop.swingx.designer.jibxhelpers.ColorMapper"
unmarshaller=
"org.jdesktop.swingx.designer.jibxhelpers.ColorMapper"
/>
<mapping
class=
"java.lang.Class"
marshaller=
"org.jdesktop.synthdesigner.synthmodel.jibxhelpers.ClassMapper"
unmarshaller=
"org.jdesktop.synthdesigner.synthmodel.jibxhelpers.ClassMapper"
/>
<!-- == UI FONT =========================================================================================== -->
<mapping
name=
"typeface"
class=
"org.jdesktop.swingx.designer.font.Typeface"
post-set=
"postSet"
>
<value
name=
"family"
field=
"name"
style=
"attribute"
usage=
"optional"
/>
<value
name=
"bold"
field=
"bold"
style=
"attribute"
usage=
"optional"
default=
"Default"
/>
<value
name=
"italic"
field=
"italic"
style=
"attribute"
usage=
"optional"
default=
"Default"
/>
<value
name=
"size"
field=
"size"
style=
"attribute"
usage=
"optional"
/>
<value
name=
"sizeOffset"
field=
"sizeOffset"
style=
"attribute"
usage=
"optional"
default=
"1"
/>
<value
name=
"uiDefaultParentName"
field=
"uiDefaultParentName"
style=
"attribute"
usage=
"optional"
/>
</mapping>
<mapping
name=
"uiFont"
class=
"org.jdesktop.synthdesigner.synthmodel.UIFont"
extends=
"org.jdesktop.synthdesigner.synthmodel.UIDefault"
>
<structure
map-as=
"org.jdesktop.synthdesigner.synthmodel.UIDefault"
/>
<collection
get-method=
"getFonts"
set-method=
"setFonts"
create-type=
"java.util.ArrayList"
/>
</mapping>
<!-- == UI INSETS =========================================================================================== -->
<mapping
name=
"uiInsets"
class=
"org.jdesktop.synthdesigner.synthmodel.UIInsets"
extends=
"org.jdesktop.synthdesigner.synthmodel.UIDefault"
>
<structure
map-as=
"org.jdesktop.synthdesigner.synthmodel.UIDefault"
/>
<structure
name=
"insets"
get-method=
"getInsets"
set-method=
"setInsets"
marshaller=
"org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"
unmarshaller=
"org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"
/>
</mapping>
<!-- == UI PAINT =========================================================================================== -->
<mapping
name=
"matte"
class=
"org.jdesktop.swingx.designer.paint.Matte"
post-set=
"postSet"
>
<value
name=
"red"
field=
"red"
style=
"attribute"
/>
<value
name=
"green"
field=
"green"
style=
"attribute"
/>
<value
name=
"blue"
field=
"blue"
style=
"attribute"
/>
<value
name=
"alpha"
field=
"alpha"
style=
"attribute"
/>
<value
name=
"uiDefaultParentName"
field=
"uiDefaultParentName"
style=
"attribute"
usage=
"optional"
/>
<value
name=
"componentPropertyName"
field=
"componentPropertyName"
style=
"attribute"
usage=
"optional"
/>
<value
name=
"hueOffset"
field=
"hueOffset"
style=
"attribute"
/>
<value
name=
"saturationOffset"
field=
"saturationOffset"
style=
"attribute"
/>
<value
name=
"brightnessOffset"
field=
"brightnessOffset"
style=
"attribute"
/>
<value
name=
"alphaOffset"
field=
"alphaOffset"
style=
"attribute"
/>
<value
name=
"uiResource"
field=
"uiResource"
style=
"attribute"
usage=
"optional"
default=
"true"
/>
</mapping>
<mapping
class=
"org.jdesktop.synthdesigner.synthmodel.UIPaint"
abstract=
"true"
type-name=
"uipaint"
extends=
"org.jdesktop.synthdesigner.synthmodel.UIDefault"
>
<structure
map-as=
"org.jdesktop.synthdesigner.synthmodel.UIDefault"
/>
<structure
get-method=
"getPaint"
set-method=
"setPaint"
/>
</mapping>
<mapping
name=
"uiPaint"
class=
"org.jdesktop.synthdesigner.synthmodel.UIPaint"
extends=
"org.jdesktop.synthdesigner.synthmodel.UIDefault"
>
<structure
map-as=
"uipaint"
/>
</mapping>
<mapping
name=
"uiColor"
class=
"org.jdesktop.synthdesigner.synthmodel.UIColor"
extends=
"org.jdesktop.synthdesigner.synthmodel.UIPaint"
>
<structure
map-as=
"uipaint"
/>
</mapping>
<!-- == UI STYLE =========================================================================================== -->
<mapping
class=
"org.jdesktop.synthdesigner.synthmodel.UIStyle"
abstract=
"true"
post-set=
"postSet"
>
<structure
field=
"font"
usage=
"optional"
/>
<structure
name=
"textForeground"
usage=
"optional"
>
<structure
field=
"textForeground"
usage=
"optional"
/>
</structure>
<structure
name=
"textBackground"
usage=
"optional"
>
<structure
field=
"textBackground"
usage=
"optional"
/>
</structure>
<structure
name=
"background"
usage=
"optional"
>
<structure
field=
"background"
usage=
"optional"
/>
</structure>
<value
name=
"inherit-font"
field=
"fontInherited"
usage=
"optional"
default=
"true"
/>
<value
name=
"inherit-textForeground"
field=
"textForegroundInherited"
usage=
"optional"
default=
"true"
/>
<value
name=
"inherit-textBackground"
field=
"textBackgroundInherited"
usage=
"optional"
default=
"true"
/>
<value
name=
"inherit-background"
field=
"backgroundInherited"
usage=
"optional"
default=
"true"
/>
<value
name=
"hintAlphaInterpolation"
field=
"hintAlphaInterpolation"
usage=
"optional"
/>
<value
name=
"hintAntialiasing"
field=
"hintAntialiasing"
usage=
"optional"
/>
<value
name=
"hintColorRendering"
field=
"hintColorRendering"
usage=
"optional"
/>
<value
name=
"hintDithering"
field=
"hintDithering"
usage=
"optional"
/>
<value
name=
"hintFractionalMetrics"
field=
"hintFractionalMetrics"
usage=
"optional"
/>
<value
name=
"hintInterpolation"
field=
"hintInterpolation"
usage=
"optional"
/>
<value
name=
"hintRendering"
field=
"hintRendering"
usage=
"optional"
/>
<value
name=
"hintStrokeControl"
field=
"hintStrokeControl"
usage=
"optional"
/>
<value
name=
"hintTextAntialiasing"
field=
"hintTextAntialiasing"
usage=
"optional"
/>
<value
name=
"cacheSettingsInherited"
field=
"cacheSettingsInherited"
usage=
"optional"
default=
"true"
/>
<value
name=
"cacheMode"
field=
"cacheMode"
usage=
"optional"
default=
"FIXED_SIZES"
/>
<value
name=
"maxHozCachedImgScaling"
field=
"maxHozCachedImgScaling"
usage=
"optional"
default=
"1"
/>
<value
name=
"maxVertCachedImgScaling"
field=
"maxVertCachedImgScaling"
usage=
"optional"
default=
"1"
/>
<collection
name=
"uiproperties"
field=
"uiProperties"
create-type=
"java.util.ArrayList"
>
<structure
marshaller=
"org.jdesktop.synthdesigner.synthmodel.jibxhelpers.UIPropertyMapper"
unmarshaller=
"org.jdesktop.synthdesigner.synthmodel.jibxhelpers.UIPropertyMapper"
/>
</collection>
</mapping>
<!-- == UI STATE =========================================================================================== -->
<mapping
name=
"stateType"
class=
"org.jdesktop.synthdesigner.synthmodel.UIStateType"
>
<value
name=
"key"
field=
"key"
style=
"attribute"
/>
<structure
name=
"codeSnippet"
usage=
"optional"
test-method=
"hasCodeSnippet"
>
<value
field=
"codeSnippet"
style=
"cdata"
usage=
"optional"
/>
</structure>
</mapping>
<mapping
name=
"state"
class=
"org.jdesktop.synthdesigner.synthmodel.UIState"
post-set=
"postSet"
pre-set=
"preSet"
>
<value
name=
"stateKeys"
field=
"stateKeys"
style=
"attribute"
get-method=
"getStateKeys"
set-method=
"setStateKeys"
serializer=
"org.jdesktop.synthdesigner.synthmodel.UIState.keysToString"
deserializer=
"org.jdesktop.synthdesigner.synthmodel.UIState.stringToKeys"
/>
<value
name=
"inverted"
field=
"inverted"
style=
"attribute"
usage=
"optional"
/>
<structure
name=
"style"
field=
"style"
/>
<structure
field=
"canvas"
marshaller=
"org.jdesktop.swingx.designer.jibxhelpers.CanvasMapper"
unmarshaller=
"org.jdesktop.swingx.designer.jibxhelpers.CanvasMapper"
/>
</mapping>
<!-- == REGIONS =========================================================================================== -->
<mapping
class=
"org.jdesktop.synthdesigner.synthmodel.UIRegion"
abstract=
"true"
type-name=
"region"
pre-set=
"preSet"
>
<value
name=
"name"
field=
"name"
style=
"attribute"
/>
<value
name=
"ui"
field=
"ui"
style=
"attribute"
usage=
"optional"
/>
<value
name=
"subregion"
field=
"subregion"
style=
"attribute"
/>
<value
name=
"key"
field=
"key"
style=
"attribute"
usage=
"optional"
/>
<value
name=
"title"
field=
"title"
style=
"attribute"
usage=
"optional"
/>
<structure
name=
"contentMargins"
field=
"contentMargins"
marshaller=
"org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"
unmarshaller=
"org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper"
/>
<structure
name=
"style"
field=
"style"
/>
<collection
name=
"backgroundStates"
field=
"backgroundStates"
create-type=
"java.util.ArrayList"
/>
<collection
name=
"foregroundStates"
field=
"foregroundStates"
create-type=
"java.util.ArrayList"
/>
<collection
name=
"borderStates"
field=
"borderStates"
create-type=
"java.util.ArrayList"
/>
<collection
name=
"regions"
field=
"subRegions"
create-type=
"java.util.ArrayList"
/>
</mapping>
<mapping
name=
"region"
class=
"org.jdesktop.synthdesigner.synthmodel.UIRegion"
>
<structure
map-as=
"region"
/>
</mapping>
<mapping
name=
"uiIconRegion"
class=
"org.jdesktop.synthdesigner.synthmodel.UIIconRegion"
extends=
"org.jdesktop.synthdesigner.synthmodel.UIRegion"
>
<structure
map-as=
"region"
/>
<value
name=
"basicKey"
field=
"basicKey"
style=
"attribute"
usage=
"optional"
/>
</mapping>
<mapping
name=
"uiComponent"
class=
"org.jdesktop.synthdesigner.synthmodel.UIComponent"
extends=
"org.jdesktop.synthdesigner.synthmodel.UIRegion"
>
<value
name=
"opaque"
field=
"opaque"
style=
"attribute"
/>
<value
name=
"componentName"
field=
"componentName"
style=
"attribute"
usage=
"optional"
/>
<value
name=
"type"
field=
"type"
style=
"attribute"
/>
<collection
name=
"stateTypes"
field=
"stateTypes"
create-type=
"java.util.ArrayList"
/>
<structure
map-as=
"region"
/>
</mapping>
<!-- == BASE MODEL =========================================================================================== -->
<mapping
name=
"synthModel"
class=
"org.jdesktop.synthdesigner.synthmodel.SynthModel"
pre-set=
"preSet"
>
<collection
name=
"insets"
field=
"insets"
create-type=
"java.util.ArrayList"
/>
<collection
name=
"colors"
field=
"colors"
create-type=
"java.util.ArrayList"
/>
<collection
name=
"fonts"
field=
"fonts"
create-type=
"java.util.ArrayList"
/>
<structure
name=
"style"
field=
"globalStyle"
/>
<collection
name=
"components"
field=
"components"
create-type=
"java.util.ArrayList"
/>
</mapping>
</binding>
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIBorder.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
import
javax.swing.border.Border
;
/**
* UIBorder
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIBorder
extends
UIDefault
<
Border
>
{
public
UIBorder
()
{
}
public
UIBorder
(
String
id
,
Border
b
)
{
super
(
id
,
b
);
}
public
Border
getBorder
()
{
return
super
.
getValue
();
}
public
void
setBorder
(
Border
b
)
{
Border
old
=
getBorder
();
super
.
setValue
(
b
);
firePropertyChange
(
"border"
,
old
,
b
);
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIColor.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
import
org.jdesktop.swingx.designer.paint.Matte
;
import
javax.swing.UIDefaults
;
import
java.awt.Color
;
/**
* UIColor
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIColor
extends
UIPaint
{
public
UIColor
()
{
}
public
UIColor
(
String
id
,
Matte
value
)
{
super
(
id
,
value
);
}
public
UIColor
(
String
id
,
Color
color
,
UIDefaults
modelDefaults
)
{
this
(
id
,
new
Matte
(
color
,
modelDefaults
));
}
public
Matte
getPaint
()
{
return
(
Matte
)
super
.
getPaint
();
}
public
void
setPaint
(
Matte
c
)
{
super
.
setPaint
(
c
);
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIComponent.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
import
org.jdesktop.swingx.designer.utils.HasUIDefaults
;
import
java.util.List
;
import
java.util.ArrayList
;
/**
* UIComponent - model node that represents the designs for a single swing component
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIComponent
extends
UIRegion
implements
HasUIDefaults
{
/** The classname of the swing component that this UIComponent represents */
private
String
type
;
/** The name of the component if its a named component or null if its a generic component */
private
String
componentName
=
null
;
/** If this components is opaque which means that when it is painted all of its bounds are filled */
private
boolean
opaque
=
false
;
/**
* A list of state types that are available to this region and sub regions of this component but not subcomponents
* of this component. If this list is empty then the standard synth set of state types are assumed.
*/
private
List
<
UIStateType
>
stateTypes
;
// =================================================================================================================
// Contructors
/** no-args contructor for JIBX */
protected
UIComponent
()
{
super
();
// create new observable list for state types so we get events for when the model changes
stateTypes
=
new
ArrayList
<
UIStateType
>();
}
public
UIComponent
(
String
name
,
String
type
,
String
ui
,
UIRegion
...
subRegions
)
{
super
(
name
,
ui
,
subRegions
);
this
.
type
=
type
;
for
(
UIRegion
r
:
subRegions
)
{
r
.
setRegion
(
this
);
}
// create new observable list for state types so we get events for when the model changes
stateTypes
=
new
ArrayList
<
UIStateType
>();
}
// =================================================================================================================
// Bean Methods
public
String
getComponentName
()
{
return
componentName
;
}
public
void
setComponentName
(
String
componentName
)
{
String
old
=
getComponentName
();
this
.
componentName
=
componentName
;
firePropertyChange
(
"componentName"
,
old
,
getComponentName
());
}
public
boolean
isOpaque
()
{
return
opaque
;
}
public
void
setOpaque
(
boolean
opaque
)
{
boolean
old
=
isOpaque
();
this
.
opaque
=
opaque
;
firePropertyChange
(
"opaque"
,
old
,
isOpaque
());
}
public
String
getType
()
{
return
type
;
}
public
void
setType
(
String
type
)
{
String
old
=
getType
();
this
.
type
=
type
;
firePropertyChange
(
"type"
,
old
,
getType
());
}
/**
* Get the list of state types that are available to this region and sub regions of this component but not
* subcomponents of this component. If this list is empty then the standard synth set of state types are assumed.
*
* @return List of available state types
*/
public
List
<
UIStateType
>
getStateTypes
()
{
return
stateTypes
;
}
@Override
public
String
getKey
()
{
if
(
key
==
null
||
""
.
equals
(
key
))
{
if
(
componentName
==
null
||
""
.
equals
(
componentName
))
{
return
getName
();
}
else
{
return
"\""
+
componentName
+
"\""
;
}
}
else
{
return
key
;
}
}
@Override
public
String
getTitle
()
{
if
(
title
==
null
||
""
.
equals
(
title
))
{
if
(
componentName
==
null
||
""
.
equals
(
componentName
))
{
return
getName
();
}
else
{
return
componentName
;
}
}
else
{
return
title
;
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIDefault.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
import
org.jdesktop.beans.AbstractBean
;
import
org.jdesktop.swingx.designer.utils.HasUIDefaults
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
javax.swing.UIDefaults
;
/**
* Represents an entry in the UI defaults table.
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIDefault
<
T
>
extends
AbstractBean
implements
HasUIDefaults
{
private
String
name
;
private
T
value
;
/**
* This is a local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
* indervidual UIDefaults nodes
*/
private
transient
UIDefaults
modelDefaults
=
null
;
public
UIDefault
()
{
}
public
UIDefault
(
String
name
,
T
value
)
{
this
.
name
=
name
;
this
.
value
=
value
;
}
public
UIDefault
(
String
name
,
T
value
,
UIDefaults
modelDefaults
)
{
this
.
name
=
name
;
this
.
value
=
value
;
this
.
modelDefaults
=
modelDefaults
;
}
// =================================================================================================================
// JIBX Methods
/**
* Called by JIBX after all fields have been set
*
* @param context The JIBX Unmarshalling Context
*/
private
void
postSet
(
IUnmarshallingContext
context
)
{
// walk up till we get synth model
for
(
int
i
=
0
;
i
<
context
.
getStackDepth
();
i
++)
{
if
(
context
.
getStackObject
(
i
)
instanceof
HasUIDefaults
)
{
modelDefaults
=
((
HasUIDefaults
)
context
.
getStackObject
(
i
)).
getUiDefaults
();
if
(
modelDefaults
!=
null
)
break
;
}
}
}
// =================================================================================================================
// Bean Methods
/**
* Get the local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
* indervidual UIDefaults nodes
*
* @return The UIDefaults for the synth model
*/
public
UIDefaults
getUiDefaults
()
{
return
modelDefaults
;
}
public
void
setValue
(
T
t
)
{
T
old
=
this
.
value
;
this
.
value
=
t
;
firePropertyChange
(
"value"
,
old
,
getValue
());
}
public
T
getValue
()
{
return
value
;
}
public
final
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
String
old
=
this
.
name
;
firePropertyChange
(
"name"
,
old
,
name
);
this
.
name
=
name
;
// update model defaults
if
(
old
!=
null
)
modelDefaults
.
remove
(
old
);
modelDefaults
.
put
(
getName
(),
getValue
());
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIDimension.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
import
java.awt.Dimension
;
/**
* UIDimension
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIDimension
extends
UIDefault
<
Dimension
>
{
public
UIDimension
()
{
}
public
Dimension
getDimension
()
{
return
super
.
getValue
();
}
public
void
setDimension
(
Dimension
d
)
{
Dimension
old
=
getDimension
();
super
.
setValue
(
d
);
firePropertyChange
(
"dimension"
,
old
,
d
);
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIIconRegion.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
/**
* A UIRegion subclass which is used for generating icons. For example, JRadioButton and JCheckBox represent themselves
* mainly via their icons. However, from the designers perspective, the main design isn't an "icon", but just a region
* on the button.
* <p/>
* That type of region is represented by a UIIconRegion. UIIconRegion contains a string which references the UIDefault
* value associated with this icon. For example, RadioButton.icon.
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIIconRegion
extends
UIRegion
{
/** The UiDefaults key which this icon should be stored for basic LaF to find it. This is absolute */
private
String
basicKey
=
null
;
public
UIIconRegion
()
{
super
();
}
public
String
getBasicKey
()
{
return
basicKey
;
}
public
void
setBasicKey
(
String
basicKey
)
{
String
old
=
getBasicKey
();
this
.
basicKey
=
basicKey
;
firePropertyChange
(
"basicKey"
,
old
,
getBasicKey
());
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIInsets.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
import
java.awt.Insets
;
/**
* UIInsets
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIInsets
extends
UIDefault
<
Insets
>
{
public
UIInsets
()
{
}
public
UIInsets
(
String
id
,
Insets
value
)
{
super
(
id
,
value
);
}
public
Insets
getInsets
()
{
return
super
.
getValue
();
}
public
void
setInsets
(
Insets
i
)
{
Insets
old
=
getInsets
();
super
.
setValue
(
i
);
firePropertyChange
(
"insets"
,
old
,
i
);
// update model defaults
getUiDefaults
().
put
(
getName
(),
i
);
}
public
String
toString
()
{
return
"UiInset("
+
getName
()
+
")"
+
((
getInsets
()
==
null
)
?
" NONE"
:
"("
+
getInsets
().
top
+
","
+
getInsets
().
left
+
","
+
getInsets
().
bottom
+
","
+
getInsets
().
right
+
")"
);
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIPaint.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
import
org.jdesktop.swingx.designer.paint.Matte
;
import
org.jdesktop.swingx.designer.paint.PaintModel
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
/**
* UIPaint
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIPaint
extends
UIDefault
<
PaintModel
>
{
/** Listener to keep model UiDefaults up to date for this UiPaint */
private
PropertyChangeListener
matteListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
PaintModel
paintModel
=
getValue
();
if
(
paintModel
instanceof
Matte
)
{
getUiDefaults
().
put
(
getName
(),
((
Matte
)
paintModel
).
getColor
());
}
// propogate the paint change up as PaintModel is a mutable object
if
(
evt
.
getPropertyName
().
equals
(
"paint"
))
{
firePropertyChange
(
"paint"
,
null
,
getPaint
());
firePropertyChange
(
"value"
,
null
,
getPaint
());
}
}
};
public
UIPaint
()
{}
public
UIPaint
(
String
id
,
PaintModel
value
)
{
super
(
id
,
value
,
(
value
instanceof
Matte
)
?
((
Matte
)
value
).
getUiDefaults
()
:
null
);
// update model defaults
if
(
value
instanceof
Matte
)
{
Matte
matte
=
(
Matte
)
value
;
if
(
getUiDefaults
()
!=
null
)
getUiDefaults
().
put
(
getName
(),
matte
.
getColor
());
matte
.
addPropertyChangeListener
(
matteListener
);
}
}
public
PaintModel
getPaint
()
{
return
super
.
getValue
();
}
public
void
setPaint
(
PaintModel
c
)
{
PaintModel
old
=
getPaint
();
if
(
old
instanceof
Matte
)
old
.
removePropertyChangeListener
(
matteListener
);
super
.
setValue
(
c
);
firePropertyChange
(
"paint"
,
old
,
c
);
// update model defaults
if
(
c
instanceof
Matte
)
{
Matte
matte
=
(
Matte
)
c
;
getUiDefaults
().
put
(
getName
(),
matte
.
getColor
());
matte
.
addPropertyChangeListener
(
matteListener
);
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIRegion.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
import
org.jdesktop.beans.AbstractBean
;
import
org.jdesktop.swingx.designer.utils.HasUIDefaults
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
javax.swing.UIDefaults
;
import
java.awt.Insets
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.util.List
;
import
java.util.ArrayList
;
/**
* Represents a "Region" in synth, which also includes entire components.
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIRegion
extends
AbstractBean
implements
HasUIDefaults
,
HasUIStyle
{
private
String
name
;
//the code-wise name of the region
protected
String
key
;
//the UIdefaults key for this region
protected
String
title
;
//the user friendly name/title of this region
/** List of background states */
private
List
<
UIState
>
backgroundStates
;
/** List of foreground states */
private
List
<
UIState
>
foregroundStates
;
/** List of border states */
private
List
<
UIState
>
borderStates
;
private
UIStyle
style
=
new
UIStyle
();
protected
Insets
contentMargins
=
new
Insets
(
0
,
0
,
0
,
0
);
/** Sub regions, if any */
private
List
<
UIRegion
>
subRegions
;
//together with name, these two fields allow me to reconstruct, in
//code, a synth Region, including a custom Region, if you make one.
private
String
ui
;
private
boolean
subregion
;
/**
* This is a local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
* indervidual UIDefaults nodes
*/
private
transient
UIDefaults
modelDefaults
=
null
;
private
UIRegion
region
;
//the region that this region belongs to
// =================================================================================================================
// Constructors
/** no-args contructor for JIBX */
protected
UIRegion
()
{
subRegions
=
new
ArrayList
<
UIRegion
>();
backgroundStates
=
new
ArrayList
<
UIState
>();
foregroundStates
=
new
ArrayList
<
UIState
>();
borderStates
=
new
ArrayList
<
UIState
>();
style
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"style."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
});
}
public
UIRegion
(
String
name
,
UIRegion
...
subRegions
)
{
this
(
name
,
null
,
true
,
subRegions
);
}
public
UIRegion
(
String
name
,
String
ui
,
UIRegion
...
subRegions
)
{
this
(
name
,
ui
,
false
,
subRegions
);
}
public
UIRegion
(
String
name
,
String
ui
,
boolean
subregion
,
UIRegion
...
subRegions
)
{
this
();
this
.
name
=
name
;
this
.
ui
=
ui
;
this
.
subregion
=
subregion
;
if
(
subRegions
!=
null
)
{
for
(
UIRegion
r
:
subRegions
)
{
if
(
r
!=
null
)
{
this
.
subRegions
.
add
(
r
);
r
.
getStyle
().
setParentStyle
(
getStyle
());
}
}
}
}
// =================================================================================================================
// JIBX Methods
/**
* Called by JIBX after all fields have been set
*
* @param context The JIBX Unmarshalling Context
*/
private
void
preSet
(
IUnmarshallingContext
context
)
{
// walk up till we get synth model
for
(
int
i
=
0
;
i
<
context
.
getStackDepth
();
i
++)
{
if
(
context
.
getStackObject
(
i
)
instanceof
HasUIDefaults
)
{
modelDefaults
=
((
HasUIDefaults
)
context
.
getStackObject
(
i
)).
getUiDefaults
();
if
(
modelDefaults
!=
null
)
break
;
}
}
for
(
int
i
=
0
;
i
<
context
.
getStackDepth
();
i
++)
{
if
(
context
.
getStackObject
(
i
)
instanceof
UIRegion
&&
context
.
getStackObject
(
i
)
!=
this
)
{
region
=
(
UIRegion
)
context
.
getStackObject
(
i
);
break
;
}
}
}
// =================================================================================================================
// Bean Methods
public
Insets
getContentMargins
()
{
return
contentMargins
;
}
public
void
setContentMargins
(
Insets
contentMargins
)
{
Insets
old
=
getContentMargins
();
this
.
contentMargins
=
contentMargins
;
firePropertyChange
(
"contentMargins"
,
old
,
getContentMargins
());
}
void
setRegion
(
UIRegion
r
)
{
this
.
region
=
r
;
}
public
UIRegion
getRegion
()
{
return
region
;
}
/**
* Get the local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
* indervidual UIDefaults nodes
*
* @return The UIDefaults for the synth model
*/
public
UIDefaults
getUiDefaults
()
{
return
modelDefaults
;
}
public
String
getName
()
{
return
name
;
}
public
final
UIRegion
[]
getSubRegions
()
{
return
subRegions
.
toArray
(
new
UIRegion
[
0
]);
}
public
final
UIState
[]
getBackgroundStates
()
{
return
backgroundStates
.
toArray
(
new
UIState
[
0
]);
}
public
final
UIState
[]
getForegroundStates
()
{
return
foregroundStates
.
toArray
(
new
UIState
[
0
]);
}
public
final
UIState
[]
getBorderStates
()
{
return
borderStates
.
toArray
(
new
UIState
[
0
]);
}
public
UIStyle
getStyle
()
{
return
style
;
}
public
final
boolean
isSubRegion
()
{
return
subregion
;
}
public
final
String
getUi
()
{
return
ui
;
}
public
void
addBackgroundState
(
UIState
state
)
{
// check if we already have that state
for
(
UIState
uiState
:
backgroundStates
)
{
if
(
uiState
.
getName
().
equals
(
state
.
getName
()))
return
;
}
backgroundStates
.
add
(
state
);
state
.
setRegion
(
this
);
firePropertyChange
(
"backgroundStates"
,
null
,
backgroundStates
);
}
public
void
removeBackgroundState
(
UIState
state
)
{
if
(
backgroundStates
.
remove
(
state
))
{
firePropertyChange
(
"backgroundStates"
,
null
,
backgroundStates
);
}
}
public
void
addForegroundState
(
UIState
state
)
{
// check if we already have that state
for
(
UIState
uiState
:
foregroundStates
)
{
if
(
uiState
.
getName
().
equals
(
state
.
getName
()))
return
;
}
foregroundStates
.
add
(
state
);
state
.
setRegion
(
this
);
firePropertyChange
(
"foregroundStates"
,
null
,
foregroundStates
);
}
public
void
removeForegroundState
(
UIState
state
)
{
if
(
foregroundStates
.
remove
(
state
))
{
firePropertyChange
(
"foregroundStates"
,
null
,
foregroundStates
);
}
}
public
void
addBorderState
(
UIState
state
)
{
// check if we already have that state
for
(
UIState
uiState
:
borderStates
)
{
if
(
uiState
.
getName
().
equals
(
state
.
getName
()))
return
;
}
borderStates
.
add
(
state
);
state
.
setRegion
(
this
);
firePropertyChange
(
"borderStates"
,
null
,
borderStates
);
}
public
void
removeBorderState
(
UIState
state
)
{
if
(
borderStates
.
remove
(
state
))
{
firePropertyChange
(
"borderStates"
,
null
,
borderStates
);
}
}
public
String
getKey
()
{
return
key
==
null
||
""
.
equals
(
key
)
?
name
:
key
;
}
public
String
getTitle
()
{
return
title
==
null
||
""
.
equals
(
title
)
?
name
:
title
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIState.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
import
org.jdesktop.beans.AbstractBean
;
import
org.jdesktop.swingx.designer.Canvas
;
import
org.jdesktop.swingx.designer.utils.HasPath
;
import
org.jdesktop.swingx.designer.utils.HasUIDefaults
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
javax.swing.UIDefaults
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
/**
* Represents a State in the Synth LAF.
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIState
extends
AbstractBean
implements
HasUIStyle
,
HasPath
{
private
List
<
String
>
stateKeys
;
private
boolean
inverted
;
//indicates whether to invert the meaning of the 9-square stretching insets
/** A cached string representing the list of stateKeys deliminated with "+" */
private
String
cachedName
=
null
;
private
Canvas
canvas
;
private
UIStyle
style
;
/** the region that this state belongs to */
private
UIRegion
region
;
/**
* This is a local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
* indervidual UIDefaults nodes
*/
private
transient
UIDefaults
modelDefaults
=
null
;
// =================================================================================================================
// Contructors
public
UIState
()
{
// Create state keys as event list so model changes are propogated
stateKeys
=
new
ArrayList
<
String
>();
}
public
UIState
(
SynthModel
model
,
UIRegion
parentRegion
,
String
...
stateTypeKeys
)
{
// Create state keys as event list so model changes are propogated
stateKeys
=
new
ArrayList
<
String
>();
this
.
stateKeys
.
addAll
(
Arrays
.
asList
(
stateTypeKeys
));
//
modelDefaults
=
model
.
getUiDefaults
();
region
=
parentRegion
;
// create new canvas
canvas
=
new
Canvas
(
100
,
30
);
canvas
.
setUiDefaults
(
modelDefaults
);
String
canvasPath
=
getPath
();
canvas
.
setResourcesDir
(
new
File
(
model
.
getResourcesDir
(),
canvasPath
));
canvas
.
setTemplatesDir
(
new
File
(
model
.
getTemplatesDir
(),
canvasPath
));
canvas
.
setImagesDir
(
new
File
(
model
.
getImagesDir
(),
canvasPath
));
canvas
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"canvas."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
});
// create new style
style
=
new
UIStyle
();
style
.
setParentStyle
(
region
.
getStyle
());
style
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"style."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
});
}
// =================================================================================================================
// JIBX Methods
/**
* JIBX needs this
*
* @param stateKeys The new list of states
*/
private
void
setStateKeys
(
List
<
String
>
stateKeys
)
{
if
(
stateKeys
!=
this
.
stateKeys
)
{
this
.
stateKeys
.
clear
();
this
.
stateKeys
.
addAll
(
stateKeys
);
}
}
/**
* Called by JIBX after all fields have been set
*
* @param context The JIBX Unmarshalling Context
*/
private
void
preSet
(
IUnmarshallingContext
context
)
{
// walk up till we get synth model
for
(
int
i
=
0
;
i
<
context
.
getStackDepth
();
i
++)
{
if
(
context
.
getStackObject
(
i
)
instanceof
HasUIDefaults
)
{
modelDefaults
=
((
HasUIDefaults
)
context
.
getStackObject
(
i
)).
getUiDefaults
();
if
(
modelDefaults
!=
null
)
break
;
}
}
for
(
int
i
=
0
;
i
<
context
.
getStackDepth
();
i
++)
{
if
(
context
.
getStackObject
(
i
)
instanceof
UIRegion
)
{
region
=
(
UIRegion
)
context
.
getStackObject
(
i
);
break
;
}
}
}
/**
* Called by JIBX after all fields have been set
*
* @param context The JIBX Unmarshalling Context
*/
private
void
postSet
(
IUnmarshallingContext
context
)
{
// add listeners to pass canvas and style events up tree
canvas
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"canvas."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
});
style
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"style."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
});
}
// =================================================================================================================
// Bean Methods
/**
* Get path to this UI State of the form /RegionA/RegionB/StateName
*
* @return Path to this state
*/
public
String
getPath
()
{
StringBuilder
buf
=
new
StringBuilder
(
getName
());
UIRegion
region
=
getRegion
();
// check if we are foreground background or border
boolean
found
=
false
;
for
(
UIState
state
:
region
.
getBackgroundStates
())
{
if
(
state
==
this
)
{
buf
.
insert
(
0
,
"Background/"
);
found
=
true
;
break
;
}
}
if
(!
found
)
{
for
(
UIState
state
:
region
.
getForegroundStates
())
{
if
(
state
==
this
)
{
buf
.
insert
(
0
,
"Foreground/"
);
found
=
true
;
break
;
}
}
}
if
(!
found
)
{
for
(
UIState
state
:
region
.
getBorderStates
())
{
if
(
state
==
this
)
{
buf
.
insert
(
0
,
"Border/"
);
found
=
true
;
break
;
}
}
}
// add parent regions
while
(
region
!=
null
)
{
buf
.
insert
(
0
,
'/'
);
if
(
region
instanceof
UIComponent
&&
((
UIComponent
)
region
).
getComponentName
()
!=
null
)
{
buf
.
insert
(
0
,
((
UIComponent
)
region
).
getComponentName
());
}
else
{
buf
.
insert
(
0
,
region
.
getName
());
}
region
=
region
.
getRegion
();
}
return
buf
.
toString
();
}
void
setRegion
(
UIRegion
r
)
{
this
.
region
=
r
;
this
.
style
.
setParentStyle
(
r
.
getStyle
());
}
public
UIRegion
getRegion
()
{
return
region
;
}
/**
* Get the local UIDefaults that contains all the UIDefaults in the synth model. It is kept uptodate by the
* indervidual UIDefaults nodes
*
* @return The UIDefaults for the synth model
*/
public
UIDefaults
getUIDefaults
()
{
return
modelDefaults
;
}
/**
* Get the list of state type keys for this state. This state is applied when the current component state matches as
* many as possible of these state types.
*
* @return List of state types that need to be true for this state. This is direct access to the data and changes to
* the returned list will effect this UiState.
*/
public
List
<
String
>
getStateKeys
()
{
return
stateKeys
;
}
public
void
setInverted
(
boolean
b
)
{
boolean
old
=
inverted
;
inverted
=
b
;
firePropertyChange
(
"invert"
,
old
,
b
);
}
public
final
boolean
isInverted
()
{
return
inverted
;
}
/**
* Get the name of this state
*
* @return
*/
public
String
getName
()
{
if
(
cachedName
==
null
)
{
StringBuilder
buf
=
new
StringBuilder
();
List
<
String
>
keys
=
new
ArrayList
<
String
>(
stateKeys
);
Collections
.
sort
(
keys
);
for
(
Iterator
<
String
>
iter
=
keys
.
iterator
();
iter
.
hasNext
();)
{
buf
.
append
(
iter
.
next
());
if
(
iter
.
hasNext
())
buf
.
append
(
'+'
);
}
cachedName
=
buf
.
toString
();
}
return
cachedName
;
}
public
final
Canvas
getCanvas
()
{
return
canvas
;
}
public
void
setCanvas
(
Canvas
c
)
{
Canvas
old
=
canvas
;
canvas
=
c
;
firePropertyChange
(
"canvas"
,
old
,
c
);
}
public
UIStyle
getStyle
()
{
return
style
;
}
// =================================================================================================================
// JIBX Helper Methods
public
static
String
keysToString
(
List
<
String
>
keys
)
{
StringBuilder
buf
=
new
StringBuilder
();
for
(
Iterator
<
String
>
iter
=
keys
.
iterator
();
iter
.
hasNext
();)
{
buf
.
append
(
iter
.
next
());
if
(
iter
.
hasNext
())
buf
.
append
(
'+'
);
}
return
buf
.
toString
();
}
public
static
List
<
String
>
stringToKeys
(
String
keysString
)
{
return
Arrays
.
asList
(
keysString
.
split
(
"\\+"
));
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIStateType.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
import
org.jdesktop.beans.AbstractBean
;
/**
* UIStateType - A UIComponents has a collection of these which constitute the avilables states which can be chosen in
* the components regions. A UIStateType can be either a custom state or one of the predefined standard states.
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIStateType
extends
AbstractBean
{
/* Keys for standard synth states */
public
static
final
String
ENABLED_KEY
=
"Enabled"
;
public
static
final
String
MOUSE_OVER_KEY
=
"MouseOver"
;
public
static
final
String
PRESSED_KEY
=
"Pressed"
;
public
static
final
String
DISABLED_KEY
=
"Disabled"
;
public
static
final
String
FOCUSED_KEY
=
"Focused"
;
public
static
final
String
SELECTED_KEY
=
"Selected"
;
public
static
final
String
DEFAULT_KEY
=
"Default"
;
public
static
final
String
[]
STANDARD_SYNTH_STATE_KEYS
=
new
String
[]{
ENABLED_KEY
,
MOUSE_OVER_KEY
,
PRESSED_KEY
,
DISABLED_KEY
,
FOCUSED_KEY
,
SELECTED_KEY
,
DEFAULT_KEY
};
public
static
final
UIStateType
[]
STANDARD_SYNTH_STATES
=
new
UIStateType
[]{
new
UIStateType
(
ENABLED_KEY
),
new
UIStateType
(
MOUSE_OVER_KEY
),
new
UIStateType
(
PRESSED_KEY
),
new
UIStateType
(
DISABLED_KEY
),
new
UIStateType
(
FOCUSED_KEY
),
new
UIStateType
(
SELECTED_KEY
),
new
UIStateType
(
DEFAULT_KEY
)
};
/** Unique string for the ui key for this state, must be unique within a components set of UiStateTypes */
private
String
key
;
/**
* Snippet of java code that defines calculates the value of this state for a particular component. The varaiable
* <code>c</code> is the component. You end with a return statement returning boolean true/false for the current
* value of this state for this component. This can be null if the key is one of that standard synth states defined
* in constants in this class.
*/
private
String
codeSnippet
;
/** JIBX no-args contructor */
private
UIStateType
()
{}
private
UIStateType
(
String
key
)
{
this
.
key
=
key
;
this
.
codeSnippet
=
null
;
}
public
UIStateType
(
String
key
,
String
codeSnippet
)
{
this
.
key
=
key
;
this
.
codeSnippet
=
codeSnippet
;
}
// =================================================================================================================
// Bean Methods
/**
* Get the ui defaults key for this state type. Unique string for the ui key for this state, must be unique within a
* components set of UiStateTypes.
*
* @return Unique ui default key
*/
public
String
getKey
()
{
return
key
;
}
/**
* Get the snippet of java code that defines calculates the value of this state for a particular component. The
* varaiable <code>c</code> is the component. You end with a return statement returning boolean true/false for the
* current value of this state for this component. This can be null if the key is one of that standard synth states
* defined in constants in this class.
*
* @return Snippet of java code or null if this is a synth standard state
*/
public
String
getCodeSnippet
()
{
return
codeSnippet
;
}
/**
* Set the snippet of java code that defines calculates the value of this state for a particular component. The
* varaiable <code>c</code> is the component. You end with a return statement returning boolean true/false for the
* current value of this state for this component. This can be null if the key is one of that standard synth states
* defined in constants in this class.
*
* @param codeSnippet Snippet of java code or null if this is a synth standard state
*/
public
void
setCodeSnippet
(
String
codeSnippet
)
{
this
.
codeSnippet
=
codeSnippet
;
}
/**
* Returns if this state type is a standard synth type and has no code snippet or a custom type that has a code
* snippet. It is used by JIBX to determin if the code snippet should be written to XML.
*
* @return <code>true</code> if codeSnippet is non null
*/
public
boolean
hasCodeSnippet
()
{
return
codeSnippet
!=
null
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIStyle.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel
;
import
org.jdesktop.beans.AbstractBean
;
import
org.jdesktop.swingx.designer.font.Typeface
;
import
org.jdesktop.swingx.designer.paint.Matte
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.util.List
;
import
java.util.ArrayList
;
/**
* UIStyle
*
* @author Richard Bair
* @author Jasper Potts
*/
public
class
UIStyle
extends
AbstractBean
{
public
static
enum
CacheMode
{
NO_CACHING
,
FIXED_SIZES
,
NINE_SQUARE_SCALE
}
public
static
enum
HintAlphaInterpolation
{
DEFAULT
,
QUALITY
,
SPEED
}
public
static
enum
HintAntialiasing
{
DEFAULT
,
ON
,
OFF
}
public
static
enum
HintColorRendering
{
DEFAULT
,
QUALITY
,
SPEED
}
public
static
enum
HintDithering
{
DEFAULT
,
DISABLE
,
ENABLE
}
public
static
enum
HintFractionalMetrics
{
DEFAULT
,
ON
,
OFF
}
public
static
enum
HintInterpolation
{
NEAREST_NEIGHBOR
,
BILINEAR
,
BICUBIC
}
public
static
enum
HintRendering
{
DEFAULT
,
QUALITY
,
SPEED
}
public
static
enum
HintStrokeControl
{
DEFAULT
,
NORMALIZE
,
PURE
}
public
static
enum
HintTextAntialiasing
{
DEFAULT
,
ON
,
OFF
,
GASP
,
LCD_HBGR
,
LCD_HRGB
,
LCD_VBGR
,
LCD_VRGB
}
private
Typeface
font
=
null
;
private
boolean
fontInherited
=
true
;
private
Matte
textForeground
=
null
;
private
boolean
textForegroundInherited
=
true
;
private
Matte
textBackground
=
null
;
private
boolean
textBackgroundInherited
=
true
;
private
Matte
background
=
null
;
private
boolean
backgroundInherited
=
true
;
private
boolean
cacheSettingsInherited
=
true
;
private
CacheMode
cacheMode
=
CacheMode
.
FIXED_SIZES
;
private
double
maxHozCachedImgScaling
=
1
;
private
double
maxVertCachedImgScaling
=
1
;
private
HintAlphaInterpolation
hintAlphaInterpolation
=
null
;
private
HintAntialiasing
hintAntialiasing
=
null
;
private
HintColorRendering
hintColorRendering
=
null
;
private
HintDithering
hintDithering
=
null
;
private
HintFractionalMetrics
hintFractionalMetrics
=
null
;
private
HintInterpolation
hintInterpolation
=
null
;
private
HintRendering
hintRendering
=
null
;
private
HintStrokeControl
hintStrokeControl
=
null
;
private
HintTextAntialiasing
hintTextAntialiasing
=
null
;
private
List
<
UIProperty
>
uiProperties
;
private
UIStyle
parentStyle
=
null
;
private
PropertyChangeListener
textForegoundListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"textForeground."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
};
private
PropertyChangeListener
textBackgroundListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"textBackground."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
};
private
PropertyChangeListener
backgroundListener
=
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
firePropertyChange
(
"background."
+
evt
.
getPropertyName
(),
evt
.
getOldValue
(),
evt
.
getNewValue
());
}
};
// =================================================================================================================
// Constructors
public
UIStyle
()
{
uiProperties
=
new
ArrayList
<
UIProperty
>();
}
// =================================================================================================================
// JIBX Methods
/**
* Called by JIBX after all fields have been set
*
* @param context The JIBX Unmarshalling Context
*/
private
void
postSet
(
IUnmarshallingContext
context
)
{
// walk up till we get a parent style
for
(
int
i
=
0
;
i
<
context
.
getStackDepth
();
i
++)
{
if
(
context
.
getStackObject
(
i
)
instanceof
HasUIStyle
)
{
HasUIStyle
hasStyle
=
(
HasUIStyle
)
context
.
getStackObject
(
i
);
if
(
hasStyle
.
getStyle
()
!=
this
)
{
parentStyle
=
hasStyle
.
getStyle
();
if
(
parentStyle
!=
null
)
break
;
}
}
}
}
// =================================================================================================================
// Bean Methods
public
UIStyle
getParentStyle
()
{
return
parentStyle
;
}
public
void
setParentStyle
(
UIStyle
parentStyle
)
{
UIStyle
old
=
getParentStyle
();
this
.
parentStyle
=
parentStyle
;
firePropertyChange
(
"parentStyle"
,
old
,
getParentStyle
());
}
public
List
<
UIProperty
>
getUiProperties
()
{
return
uiProperties
;
}
public
void
addUiProperty
(
UIProperty
uiProperty
)
{
uiProperties
.
add
(
uiProperty
);
// todo not quite sure what events we want here
fireIndexedPropertyChange
(
"uiProperties"
,
uiProperties
.
size
(),
null
,
uiProperty
);
// firePropertyChange("uiProperties", null, uiProperties);
}
public
void
removeUiProperty
(
UIProperty
uiProperty
)
{
int
index
=
uiProperties
.
indexOf
(
uiProperty
);
if
(
index
!=
-
1
)
{
uiProperties
.
remove
(
uiProperty
);
// todo not quite sure what events we want here
fireIndexedPropertyChange
(
"uiProperties"
,
index
,
null
,
uiProperty
);
// firePropertyChange("uiProperties", null, uiProperties);
}
}
public
Typeface
getFont
()
{
if
(
isFontInherited
())
{
return
parentStyle
==
null
?
font
:
parentStyle
.
getFont
();
}
else
{
return
font
;
}
}
public
void
setFont
(
Typeface
font
)
{
Typeface
old
=
getFont
();
this
.
font
=
font
;
firePropertyChange
(
"font"
,
old
,
font
);
}
public
boolean
isFontInherited
()
{
return
fontInherited
;
}
public
void
setFontInherited
(
boolean
b
)
{
boolean
old
=
isFontInherited
();
fontInherited
=
b
;
firePropertyChange
(
"fontInherited"
,
old
,
b
);
if
(!
fontInherited
&&
font
==
null
&&
parentStyle
!=
null
&&
parentStyle
.
getFont
()
!=
null
)
{
font
=
parentStyle
.
getFont
().
clone
();
firePropertyChange
(
"font"
,
null
,
font
);
}
}
public
Matte
getTextForeground
()
{
if
(
isTextForegroundInherited
())
{
return
parentStyle
==
null
?
null
:
parentStyle
.
getTextForeground
();
}
else
{
return
textForeground
;
}
}
public
boolean
isTextForegroundInherited
()
{
return
textForegroundInherited
;
}
public
void
setTextForegroundInherited
(
boolean
b
)
{
boolean
old
=
isTextForegroundInherited
();
textForegroundInherited
=
b
;
firePropertyChange
(
"foregroundInherited"
,
old
,
b
);
if
(!
textForegroundInherited
&&
textForeground
==
null
&&
parentStyle
!=
null
&&
parentStyle
.
getTextForeground
()
!=
null
)
{
textForeground
=
parentStyle
.
getTextForeground
().
clone
();
firePropertyChange
(
"textForeground"
,
null
,
textForeground
);
}
}
public
void
setTextForeground
(
Matte
textForeground
)
{
Matte
old
=
this
.
textForeground
;
if
(
old
!=
null
)
old
.
removePropertyChangeListener
(
textForegoundListener
);
this
.
textForeground
=
textForeground
;
if
(
this
.
textForeground
!=
null
)
this
.
textForeground
.
addPropertyChangeListener
(
textForegoundListener
);
firePropertyChange
(
"textForeground"
,
old
,
this
.
textForeground
);
}
public
Matte
getTextBackground
()
{
if
(
isTextBackgroundInherited
())
{
return
parentStyle
==
null
?
null
:
parentStyle
.
getBackground
();
}
else
{
return
textBackground
;
}
}
public
boolean
isTextBackgroundInherited
()
{
return
textBackgroundInherited
;
}
public
void
setTextBackgroundInherited
(
boolean
b
)
{
boolean
old
=
isBackgroundInherited
();
textBackgroundInherited
=
b
;
firePropertyChange
(
"textBackgroundInherited"
,
old
,
b
);
if
(!
textBackgroundInherited
&&
textBackground
==
null
&&
parentStyle
!=
null
&&
parentStyle
.
getTextBackground
()
!=
null
)
{
textBackground
=
parentStyle
.
getTextBackground
().
clone
();
firePropertyChange
(
"textBackground"
,
null
,
textBackground
);
}
}
public
void
setTextBackground
(
Matte
textBackground
)
{
Matte
old
=
this
.
textBackground
;
if
(
old
!=
null
)
old
.
removePropertyChangeListener
(
textBackgroundListener
);
this
.
textBackground
=
textBackground
;
if
(
this
.
textBackground
!=
null
)
this
.
textBackground
.
addPropertyChangeListener
(
textBackgroundListener
);
firePropertyChange
(
"textBackground"
,
old
,
this
.
textBackground
);
}
public
Matte
getBackground
()
{
if
(
isBackgroundInherited
())
{
return
parentStyle
==
null
?
null
:
parentStyle
.
getBackground
();
}
else
{
return
background
;
}
}
public
boolean
isBackgroundInherited
()
{
return
backgroundInherited
;
}
public
void
setBackgroundInherited
(
boolean
b
)
{
boolean
old
=
isBackgroundInherited
();
backgroundInherited
=
b
;
firePropertyChange
(
"backgroundInherited"
,
old
,
b
);
if
(!
backgroundInherited
&&
background
==
null
&&
parentStyle
!=
null
&&
parentStyle
.
getBackground
()
!=
null
)
{
background
=
parentStyle
.
getBackground
().
clone
();
firePropertyChange
(
"background"
,
null
,
background
);
}
}
public
void
setBackground
(
Matte
background
)
{
Matte
old
=
this
.
background
;
if
(
old
!=
null
)
old
.
removePropertyChangeListener
(
backgroundListener
);
this
.
background
=
background
;
if
(
this
.
background
!=
null
)
this
.
background
.
addPropertyChangeListener
(
backgroundListener
);
firePropertyChange
(
"background"
,
old
,
this
.
background
);
}
public
HintAlphaInterpolation
getHintAlphaInterpolation
()
{
return
hintAlphaInterpolation
;
}
public
void
setHintAlphaInterpolation
(
HintAlphaInterpolation
hintAlphaInterpolation
)
{
HintAlphaInterpolation
old
=
getHintAlphaInterpolation
();
this
.
hintAlphaInterpolation
=
hintAlphaInterpolation
;
firePropertyChange
(
"hintAlphaInterpolation"
,
old
,
getHintAlphaInterpolation
());
}
public
HintAntialiasing
getHintAntialiasing
()
{
return
hintAntialiasing
;
}
public
void
setHintAntialiasing
(
HintAntialiasing
hintAntialiasing
)
{
HintAntialiasing
old
=
getHintAntialiasing
();
this
.
hintAntialiasing
=
hintAntialiasing
;
firePropertyChange
(
"hintAntialiasing"
,
old
,
getHintAntialiasing
());
}
public
HintColorRendering
getHintColorRendering
()
{
return
hintColorRendering
;
}
public
void
setHintColorRendering
(
HintColorRendering
hintColorRendering
)
{
HintColorRendering
old
=
getHintColorRendering
();
this
.
hintColorRendering
=
hintColorRendering
;
firePropertyChange
(
"hintColorRendering"
,
old
,
getHintColorRendering
());
}
public
HintDithering
getHintDithering
()
{
return
hintDithering
;
}
public
void
setHintDithering
(
HintDithering
hintDithering
)
{
HintDithering
old
=
getHintDithering
();
this
.
hintDithering
=
hintDithering
;
firePropertyChange
(
"hintDithering"
,
old
,
getHintDithering
());
}
public
HintFractionalMetrics
getHintFractionalMetrics
()
{
return
hintFractionalMetrics
;
}
public
void
setHintFractionalMetrics
(
HintFractionalMetrics
hintFractionalMetrics
)
{
HintFractionalMetrics
old
=
getHintFractionalMetrics
();
this
.
hintFractionalMetrics
=
hintFractionalMetrics
;
firePropertyChange
(
"hintFractionalMetrics"
,
old
,
getHintFractionalMetrics
());
}
public
HintInterpolation
getHintInterpolation
()
{
return
hintInterpolation
;
}
public
void
setHintInterpolation
(
HintInterpolation
hintInterpolation
)
{
HintInterpolation
old
=
getHintInterpolation
();
this
.
hintInterpolation
=
hintInterpolation
;
firePropertyChange
(
"hintInterpolation"
,
old
,
getHintInterpolation
());
}
public
HintRendering
getHintRendering
()
{
return
hintRendering
;
}
public
void
setHintRendering
(
HintRendering
hintRendering
)
{
HintRendering
old
=
getHintRendering
();
this
.
hintRendering
=
hintRendering
;
firePropertyChange
(
"hintRendering"
,
old
,
getHintRendering
());
}
public
HintStrokeControl
getHintStrokeControl
()
{
return
hintStrokeControl
;
}
public
void
setHintStrokeControl
(
HintStrokeControl
hintStrokeControl
)
{
HintStrokeControl
old
=
getHintStrokeControl
();
this
.
hintStrokeControl
=
hintStrokeControl
;
firePropertyChange
(
"hintStrokeControl"
,
old
,
getHintStrokeControl
());
}
public
HintTextAntialiasing
getHintTextAntialiasing
()
{
return
hintTextAntialiasing
;
}
public
void
setHintTextAntialiasing
(
HintTextAntialiasing
hintTextAntialiasing
)
{
HintTextAntialiasing
old
=
getHintTextAntialiasing
();
this
.
hintTextAntialiasing
=
hintTextAntialiasing
;
firePropertyChange
(
"hintTextAntialiasing"
,
old
,
getHintTextAntialiasing
());
}
public
boolean
isCacheSettingsInherited
()
{
return
cacheSettingsInherited
;
}
public
void
setCacheSettingsInherited
(
boolean
cacheSettingsInherited
)
{
boolean
old
=
isCacheSettingsInherited
();
this
.
cacheSettingsInherited
=
cacheSettingsInherited
;
firePropertyChange
(
"cacheSettingsInherited"
,
old
,
isCacheSettingsInherited
());
}
public
CacheMode
getCacheMode
()
{
if
(
isCacheSettingsInherited
())
{
return
(
parentStyle
==
null
)?
CacheMode
.
FIXED_SIZES
:
parentStyle
.
getCacheMode
();
}
else
{
return
cacheMode
;
}
}
public
void
setCacheMode
(
CacheMode
cacheMode
)
{
CacheMode
old
=
this
.
cacheMode
;
this
.
cacheMode
=
cacheMode
;
if
(
isCacheSettingsInherited
())
{
setCacheSettingsInherited
(
false
);
UIStyle
parent
=
getParentStyle
();
setMaxHozCachedImgScaling
(
parent
==
null
?
1
:
parent
.
getMaxHozCachedImgScaling
());
setMaxVertCachedImgScaling
(
parent
==
null
?
1
:
parent
.
getMaxVertCachedImgScaling
());
}
firePropertyChange
(
"cacheMode"
,
old
,
cacheMode
);
}
public
double
getMaxHozCachedImgScaling
()
{
if
(
isCacheSettingsInherited
())
{
return
parentStyle
==
null
?
1
:
parentStyle
.
getMaxHozCachedImgScaling
();
}
else
{
return
maxHozCachedImgScaling
;
}
}
public
void
setMaxHozCachedImgScaling
(
double
maxHozCachedImgScaling
)
{
double
old
=
getMaxHozCachedImgScaling
();
this
.
maxHozCachedImgScaling
=
maxHozCachedImgScaling
;
if
(
isCacheSettingsInherited
())
{
setCacheSettingsInherited
(
false
);
setCacheMode
((
parentStyle
==
null
)?
CacheMode
.
FIXED_SIZES
:
parentStyle
.
getCacheMode
());
setMaxVertCachedImgScaling
(
parentStyle
==
null
?
1
:
parentStyle
.
getMaxVertCachedImgScaling
());
}
firePropertyChange
(
"maxHozCachedImgScaling"
,
old
,
getMaxHozCachedImgScaling
());
}
public
double
getMaxVertCachedImgScaling
()
{
if
(
isCacheSettingsInherited
())
{
return
parentStyle
==
null
?
1
:
parentStyle
.
getMaxVertCachedImgScaling
();
}
else
{
return
maxVertCachedImgScaling
;
}
}
public
void
setMaxVertCachedImgScaling
(
double
maxVertCachedImgScaling
)
{
double
old
=
getMaxVertCachedImgScaling
();
this
.
maxVertCachedImgScaling
=
maxVertCachedImgScaling
;
if
(
isCacheSettingsInherited
())
{
setCacheSettingsInherited
(
false
);
setCacheMode
((
parentStyle
==
null
)?
CacheMode
.
FIXED_SIZES
:
parentStyle
.
getCacheMode
());
setMaxHozCachedImgScaling
(
parentStyle
==
null
?
1
:
parentStyle
.
getMaxHozCachedImgScaling
());
}
firePropertyChange
(
"maxVertCachedImgScaling"
,
old
,
getMaxVertCachedImgScaling
());
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/BorderMapper.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel.jibxhelpers
;
import
org.jibx.runtime.IMarshaller
;
import
org.jibx.runtime.IUnmarshaller
;
import
org.jibx.runtime.IAliasable
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
org.jibx.runtime.JiBXException
;
import
org.jibx.runtime.IMarshallingContext
;
import
org.jibx.runtime.impl.MarshallingContext
;
import
org.jibx.runtime.impl.UnmarshallingContext
;
import
org.jdesktop.swingx.designer.jibxhelpers.ColorMapper
;
import
javax.swing.border.LineBorder
;
import
javax.swing.border.EmptyBorder
;
import
javax.swing.border.EtchedBorder
;
import
javax.swing.border.BevelBorder
;
import
javax.swing.border.MatteBorder
;
import
javax.swing.border.CompoundBorder
;
import
javax.swing.border.Border
;
import
javax.swing.BorderFactory
;
import
java.awt.Insets
;
import
java.awt.Color
;
import
org.jdesktop.synthdesigner.synthmodel.PainterBorder
;
/**
* BorderMapper - JIBX xml mapper for swing standard borders
*
* @author Jasper Potts
*/
public
class
BorderMapper
implements
IMarshaller
,
IUnmarshaller
,
IAliasable
{
private
static
enum
BorderType
{
empty
,
line
,
etched
,
bevel
,
matte
,
compound
,
painter
}
private
static
enum
SubType
{
raised
(
EtchedBorder
.
RAISED
),
lowered
(
EtchedBorder
.
LOWERED
);
private
int
subtype
;
SubType
(
int
type
)
{
this
.
subtype
=
type
;
}
public
int
getSubType
()
{
return
subtype
;
}
}
private
static
final
String
ELEMENT_NAME
=
"border"
;
private
static
final
String
TYPE_NAME
=
"type"
;
private
static
final
String
SUB_TYPE_NAME
=
"subtype"
;
private
static
final
String
TOP_NAME
=
"top"
;
private
static
final
String
BOTTOM_NAME
=
"bottom"
;
private
static
final
String
LEFT_NAME
=
"left"
;
private
static
final
String
RIGHT_NAME
=
"right"
;
private
static
final
String
THICKNESS_NAME
=
"thickness"
;
private
static
final
String
INSIDE_NAME
=
"inside"
;
private
static
final
String
OUTSIDE_NAME
=
"outside"
;
private
static
final
String
PAINTER_NAME
=
"painter"
;
private
String
uri
;
private
int
index
;
private
String
name
;
public
BorderMapper
()
{
uri
=
null
;
index
=
0
;
name
=
ELEMENT_NAME
;
}
public
BorderMapper
(
String
uri
,
int
index
,
String
name
)
{
this
.
uri
=
uri
;
this
.
index
=
index
;
this
.
name
=
name
;
}
public
boolean
isExtension
(
int
i
)
{
return
false
;
}
public
boolean
isPresent
(
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
return
iUnmarshallingContext
.
isAt
(
uri
,
ELEMENT_NAME
);
}
public
void
marshal
(
Object
object
,
IMarshallingContext
iMarshallingContext
)
throws
JiBXException
{
if
(!(
iMarshallingContext
instanceof
MarshallingContext
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
{
MarshallingContext
ctx
=
(
MarshallingContext
)
iMarshallingContext
;
if
(
object
instanceof
PainterBorder
)
{
PainterBorder
border
=
(
PainterBorder
)
object
;
Insets
insets
=
border
.
getBorderInsets
();
ctx
.
startTagAttributes
(
index
,
name
)
.
attribute
(
index
,
TYPE_NAME
,
BorderType
.
painter
.
toString
())
.
attribute
(
index
,
PAINTER_NAME
,
border
.
getPainterName
())
.
attribute
(
index
,
TOP_NAME
,
insets
.
top
)
.
attribute
(
index
,
BOTTOM_NAME
,
insets
.
bottom
)
.
attribute
(
index
,
LEFT_NAME
,
insets
.
left
)
.
attribute
(
index
,
RIGHT_NAME
,
insets
.
right
)
.
closeStartContent
();
ctx
.
endTag
(
index
,
name
);
}
else
if
(
object
instanceof
EmptyBorder
)
{
Insets
insets
=
((
EmptyBorder
)
object
).
getBorderInsets
();
ctx
.
startTagAttributes
(
index
,
name
)
.
attribute
(
index
,
TYPE_NAME
,
BorderType
.
empty
.
toString
())
.
attribute
(
index
,
TOP_NAME
,
insets
.
top
)
.
attribute
(
index
,
BOTTOM_NAME
,
insets
.
bottom
)
.
attribute
(
index
,
LEFT_NAME
,
insets
.
left
)
.
attribute
(
index
,
RIGHT_NAME
,
insets
.
right
)
.
closeStartEmpty
();
}
else
if
(
object
instanceof
LineBorder
)
{
LineBorder
border
=
(
LineBorder
)
object
;
ctx
.
startTagAttributes
(
index
,
name
).
attribute
(
index
,
TYPE_NAME
,
BorderType
.
line
.
toString
()).
attribute
(
index
,
THICKNESS_NAME
,
border
.
getThickness
()).
closeStartContent
();
new
ColorMapper
().
marshal
(
border
.
getLineColor
(),
ctx
);
ctx
.
endTag
(
index
,
name
);
}
else
if
(
object
instanceof
EtchedBorder
)
{
EtchedBorder
border
=
(
EtchedBorder
)
object
;
ctx
.
startTagAttributes
(
index
,
name
).
attribute
(
index
,
TYPE_NAME
,
BorderType
.
etched
.
toString
()).
attribute
(
index
,
SUB_TYPE_NAME
,
border
.
getEtchType
()==
EtchedBorder
.
RAISED
?
SubType
.
raised
.
toString
():
SubType
.
lowered
.
toString
()).
closeStartContent
();
new
ColorMapper
().
marshal
(
border
.
getHighlightColor
(),
ctx
);
new
ColorMapper
().
marshal
(
border
.
getShadowColor
(),
ctx
);
ctx
.
endTag
(
index
,
name
);
}
else
if
(
object
instanceof
BevelBorder
)
{
BevelBorder
border
=
(
BevelBorder
)
object
;
ctx
.
startTagAttributes
(
index
,
name
).
attribute
(
index
,
TYPE_NAME
,
BorderType
.
bevel
.
toString
()).
attribute
(
index
,
SUB_TYPE_NAME
,
border
.
getBevelType
()==
BevelBorder
.
RAISED
?
SubType
.
raised
.
toString
():
SubType
.
lowered
.
toString
()).
closeStartContent
();
new
ColorMapper
().
marshal
(
border
.
getHighlightInnerColor
(),
ctx
);
new
ColorMapper
().
marshal
(
border
.
getHighlightOuterColor
(),
ctx
);
new
ColorMapper
().
marshal
(
border
.
getShadowInnerColor
(),
ctx
);
new
ColorMapper
().
marshal
(
border
.
getHighlightOuterColor
(),
ctx
);
ctx
.
endTag
(
index
,
name
);
}
else
if
(
object
instanceof
MatteBorder
)
{
MatteBorder
border
=
(
MatteBorder
)
object
;
Insets
insets
=
((
EmptyBorder
)
object
).
getBorderInsets
();
ctx
.
startTagAttributes
(
index
,
name
)
.
attribute
(
index
,
TYPE_NAME
,
BorderType
.
matte
.
toString
())
.
attribute
(
index
,
TOP_NAME
,
insets
.
top
)
.
attribute
(
index
,
BOTTOM_NAME
,
insets
.
bottom
)
.
attribute
(
index
,
LEFT_NAME
,
insets
.
left
)
.
attribute
(
index
,
RIGHT_NAME
,
insets
.
right
)
.
closeStartContent
();
new
ColorMapper
().
marshal
(
border
.
getMatteColor
(),
ctx
);
// todo: we should support tiled icons here to be 100% complete
ctx
.
endTag
(
index
,
name
);
}
else
if
(
object
instanceof
CompoundBorder
)
{
CompoundBorder
border
=
(
CompoundBorder
)
object
;
ctx
.
startTagAttributes
(
index
,
name
)
.
attribute
(
index
,
TYPE_NAME
,
BorderType
.
compound
.
toString
())
.
closeStartContent
();
new
BorderMapper
(
null
,
0
,
INSIDE_NAME
).
marshal
(
border
.
getInsideBorder
(),
ctx
);
new
BorderMapper
(
null
,
0
,
OUTSIDE_NAME
).
marshal
(
border
.
getOutsideBorder
(),
ctx
);
ctx
.
endTag
(
index
,
name
);
}
else
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
}
}
public
Object
unmarshal
(
Object
object
,
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
Border
border
=
null
;
// make sure we're at the appropriate start tag
UnmarshallingContext
ctx
=
(
UnmarshallingContext
)
iUnmarshallingContext
;
if
(!
ctx
.
isAt
(
uri
,
name
))
{
ctx
.
throwStartTagNameError
(
uri
,
name
);
}
// get type
BorderType
type
=
BorderType
.
valueOf
(
ctx
.
attributeText
(
uri
,
TYPE_NAME
)
.
toLowerCase
());
int
top
,
bottom
,
left
,
right
;
Color
color
;
switch
(
type
){
case
empty:
top
=
ctx
.
attributeInt
(
uri
,
TOP_NAME
,
index
);
bottom
=
ctx
.
attributeInt
(
uri
,
BOTTOM_NAME
,
index
);
left
=
ctx
.
attributeInt
(
uri
,
LEFT_NAME
,
index
);
right
=
ctx
.
attributeInt
(
uri
,
RIGHT_NAME
,
index
);
border
=
BorderFactory
.
createEmptyBorder
(
top
,
left
,
bottom
,
right
);
break
;
case
line:
int
thickness
=
ctx
.
attributeInt
(
uri
,
THICKNESS_NAME
,
index
);
ctx
.
parsePastStartTag
(
uri
,
name
);
color
=
(
Color
)
new
ColorMapper
().
unmarshal
(
null
,
ctx
);
border
=
BorderFactory
.
createLineBorder
(
color
,
thickness
);
break
;
case
etched:
SubType
etchedType
=
SubType
.
valueOf
(
ctx
.
attributeText
(
uri
,
SUB_TYPE_NAME
).
toLowerCase
());
ctx
.
parsePastStartTag
(
uri
,
name
);
Color
highColor
=
(
Color
)
new
ColorMapper
()
.
unmarshal
(
null
,
ctx
);
Color
shadowColor
=
(
Color
)
new
ColorMapper
()
.
unmarshal
(
null
,
ctx
);
border
=
BorderFactory
.
createEtchedBorder
(
etchedType
.
getSubType
(),
highColor
,
shadowColor
);
break
;
case
bevel:
SubType
bevelType
=
SubType
.
valueOf
(
ctx
.
attributeText
(
uri
,
SUB_TYPE_NAME
).
toLowerCase
());
ctx
.
parsePastStartTag
(
uri
,
name
);
Color
innerHighColor
=
(
Color
)
new
ColorMapper
()
.
unmarshal
(
null
,
ctx
);
Color
outerHighColor
=
(
Color
)
new
ColorMapper
()
.
unmarshal
(
null
,
ctx
);
Color
innerShadowColor
=
(
Color
)
new
ColorMapper
()
.
unmarshal
(
null
,
ctx
);
Color
outerShadowColor
=
(
Color
)
new
ColorMapper
()
.
unmarshal
(
null
,
ctx
);
border
=
BorderFactory
.
createBevelBorder
(
bevelType
.
getSubType
(),
outerHighColor
,
innerHighColor
,
outerShadowColor
,
innerShadowColor
);
break
;
case
matte:
top
=
ctx
.
attributeInt
(
uri
,
TOP_NAME
,
index
);
bottom
=
ctx
.
attributeInt
(
uri
,
BOTTOM_NAME
,
index
);
left
=
ctx
.
attributeInt
(
uri
,
LEFT_NAME
,
index
);
right
=
ctx
.
attributeInt
(
uri
,
RIGHT_NAME
,
index
);
ctx
.
parsePastStartTag
(
uri
,
name
);
color
=
(
Color
)
new
ColorMapper
().
unmarshal
(
null
,
ctx
);
border
=
BorderFactory
.
createMatteBorder
(
top
,
left
,
bottom
,
right
,
color
);
break
;
case
compound:
ctx
.
parsePastStartTag
(
uri
,
name
);
Border
inside
=
(
Border
)
new
BorderMapper
(
null
,
0
,
INSIDE_NAME
)
.
unmarshal
(
null
,
ctx
);
Border
outside
=
(
Border
)
new
BorderMapper
(
null
,
0
,
OUTSIDE_NAME
)
.
unmarshal
(
null
,
ctx
);
border
=
BorderFactory
.
createCompoundBorder
(
outside
,
inside
);
break
;
case
painter:
String
painterName
=
ctx
.
attributeText
(
uri
,
PAINTER_NAME
);
top
=
ctx
.
attributeInt
(
uri
,
TOP_NAME
,
index
);
bottom
=
ctx
.
attributeInt
(
uri
,
BOTTOM_NAME
,
index
);
left
=
ctx
.
attributeInt
(
uri
,
LEFT_NAME
,
index
);
right
=
ctx
.
attributeInt
(
uri
,
RIGHT_NAME
,
index
);
border
=
new
PainterBorder
(
painterName
,
top
,
left
,
bottom
,
right
);
}
ctx
.
parsePastEndTag
(
uri
,
name
);
return
border
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/ClassMapper.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel.jibxhelpers
;
import
org.jibx.runtime.IMarshaller
;
import
org.jibx.runtime.IMarshallingContext
;
import
org.jibx.runtime.IUnmarshaller
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
org.jibx.runtime.JiBXException
;
import
org.jibx.runtime.impl.MarshallingContext
;
import
org.jibx.runtime.impl.UnmarshallingContext
;
public
class
ClassMapper
implements
IMarshaller
,
IUnmarshaller
{
private
static
final
String
ELEMENT_NAME
=
"type"
;
public
boolean
isExtension
(
int
i
)
{
return
false
;
}
public
boolean
isPresent
(
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
return
iUnmarshallingContext
.
isAt
(
null
,
ELEMENT_NAME
);
}
public
void
marshal
(
Object
object
,
IMarshallingContext
iMarshallingContext
)
throws
JiBXException
{
if
(!(
object
instanceof
Class
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
if
(!(
iMarshallingContext
instanceof
MarshallingContext
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
{
MarshallingContext
ctx
=
(
MarshallingContext
)
iMarshallingContext
;
Class
clazz
=
(
Class
)
object
;
ctx
.
startTagAttributes
(
0
,
ELEMENT_NAME
).
attribute
(
0
,
"value"
,
clazz
.
getName
()).
closeStartEmpty
();
}
}
public
Object
unmarshal
(
Object
object
,
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
// make sure we're at the appropriate start tag
UnmarshallingContext
ctx
=
(
UnmarshallingContext
)
iUnmarshallingContext
;
if
(!
ctx
.
isAt
(
null
,
ELEMENT_NAME
))
{
ctx
.
throwStartTagNameError
(
null
,
ELEMENT_NAME
);
}
// get values
String
value
=
ctx
.
attributeText
(
null
,
"value"
,
null
);
ctx
.
parsePastEndTag
(
null
,
ELEMENT_NAME
);
// create
try
{
return
Class
.
forName
(
value
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/FontMapper.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel.jibxhelpers
;
import
org.jibx.runtime.IMarshaller
;
import
org.jibx.runtime.IMarshallingContext
;
import
org.jibx.runtime.IUnmarshaller
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
org.jibx.runtime.JiBXException
;
import
org.jibx.runtime.impl.MarshallingContext
;
import
org.jibx.runtime.impl.UnmarshallingContext
;
import
java.awt.Font
;
/**
* FontMapper
*
* @author Created by Jasper Potts (Jun 8, 2007)
*/
public
class
FontMapper
implements
IMarshaller
,
IUnmarshaller
{
private
static
final
String
ELEMENT_NAME
=
"font"
;
private
static
final
String
FAMILY_NAME
=
"family"
;
private
static
final
String
STYLE_NAME
=
"style"
;
private
static
final
String
SIZE_NAME
=
"size"
;
public
boolean
isExtension
(
int
i
)
{
return
false
;
}
public
boolean
isPresent
(
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
return
iUnmarshallingContext
.
isAt
(
null
,
ELEMENT_NAME
);
}
public
void
marshal
(
Object
object
,
IMarshallingContext
iMarshallingContext
)
throws
JiBXException
{
if
(!(
object
instanceof
Font
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
if
(!(
iMarshallingContext
instanceof
MarshallingContext
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
{
MarshallingContext
ctx
=
(
MarshallingContext
)
iMarshallingContext
;
Font
font
=
(
Font
)
object
;
ctx
.
startTagAttributes
(
0
,
ELEMENT_NAME
).
attribute
(
0
,
FAMILY_NAME
,
font
.
getFamily
()).
attribute
(
0
,
STYLE_NAME
,
font
.
getStyle
()).
attribute
(
0
,
SIZE_NAME
,
font
.
getSize
()).
closeStartEmpty
();
}
}
public
Object
unmarshal
(
Object
object
,
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
// make sure we're at the appropriate start tag
UnmarshallingContext
ctx
=
(
UnmarshallingContext
)
iUnmarshallingContext
;
if
(!
ctx
.
isAt
(
null
,
ELEMENT_NAME
))
{
ctx
.
throwStartTagNameError
(
null
,
ELEMENT_NAME
);
}
// get values
String
name
=
ctx
.
attributeText
(
null
,
FAMILY_NAME
,
null
);
int
style
=
ctx
.
attributeInt
(
null
,
STYLE_NAME
,
0
);
int
size
=
ctx
.
attributeInt
(
null
,
SIZE_NAME
,
0
);
ctx
.
parsePastEndTag
(
null
,
ELEMENT_NAME
);
// create
return
new
Font
(
name
,
style
,
size
);
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/UIPropertyMapper.java
已删除
100644 → 0
浏览文件 @
feb1bd83
/*
* Copyright 2005-2006 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
org.jdesktop.synthdesigner.synthmodel.jibxhelpers
;
import
org.jdesktop.swingx.designer.jibxhelpers.DimensionMapper
;
import
org.jdesktop.swingx.designer.jibxhelpers.InsetsMapper
;
import
org.jdesktop.synthdesigner.synthmodel.UIProperty
;
import
org.jibx.runtime.IMarshallable
;
import
org.jibx.runtime.IMarshaller
;
import
org.jibx.runtime.IMarshallingContext
;
import
org.jibx.runtime.IUnmarshaller
;
import
org.jibx.runtime.IUnmarshallingContext
;
import
org.jibx.runtime.JiBXException
;
import
org.jibx.runtime.impl.MarshallingContext
;
import
org.jibx.runtime.impl.UnmarshallingContext
;
/**
* UIPropertyMapper
*
* @author Created by Jasper Potts (Jul 10, 2007)
*/
public
class
UIPropertyMapper
implements
IMarshaller
,
IUnmarshaller
{
private
static
final
String
ELEMENT_NAME
=
"uiProperty"
;
private
static
final
String
NAME_NAME
=
"name"
;
private
static
final
String
TYPE_NAME
=
"type"
;
private
static
final
String
VALUE_NAME
=
"value"
;
public
boolean
isExtension
(
int
i
)
{
return
false
;
}
public
boolean
isPresent
(
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
return
iUnmarshallingContext
.
isAt
(
null
,
ELEMENT_NAME
);
}
public
void
marshal
(
Object
object
,
IMarshallingContext
iMarshallingContext
)
throws
JiBXException
{
if
(!(
object
instanceof
UIProperty
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
if
(!(
iMarshallingContext
instanceof
MarshallingContext
))
{
throw
new
JiBXException
(
"Invalid object type for marshaller"
);
}
else
{
MarshallingContext
ctx
=
(
MarshallingContext
)
iMarshallingContext
;
UIProperty
property
=
(
UIProperty
)
object
;
ctx
.
startTagAttributes
(
0
,
ELEMENT_NAME
);
ctx
.
attribute
(
0
,
NAME_NAME
,
property
.
getName
());
ctx
.
attribute
(
0
,
TYPE_NAME
,
property
.
getType
().
toString
());
switch
(
property
.
getType
())
{
case
BOOLEAN:
case
DOUBLE:
case
INT:
case
FLOAT:
case
STRING:
ctx
.
attribute
(
0
,
VALUE_NAME
,
property
.
getValue
().
toString
());
ctx
.
closeStartEmpty
();
break
;
case
INSETS:
ctx
.
closeStartContent
();
new
InsetsMapper
().
marshal
(
property
.
getValue
(),
ctx
);
ctx
.
endTag
(
0
,
ELEMENT_NAME
);
break
;
case
COLOR:
case
FONT:
ctx
.
closeStartContent
();
if
(
property
.
getValue
()
instanceof
IMarshallable
)
{
((
IMarshallable
)
property
.
getValue
()).
marshal
(
ctx
);
}
else
{
throw
new
JiBXException
(
"Mapped value is not marshallable"
);
}
ctx
.
endTag
(
0
,
ELEMENT_NAME
);
break
;
case
DIMENSION:
ctx
.
closeStartContent
();
new
DimensionMapper
().
marshal
(
property
.
getValue
(),
ctx
);
ctx
.
endTag
(
0
,
ELEMENT_NAME
);
break
;
case
BORDER:
ctx
.
closeStartContent
();
new
BorderMapper
().
marshal
(
property
.
getValue
(),
ctx
);
ctx
.
endTag
(
0
,
ELEMENT_NAME
);
break
;
}
}
}
public
Object
unmarshal
(
Object
object
,
IUnmarshallingContext
iUnmarshallingContext
)
throws
JiBXException
{
// make sure we're at the appropriate start tag
UnmarshallingContext
ctx
=
(
UnmarshallingContext
)
iUnmarshallingContext
;
if
(!
ctx
.
isAt
(
null
,
ELEMENT_NAME
))
{
ctx
.
throwStartTagNameError
(
null
,
ELEMENT_NAME
);
}
// get values
Object
value
=
null
;
String
name
=
ctx
.
attributeText
(
null
,
NAME_NAME
,
null
);
UIProperty
.
PropertyType
type
=
UIProperty
.
PropertyType
.
valueOf
(
ctx
.
attributeText
(
null
,
TYPE_NAME
,
null
));
switch
(
type
)
{
case
BOOLEAN:
value
=
Boolean
.
parseBoolean
(
ctx
.
attributeText
(
null
,
VALUE_NAME
,
null
));
break
;
case
DOUBLE:
value
=
Double
.
parseDouble
(
ctx
.
attributeText
(
null
,
VALUE_NAME
,
null
));
break
;
case
INT:
value
=
Integer
.
parseInt
(
ctx
.
attributeText
(
null
,
VALUE_NAME
,
null
));
break
;
case
FLOAT:
value
=
Float
.
parseFloat
(
ctx
.
attributeText
(
null
,
VALUE_NAME
,
null
));
break
;
case
STRING:
value
=
ctx
.
attributeText
(
null
,
VALUE_NAME
,
null
);
break
;
case
INSETS:
ctx
.
parsePastStartTag
(
null
,
ELEMENT_NAME
);
value
=
new
InsetsMapper
().
unmarshal
(
value
,
ctx
);
break
;
case
COLOR:
case
FONT:
ctx
.
parsePastStartTag
(
null
,
ELEMENT_NAME
);
value
=
ctx
.
unmarshalElement
();
break
;
case
DIMENSION:
ctx
.
parsePastStartTag
(
null
,
ELEMENT_NAME
);
value
=
new
DimensionMapper
().
unmarshal
(
value
,
ctx
);
break
;
case
BORDER:
ctx
.
parsePastStartTag
(
null
,
ELEMENT_NAME
);
value
=
new
BorderMapper
().
unmarshal
(
value
,
ctx
);
break
;
}
ctx
.
parsePastEndTag
(
null
,
ELEMENT_NAME
);
// create
return
new
UIProperty
(
name
,
type
,
value
);
}
}
src/share/classes/com/sun/beans/finder/BeanInfoFinder.java
浏览文件 @
04a8b4d8
...
...
@@ -52,8 +52,14 @@ public final class BeanInfoFinder
}
@Override
protected
BeanInfo
instantiate
(
Class
<?>
type
,
String
name
)
{
BeanInfo
info
=
super
.
instantiate
(
type
,
name
);
protected
BeanInfo
instantiate
(
Class
<?>
type
,
String
prefix
,
String
name
)
{
// this optimization will only use the BeanInfo search path
// if is has changed from the original
// or trying to get the ComponentBeanInfo
BeanInfo
info
=
!
DEFAULT
.
equals
(
prefix
)
||
"ComponentBeanInfo"
.
equals
(
name
)
?
super
.
instantiate
(
type
,
prefix
,
name
)
:
null
;
if
(
info
!=
null
)
{
// make sure that the returned BeanInfo matches the class
BeanDescriptor
bd
=
info
.
getBeanDescriptor
();
...
...
@@ -89,14 +95,4 @@ public final class BeanInfoFinder
}
return
null
;
}
@Override
protected
BeanInfo
instantiate
(
Class
<?>
type
,
String
prefix
,
String
name
)
{
// this optimization will only use the BeanInfo search path
// if is has changed from the original
// or trying to get the ComponentBeanInfo
return
!
DEFAULT
.
equals
(
prefix
)
||
"ComponentBeanInfo"
.
equals
(
name
)
?
super
.
instantiate
(
type
,
prefix
,
name
)
:
null
;
}
}
src/share/classes/com/sun/java/swing/plaf/windows/DesktopProperty.java
浏览文件 @
04a8b4d8
/*
* Copyright 2001-200
8
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2001-200
9
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
...
...
@@ -49,7 +49,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
/**
* ReferenceQueue of unreferenced WeakPCLs.
*/
private
static
ReferenceQueue
<
DesktopProperty
>
queue
;
private
static
final
ReferenceQueue
<
DesktopProperty
>
queue
=
new
ReferenceQueue
<
DesktopProperty
>()
;
/**
* PropertyChangeListener attached to the Toolkit.
...
...
@@ -58,7 +58,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
/**
* Key used to lookup value from desktop.
*/
private
String
key
;
private
final
String
key
;
/**
* Value to return.
*/
...
...
@@ -66,17 +66,8 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
/**
* Fallback value in case we get null from desktop.
*/
private
Object
fallback
;
private
final
Object
fallback
;
/**
* Toolkit.
*/
private
Toolkit
toolkit
;
static
{
queue
=
new
ReferenceQueue
<
DesktopProperty
>();
}
/**
* Cleans up any lingering state held by unrefeernced
...
...
@@ -138,13 +129,10 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
*
* @param key Key used in looking up desktop value.
* @param fallback Value used if desktop property is null.
* @param toolkit Toolkit used to fetch property from, can be null
* in which default will be used.
*/
public
DesktopProperty
(
String
key
,
Object
fallback
,
Toolkit
toolkit
)
{
public
DesktopProperty
(
String
key
,
Object
fallback
)
{
this
.
key
=
key
;
this
.
fallback
=
fallback
;
this
.
toolkit
=
toolkit
;
// The only sure fire way to clear our references is to create a
// Thread and wait for a reference to be added to the queue.
// Because it is so rare that you will actually change the look
...
...
@@ -175,13 +163,14 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
* Returns the value from the desktop.
*/
protected
Object
getValueFromDesktop
()
{
if
(
this
.
toolkit
==
null
)
{
this
.
toolkit
=
Toolkit
.
getDefaultToolkit
();
Toolkit
toolkit
=
Toolkit
.
getDefaultToolkit
();
if
(
pcl
==
null
)
{
pcl
=
new
WeakPCL
(
this
,
getKey
(),
UIManager
.
getLookAndFeel
());
toolkit
.
addPropertyChangeListener
(
getKey
(),
pcl
);
}
Object
value
=
toolkit
.
getDesktopProperty
(
getKey
());
pcl
=
new
WeakPCL
(
this
,
toolkit
,
getKey
(),
UIManager
.
getLookAndFeel
());
toolkit
.
addPropertyChangeListener
(
getKey
(),
pcl
);
return
value
;
return
toolkit
.
getDesktopProperty
(
getKey
());
}
/**
...
...
@@ -205,12 +194,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
* <code>createValue</code> will ask for the property again.
*/
public
void
invalidate
()
{
if
(
pcl
!=
null
)
{
toolkit
.
removePropertyChangeListener
(
getKey
(),
pcl
);
toolkit
=
null
;
pcl
=
null
;
value
=
null
;
}
value
=
null
;
}
/**
...
...
@@ -271,13 +255,11 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
*/
private
static
class
WeakPCL
extends
WeakReference
<
DesktopProperty
>
implements
PropertyChangeListener
{
private
Toolkit
kit
;
private
String
key
;
private
LookAndFeel
laf
;
WeakPCL
(
DesktopProperty
target
,
Toolkit
kit
,
String
key
,
LookAndFeel
laf
)
{
WeakPCL
(
DesktopProperty
target
,
String
key
,
LookAndFeel
laf
)
{
super
(
target
,
queue
);
this
.
kit
=
kit
;
this
.
key
=
key
;
this
.
laf
=
laf
;
}
...
...
@@ -297,7 +279,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
}
void
dispose
()
{
kit
.
removePropertyChangeListener
(
key
,
this
);
Toolkit
.
getDefaultToolkit
()
.
removePropertyChangeListener
(
key
,
this
);
}
}
}
src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java
浏览文件 @
04a8b4d8
/*
* Copyright 1997-200
8
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-200
9
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
...
...
@@ -43,7 +43,6 @@ import java.security.AccessController;
import
java.security.PrivilegedAction
;
import
sun.awt.shell.ShellFolder
;
import
sun.awt.OSInfo
;
import
sun.swing.*
;
import
javax.accessibility.*
;
...
...
@@ -58,8 +57,6 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
// The following are private because the implementation of the
// Windows FileChooser L&F is not complete yet.
private
static
final
OSInfo
.
WindowsVersion
OS_VERSION
=
OSInfo
.
getWindowsVersion
();
private
JPanel
centerPanel
;
private
JLabel
lookInLabel
;
...
...
@@ -118,18 +115,9 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
private
String
upFolderToolTipText
=
null
;
private
String
upFolderAccessibleName
=
null
;
private
String
homeFolderToolTipText
=
null
;
private
String
homeFolderAccessibleName
=
null
;
private
String
newFolderToolTipText
=
null
;
private
String
newFolderAccessibleName
=
null
;
private
String
listViewButtonToolTipText
=
null
;
private
String
listViewButtonAccessibleName
=
null
;
private
String
detailsViewButtonToolTipText
=
null
;
private
String
detailsViewButtonAccessibleName
=
null
;
private
String
viewMenuButtonToolTipText
=
null
;
private
String
viewMenuButtonAccessibleName
=
null
;
...
...
@@ -231,9 +219,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
// Directory manipulation buttons
JToolBar
topPanel
=
new
JToolBar
();
topPanel
.
setFloatable
(
false
);
if
(
OS_VERSION
.
compareTo
(
OSInfo
.
WINDOWS_ME
)
>=
0
)
{
topPanel
.
putClientProperty
(
"JToolBar.isRollover"
,
Boolean
.
TRUE
);
}
topPanel
.
putClientProperty
(
"JToolBar.isRollover"
,
Boolean
.
TRUE
);
// Add the top panel to the fileChooser
fc
.
add
(
topPanel
,
BorderLayout
.
NORTH
);
...
...
@@ -287,218 +273,103 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
topPanel
.
add
(
Box
.
createRigidArea
(
hstrut10
));
// Up Button
JButton
upFolderButton
=
new
JButton
(
getChangeToParentDirectoryAction
());
upFolderButton
.
setText
(
null
);
upFolderButton
.
setIcon
(
upFolderIcon
);
upFolderButton
.
setToolTipText
(
upFolderToolTipText
);
upFolderButton
.
putClientProperty
(
AccessibleContext
.
ACCESSIBLE_NAME_PROPERTY
,
upFolderAccessibleName
);
upFolderButton
.
putClientProperty
(
WindowsLookAndFeel
.
HI_RES_DISABLED_ICON_CLIENT_KEY
,
Boolean
.
TRUE
);
upFolderButton
.
setAlignmentX
(
JComponent
.
LEFT_ALIGNMENT
);
upFolderButton
.
setAlignmentY
(
JComponent
.
CENTER_ALIGNMENT
);
upFolderButton
.
setMargin
(
shrinkwrap
);
upFolderButton
.
setFocusPainted
(
false
);
JButton
upFolderButton
=
createToolButton
(
getChangeToParentDirectoryAction
(),
upFolderIcon
,
upFolderToolTipText
,
upFolderAccessibleName
);
topPanel
.
add
(
upFolderButton
);
if
(
OS_VERSION
.
compareTo
(
OSInfo
.
WINDOWS_ME
)
<
0
)
{
topPanel
.
add
(
Box
.
createRigidArea
(
hstrut10
));
}
JButton
b
;
if
(
OS_VERSION
==
OSInfo
.
WINDOWS_98
)
{
// Desktop Button
File
homeDir
=
fsv
.
getHomeDirectory
();
String
toolTipText
=
homeFolderToolTipText
;
if
(
fsv
.
isRoot
(
homeDir
))
{
toolTipText
=
getFileView
(
fc
).
getName
(
homeDir
);
// Probably "Desktop".
}
b
=
new
JButton
(
getFileView
(
fc
).
getIcon
(
homeDir
));
b
.
setToolTipText
(
toolTipText
);
b
.
putClientProperty
(
AccessibleContext
.
ACCESSIBLE_NAME_PROPERTY
,
toolTipText
);
b
.
setAlignmentX
(
JComponent
.
LEFT_ALIGNMENT
);
b
.
setAlignmentY
(
JComponent
.
CENTER_ALIGNMENT
);
b
.
setMargin
(
shrinkwrap
);
b
.
setFocusPainted
(
false
);
b
.
addActionListener
(
getGoHomeAction
());
topPanel
.
add
(
b
);
topPanel
.
add
(
Box
.
createRigidArea
(
hstrut10
));
}
// New Directory Button
if
(!
UIManager
.
getBoolean
(
"FileChooser.readOnly"
))
{
b
=
new
JButton
(
filePane
.
getNewFolderAction
());
b
.
setText
(
null
);
b
.
setIcon
(
newFolderIcon
);
b
.
setToolTipText
(
newFolderToolTipText
);
b
.
putClientProperty
(
AccessibleContext
.
ACCESSIBLE_NAME_PROPERTY
,
newFolderAccessibleName
);
b
.
putClientProperty
(
WindowsLookAndFeel
.
HI_RES_DISABLED_ICON_CLIENT_KEY
,
Boolean
.
TRUE
);
b
.
setAlignmentX
(
JComponent
.
LEFT_ALIGNMENT
);
b
.
setAlignmentY
(
JComponent
.
CENTER_ALIGNMENT
);
b
.
setMargin
(
shrinkwrap
);
b
.
setFocusPainted
(
false
);
topPanel
.
add
(
b
);
JButton
newFolderButton
=
createToolButton
(
filePane
.
getNewFolderAction
(),
newFolderIcon
,
newFolderToolTipText
,
newFolderAccessibleName
);
topPanel
.
add
(
newFolderButton
);
}
if
(
OS_VERSION
.
compareTo
(
OSInfo
.
WINDOWS_ME
)
<
0
)
{
topPanel
.
add
(
Box
.
createRigidArea
(
hstrut10
));
// View button group
ButtonGroup
viewButtonGroup
=
new
ButtonGroup
();
// List Button
final
JToggleButton
listViewButton
=
new
JToggleButton
(
listViewIcon
);
listViewButton
.
setToolTipText
(
listViewButtonToolTipText
);
listViewButton
.
putClientProperty
(
AccessibleContext
.
ACCESSIBLE_NAME_PROPERTY
,
listViewButtonAccessibleName
);
listViewButton
.
putClientProperty
(
WindowsLookAndFeel
.
HI_RES_DISABLED_ICON_CLIENT_KEY
,
Boolean
.
TRUE
);
listViewButton
.
setFocusPainted
(
false
);
listViewButton
.
setSelected
(
true
);
listViewButton
.
setAlignmentX
(
JComponent
.
LEFT_ALIGNMENT
);
listViewButton
.
setAlignmentY
(
JComponent
.
CENTER_ALIGNMENT
);
listViewButton
.
setMargin
(
shrinkwrap
);
listViewButton
.
addActionListener
(
filePane
.
getViewTypeAction
(
FilePane
.
VIEWTYPE_LIST
));
topPanel
.
add
(
listViewButton
);
viewButtonGroup
.
add
(
listViewButton
);
// Details Button
final
JToggleButton
detailsViewButton
=
new
JToggleButton
(
detailsViewIcon
);
detailsViewButton
.
setToolTipText
(
detailsViewButtonToolTipText
);
detailsViewButton
.
putClientProperty
(
AccessibleContext
.
ACCESSIBLE_NAME_PROPERTY
,
detailsViewButtonAccessibleName
);
detailsViewButton
.
putClientProperty
(
WindowsLookAndFeel
.
HI_RES_DISABLED_ICON_CLIENT_KEY
,
Boolean
.
TRUE
);
detailsViewButton
.
setFocusPainted
(
false
);
detailsViewButton
.
setAlignmentX
(
JComponent
.
LEFT_ALIGNMENT
);
detailsViewButton
.
setAlignmentY
(
JComponent
.
CENTER_ALIGNMENT
);
detailsViewButton
.
setMargin
(
shrinkwrap
);
detailsViewButton
.
addActionListener
(
filePane
.
getViewTypeAction
(
FilePane
.
VIEWTYPE_DETAILS
));
topPanel
.
add
(
detailsViewButton
);
viewButtonGroup
.
add
(
detailsViewButton
);
topPanel
.
add
(
Box
.
createRigidArea
(
new
Dimension
(
60
,
0
)));
filePane
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
if
(
"viewType"
.
equals
(
e
.
getPropertyName
()))
{
int
viewType
=
filePane
.
getViewType
();
switch
(
viewType
)
{
case
FilePane
.
VIEWTYPE_LIST
:
listViewButton
.
setSelected
(
true
);
break
;
case
FilePane
.
VIEWTYPE_DETAILS
:
detailsViewButton
.
setSelected
(
true
);
break
;
}
}
// View button group
ButtonGroup
viewButtonGroup
=
new
ButtonGroup
();
// Popup Menu
final
JPopupMenu
viewTypePopupMenu
=
new
JPopupMenu
();
final
JRadioButtonMenuItem
listViewMenuItem
=
new
JRadioButtonMenuItem
(
filePane
.
getViewTypeAction
(
FilePane
.
VIEWTYPE_LIST
));
listViewMenuItem
.
setSelected
(
filePane
.
getViewType
()
==
FilePane
.
VIEWTYPE_LIST
);
viewTypePopupMenu
.
add
(
listViewMenuItem
);
viewButtonGroup
.
add
(
listViewMenuItem
);
final
JRadioButtonMenuItem
detailsViewMenuItem
=
new
JRadioButtonMenuItem
(
filePane
.
getViewTypeAction
(
FilePane
.
VIEWTYPE_DETAILS
));
detailsViewMenuItem
.
setSelected
(
filePane
.
getViewType
()
==
FilePane
.
VIEWTYPE_DETAILS
);
viewTypePopupMenu
.
add
(
detailsViewMenuItem
);
viewButtonGroup
.
add
(
detailsViewMenuItem
);
// Create icon for viewMenuButton
BufferedImage
image
=
new
BufferedImage
(
viewMenuIcon
.
getIconWidth
()
+
7
,
viewMenuIcon
.
getIconHeight
(),
BufferedImage
.
TYPE_INT_ARGB
);
Graphics
graphics
=
image
.
getGraphics
();
viewMenuIcon
.
paintIcon
(
filePane
,
graphics
,
0
,
0
);
int
x
=
image
.
getWidth
()
-
5
;
int
y
=
image
.
getHeight
()
/
2
-
1
;
graphics
.
setColor
(
Color
.
BLACK
);
graphics
.
fillPolygon
(
new
int
[]{
x
,
x
+
5
,
x
+
2
},
new
int
[]{
y
,
y
,
y
+
3
},
3
);
// Details Button
final
JButton
viewMenuButton
=
createToolButton
(
null
,
new
ImageIcon
(
image
),
viewMenuButtonToolTipText
,
viewMenuButtonAccessibleName
);
viewMenuButton
.
addMouseListener
(
new
MouseAdapter
()
{
public
void
mousePressed
(
MouseEvent
e
)
{
if
(
SwingUtilities
.
isLeftMouseButton
(
e
)
&&
!
viewMenuButton
.
isSelected
())
{
viewMenuButton
.
setSelected
(
true
);
viewTypePopupMenu
.
show
(
viewMenuButton
,
0
,
viewMenuButton
.
getHeight
());
}
});
}
else
{
// After Windows Me
// View button group
ButtonGroup
viewButtonGroup
=
new
ButtonGroup
();
// Popup Menu
final
JPopupMenu
viewTypePopupMenu
=
new
JPopupMenu
();
final
JRadioButtonMenuItem
listViewMenuItem
=
new
JRadioButtonMenuItem
(
filePane
.
getViewTypeAction
(
FilePane
.
VIEWTYPE_LIST
));
listViewMenuItem
.
setSelected
(
filePane
.
getViewType
()
==
FilePane
.
VIEWTYPE_LIST
);
viewTypePopupMenu
.
add
(
listViewMenuItem
);
viewButtonGroup
.
add
(
listViewMenuItem
);
final
JRadioButtonMenuItem
detailsViewMenuItem
=
new
JRadioButtonMenuItem
(
filePane
.
getViewTypeAction
(
FilePane
.
VIEWTYPE_DETAILS
));
detailsViewMenuItem
.
setSelected
(
filePane
.
getViewType
()
==
FilePane
.
VIEWTYPE_DETAILS
);
viewTypePopupMenu
.
add
(
detailsViewMenuItem
);
viewButtonGroup
.
add
(
detailsViewMenuItem
);
// Create icon for viewMenuButton
BufferedImage
image
=
new
BufferedImage
(
viewMenuIcon
.
getIconWidth
()
+
7
,
viewMenuIcon
.
getIconHeight
(),
BufferedImage
.
TYPE_INT_ARGB
);
Graphics
graphics
=
image
.
getGraphics
();
viewMenuIcon
.
paintIcon
(
filePane
,
graphics
,
0
,
0
);
int
x
=
image
.
getWidth
()
-
5
;
int
y
=
image
.
getHeight
()
/
2
-
1
;
graphics
.
setColor
(
Color
.
BLACK
);
graphics
.
fillPolygon
(
new
int
[]{
x
,
x
+
5
,
x
+
2
},
new
int
[]{
y
,
y
,
y
+
3
},
3
);
// Details Button
final
JButton
viewMenuButton
=
new
JButton
(
new
ImageIcon
(
image
));
viewMenuButton
.
setToolTipText
(
viewMenuButtonToolTipText
);
viewMenuButton
.
putClientProperty
(
AccessibleContext
.
ACCESSIBLE_NAME_PROPERTY
,
viewMenuButtonAccessibleName
);
viewMenuButton
.
putClientProperty
(
WindowsLookAndFeel
.
HI_RES_DISABLED_ICON_CLIENT_KEY
,
Boolean
.
TRUE
);
viewMenuButton
.
setFocusable
(
false
);
viewMenuButton
.
setAlignmentX
(
JComponent
.
LEFT_ALIGNMENT
);
viewMenuButton
.
setAlignmentY
(
JComponent
.
CENTER_ALIGNMENT
);
viewMenuButton
.
setMargin
(
shrinkwrap
);
viewMenuButton
.
setModel
(
new
DefaultButtonModel
()
{
public
void
setPressed
(
boolean
b
)
{
}
});
viewMenuButton
.
addKeyListener
(
new
KeyAdapter
()
{
public
void
keyPressed
(
KeyEvent
e
)
{
// Forbid keyboard actions if the button is not in rollover state
if
(
e
.
getKeyCode
()
==
KeyEvent
.
VK_SPACE
&&
viewMenuButton
.
getModel
().
isRollover
())
{
viewMenuButton
.
setSelected
(
true
);
viewTypePopupMenu
.
show
(
viewMenuButton
,
0
,
viewMenuButton
.
getHeight
());
}
}
});
viewTypePopupMenu
.
addPopupMenuListener
(
new
PopupMenuListener
()
{
public
void
popupMenuWillBecomeVisible
(
PopupMenuEvent
e
)
{
}
public
void
setArmed
(
boolean
b
)
{
}
public
void
popupMenuWillBecomeInvisible
(
PopupMenuEvent
e
)
{
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
public
void
run
()
{
viewMenuButton
.
setSelected
(
false
);
}
});
}
public
void
setSelected
(
boolean
b
)
{
super
.
setSelected
(
b
);
public
void
popupMenuCanceled
(
PopupMenuEvent
e
)
{
}
});
if
(
b
)
{
stateMask
|=
PRESSED
|
ARMED
;
}
else
{
stateMask
&=
~(
PRESSED
|
ARMED
);
}
}
});
viewMenuButton
.
addMouseListener
(
new
MouseAdapter
()
{
public
void
mousePressed
(
MouseEvent
e
)
{
if
(
SwingUtilities
.
isLeftMouseButton
(
e
))
{
viewMenuButton
.
setSelected
(!
viewMenuButton
.
isSelected
());
if
(
viewMenuButton
.
isSelected
())
{
viewTypePopupMenu
.
show
(
viewMenuButton
,
0
,
viewMenuButton
.
getHeight
());
}
}
}
});
viewTypePopupMenu
.
addPopupMenuListener
(
new
PopupMenuListener
()
{
public
void
popupMenuWillBecomeVisible
(
PopupMenuEvent
e
)
{
}
topPanel
.
add
(
viewMenuButton
);
public
void
popupMenuWillBecomeInvisible
(
PopupMenuEvent
e
)
{
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
public
void
run
()
{
viewMenuButton
.
setSelected
(
false
);
}
});
}
topPanel
.
add
(
Box
.
createRigidArea
(
new
Dimension
(
80
,
0
)));
public
void
popupMenuCanceled
(
PopupMenuEvent
e
)
{
}
});
topPanel
.
add
(
viewMenuButton
);
topPanel
.
add
(
Box
.
createRigidArea
(
new
Dimension
(
80
,
0
)));
filePane
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
if
(
"viewType"
.
equals
(
e
.
getPropertyName
()))
{
switch
(
filePane
.
getViewType
())
{
case
FilePane
.
VIEWTYPE_LIST
:
listViewMenuItem
.
setSelected
(
true
);
break
;
case
FilePane
.
VIEWTYPE_DETAILS
:
detailsViewMenuItem
.
setSelected
(
true
);
break
;
}
filePane
.
addPropertyChangeListener
(
new
PropertyChangeListener
()
{
public
void
propertyChange
(
PropertyChangeEvent
e
)
{
if
(
"viewType"
.
equals
(
e
.
getPropertyName
()))
{
switch
(
filePane
.
getViewType
())
{
case
FilePane
.
VIEWTYPE_LIST
:
listViewMenuItem
.
setSelected
(
true
);
break
;
case
FilePane
.
VIEWTYPE_DETAILS
:
detailsViewMenuItem
.
setSelected
(
true
);
break
;
}
}
}
);
}
}
}
);
// ************************************** //
// ******* Add the directory pane ******* //
...
...
@@ -622,19 +493,18 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
// Decide whether to use the ShellFolder class to populate shortcut
// panel and combobox.
JFileChooser
fc
=
getFileChooser
();
if
(
OS_VERSION
.
compareTo
(
OSInfo
.
WINDOWS_ME
)
>=
0
)
{
if
(
FilePane
.
usesShellFolder
(
fc
))
{
if
(
placesBar
==
null
&&
!
UIManager
.
getBoolean
(
"FileChooser.noPlacesBar"
))
{
placesBar
=
new
WindowsPlacesBar
(
fc
,
XPStyle
.
getXP
()
!=
null
);
fc
.
add
(
placesBar
,
BorderLayout
.
BEFORE_LINE_BEGINS
);
fc
.
addPropertyChangeListener
(
placesBar
);
}
}
else
{
if
(
placesBar
!=
null
)
{
fc
.
remove
(
placesBar
);
fc
.
removePropertyChangeListener
(
placesBar
);
placesBar
=
null
;
}
if
(
FilePane
.
usesShellFolder
(
fc
))
{
if
(
placesBar
==
null
&&
!
UIManager
.
getBoolean
(
"FileChooser.noPlacesBar"
))
{
placesBar
=
new
WindowsPlacesBar
(
fc
,
XPStyle
.
getXP
()
!=
null
);
fc
.
add
(
placesBar
,
BorderLayout
.
BEFORE_LINE_BEGINS
);
fc
.
addPropertyChangeListener
(
placesBar
);
}
}
else
{
if
(
placesBar
!=
null
)
{
fc
.
remove
(
placesBar
);
fc
.
removePropertyChangeListener
(
placesBar
);
placesBar
=
null
;
}
}
}
...
...
@@ -673,18 +543,9 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
upFolderToolTipText
=
UIManager
.
getString
(
"FileChooser.upFolderToolTipText"
,
l
);
upFolderAccessibleName
=
UIManager
.
getString
(
"FileChooser.upFolderAccessibleName"
,
l
);
homeFolderToolTipText
=
UIManager
.
getString
(
"FileChooser.homeFolderToolTipText"
,
l
);
homeFolderAccessibleName
=
UIManager
.
getString
(
"FileChooser.homeFolderAccessibleName"
,
l
);
newFolderToolTipText
=
UIManager
.
getString
(
"FileChooser.newFolderToolTipText"
,
l
);
newFolderAccessibleName
=
UIManager
.
getString
(
"FileChooser.newFolderAccessibleName"
,
l
);
listViewButtonToolTipText
=
UIManager
.
getString
(
"FileChooser.listViewButtonToolTipText"
,
l
);
listViewButtonAccessibleName
=
UIManager
.
getString
(
"FileChooser.listViewButtonAccessibleName"
,
l
);
detailsViewButtonToolTipText
=
UIManager
.
getString
(
"FileChooser.detailsViewButtonToolTipText"
,
l
);
detailsViewButtonAccessibleName
=
UIManager
.
getString
(
"FileChooser.detailsViewButtonAccessibleName"
,
l
);
viewMenuButtonToolTipText
=
UIManager
.
getString
(
"FileChooser.viewMenuButtonToolTipText"
,
l
);
viewMenuButtonAccessibleName
=
UIManager
.
getString
(
"FileChooser.viewMenuButtonAccessibleName"
,
l
);
}
...
...
@@ -1052,6 +913,65 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
return
new
DirectoryComboBoxRenderer
();
}
private
static
JButton
createToolButton
(
Action
a
,
Icon
defaultIcon
,
String
toolTipText
,
String
accessibleName
)
{
final
JButton
result
=
new
JButton
(
a
);
result
.
setText
(
null
);
result
.
setIcon
(
defaultIcon
);
result
.
setToolTipText
(
toolTipText
);
result
.
setRequestFocusEnabled
(
false
);
result
.
putClientProperty
(
AccessibleContext
.
ACCESSIBLE_NAME_PROPERTY
,
accessibleName
);
result
.
putClientProperty
(
WindowsLookAndFeel
.
HI_RES_DISABLED_ICON_CLIENT_KEY
,
Boolean
.
TRUE
);
result
.
setAlignmentX
(
JComponent
.
LEFT_ALIGNMENT
);
result
.
setAlignmentY
(
JComponent
.
CENTER_ALIGNMENT
);
result
.
setMargin
(
shrinkwrap
);
result
.
setFocusPainted
(
false
);
result
.
setModel
(
new
DefaultButtonModel
()
{
public
void
setPressed
(
boolean
b
)
{
// Forbid keyboard actions if the button is not in rollover state
if
(!
b
||
isRollover
())
{
super
.
setPressed
(
b
);
}
}
public
void
setRollover
(
boolean
b
)
{
if
(
b
&&
!
isRollover
())
{
// Reset other buttons
for
(
Component
component
:
result
.
getParent
().
getComponents
())
{
if
(
component
instanceof
JButton
&&
component
!=
result
)
{
((
JButton
)
component
).
getModel
().
setRollover
(
false
);
}
}
}
super
.
setRollover
(
b
);
}
public
void
setSelected
(
boolean
b
)
{
super
.
setSelected
(
b
);
if
(
b
)
{
stateMask
|=
PRESSED
|
ARMED
;
}
else
{
stateMask
&=
~(
PRESSED
|
ARMED
);
}
}
});
result
.
addFocusListener
(
new
FocusAdapter
()
{
public
void
focusGained
(
FocusEvent
e
)
{
result
.
getModel
().
setRollover
(
true
);
}
public
void
focusLost
(
FocusEvent
e
)
{
result
.
getModel
().
setRollover
(
false
);
}
});
return
result
;
}
//
// Renderer for DirectoryComboBox
//
...
...
src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
浏览文件 @
04a8b4d8
/*
* Copyright 1997-200
8
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1997-200
9
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
...
...
@@ -104,7 +104,6 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
new
StringUIClientPropertyKey
(
"WindowsLookAndFeel.generateHiResDisabledIcon"
);
private
Toolkit
toolkit
;
private
boolean
updatePending
=
false
;
private
boolean
useSystemFontSettings
=
true
;
...
...
@@ -149,7 +148,6 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
public
void
initialize
()
{
super
.
initialize
();
toolkit
=
Toolkit
.
getDefaultToolkit
();
// Set the flag which determines which version of Windows should
// be rendered. This flag only need to be set once.
...
...
@@ -470,80 +468,61 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
Object
ControlBackgroundColor
=
new
DesktopProperty
(
"win.3d.backgroundColor"
,
table
.
get
(
"control"
),
toolkit
);
table
.
get
(
"control"
));
Object
ControlLightColor
=
new
DesktopProperty
(
"win.3d.lightColor"
,
table
.
get
(
"controlHighlight"
),
toolkit
);
table
.
get
(
"controlHighlight"
));
Object
ControlHighlightColor
=
new
DesktopProperty
(
"win.3d.highlightColor"
,
table
.
get
(
"controlLtHighlight"
),
toolkit
);
table
.
get
(
"controlLtHighlight"
));
Object
ControlShadowColor
=
new
DesktopProperty
(
"win.3d.shadowColor"
,
table
.
get
(
"controlShadow"
),
toolkit
);
table
.
get
(
"controlShadow"
));
Object
ControlDarkShadowColor
=
new
DesktopProperty
(
"win.3d.darkShadowColor"
,
table
.
get
(
"controlDkShadow"
),
toolkit
);
table
.
get
(
"controlDkShadow"
));
Object
ControlTextColor
=
new
DesktopProperty
(
"win.button.textColor"
,
table
.
get
(
"controlText"
),
toolkit
);
table
.
get
(
"controlText"
));
Object
MenuBackgroundColor
=
new
DesktopProperty
(
"win.menu.backgroundColor"
,
table
.
get
(
"menu"
),
toolkit
);
table
.
get
(
"menu"
));
Object
MenuBarBackgroundColor
=
new
DesktopProperty
(
"win.menubar.backgroundColor"
,
table
.
get
(
"menu"
),
toolkit
);
table
.
get
(
"menu"
));
Object
MenuTextColor
=
new
DesktopProperty
(
"win.menu.textColor"
,
table
.
get
(
"menuText"
),
toolkit
);
table
.
get
(
"menuText"
));
Object
SelectionBackgroundColor
=
new
DesktopProperty
(
"win.item.highlightColor"
,
table
.
get
(
"textHighlight"
),
toolkit
);
table
.
get
(
"textHighlight"
));
Object
SelectionTextColor
=
new
DesktopProperty
(
"win.item.highlightTextColor"
,
table
.
get
(
"textHighlightText"
),
toolkit
);
table
.
get
(
"textHighlightText"
));
Object
WindowBackgroundColor
=
new
DesktopProperty
(
"win.frame.backgroundColor"
,
table
.
get
(
"window"
),
toolkit
);
table
.
get
(
"window"
));
Object
WindowTextColor
=
new
DesktopProperty
(
"win.frame.textColor"
,
table
.
get
(
"windowText"
),
toolkit
);
table
.
get
(
"windowText"
));
Object
WindowBorderWidth
=
new
DesktopProperty
(
"win.frame.sizingBorderWidth"
,
Integer
.
valueOf
(
1
),
toolkit
);
Integer
.
valueOf
(
1
));
Object
TitlePaneHeight
=
new
DesktopProperty
(
"win.frame.captionHeight"
,
Integer
.
valueOf
(
18
),
toolkit
);
Integer
.
valueOf
(
18
));
Object
TitleButtonWidth
=
new
DesktopProperty
(
"win.frame.captionButtonWidth"
,
Integer
.
valueOf
(
16
),
toolkit
);
Integer
.
valueOf
(
16
));
Object
TitleButtonHeight
=
new
DesktopProperty
(
"win.frame.captionButtonHeight"
,
Integer
.
valueOf
(
16
),
toolkit
);
Integer
.
valueOf
(
16
));
Object
InactiveTextColor
=
new
DesktopProperty
(
"win.text.grayedTextColor"
,
table
.
get
(
"textInactiveText"
),
toolkit
);
table
.
get
(
"textInactiveText"
));
Object
ScrollbarBackgroundColor
=
new
DesktopProperty
(
"win.scrollbar.backgroundColor"
,
table
.
get
(
"scrollbar"
),
toolkit
);
table
.
get
(
"scrollbar"
));
Object
TextBackground
=
new
XPColorValue
(
Part
.
EP_EDIT
,
null
,
Prop
.
FILLCOLOR
,
WindowBackgroundColor
);
...
...
@@ -566,32 +545,22 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
Object
ToolTipFont
=
sansSerifPlain12
;
Object
IconFont
=
ControlFont
;
Object
scrollBarWidth
=
new
DesktopProperty
(
"win.scrollbar.width"
,
Integer
.
valueOf
(
16
),
toolkit
);
Object
scrollBarWidth
=
new
DesktopProperty
(
"win.scrollbar.width"
,
Integer
.
valueOf
(
16
));
Object
menuBarHeight
=
new
DesktopProperty
(
"win.menu.height"
,
null
,
toolkit
);
Object
menuBarHeight
=
new
DesktopProperty
(
"win.menu.height"
,
null
);
Object
hotTrackingOn
=
new
DesktopProperty
(
"win.item.hotTrackingOn"
,
true
,
toolkit
);
Object
hotTrackingOn
=
new
DesktopProperty
(
"win.item.hotTrackingOn"
,
true
);
Object
showMnemonics
=
new
DesktopProperty
(
"win.menu.keyboardCuesOn"
,
Boolean
.
TRUE
,
toolkit
);
Object
showMnemonics
=
new
DesktopProperty
(
"win.menu.keyboardCuesOn"
,
Boolean
.
TRUE
);
if
(
useSystemFontSettings
)
{
MenuFont
=
getDesktopFontValue
(
"win.menu.font"
,
MenuFont
,
toolkit
);
FixedControlFont
=
getDesktopFontValue
(
"win.ansiFixed.font"
,
FixedControlFont
,
toolkit
);
ControlFont
=
getDesktopFontValue
(
"win.defaultGUI.font"
,
ControlFont
,
toolkit
);
MessageFont
=
getDesktopFontValue
(
"win.messagebox.font"
,
MessageFont
,
toolkit
);
WindowFont
=
getDesktopFontValue
(
"win.frame.captionFont"
,
WindowFont
,
toolkit
);
IconFont
=
getDesktopFontValue
(
"win.icon.font"
,
IconFont
,
toolkit
);
ToolTipFont
=
getDesktopFontValue
(
"win.tooltip.font"
,
ToolTipFont
,
toolkit
);
MenuFont
=
getDesktopFontValue
(
"win.menu.font"
,
MenuFont
);
FixedControlFont
=
getDesktopFontValue
(
"win.ansiFixed.font"
,
FixedControlFont
);
ControlFont
=
getDesktopFontValue
(
"win.defaultGUI.font"
,
ControlFont
);
MessageFont
=
getDesktopFontValue
(
"win.messagebox.font"
,
MessageFont
);
WindowFont
=
getDesktopFontValue
(
"win.frame.captionFont"
,
WindowFont
);
IconFont
=
getDesktopFontValue
(
"win.icon.font"
,
IconFont
);
ToolTipFont
=
getDesktopFontValue
(
"win.tooltip.font"
,
ToolTipFont
);
/* Put the desktop AA settings in the defaults.
* JComponent.setUI() retrieves this and makes it available
...
...
@@ -605,26 +574,14 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
new
FontDesktopProperty
(
SunToolkit
.
DESKTOPFONTHINTS
);
}
if
(
useSystemFontSizeSettings
)
{
MenuFont
=
new
WindowsFontSizeProperty
(
"win.menu.font.height"
,
toolkit
,
Font
.
DIALOG
,
Font
.
PLAIN
,
12
);
FixedControlFont
=
new
WindowsFontSizeProperty
(
"win.ansiFixed.font.height"
,
toolkit
,
Font
.
MONOSPACED
,
MenuFont
=
new
WindowsFontSizeProperty
(
"win.menu.font.height"
,
Font
.
DIALOG
,
Font
.
PLAIN
,
12
);
FixedControlFont
=
new
WindowsFontSizeProperty
(
"win.ansiFixed.font.height"
,
Font
.
MONOSPACED
,
Font
.
PLAIN
,
12
);
ControlFont
=
new
WindowsFontSizeProperty
(
"win.defaultGUI.font.height"
,
toolkit
,
Font
.
DIALOG
,
Font
.
PLAIN
,
12
);
MessageFont
=
new
WindowsFontSizeProperty
(
"win.messagebox.font.height"
,
toolkit
,
Font
.
DIALOG
,
Font
.
PLAIN
,
12
);
WindowFont
=
new
WindowsFontSizeProperty
(
"win.frame.captionFont.height"
,
toolkit
,
Font
.
DIALOG
,
Font
.
BOLD
,
12
);
ToolTipFont
=
new
WindowsFontSizeProperty
(
"win.tooltip.font.height"
,
toolkit
,
Font
.
SANS_SERIF
,
Font
.
PLAIN
,
12
);
IconFont
=
new
WindowsFontSizeProperty
(
"win.icon.font.height"
,
toolkit
,
Font
.
DIALOG
,
Font
.
PLAIN
,
12
);
ControlFont
=
new
WindowsFontSizeProperty
(
"win.defaultGUI.font.height"
,
Font
.
DIALOG
,
Font
.
PLAIN
,
12
);
MessageFont
=
new
WindowsFontSizeProperty
(
"win.messagebox.font.height"
,
Font
.
DIALOG
,
Font
.
PLAIN
,
12
);
WindowFont
=
new
WindowsFontSizeProperty
(
"win.frame.captionFont.height"
,
Font
.
DIALOG
,
Font
.
BOLD
,
12
);
ToolTipFont
=
new
WindowsFontSizeProperty
(
"win.tooltip.font.height"
,
Font
.
SANS_SERIF
,
Font
.
PLAIN
,
12
);
IconFont
=
new
WindowsFontSizeProperty
(
"win.icon.font.height"
,
Font
.
DIALOG
,
Font
.
PLAIN
,
12
);
}
...
...
@@ -752,8 +709,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
// DeskTop.
"Desktop.background"
,
new
DesktopProperty
(
"win.desktop.backgroundColor"
,
table
.
get
(
"desktop"
),
toolkit
),
table
.
get
(
"desktop"
)),
"Desktop.ancestorInputMap"
,
new
UIDefaults
.
LazyInputMap
(
new
Object
[]
{
"ctrl F5"
,
"restore"
,
...
...
@@ -819,7 +775,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
"FileChooser.filesOfTypeLabelMnemonic"
,
Integer
.
valueOf
(
KeyEvent
.
VK_T
),
"FileChooser.usesSingleFilePane"
,
Boolean
.
TRUE
,
"FileChooser.noPlacesBar"
,
new
DesktopProperty
(
"win.comdlg.noPlacesBar"
,
Boolean
.
FALSE
,
toolkit
),
Boolean
.
FALSE
),
"FileChooser.ancestorInputMap"
,
new
UIDefaults
.
LazyInputMap
(
new
Object
[]
{
"ESCAPE"
,
"cancelSelection"
,
...
...
@@ -861,36 +817,28 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
"InternalFrame.resizeIconShadow"
,
ControlShadowColor
,
"InternalFrame.activeBorderColor"
,
new
DesktopProperty
(
"win.frame.activeBorderColor"
,
table
.
get
(
"windowBorder"
),
toolkit
),
table
.
get
(
"windowBorder"
)),
"InternalFrame.inactiveBorderColor"
,
new
DesktopProperty
(
"win.frame.inactiveBorderColor"
,
table
.
get
(
"windowBorder"
),
toolkit
),
table
.
get
(
"windowBorder"
)),
"InternalFrame.activeTitleBackground"
,
new
DesktopProperty
(
"win.frame.activeCaptionColor"
,
table
.
get
(
"activeCaption"
),
toolkit
),
table
.
get
(
"activeCaption"
)),
"InternalFrame.activeTitleGradient"
,
new
DesktopProperty
(
"win.frame.activeCaptionGradientColor"
,
table
.
get
(
"activeCaption"
),
toolkit
),
table
.
get
(
"activeCaption"
)),
"InternalFrame.activeTitleForeground"
,
new
DesktopProperty
(
"win.frame.captionTextColor"
,
table
.
get
(
"activeCaptionText"
),
toolkit
),
table
.
get
(
"activeCaptionText"
)),
"InternalFrame.inactiveTitleBackground"
,
new
DesktopProperty
(
"win.frame.inactiveCaptionColor"
,
table
.
get
(
"inactiveCaption"
),
toolkit
),
table
.
get
(
"inactiveCaption"
)),
"InternalFrame.inactiveTitleGradient"
,
new
DesktopProperty
(
"win.frame.inactiveCaptionGradientColor"
,
table
.
get
(
"inactiveCaption"
),
toolkit
),
table
.
get
(
"inactiveCaption"
)),
"InternalFrame.inactiveTitleForeground"
,
new
DesktopProperty
(
"win.frame.inactiveCaptionTextColor"
,
table
.
get
(
"inactiveCaptionText"
),
toolkit
),
table
.
get
(
"inactiveCaptionText"
)),
"InternalFrame.maximizeIcon"
,
WindowsIconFactory
.
createFrameMaximizeIcon
(),
...
...
@@ -1529,12 +1477,8 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
// *** ToolTip
"ToolTip.font"
,
ToolTipFont
,
"ToolTip.background"
,
new
DesktopProperty
(
"win.tooltip.backgroundColor"
,
table
.
get
(
"info"
),
toolkit
),
"ToolTip.foreground"
,
new
DesktopProperty
(
"win.tooltip.textColor"
,
table
.
get
(
"infoText"
),
toolkit
),
"ToolTip.background"
,
new
DesktopProperty
(
"win.tooltip.backgroundColor"
,
table
.
get
(
"info"
)),
"ToolTip.foreground"
,
new
DesktopProperty
(
"win.tooltip.textColor"
,
table
.
get
(
"infoText"
)),
// *** ToolTipManager
"ToolTipManager.enableToolTipMode"
,
"activeApplication"
,
...
...
@@ -1798,10 +1742,9 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
* represented in the current encoding this will return null and
* turn off the use of system fonts.
*/
private
Object
getDesktopFontValue
(
String
fontName
,
Object
backup
,
Toolkit
kit
)
{
private
Object
getDesktopFontValue
(
String
fontName
,
Object
backup
)
{
if
(
useSystemFontSettings
)
{
return
new
WindowsFontProperty
(
fontName
,
backup
,
kit
);
return
new
WindowsFontProperty
(
fontName
,
backup
);
}
return
null
;
}
...
...
@@ -1989,7 +1932,6 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
public
void
uninitialize
()
{
super
.
uninitialize
();
toolkit
=
null
;
if
(
WindowsPopupMenuUI
.
mnemonicListener
!=
null
)
{
MenuSelectionManager
.
defaultManager
().
...
...
@@ -2309,8 +2251,8 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
* is returned, it is mapped to 'Microsoft Sans Serif'.
*/
private
static
class
WindowsFontProperty
extends
DesktopProperty
{
WindowsFontProperty
(
String
key
,
Object
backup
,
Toolkit
kit
)
{
super
(
key
,
backup
,
kit
);
WindowsFontProperty
(
String
key
,
Object
backup
)
{
super
(
key
,
backup
);
}
public
void
invalidate
(
LookAndFeel
laf
)
{
...
...
@@ -2372,9 +2314,9 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
private
int
fontSize
;
private
int
fontStyle
;
WindowsFontSizeProperty
(
String
key
,
Toolkit
toolkit
,
String
fontName
,
WindowsFontSizeProperty
(
String
key
,
String
fontName
,
int
fontStyle
,
int
fontSize
)
{
super
(
key
,
null
,
toolkit
);
super
(
key
,
null
);
this
.
fontName
=
fontName
;
this
.
fontSize
=
fontSize
;
this
.
fontStyle
=
fontStyle
;
...
...
@@ -2508,7 +2450,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
private
class
TriggerDesktopProperty
extends
DesktopProperty
{
TriggerDesktopProperty
(
String
key
)
{
super
(
key
,
null
,
toolkit
);
super
(
key
,
null
);
// This call adds a property change listener for the property,
// which triggers a call to updateUI(). The value returned
// is not interesting here.
...
...
src/share/classes/java/util/SimpleTimeZone.java
浏览文件 @
04a8b4d8
...
...
@@ -1372,7 +1372,7 @@ public class SimpleTimeZone extends TimeZone {
throw
new
IllegalArgumentException
(
"Illegal start month "
+
startMonth
);
}
if
(
startTime
<
0
||
startTime
>
=
millisPerDay
)
{
if
(
startTime
<
0
||
startTime
>
millisPerDay
)
{
throw
new
IllegalArgumentException
(
"Illegal start time "
+
startTime
);
}
...
...
@@ -1419,7 +1419,7 @@ public class SimpleTimeZone extends TimeZone {
throw
new
IllegalArgumentException
(
"Illegal end month "
+
endMonth
);
}
if
(
endTime
<
0
||
endTime
>
=
millisPerDay
)
{
if
(
endTime
<
0
||
endTime
>
millisPerDay
)
{
throw
new
IllegalArgumentException
(
"Illegal end time "
+
endTime
);
}
...
...
src/share/classes/javax/swing/JEditorPane.java
浏览文件 @
04a8b4d8
...
...
@@ -24,6 +24,8 @@
*/
package
javax.swing
;
import
sun.swing.SwingUtilities2
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.lang.reflect.*
;
...
...
@@ -1123,6 +1125,7 @@ public class JEditorPane extends JTextComponent {
* @param content the content to replace the selection with. This
* value can be <code>null</code>
*/
@Override
public
void
replaceSelection
(
String
content
)
{
if
(!
isEditable
())
{
UIManager
.
getLookAndFeel
().
provideErrorFeedback
(
JEditorPane
.
this
);
...
...
@@ -1133,6 +1136,7 @@ public class JEditorPane extends JTextComponent {
try
{
Document
doc
=
getDocument
();
Caret
caret
=
getCaret
();
boolean
composedTextSaved
=
saveComposedText
(
caret
.
getDot
());
int
p0
=
Math
.
min
(
caret
.
getDot
(),
caret
.
getMark
());
int
p1
=
Math
.
max
(
caret
.
getDot
(),
caret
.
getMark
());
if
(
doc
instanceof
AbstractDocument
)
{
...
...
@@ -1148,6 +1152,9 @@ public class JEditorPane extends JTextComponent {
getInputAttributes
());
}
}
if
(
composedTextSaved
)
{
restoreComposedText
();
}
}
catch
(
BadLocationException
e
)
{
UIManager
.
getLookAndFeel
().
provideErrorFeedback
(
JEditorPane
.
this
);
}
...
...
@@ -1323,8 +1330,8 @@ public class JEditorPane extends JTextComponent {
*/
public
Dimension
getPreferredSize
()
{
Dimension
d
=
super
.
getPreferredSize
();
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
(
JViewport
)
getParent
();
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
port
!=
null
)
{
TextUI
ui
=
getUI
();
int
prefWidth
=
d
.
width
;
int
prefHeight
=
d
.
height
;
...
...
@@ -1445,8 +1452,8 @@ public class JEditorPane extends JTextComponent {
* match its own, false otherwise
*/
public
boolean
getScrollableTracksViewportWidth
()
{
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
(
JViewport
)
getParent
();
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
port
!=
null
)
{
TextUI
ui
=
getUI
();
int
w
=
port
.
getWidth
();
Dimension
min
=
ui
.
getMinimumSize
(
this
);
...
...
@@ -1467,8 +1474,8 @@ public class JEditorPane extends JTextComponent {
* false otherwise
*/
public
boolean
getScrollableTracksViewportHeight
()
{
if
(
getParent
()
instanceof
JViewport
)
{
JViewport
port
=
(
JViewport
)
getParent
();
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
port
!=
null
)
{
TextUI
ui
=
getUI
();
int
h
=
port
.
getHeight
();
Dimension
min
=
ui
.
getMinimumSize
(
this
);
...
...
src/share/classes/javax/swing/JLayer.java
浏览文件 @
04a8b4d8
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
* 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
javax.swing
;
...
...
@@ -158,7 +178,7 @@ public final class JLayer<V extends Component>
* @return the {@code JLayer}'s view component
* or {@code null} if none exists
*
* @see #setView(
V
)
* @see #setView(
Component
)
*/
public
V
getView
()
{
return
view
;
...
...
@@ -259,7 +279,7 @@ public final class JLayer<V extends Component>
* @throws UnsupportedOperationException this method is not supported
*
* @see #setView(Component)
* @see #setGlassPane(
Component
)
* @see #setGlassPane(
JPanel
)
*/
protected
void
addImpl
(
Component
comp
,
Object
constraints
,
int
index
)
{
throw
new
UnsupportedOperationException
(
...
...
@@ -319,7 +339,7 @@ public final class JLayer<V extends Component>
* @return false if {@code JLayer}'s {@code glassPane} is visible
*/
public
boolean
isOptimizedDrawingEnabled
()
{
return
!
glassPane
.
isVisible
();
return
glassPane
==
null
||
!
glassPane
.
isVisible
();
}
/**
...
...
@@ -388,7 +408,10 @@ public final class JLayer<V extends Component>
if
(
layerEventMask
!=
oldEventMask
)
{
disableEvents
(
oldEventMask
);
enableEvents
(
eventMask
);
eventController
.
updateAWTEventListener
(
this
);
if
(
isDisplayable
())
{
eventController
.
updateAWTEventListener
(
oldEventMask
,
layerEventMask
);
}
}
}
...
...
@@ -475,9 +498,6 @@ public final class JLayer<V extends Component>
if
(
getUI
()
!=
null
)
{
return
getUI
().
getScrollableTracksViewportHeight
(
this
);
}
if
(
getParent
()
instanceof
JViewport
)
{
return
((
getParent
()).
getHeight
()
>
getPreferredSize
().
height
);
}
return
false
;
}
...
...
@@ -498,9 +518,6 @@ public final class JLayer<V extends Component>
if
(
getUI
()
!=
null
)
{
return
getUI
().
getScrollableTracksViewportWidth
(
this
);
}
if
(
getParent
()
instanceof
JViewport
)
{
return
((
getParent
()).
getWidth
()
>
getPreferredSize
().
width
);
}
return
false
;
}
...
...
@@ -535,20 +552,36 @@ public final class JLayer<V extends Component>
private
void
readObject
(
ObjectInputStream
s
)
throws
IOException
,
ClassNotFoundException
{
s
.
defaultReadObject
();
if
(
getUI
()
!=
null
)
{
setUI
(
getUI
()
);
if
(
layerUI
!=
null
)
{
setUI
(
layerUI
);
}
if
(
getLayerEventMask
()
!=
0
)
{
eventController
.
updateAWTEventListener
(
this
);
if
(
eventMask
!=
0
)
{
eventController
.
updateAWTEventListener
(
0
,
eventMask
);
}
}
/**
* {@inheritDoc}
*/
public
void
addNotify
()
{
super
.
addNotify
();
eventController
.
updateAWTEventListener
(
0
,
eventMask
);
}
/**
* {@inheritDoc}
*/
public
void
removeNotify
()
{
super
.
removeNotify
();
eventController
.
updateAWTEventListener
(
eventMask
,
0
);
}
/**
* static AWTEventListener to be shared with all AbstractLayerUIs
*/
private
static
class
LayerEventController
implements
AWTEventListener
{
private
ArrayList
<
WeakReference
<
JLayer
>>
layer
List
=
new
ArrayList
<
WeakReference
<
JLayer
>
>();
private
ArrayList
<
Long
>
layerMask
List
=
new
ArrayList
<
Long
>();
private
long
currentEventMask
;
...
...
@@ -572,37 +605,24 @@ public final class JLayer<V extends Component>
}
}
private
boolean
layerListContains
(
JLayer
l
)
{
for
(
WeakReference
<
JLayer
>
layerWeakReference
:
layerList
)
{
if
(
layerWeakReference
.
get
()
==
l
)
{
return
true
;
}
private
void
updateAWTEventListener
(
long
oldEventMask
,
long
newEventMask
)
{
if
(
oldEventMask
!=
0
)
{
layerMaskList
.
remove
(
oldEventMask
);
}
return
false
;
}
private
void
updateAWTEventListener
(
JLayer
layer
)
{
if
(!
layerListContains
(
layer
)
&&
layer
.
getLayerEventMask
()
!=
0
)
{
layerList
.
add
(
new
WeakReference
<
JLayer
>(
layer
));
if
(
newEventMask
!=
0
)
{
layerMaskList
.
add
(
newEventMask
);
}
long
combinedMask
=
0
;
Iterator
<
WeakReference
<
JLayer
>>
it
=
layerList
.
iterator
();
while
(
it
.
hasNext
())
{
WeakReference
<
JLayer
>
weakRef
=
it
.
next
();
JLayer
currLayer
=
weakRef
.
get
();
if
(
currLayer
==
null
)
{
it
.
remove
();
}
else
{
combinedMask
|=
currLayer
.
getLayerEventMask
();
}
for
(
Long
mask
:
layerMaskList
)
{
combinedMask
|=
mask
;
}
if
(
combinedMask
==
0
)
{
removeAWTEventListener
();
layerList
.
clear
();
}
else
if
(
getCurrentEventMask
()
!=
combinedMask
)
{
removeAWTEventListener
();
addAWTEventListener
(
combinedMask
);
}
currentEventMask
=
combinedMask
;
}
private
long
getCurrentEventMask
()
{
...
...
@@ -617,7 +637,7 @@ public final class JLayer<V extends Component>
return
null
;
}
});
currentEventMask
=
eventMask
;
}
private
void
removeAWTEventListener
()
{
...
...
@@ -628,7 +648,6 @@ public final class JLayer<V extends Component>
return
null
;
}
});
currentEventMask
=
0
;
}
private
boolean
isEventEnabled
(
long
eventMask
,
int
id
)
{
...
...
@@ -785,4 +804,4 @@ public final class JLayer<V extends Component>
public
void
removeLayoutComponent
(
Component
comp
)
{
}
}
}
\ No newline at end of file
}
src/share/classes/javax/swing/JList.java
浏览文件 @
04a8b4d8
...
...
@@ -2722,8 +2722,9 @@ public class JList extends JComponent implements Scrollable, Accessible
getVisibleRowCount
()
<=
0
)
{
return
true
;
}
if
(
getParent
()
instanceof
JViewport
)
{
return
(
getParent
().
getWidth
()
>
getPreferredSize
().
width
);
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
port
!=
null
)
{
return
port
.
getWidth
()
>
getPreferredSize
().
width
;
}
return
false
;
}
...
...
@@ -2747,8 +2748,9 @@ public class JList extends JComponent implements Scrollable, Accessible
getVisibleRowCount
()
<=
0
)
{
return
true
;
}
if
(
getParent
()
instanceof
JViewport
)
{
return
(
getParent
().
getHeight
()
>
getPreferredSize
().
height
);
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
port
!=
null
)
{
return
port
.
getHeight
()
>
getPreferredSize
().
height
;
}
return
false
;
}
...
...
src/share/classes/javax/swing/JTable.java
浏览文件 @
04a8b4d8
...
...
@@ -718,9 +718,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #addNotify
*/
protected
void
configureEnclosingScrollPane
()
{
Container
p
=
getParent
(
);
if
(
p
instanceof
JViewport
)
{
Container
gp
=
p
.
getParent
();
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
p
ort
!=
null
)
{
Container
gp
=
p
ort
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
// Make certain we are the viewPort's view and not, for
...
...
@@ -750,9 +750,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* from configureEnclosingScrollPane() and updateUI() in a safe manor.
*/
private
void
configureEnclosingScrollPaneUI
()
{
Container
p
=
getParent
(
);
if
(
p
instanceof
JViewport
)
{
Container
gp
=
p
.
getParent
();
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
p
ort
!=
null
)
{
Container
gp
=
p
ort
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
// Make certain we are the viewPort's view and not, for
...
...
@@ -819,9 +819,9 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @since 1.3
*/
protected
void
unconfigureEnclosingScrollPane
()
{
Container
p
=
getParent
(
);
if
(
p
instanceof
JViewport
)
{
Container
gp
=
p
.
getParent
();
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
p
ort
!=
null
)
{
Container
gp
=
p
ort
.
getParent
();
if
(
gp
instanceof
JScrollPane
)
{
JScrollPane
scrollPane
=
(
JScrollPane
)
gp
;
// Make certain we are the viewPort's view and not, for
...
...
@@ -5215,9 +5215,10 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* @see #getFillsViewportHeight
*/
public
boolean
getScrollableTracksViewportHeight
()
{
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
return
getFillsViewportHeight
()
&&
getParent
()
instanceof
JViewport
&&
(
getParent
().
getHeight
()
>
getPreferredSize
().
height
)
;
&&
port
!=
null
&&
port
.
getHeight
()
>
getPreferredSize
().
height
;
}
/**
...
...
src/share/classes/javax/swing/JTextField.java
浏览文件 @
04a8b4d8
...
...
@@ -24,6 +24,8 @@
*/
package
javax.swing
;
import
sun.swing.SwingUtilities2
;
import
java.awt.*
;
import
java.awt.event.*
;
import
java.beans.*
;
...
...
@@ -288,11 +290,7 @@ public class JTextField extends JTextComponent implements SwingConstants {
* @see JComponent#isValidateRoot
*/
public
boolean
isValidateRoot
()
{
Component
parent
=
getParent
();
if
(
parent
instanceof
JViewport
)
{
return
false
;
}
return
true
;
return
SwingUtilities2
.
getViewport
(
this
)
==
null
;
}
...
...
src/share/classes/javax/swing/JTextPane.java
浏览文件 @
04a8b4d8
...
...
@@ -170,6 +170,7 @@ public class JTextPane extends JEditorPane {
*
* @param content the content to replace the selection with
*/
@Override
public
void
replaceSelection
(
String
content
)
{
replaceSelection
(
content
,
true
);
}
...
...
@@ -183,6 +184,7 @@ public class JTextPane extends JEditorPane {
if
(
doc
!=
null
)
{
try
{
Caret
caret
=
getCaret
();
boolean
composedTextSaved
=
saveComposedText
(
caret
.
getDot
());
int
p0
=
Math
.
min
(
caret
.
getDot
(),
caret
.
getMark
());
int
p1
=
Math
.
max
(
caret
.
getDot
(),
caret
.
getMark
());
AttributeSet
attr
=
getInputAttributes
().
copyAttributes
();
...
...
@@ -197,6 +199,9 @@ public class JTextPane extends JEditorPane {
doc
.
insertString
(
p0
,
content
,
attr
);
}
}
if
(
composedTextSaved
)
{
restoreComposedText
();
}
}
catch
(
BadLocationException
e
)
{
UIManager
.
getLookAndFeel
().
provideErrorFeedback
(
JTextPane
.
this
);
}
...
...
src/share/classes/javax/swing/JTree.java
浏览文件 @
04a8b4d8
...
...
@@ -3498,8 +3498,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportWidth
*/
public
boolean
getScrollableTracksViewportWidth
()
{
if
(
getParent
()
instanceof
JViewport
)
{
return
getParent
().
getWidth
()
>
getPreferredSize
().
width
;
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
port
!=
null
)
{
return
port
.
getWidth
()
>
getPreferredSize
().
width
;
}
return
false
;
}
...
...
@@ -3514,8 +3515,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* @see Scrollable#getScrollableTracksViewportHeight
*/
public
boolean
getScrollableTracksViewportHeight
()
{
if
(
getParent
()
instanceof
JViewport
)
{
return
getParent
().
getHeight
()
>
getPreferredSize
().
height
;
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
port
!=
null
)
{
return
port
.
getHeight
()
>
getPreferredSize
().
height
;
}
return
false
;
}
...
...
src/share/classes/javax/swing/SwingUtilities.java
浏览文件 @
04a8b4d8
...
...
@@ -999,24 +999,20 @@ public class SwingUtilities implements SwingConstants
textR
.
height
=
(
int
)
v
.
getPreferredSpan
(
View
.
Y_AXIS
);
}
else
{
textR
.
width
=
SwingUtilities2
.
stringWidth
(
c
,
fm
,
text
);
// Take into account the left and right side bearings.
// This gives more space than it is actually needed,
// but there are two reasons:
// 1. If we set the width to the actual bounds,
// all callers would have to account for the bearings
// themselves. NOTE: all pref size calculations don't do it.
// 2. You can do a drawString at the returned location
// and the text won't be clipped.
lsb
=
SwingUtilities2
.
getLeftSideBearing
(
c
,
fm
,
text
);
if
(
lsb
<
0
)
{
// If lsb is negative, add it to the width and later
// adjust the x location. This gives more space than is
// actually needed.
// This is done like this for two reasons:
// 1. If we set the width to the actual bounds all
// callers would have to account for negative lsb
// (pref size calculations ONLY look at width of
// textR)
// 2. You can do a drawString at the returned location
// and the text won't be clipped.
textR
.
width
-=
lsb
;
}
rsb
=
SwingUtilities2
.
getRightSideBearing
(
c
,
fm
,
text
);
if
(
rsb
>
0
)
{
textR
.
width
+=
rsb
;
}
if
(
textR
.
width
>
availTextWidth
)
{
text
=
SwingUtilities2
.
clipString
(
c
,
fm
,
text
,
availTextWidth
);
...
...
src/share/classes/javax/swing/plaf/LayerUI.java
浏览文件 @
04a8b4d8
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
* 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
javax.swing.plaf
;
...
...
@@ -202,6 +222,7 @@ public class LayerUI<V extends Component>
* Returns an array of all the listeners which have been associated
* with the named property.
*
* @param propertyName The name of the property being listened to
* @return all of the {@code PropertyChangeListener}s associated with
* the named property; if no such listeners have been added or
* if {@code propertyName} is {@code null}, an empty
...
...
@@ -242,6 +263,7 @@ public class LayerUI<V extends Component>
/**
* Returns the preferred size of the viewport for a view component.
*
* @param l the {@code JLayer} component where this UI delegate is being installed
* @return the preferred size of the viewport for a view component
* @see Scrollable#getPreferredScrollableViewportSize()
*/
...
...
@@ -257,6 +279,10 @@ public class LayerUI<V extends Component>
* that display logical rows or columns in order to completely expose
* one block of rows or columns, depending on the value of orientation.
*
* @param l the {@code JLayer} component where this UI delegate is being installed
* @param visibleRect The view area visible within the viewport
* @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
* @param direction Less than zero to scroll up/left, greater than zero for down/right.
* @return the "block" increment for scrolling in the specified direction
* @see Scrollable#getScrollableBlockIncrement(Rectangle, int, int)
*/
...
...
@@ -276,6 +302,7 @@ public class LayerUI<V extends Component>
* determine the height of the layer, unless the preferred height
* of the layer is smaller than the height of the viewport.
*
* @param l the {@code JLayer} component where this UI delegate is being installed
* @return whether the layer should track the height of the viewport
* @see Scrollable#getScrollableTracksViewportHeight()
*/
...
...
@@ -283,9 +310,6 @@ public class LayerUI<V extends Component>
if
(
l
.
getView
()
instanceof
Scrollable
)
{
return
((
Scrollable
)
l
.
getView
()).
getScrollableTracksViewportHeight
();
}
if
(
l
.
getParent
()
instanceof
JViewport
)
{
return
(((
JViewport
)
l
.
getParent
()).
getHeight
()
>
l
.
getPreferredSize
().
height
);
}
return
false
;
}
...
...
@@ -294,6 +318,7 @@ public class LayerUI<V extends Component>
* determine the width of the layer, unless the preferred width
* of the layer is smaller than the width of the viewport.
*
* @param l the {@code JLayer} component where this UI delegate is being installed
* @return whether the layer should track the width of the viewport
* @see Scrollable
* @see LayerUI#getScrollableTracksViewportWidth(JLayer)
...
...
@@ -302,9 +327,6 @@ public class LayerUI<V extends Component>
if
(
l
.
getView
()
instanceof
Scrollable
)
{
return
((
Scrollable
)
l
.
getView
()).
getScrollableTracksViewportWidth
();
}
if
(
l
.
getParent
()
instanceof
JViewport
)
{
return
(((
JViewport
)
l
.
getParent
()).
getWidth
()
>
l
.
getPreferredSize
().
width
);
}
return
false
;
}
...
...
@@ -318,6 +340,10 @@ public class LayerUI<V extends Component>
* Scrolling containers, like JScrollPane, will use this method
* each time the user requests a unit scroll.
*
* @param l the {@code JLayer} component where this UI delegate is being installed
* @param visibleRect The view area visible within the viewport
* @param orientation Either SwingConstants.VERTICAL or SwingConstants.HORIZONTAL.
* @param direction Less than zero to scroll up/left, greater than zero for down/right.
* @return The "unit" increment for scrolling in the specified direction.
* This value should always be positive.
* @see Scrollable#getScrollableUnitIncrement(Rectangle, int, int)
...
...
@@ -367,4 +393,4 @@ public class LayerUI<V extends Component>
}
return
super
.
getBaselineResizeBehavior
(
c
);
}
}
\ No newline at end of file
}
src/share/classes/javax/swing/plaf/basic/BasicSliderUI.java
浏览文件 @
04a8b4d8
...
...
@@ -1507,7 +1507,8 @@ public class BasicSliderUI extends SliderUI{
propertyName
==
"paintTicks"
||
propertyName
==
"paintTrack"
||
propertyName
==
"font"
||
propertyName
==
"paintLabels"
)
{
propertyName
==
"paintLabels"
||
propertyName
==
"Slider.paintThumbArrowShape"
)
{
checkedLabelBaselines
=
false
;
calculateGeometry
();
slider
.
repaint
();
...
...
src/share/classes/javax/swing/plaf/metal/MetalFontDesktopProperty.java
浏览文件 @
04a8b4d8
/*
* Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2001
-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
...
...
@@ -25,8 +25,6 @@
package
javax.swing.plaf.metal
;
import
java.awt.*
;
import
java.beans.*
;
import
javax.swing.*
;
/**
* DesktopProperty that only uses font height in configuring font. This
...
...
@@ -60,7 +58,7 @@ class MetalFontDesktopProperty extends com.sun.java.swing.plaf.windows.DesktopPr
* @param type MetalTheme font type.
*/
MetalFontDesktopProperty
(
int
type
)
{
this
(
propertyMapping
[
type
],
Toolkit
.
getDefaultToolkit
(),
type
);
this
(
propertyMapping
[
type
],
type
);
}
/**
...
...
@@ -72,8 +70,8 @@ class MetalFontDesktopProperty extends com.sun.java.swing.plaf.windows.DesktopPr
* @param type Type of font being used, corresponds to MetalTheme font
* type.
*/
MetalFontDesktopProperty
(
String
key
,
Toolkit
kit
,
int
type
)
{
super
(
key
,
null
,
kit
);
MetalFontDesktopProperty
(
String
key
,
int
type
)
{
super
(
key
,
null
);
this
.
type
=
type
;
}
...
...
src/share/classes/javax/swing/plaf/metal/MetalLookAndFeel.java
浏览文件 @
04a8b4d8
/*
* Copyright 1998-200
8
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 1998-200
9
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
...
...
@@ -1541,10 +1541,8 @@ public class MetalLookAndFeel extends BasicLookAndFeel
table
.
putDefaults
(
defaults
);
if
(
isWindows
()
&&
useSystemFonts
()
&&
theme
.
isSystemTheme
())
{
Toolkit
kit
=
Toolkit
.
getDefaultToolkit
();
Object
messageFont
=
new
MetalFontDesktopProperty
(
"win.messagebox.font.height"
,
kit
,
MetalTheme
.
CONTROL_TEXT_FONT
);
"win.messagebox.font.height"
,
MetalTheme
.
CONTROL_TEXT_FONT
);
defaults
=
new
Object
[]
{
"OptionPane.messageFont"
,
messageFont
,
...
...
src/share/classes/javax/swing/plaf/nimbus/Defaults.template
浏览文件 @
04a8b4d8
...
...
@@ -101,14 +101,7 @@ final class ${LAF_NAME}Defaults {
*/
private
FontUIResource
defaultFont
;
/**
*
Map
of
lists
of
derived
colors
keyed
by
the
DerivedColorKeys
*/
private
Map
<
DerivedColorKey
,
DerivedColor
>
derivedColorsMap
=
new
HashMap
<
DerivedColorKey
,
DerivedColor
>();
/**
Tempory
key
used
for
fetching
from
the
derivedColorsMap
*/
private
final
DerivedColorKey
tmpDCKey
=
new
DerivedColorKey
();
private
ColorTree
colorTree
=
new
ColorTree
();
/**
Listener
for
changes
to
user
defaults
table
*/
private
DefaultsListener
defaultsListener
=
new
DefaultsListener
();
...
...
@@ -117,14 +110,14 @@ final class ${LAF_NAME}Defaults {
void
initialize
()
{
//
add
listener
for
derived
colors
UIManager
.
addPropertyChangeListener
(
defaultsListener
);
UIManager
.
getDefaults
().
addPropertyChangeListener
(
defaultsListener
);
UIManager
.
getDefaults
().
addPropertyChangeListener
(
colorTree
);
}
/**
Called
by
UIManager
when
this
look
and
feel
is
uninstalled
.
*/
void
uninitialize
()
{
//
remove
listener
for
derived
colors
UIManager
.
getDefaults
().
removePropertyChangeListener
(
defaultsListener
);
UIManager
.
removePropertyChangeListener
(
defaultsListener
);
UIManager
.
getDefaults
().
removePropertyChangeListener
(
colorTree
);
}
/**
...
...
@@ -663,22 +656,23 @@ ${UI_DEFAULT_INIT}
}
}
/**
*
Get
a
derived
color
,
derived
colors
are
shared
instances
and
will
be
*
updated
when
its
parent
UIDefault
color
changes
.
*
*
@
param
uiDefaultParentName
The
parent
UIDefault
key
*
@
param
hOffset
The
hue
offset
*
@
param
sOffset
The
saturation
offset
*
@
param
bOffset
The
brightness
offset
*
@
param
aOffset
The
alpha
offset
*
@
return
The
stored
derived
color
*/
public
DerivedColor
getDerivedColor
(
String
uiDefaultParentName
,
float
hOffset
,
float
sOffset
,
float
bOffset
,
int
aOffset
){
return
getDerivedColor
(
uiDefaultParentName
,
hOffset
,
sOffset
,
bOffset
,
aOffset
,
true
);
private
void
addColor
(
UIDefaults
d
,
String
uin
,
int
r
,
int
g
,
int
b
,
int
a
)
{
Color
color
=
new
ColorUIResource
(
new
Color
(
r
,
g
,
b
,
a
));
colorTree
.
addColor
(
uin
,
color
);
d
.
put
(
uin
,
color
);
}
private
void
addColor
(
UIDefaults
d
,
String
uin
,
String
parentUin
,
float
hOffset
,
float
sOffset
,
float
bOffset
,
int
aOffset
)
{
addColor
(
d
,
uin
,
parentUin
,
hOffset
,
sOffset
,
bOffset
,
aOffset
,
true
);
}
private
void
addColor
(
UIDefaults
d
,
String
uin
,
String
parentUin
,
float
hOffset
,
float
sOffset
,
float
bOffset
,
int
aOffset
,
boolean
uiResource
)
{
Color
color
=
getDerivedColor
(
uin
,
parentUin
,
hOffset
,
sOffset
,
bOffset
,
aOffset
,
uiResource
);
d
.
put
(
uin
,
color
);
}
/**
...
...
@@ -694,89 +688,110 @@ ${UI_DEFAULT_INIT}
*
false
if
it
should
not
be
a
UIResource
*
@
return
The
stored
derived
color
*/
public
DerivedColor
getDerivedColor
(
String
uiDefaultParentName
,
public
DerivedColor
getDerivedColor
(
String
parentUin
,
float
hOffset
,
float
sOffset
,
float
bOffset
,
int
aOffset
,
boolean
uiResource
){
tmpDCKey
.
set
(
uiDefaultParentName
,
hOffset
,
sOffset
,
bOffset
,
aOffset
,
uiResource
);
DerivedColor
color
=
derivedColorsMap
.
get
(
tmpDCKey
);
if
(
color
==
null
){
if
(
uiResource
)
{
color
=
new
DerivedColor
.
UIResource
(
uiDefaultParentName
,
hOffset
,
sOffset
,
bOffset
,
aOffset
);
}
else
{
color
=
new
DerivedColor
(
uiDefaultParentName
,
hOffset
,
sOffset
,
bOffset
,
aOffset
);
}
//
calculate
the
initial
value
color
.
rederiveColor
();
//
add
the
listener
so
that
if
the
color
changes
we
'll propogate it
color.addPropertyChangeListener(defaultsListener);
// add to the derived colors table
derivedColorsMap.put(new DerivedColorKey(uiDefaultParentName,
hOffset, sOffset, bOffset, aOffset, uiResource),color);
return
getDerivedColor
(
null
,
parentUin
,
hOffset
,
sOffset
,
bOffset
,
aOffset
,
uiResource
);
}
private
DerivedColor
getDerivedColor
(
String
uin
,
String
parentUin
,
float
hOffset
,
float
sOffset
,
float
bOffset
,
int
aOffset
,
boolean
uiResource
)
{
DerivedColor
color
;
if
(
uiResource
)
{
color
=
new
DerivedColor
.
UIResource
(
parentUin
,
hOffset
,
sOffset
,
bOffset
,
aOffset
);
}
else
{
color
=
new
DerivedColor
(
parentUin
,
hOffset
,
sOffset
,
bOffset
,
aOffset
);
}
if
(
derivedColors
.
containsKey
(
color
))
{
return
derivedColors
.
get
(
color
);
}
else
{
derivedColors
.
put
(
color
,
color
);
color
.
rederiveColor
();
///
move
to
ARP
.
decodeColor
()
?
colorTree
.
addColor
(
uin
,
color
);
return
color
;
}
return color;
}
/**
* Key class for derived colors
*/
private class DerivedColorKey {
private String uiDefaultParentName;
private float hOffset, sOffset, bOffset;
private int aOffset;
private boolean uiResource;
DerivedColorKey(){}
DerivedColorKey(String uiDefaultParentName, float hOffset,
float sOffset, float bOffset, int aOffset,
boolean uiResource) {
set(uiDefaultParentName, hOffset, sOffset, bOffset, aOffset, uiResource);
private
Map
<
DerivedColor
,
DerivedColor
>
derivedColors
=
new
HashMap
<
DerivedColor
,
DerivedColor
>();
private
class
ColorTree
implements
PropertyChangeListener
{
private
Node
root
=
new
Node
(
null
,
null
);
private
Map
<
String
,
Node
>
nodes
=
new
HashMap
<
String
,
Node
>();
public
Color
getColor
(
String
uin
)
{
return
nodes
.
get
(
uin
).
color
;
}
void set (String uiDefaultParentName, float hOffset,
float sOffset, float bOffset, int aOffset,
boolean uiResource) {
this.uiDefaultParentName = uiDefaultParentName;
this.hOffset = hOffset;
this.sOffset = sOffset;
this.bOffset = bOffset;
this.aOffset = aOffset;
this.uiResource = uiResource;
public
void
addColor
(
String
uin
,
Color
color
)
{
Node
parent
=
getParentNode
(
color
);
Node
node
=
new
Node
(
color
,
parent
);
parent
.
children
.
add
(
node
);
if
(
uin
!= null) {
nodes
.
put
(
uin
,
node
);
}
}
@Override
public boolean equals(Object o) {
if (
this == o) return true;
if (!(o instanceof DerivedColorKey)) return false
;
DerivedColorKey that = (DerivedColorKey) o
;
if (aOffset != that.aOffset) return false;
if (Float.compare(that.bOffset, bOffset) != 0) return false
;
if (Float.compare(that.hOffset, hOffset) != 0) return false;
if (Float.compare(that.sOffset, sOffset) != 0) return false;
if (uiDefaultParentName != null ?
!uiDefaultParentName.equals(that.uiDefaultParentName) :
that.uiDefaultParentName != null) return false;
if (this.uiResource != that.uiResource) return false;
r
eturn true
;
private
Node
getParentNode
(
Color
color
)
{
Node
parent
=
root
;
if
(
color
instanceof
DerivedColor
)
{
String
parentUin
=
((
DerivedColor
)
color
).
getUiDefaultParentName
()
;
Node
p
=
nodes
.
get
(
parentUin
)
;
if
(
p
!= null) {
parent
=
p
;
}
}
return
parent
;
}
public
void
update
()
{
r
oot
.
update
()
;
}
@
Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + uiDefaultParentName.hashCode();
result = 31 * result + hOffset != +0.0f ?
Float.floatToIntBits(hOffset) : 0;
result = 31 * result + sOffset != +0.0f ?
Float.floatToIntBits(sOffset) : 0;
result = 31 * result + bOffset != +0.0f ?
Float.floatToIntBits(bOffset) : 0;
result = 31 * result + aOffset;
result = 31 * result + (uiResource ? 1 : 0);
return result;
public
void
propertyChange
(
PropertyChangeEvent
ev
)
{
String
name
=
ev
.
getPropertyName
();
Node
node
=
nodes
.
get
(
name
);
if
(
node
!= null) {
//
this
is
a
registered
color
node
.
parent
.
children
.
remove
(
node
);
Color
color
=
(
Color
)
ev
.
getNewValue
();
Node
parent
=
getParentNode
(
color
);
node
.
set
(
color
,
parent
);
parent
.
children
.
add
(
node
);
node
.
update
();
}
}
class
Node
{
Color
color
;
Node
parent
;
List
<
Node
>
children
=
new
LinkedList
<
Node
>();
Node
(
Color
color
,
Node
parent
)
{
set
(
color
,
parent
);
}
public
void
set
(
Color
color
,
Node
parent
)
{
this
.
color
=
color
;
this
.
parent
=
parent
;
}
public
void
update
()
{
if
(
color
instanceof
DerivedColor
)
{
((
DerivedColor
)
color
).
rederiveColor
();
}
for
(
Node
child
:
children
)
{
child
.
update
();
}
}
}
}
...
...
@@ -786,49 +801,12 @@ ${UI_DEFAULT_INIT}
private
class
DefaultsListener
implements
PropertyChangeListener
{
@
Override
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
Object src = evt.getSource();
String key = evt.getPropertyName();
if (key.equals("lookAndFeel")){
if
(
"lookAndFeel"
.
equals
(
evt
.
getPropertyName
()))
{
//
LAF
has
been
installed
,
this
is
the
first
point
at
which
we
//
can
access
our
defaults
table
via
UIManager
so
before
now
//
all
derived
colors
will
be
incorrect
.
//
First
we
need
to
update
for (DerivedColor color : derivedColorsMap.values()) {
color.rederiveColor();
}
} else if (src instanceof DerivedColor && key.equals("rgb")) {
// derived color that is in UIManager defaults has changed
// update all its dependent colors. Don'
t
worry
about
doing
//
this
recursively
since
calling
rederiveColor
will
cause
//
another
PCE
to
be
fired
,
ending
up
here
and
essentially
//
recursing
DerivedColor
parentColor
=
(
DerivedColor
)
src
;
String
parentKey
=
null
;
Set
<
Map
.
Entry
<
Object
,
Object
>>
entries
=
UIManager
.
getDefaults
().
entrySet
();
for
(
Map
.
Entry
entry
:
entries
)
{
Object
value
=
entry
.
getValue
();
if
(
value
==
parentColor
)
{
parentKey
=
entry
.
getKey
().
toString
();
}
}
if
(
parentKey
==
null
)
{
//
couldn
't find the DerivedColor in the UIDefaults map,
//so we just bail.
return;
}
for (Map.Entry entry : entries) {
Object value = entry.getValue();
if (value instanceof DerivedColor) {
DerivedColor color = (DerivedColor)entry.getValue();
if (parentKey.equals(color.getUiDefaultParentName())) {
color.rederiveColor();
}
}
}
colorTree
.
update
();
}
}
}
...
...
@@ -875,4 +853,3 @@ ${UI_DEFAULT_INIT}
}
}
}
src/share/classes/javax/swing/plaf/nimbus/DerivedColor.java
浏览文件 @
04a8b4d8
...
...
@@ -39,8 +39,6 @@ import java.beans.PropertyChangeListener;
* @author Jasper Potts
*/
class
DerivedColor
extends
Color
{
private
final
PropertyChangeSupport
changeSupport
=
new
PropertyChangeSupport
(
this
);
private
final
String
uiDefaultParentName
;
private
final
float
hOffset
,
sOffset
,
bOffset
;
private
final
int
aOffset
;
...
...
@@ -79,7 +77,6 @@ class DerivedColor extends Color {
* Recalculate the derived color from the UIManager parent color and offsets
*/
public
void
rederiveColor
()
{
int
old
=
argbValue
;
Color
src
=
UIManager
.
getColor
(
uiDefaultParentName
);
if
(
src
!=
null
)
{
float
[]
tmp
=
Color
.
RGBtoHSB
(
src
.
getRed
(),
src
.
getGreen
(),
src
.
getBlue
(),
null
);
...
...
@@ -97,7 +94,6 @@ class DerivedColor extends Color {
int
alpha
=
clamp
(
aOffset
);
argbValue
=
(
Color
.
HSBtoRGB
(
tmp
[
0
],
tmp
[
1
],
tmp
[
2
])
&
0xFFFFFF
)
|
(
alpha
<<
24
);
}
changeSupport
.
firePropertyChange
(
"rgb"
,
old
,
argbValue
);
}
/**
...
...
@@ -141,35 +137,6 @@ class DerivedColor extends Color {
return
result
;
}
/**
* Add a PropertyChangeListener to the listener list.
* The listener is registered for all properties.
* The same listener object may be added more than once, and will be called
* as many times as it is added.
* If <code>listener</code> is null, no exception is thrown and no action
* is taken.
*
* @param listener The PropertyChangeListener to be added
*/
public
void
addPropertyChangeListener
(
PropertyChangeListener
listener
)
{
changeSupport
.
addPropertyChangeListener
(
listener
);
}
/**
* Remove a PropertyChangeListener from the listener list.
* This removes a PropertyChangeListener that was registered
* for all properties.
* If <code>listener</code> was added more than once to the same event
* source, it will be notified one less time after being removed.
* If <code>listener</code> is null, or was never added, no exception is
* thrown and no action is taken.
*
* @param listener The PropertyChangeListener to be removed
*/
public
void
removePropertyChangeListener
(
PropertyChangeListener
listener
)
{
changeSupport
.
removePropertyChangeListener
(
listener
);
}
private
float
clamp
(
float
value
)
{
if
(
value
<
0
)
{
value
=
0
;
...
...
@@ -211,5 +178,15 @@ class DerivedColor extends Color {
float
bOffset
,
int
aOffset
)
{
super
(
uiDefaultParentName
,
hOffset
,
sOffset
,
bOffset
,
aOffset
);
}
@Override
public
boolean
equals
(
Object
o
)
{
return
(
o
instanceof
UIResource
)
&&
super
.
equals
(
o
);
}
@Override
public
int
hashCode
()
{
return
super
.
hashCode
()
+
7
;
}
}
}
src/share/classes/javax/swing/plaf/nimbus/NimbusLookAndFeel.java
浏览文件 @
04a8b4d8
...
...
@@ -40,6 +40,9 @@ import java.awt.Container;
import
java.awt.Graphics2D
;
import
java.awt.LayoutManager
;
import
java.awt.image.BufferedImage
;
import
java.beans.PropertyChangeEvent
;
import
java.beans.PropertyChangeListener
;
import
java.util.*
;
import
javax.swing.GrayFilter
;
import
javax.swing.Icon
;
import
javax.swing.JToolBar
;
...
...
@@ -87,6 +90,8 @@ public class NimbusLookAndFeel extends SynthLookAndFeel {
*/
private
UIDefaults
uiDefaults
;
private
DefaultsListener
defaultsListener
=
new
DefaultsListener
();
/**
* Create a new NimbusLookAndFeel.
*/
...
...
@@ -115,8 +120,7 @@ public class NimbusLookAndFeel extends SynthLookAndFeel {
defaults
.
uninitialize
();
// clear all cached images to free memory
ImageCache
.
getInstance
().
flush
();
// remove the listeners and things installed by NimbusStyle
NimbusStyle
.
uninitialize
();
UIManager
.
getDefaults
().
removePropertyChangeListener
(
defaultsListener
);
}
/**
...
...
@@ -515,4 +519,62 @@ public class NimbusLookAndFeel extends SynthLookAndFeel {
return
obj
;
}
}
private
Map
<
String
,
Map
<
String
,
Object
>>
compiledDefaults
=
null
;
private
boolean
defaultListenerAdded
=
false
;
static
String
parsePrefix
(
String
key
)
{
if
(
key
==
null
)
{
return
null
;
}
boolean
inquotes
=
false
;
for
(
int
i
=
0
;
i
<
key
.
length
();
i
++)
{
char
c
=
key
.
charAt
(
i
);
if
(
c
==
'"'
)
{
inquotes
=
!
inquotes
;
}
else
if
((
c
==
'['
||
c
==
'.'
)
&&
!
inquotes
)
{
return
key
.
substring
(
0
,
i
);
}
}
return
null
;
}
Map
<
String
,
Object
>
getDefaultsForPrefix
(
String
prefix
)
{
if
(
compiledDefaults
==
null
)
{
compiledDefaults
=
new
HashMap
<
String
,
Map
<
String
,
Object
>>();
for
(
Map
.
Entry
<
Object
,
Object
>
entry:
UIManager
.
getDefaults
().
entrySet
())
{
if
(
entry
.
getKey
()
instanceof
String
)
{
addDefault
((
String
)
entry
.
getKey
(),
entry
.
getValue
());
}
}
if
(!
defaultListenerAdded
)
{
UIManager
.
getDefaults
().
addPropertyChangeListener
(
defaultsListener
);
defaultListenerAdded
=
true
;
}
}
return
compiledDefaults
.
get
(
prefix
);
}
private
void
addDefault
(
String
key
,
Object
value
)
{
String
prefix
=
parsePrefix
(
key
);
if
(
prefix
!=
null
)
{
Map
<
String
,
Object
>
keys
=
compiledDefaults
.
get
(
prefix
);
if
(
keys
==
null
)
{
keys
=
new
HashMap
<
String
,
Object
>();
compiledDefaults
.
put
(
prefix
,
keys
);
}
keys
.
put
(
key
,
value
);
}
}
private
class
DefaultsListener
implements
PropertyChangeListener
{
@Override
public
void
propertyChange
(
PropertyChangeEvent
ev
)
{
String
key
=
ev
.
getPropertyName
();
if
(
"UIDefaults"
.
equals
(
key
))
{
compiledDefaults
=
null
;
}
else
{
addDefault
(
key
,
ev
.
getNewValue
());
}
}
}
}
src/share/classes/javax/swing/plaf/nimbus/NimbusStyle.java
浏览文件 @
04a8b4d8
...
...
@@ -26,7 +26,6 @@ package javax.swing.plaf.nimbus;
import
javax.swing.Painter
;
import
java.beans.PropertyChangeEvent
;
import
javax.swing.JComponent
;
import
javax.swing.UIDefaults
;
import
javax.swing.UIManager
;
...
...
@@ -39,16 +38,13 @@ import javax.swing.plaf.synth.SynthStyle;
import
java.awt.Color
;
import
java.awt.Font
;
import
java.awt.Insets
;
import
java.beans.PropertyChangeListener
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
sun.awt.AppContext
;
/**
* <p>A SynthStyle implementation used by Nimbus. Each Region that has been
...
...
@@ -232,42 +228,6 @@ public final class NimbusStyle extends SynthStyle {
super
.
installDefaults
(
ctx
);
}
static
String
parsePrefix
(
String
key
)
{
if
(
key
==
null
)
return
null
;
boolean
inquotes
=
false
;
for
(
int
i
=
0
;
i
<
key
.
length
();
i
++)
{
char
c
=
key
.
charAt
(
i
);
if
(
c
==
'"'
)
{
inquotes
=
!
inquotes
;
}
else
if
((
c
==
'['
||
c
==
'.'
)
&&
!
inquotes
)
{
return
key
.
substring
(
0
,
i
);
}
}
return
null
;
}
/**
* Called by NimbusLookAndFeel when the look and feel is being uninstalled.
* Performs general cleanup of any app-context specific data.
*/
static
void
uninitialize
()
{
// get the appcontext that we've stored data in
AppContext
ctx
=
AppContext
.
getAppContext
();
// get the pcl stored in app context
PropertyChangeListener
pcl
=
(
PropertyChangeListener
)
ctx
.
get
(
"NimbusStyle.defaults.pcl"
);
// if the pcl exists, uninstall it from the UIDefaults tables
if
(
pcl
!=
null
)
{
UIManager
.
getDefaults
().
removePropertyChangeListener
(
pcl
);
UIManager
.
getLookAndFeelDefaults
().
removePropertyChangeListener
(
pcl
);
}
// clear out the compiled defaults
ctx
.
put
(
"NimbusStyle.defaults"
,
null
);
}
/**
* Pulls data out of UIDefaults, if it has not done so already, and sets
* up the internal state.
...
...
@@ -283,66 +243,9 @@ public final class NimbusStyle extends SynthStyle {
// any Nimbus.Overrides)
values
=
new
Values
();
// the profiler revealed that a great deal of CPU time and useless
// garbage was being produced by this method and the init method. One
// culprit was the creation and reparsing of the entire UIDefaults
// map on each call to this method where "values" was null. It turns
// out this was happening a lot.
// To remove this bottleneck, we store the compiled TreeMaps of defaults
// in the appContext for reuse. It is nulled whenever the UIDefaults
// changes and recomputed when necessary.
final
AppContext
ctx
=
AppContext
.
getAppContext
();
// fetch the defaults from the app context. If null, then create and
// store the compiled defaults
Map
<
String
,
TreeMap
<
String
,
Object
>>
compiledDefaults
=
(
Map
<
String
,
TreeMap
<
String
,
Object
>>)
ctx
.
get
(
"NimbusStyle.defaults"
);
if
(
compiledDefaults
==
null
)
{
// the entire UIDefaults tables are parsed and compiled into
// this map of maps. The key of the compiledDefaults is the
// prefix for each style, while the value is a map of
// keys->values for that prefix.
compiledDefaults
=
new
HashMap
<
String
,
TreeMap
<
String
,
Object
>>();
// get all the defaults from UIManager.getDefaults() and put them
// into the compiledDefaults
compileDefaults
(
compiledDefaults
,
UIManager
.
getDefaults
());
// This second statement pulls defaults from the laf defaults
UIDefaults
lafDefaults
=
UIManager
.
getLookAndFeelDefaults
();
compileDefaults
(
compiledDefaults
,
lafDefaults
);
// if it has not already been done, add a listener to both
// UIManager.getDefaults() and UIManager.getLookAndFeelDefaults().
PropertyChangeListener
pcl
=
(
PropertyChangeListener
)
ctx
.
get
(
"NimbusStyle.defaults.pcl"
);
// if pcl is null, then it has not yet been registered with
// the UIManager defaults for this app context
if
(
pcl
==
null
)
{
// create a PCL which will simply clear out the compiled
// defaults from the app context, causing it to be recomputed
// on subsequent passes
pcl
=
new
DefaultsListener
();
// add the PCL to both defaults tables that we pay attention
// to, so that if the UIDefaults are updated, then the
// precompiled defaults will be cleared from the app context
// and recomputed on subsequent passes
UIManager
.
getDefaults
().
addPropertyChangeListener
(
pcl
);
UIManager
.
getLookAndFeelDefaults
().
addPropertyChangeListener
(
pcl
);
// save the PCL to the app context as a marker indicating
// that the PCL has been registered so we don't end up adding
// more than one listener to the UIDefaults tables.
ctx
.
put
(
"NimbusStyle.defaults.pcl"
,
pcl
);
}
// store the defaults for reuse
ctx
.
put
(
"NimbusStyle.defaults"
,
compiledDefaults
);
}
TreeMap
<
String
,
Object
>
defaults
=
compiledDefaults
.
get
(
prefix
);
Map
<
String
,
Object
>
defaults
=
((
NimbusLookAndFeel
)
UIManager
.
getLookAndFeel
()).
getDefaultsForPrefix
(
prefix
);
// inspect the client properties for the key "Nimbus.Overrides". If the
// value is an instance of UIDefaults, then these defaults are used
...
...
@@ -371,52 +274,6 @@ public final class NimbusStyle extends SynthStyle {
}
}
// Now that I've accumulated all the defaults pertaining to this
// style, call init which will read these defaults and configure
// the default "values".
init
(
values
,
defaults
);
}
/**
* Iterates over all the keys in the specified UIDefaults and compiles
* those keys into the comiledDefaults data structure. It relies on
* parsing the "prefix" out of the key. If the key is not a String or is
* null then it is ignored. In all other cases a prefix is parsed out
* (even if that prefix is the empty String or is a "fake" prefix. That
* is, suppose you had a key Foo~~MySpecial.KeyThing~~. In this case this
* is not a Nimbus formatted key, but we don't care, we treat it as if it
* is. This doesn't pose any harm, it will simply never be used).
*
* @param compiledDefaults
* @param d
*/
private
void
compileDefaults
(
Map
<
String
,
TreeMap
<
String
,
Object
>>
compiledDefaults
,
UIDefaults
d
)
{
for
(
Object
obj
:
new
HashSet
(
d
.
keySet
()))
{
if
(
obj
instanceof
String
)
{
String
key
=
(
String
)
obj
;
String
kp
=
parsePrefix
(
key
);
if
(
kp
==
null
)
continue
;
TreeMap
<
String
,
Object
>
map
=
compiledDefaults
.
get
(
kp
);
if
(
map
==
null
)
{
map
=
new
TreeMap
<
String
,
Object
>();
compiledDefaults
.
put
(
kp
,
map
);
}
map
.
put
(
key
,
d
.
get
(
key
));
}
}
}
/**
* Initializes the given <code>Values</code> object with the defaults
* contained in the given TreeMap.
*
* @param v The Values object to be initialized
* @param myDefaults a map of UIDefaults to use in initializing the Values.
* This map must contain only keys associated with this Style.
*/
private
void
init
(
Values
v
,
TreeMap
<
String
,
Object
>
myDefaults
)
{
//a list of the different types of states used by this style. This
//list may contain only "standard" states (those defined by Synth),
//or it may contain custom states, or it may contain only "standard"
...
...
@@ -433,7 +290,7 @@ public final class NimbusStyle extends SynthStyle {
//"values" stateTypes to be a non-null array.
//Otherwise, let the "values" stateTypes be null to indicate that
//there are no custom states or custom state ordering
String
statesString
=
(
String
)
myD
efaults
.
get
(
prefix
+
".States"
);
String
statesString
=
(
String
)
d
efaults
.
get
(
prefix
+
".States"
);
if
(
statesString
!=
null
)
{
String
s
[]
=
statesString
.
split
(
","
);
for
(
int
i
=
0
;
i
<
s
.
length
;
i
++)
{
...
...
@@ -442,7 +299,7 @@ public final class NimbusStyle extends SynthStyle {
//this is a non-standard state name, so look for the
//custom state associated with it
String
stateName
=
prefix
+
"."
+
s
[
i
];
State
customState
=
(
State
)
myD
efaults
.
get
(
stateName
);
State
customState
=
(
State
)
d
efaults
.
get
(
stateName
);
if
(
customState
!=
null
)
{
states
.
add
(
customState
);
}
...
...
@@ -455,7 +312,7 @@ public final class NimbusStyle extends SynthStyle {
//to be non-null. Otherwise, leave it null (meaning, use the
//standard synth states).
if
(
states
.
size
()
>
0
)
{
v
.
stateTypes
=
states
.
toArray
(
new
State
[
states
.
size
()]);
v
alues
.
stateTypes
=
states
.
toArray
(
new
State
[
states
.
size
()]);
}
//assign codes for each of the state types
...
...
@@ -490,7 +347,7 @@ public final class NimbusStyle extends SynthStyle {
}
//Now iterate over all the keys in the defaults table
for
(
String
key
:
myD
efaults
.
keySet
())
{
for
(
String
key
:
d
efaults
.
keySet
())
{
//The key is something like JButton.Enabled.backgroundPainter,
//or JButton.States, or JButton.background.
//Remove the "JButton." portion of the key
...
...
@@ -528,11 +385,11 @@ public final class NimbusStyle extends SynthStyle {
//otherwise, assume it is a property and install it on the
//values object
if
(
"contentMargins"
.
equals
(
property
))
{
v
.
contentMargins
=
(
Insets
)
myD
efaults
.
get
(
key
);
v
alues
.
contentMargins
=
(
Insets
)
d
efaults
.
get
(
key
);
}
else
if
(
"States"
.
equals
(
property
))
{
//ignore
}
else
{
v
.
defaults
.
put
(
property
,
myD
efaults
.
get
(
key
));
v
alues
.
defaults
.
put
(
property
,
d
efaults
.
get
(
key
));
}
}
else
{
//it is possible that the developer has a malformed UIDefaults
...
...
@@ -582,13 +439,13 @@ public final class NimbusStyle extends SynthStyle {
//so put it in the UIDefaults associated with that runtime
//state
if
(
"backgroundPainter"
.
equals
(
property
))
{
rs
.
backgroundPainter
=
(
Painter
)
myDefaults
.
get
(
key
);
rs
.
backgroundPainter
=
getPainter
(
defaults
,
key
);
}
else
if
(
"foregroundPainter"
.
equals
(
property
))
{
rs
.
foregroundPainter
=
(
Painter
)
myDefaults
.
get
(
key
);
rs
.
foregroundPainter
=
getPainter
(
defaults
,
key
);
}
else
if
(
"borderPainter"
.
equals
(
property
))
{
rs
.
borderPainter
=
(
Painter
)
myDefaults
.
get
(
key
);
rs
.
borderPainter
=
getPainter
(
defaults
,
key
);
}
else
{
rs
.
defaults
.
put
(
property
,
myD
efaults
.
get
(
key
));
rs
.
defaults
.
put
(
property
,
d
efaults
.
get
(
key
));
}
}
}
...
...
@@ -598,7 +455,15 @@ public final class NimbusStyle extends SynthStyle {
Collections
.
sort
(
runtimeStates
,
STATE_COMPARATOR
);
//finally, set the array of runtime states on the values object
v
.
states
=
runtimeStates
.
toArray
(
new
RuntimeState
[
runtimeStates
.
size
()]);
values
.
states
=
runtimeStates
.
toArray
(
new
RuntimeState
[
runtimeStates
.
size
()]);
}
private
Painter
getPainter
(
Map
<
String
,
Object
>
defaults
,
String
key
)
{
Object
p
=
defaults
.
get
(
key
);
if
(
p
instanceof
UIDefaults
.
LazyValue
)
{
p
=
((
UIDefaults
.
LazyValue
)
p
).
createValue
(
UIManager
.
getDefaults
());
}
return
(
p
instanceof
Painter
?
(
Painter
)
p
:
null
);
}
/**
...
...
@@ -1245,15 +1110,4 @@ public final class NimbusStyle extends SynthStyle {
return
hash
;
}
}
/**
* This listener is used to listen to the UIDefaults tables and clear out
* the cached-precompiled map of defaults in that case.
*/
private
static
final
class
DefaultsListener
implements
PropertyChangeListener
{
@Override
public
void
propertyChange
(
PropertyChangeEvent
evt
)
{
AppContext
.
getAppContext
().
put
(
"NimbusStyle.defaults"
,
null
);
}
}
}
src/share/classes/javax/swing/plaf/synth/SynthMenuItemLayoutHelper.java
浏览文件 @
04a8b4d8
...
...
@@ -195,7 +195,7 @@ class SynthMenuItemLayoutHelper extends MenuItemLayoutHelper {
getHorizontalAlignment
(),
getVerticalAlignment
(),
getHorizontalTextPosition
(),
getVerticalTextPosition
(),
getViewRect
(),
iconRect
,
textRect
,
getGap
());
textRect
.
width
+=
getLeftTextExtraWidth
()
+
getRightTextExtraWidth
()
;
textRect
.
width
+=
getLeftTextExtraWidth
();
Rectangle
labelRect
=
iconRect
.
union
(
textRect
);
getLabelSize
().
setHeight
(
labelRect
.
height
);
getLabelSize
().
setWidth
(
labelRect
.
width
);
...
...
src/share/classes/javax/swing/text/JTextComponent.java
浏览文件 @
04a8b4d8
...
...
@@ -2069,8 +2069,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* width to match its own
*/
public
boolean
getScrollableTracksViewportWidth
()
{
if
(
getParent
()
instanceof
JViewport
)
{
return
(
getParent
().
getWidth
()
>
getPreferredSize
().
width
);
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
port
!=
null
)
{
return
port
.
getWidth
()
>
getPreferredSize
().
width
;
}
return
false
;
}
...
...
@@ -2089,8 +2090,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* to match its own
*/
public
boolean
getScrollableTracksViewportHeight
()
{
if
(
getParent
()
instanceof
JViewport
)
{
return
(
getParent
().
getHeight
()
>
getPreferredSize
().
height
);
JViewport
port
=
SwingUtilities2
.
getViewport
(
this
);
if
(
port
!=
null
)
{
return
(
port
.
getHeight
()
>
getPreferredSize
().
height
);
}
return
false
;
}
...
...
@@ -4813,7 +4815,18 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
new
AttributedString
(
text
,
composedIndex
,
text
.
getEndIndex
()));
}
private
boolean
saveComposedText
(
int
pos
)
{
/**
* Saves composed text around the specified position.
*
* The composed text (if any) around the specified position is saved
* in a backing store and removed from the document.
*
* @param pos document position to identify the composed text location
* @return {@code true} if the composed text exists and is saved,
* {@code false} otherwise
* @see #restoreComposedText
*/
protected
boolean
saveComposedText
(
int
pos
)
{
if
(
composedTextExists
())
{
int
start
=
composedTextStart
.
getOffset
();
int
len
=
composedTextEnd
.
getOffset
()
-
...
...
@@ -4828,7 +4841,15 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
return
false
;
}
private
void
restoreComposedText
()
{
/**
* Restores composed text previously saved by {@code saveComposedText}.
*
* The saved composed text is inserted back into the document. This method
* should be invoked only if {@code saveComposedText} returns {@code true}.
*
* @see #saveComposedText
*/
protected
void
restoreComposedText
()
{
Document
doc
=
getDocument
();
try
{
doc
.
insertString
(
caret
.
getDot
(),
...
...
src/share/classes/javax/swing/tree/DefaultTreeSelectionModel.java
浏览文件 @
04a8b4d8
...
...
@@ -1067,10 +1067,13 @@ public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeS
}
/**
* Notifies listeners of a change in path. changePaths should contain
* instances of PathPlaceHolder.
*/
protected
void
notifyPathChange
(
Vector
<
PathPlaceHolder
>
changedPaths
,
* Notifies listeners of a change in path. changePaths should contain
* instances of PathPlaceHolder.
*
* @deprecated As of JDK version 1.7
*/
@Deprecated
protected
void
notifyPathChange
(
Vector
changedPaths
,
TreePath
oldLeadSelection
)
{
int
cPathCount
=
changedPaths
.
size
();
boolean
[]
newness
=
new
boolean
[
cPathCount
];
...
...
@@ -1078,7 +1081,7 @@ public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeS
PathPlaceHolder
placeholder
;
for
(
int
counter
=
0
;
counter
<
cPathCount
;
counter
++)
{
placeholder
=
changedPaths
.
elementAt
(
counter
);
placeholder
=
(
PathPlaceHolder
)
changedPaths
.
elementAt
(
counter
);
newness
[
counter
]
=
placeholder
.
isNew
;
paths
[
counter
]
=
placeholder
.
path
;
}
...
...
src/share/classes/sun/swing/MenuItemLayoutHelper.java
浏览文件 @
04a8b4d8
...
...
@@ -84,7 +84,6 @@ public class MenuItemLayoutHelper {
private
int
minTextOffset
;
private
int
leftTextExtraWidth
;
private
int
rightTextExtraWidth
;
private
Rectangle
viewRect
;
...
...
@@ -157,7 +156,6 @@ public class MenuItemLayoutHelper {
private
void
calcExtraWidths
()
{
leftTextExtraWidth
=
getLeftExtraWidth
(
text
);
rightTextExtraWidth
=
getRightExtraWidth
(
text
);
}
private
int
getLeftExtraWidth
(
String
str
)
{
...
...
@@ -169,15 +167,6 @@ public class MenuItemLayoutHelper {
}
}
private
int
getRightExtraWidth
(
String
str
)
{
int
rsb
=
SwingUtilities2
.
getRightSideBearing
(
mi
,
fm
,
str
);
if
(
rsb
>
0
)
{
return
rsb
;
}
else
{
return
0
;
}
}
private
void
setOriginalWidths
()
{
iconSize
.
origWidth
=
iconSize
.
width
;
textSize
.
origWidth
=
textSize
.
width
;
...
...
@@ -313,7 +302,7 @@ public class MenuItemLayoutHelper {
verticalAlignment
,
horizontalAlignment
,
verticalTextPosition
,
horizontalTextPosition
,
viewRect
,
iconRect
,
textRect
,
gap
);
textRect
.
width
+=
leftTextExtraWidth
+
rightTextExtraWidth
;
textRect
.
width
+=
leftTextExtraWidth
;
Rectangle
labelRect
=
iconRect
.
union
(
textRect
);
labelSize
.
height
=
labelRect
.
height
;
labelSize
.
width
=
labelRect
.
width
;
...
...
@@ -1121,10 +1110,6 @@ public class MenuItemLayoutHelper {
return
leftTextExtraWidth
;
}
public
int
getRightTextExtraWidth
()
{
return
rightTextExtraWidth
;
}
/**
* Returns false if the component is a JMenu and it is a top
* level menu (on the menubar).
...
...
src/share/classes/sun/swing/SwingUtilities2.java
浏览文件 @
04a8b4d8
...
...
@@ -27,7 +27,6 @@ package sun.swing;
import
java.security.*
;
import
java.lang.reflect.*
;
import
java.lang.ref.SoftReference
;
import
java.awt.*
;
import
static
java
.
awt
.
RenderingHints
.*;
import
java.awt.event.*
;
...
...
@@ -78,17 +77,23 @@ public class SwingUtilities2 {
public
static
final
Object
LAF_STATE_KEY
=
new
StringBuffer
(
"LookAndFeel State"
);
// Most of applications use 10 or less fonts simultaneously
private
static
final
int
STRONG_BEARING_CACHE_SIZE
=
10
;
// Strong cache for the left and right side bearings
// for STRONG_BEARING_CACHE_SIZE most recently used fonts.
private
static
BearingCacheEntry
[]
strongBearingCache
=
new
BearingCacheEntry
[
STRONG_BEARING_CACHE_SIZE
];
// Next index to insert an entry into the strong bearing cache
private
static
int
strongBearingCacheNextIndex
=
0
;
// Soft cache for the left and right side bearings
private
static
Set
<
SoftReference
<
BearingCacheEntry
>>
softBearingCache
=
new
HashSet
<
SoftReference
<
BearingCacheEntry
>>();
// Maintain a cache of CACHE_SIZE fonts and the left side bearing
// of the characters falling into the range MIN_CHAR_INDEX to
// MAX_CHAR_INDEX. The values in fontCache are created as needed.
private
static
LSBCacheEntry
[]
fontCache
;
// Windows defines 6 font desktop properties, we will therefore only
// cache the metrics for 6 fonts.
private
static
final
int
CACHE_SIZE
=
6
;
// nextIndex in fontCache to insert a font into.
private
static
int
nextIndex
;
// LSBCacheEntry used to search in fontCache to see if we already
// have an entry for a particular font
private
static
LSBCacheEntry
searchKey
;
// getLeftSideBearing will consult all characters that fall in the
// range MIN_CHAR_INDEX to MAX_CHAR_INDEX.
private
static
final
int
MIN_CHAR_INDEX
=
(
int
)
'W'
;
private
static
final
int
MAX_CHAR_INDEX
=
(
int
)
'W'
+
1
;
public
static
final
FontRenderContext
DEFAULT_FRC
=
new
FontRenderContext
(
null
,
false
,
false
);
...
...
@@ -183,6 +188,10 @@ public class SwingUtilities2 {
private
static
final
Object
charsBufferLock
=
new
Object
();
private
static
char
[]
charsBuffer
=
new
char
[
CHAR_BUFFER_SIZE
];
static
{
fontCache
=
new
LSBCacheEntry
[
CACHE_SIZE
];
}
/**
* checks whether TextLayout is required to handle characters.
*
...
...
@@ -226,7 +235,9 @@ public class SwingUtilities2 {
/**
* Returns the left side bearing of the first character of string. The
* left side bearing is calculated from the passed in FontMetrics.
* left side bearing is calculated from the passed in
* FontMetrics. If the passed in String is less than one
* character, this will throw a StringIndexOutOfBoundsException exception.
*
* @param c JComponent that will display the string
* @param fm FontMetrics used to measure the String width
...
...
@@ -234,14 +245,11 @@ public class SwingUtilities2 {
*/
public
static
int
getLeftSideBearing
(
JComponent
c
,
FontMetrics
fm
,
String
string
)
{
if
((
string
==
null
)
||
(
string
.
length
()
==
0
))
{
return
0
;
}
return
getLeftSideBearing
(
c
,
fm
,
string
.
charAt
(
0
));
}
/**
* Returns the left side bearing of the
specified character
. The
* Returns the left side bearing of the
first character of string
. The
* left side bearing is calculated from the passed in FontMetrics.
*
* @param c JComponent that will display the string
...
...
@@ -250,105 +258,37 @@ public class SwingUtilities2 {
*/
public
static
int
getLeftSideBearing
(
JComponent
c
,
FontMetrics
fm
,
char
firstChar
)
{
return
getBearing
(
c
,
fm
,
firstChar
,
true
);
}
int
charIndex
=
(
int
)
firstChar
;
if
(
charIndex
<
MAX_CHAR_INDEX
&&
charIndex
>=
MIN_CHAR_INDEX
)
{
byte
[]
lsbs
=
null
;
/**
* Returns the right side bearing of the last character of string. The
* right side bearing is calculated from the passed in FontMetrics.
*
* @param c JComponent that will display the string
* @param fm FontMetrics used to measure the String width
* @param string String to get the right side bearing for.
*/
public
static
int
getRightSideBearing
(
JComponent
c
,
FontMetrics
fm
,
String
string
)
{
if
((
string
==
null
)
||
(
string
.
length
()
==
0
))
{
return
0
;
}
return
getRightSideBearing
(
c
,
fm
,
string
.
charAt
(
string
.
length
()
-
1
));
}
/**
* Returns the right side bearing of the specified character. The
* right side bearing is calculated from the passed in FontMetrics.
*
* @param c JComponent that will display the string
* @param fm FontMetrics used to measure the String width
* @param lastChar Character to get the right side bearing for.
*/
public
static
int
getRightSideBearing
(
JComponent
c
,
FontMetrics
fm
,
char
lastChar
)
{
return
getBearing
(
c
,
fm
,
lastChar
,
false
);
}
/* Calculates the left and right side bearing for a character.
* Strongly caches bearings for STRONG_BEARING_CACHE_SIZE
* most recently used Fonts and softly caches as many as GC allows.
*/
private
static
int
getBearing
(
JComponent
comp
,
FontMetrics
fm
,
char
c
,
boolean
isLeftBearing
)
{
if
(
fm
==
null
)
{
if
(
comp
==
null
)
{
return
0
;
}
else
{
fm
=
comp
.
getFontMetrics
(
comp
.
getFont
());
}
}
synchronized
(
SwingUtilities2
.
class
)
{
BearingCacheEntry
entry
=
null
;
BearingCacheEntry
searchKey
=
new
BearingCacheEntry
(
fm
);
// See if we already have an entry in the strong cache
for
(
BearingCacheEntry
cacheEntry
:
strongBearingCache
)
{
if
(
searchKey
.
equals
(
cacheEntry
))
{
entry
=
cacheEntry
;
break
;
FontRenderContext
frc
=
getFontRenderContext
(
c
,
fm
);
Font
font
=
fm
.
getFont
();
synchronized
(
SwingUtilities2
.
class
)
{
LSBCacheEntry
entry
=
null
;
if
(
searchKey
==
null
)
{
searchKey
=
new
LSBCacheEntry
(
frc
,
font
);
}
else
{
searchKey
.
reset
(
frc
,
font
);
}
}
// See if we already have an entry in the soft cache
if
(
entry
==
null
)
{
Iterator
<
SoftReference
<
BearingCacheEntry
>>
iter
=
softBearingCache
.
iterator
();
while
(
iter
.
hasNext
())
{
BearingCacheEntry
cacheEntry
=
iter
.
next
().
get
();
if
(
cacheEntry
==
null
)
{
// Remove discarded soft reference from the cache
iter
.
remove
();
continue
;
}
// See if we already have an entry for this pair
for
(
LSBCacheEntry
cacheEntry
:
fontCache
)
{
if
(
searchKey
.
equals
(
cacheEntry
))
{
entry
=
cacheEntry
;
putEntryInStrongCache
(
entry
);
break
;
}
}
if
(
entry
==
null
)
{
// No entry for this pair, add it.
entry
=
searchKey
;
fontCache
[
nextIndex
]
=
searchKey
;
searchKey
=
null
;
nextIndex
=
(
nextIndex
+
1
)
%
CACHE_SIZE
;
}
return
entry
.
getLeftSideBearing
(
firstChar
);
}
if
(
entry
==
null
)
{
// No entry, add it
entry
=
searchKey
;
cacheEntry
(
entry
);
}
return
(
isLeftBearing
)
?
entry
.
getLeftSideBearing
(
c
)
:
entry
.
getRightSideBearing
(
c
);
}
}
private
synchronized
static
void
cacheEntry
(
BearingCacheEntry
entry
)
{
// Move the oldest entry from the strong cache into the soft cache
BearingCacheEntry
oldestEntry
=
strongBearingCache
[
strongBearingCacheNextIndex
];
if
(
oldestEntry
!=
null
)
{
softBearingCache
.
add
(
new
SoftReference
<
BearingCacheEntry
>(
oldestEntry
));
}
// Put entry in the strong cache
putEntryInStrongCache
(
entry
);
}
private
synchronized
static
void
putEntryInStrongCache
(
BearingCacheEntry
entry
)
{
strongBearingCache
[
strongBearingCacheNextIndex
]
=
entry
;
strongBearingCacheNextIndex
=
(
strongBearingCacheNextIndex
+
1
)
%
STRONG_BEARING_CACHE_SIZE
;
return
0
;
}
/**
...
...
@@ -1063,99 +1003,72 @@ public class SwingUtilities2 {
}
/**
* BearingCacheEntry is used to cache left and right character bearings
* for a particular <code>Font</code> and <code>FontRenderContext</code>.
* LSBCacheEntry is used to cache the left side bearing (lsb) for
* a particular <code>Font</code> and <code>FontRenderContext</code>.
* This only caches characters that fall in the range
* <code>MIN_CHAR_INDEX</code> to <code>MAX_CHAR_INDEX</code>.
*/
private
static
class
BearingCacheEntry
{
private
FontMetrics
fontMetrics
;
private
static
class
LSBCacheEntry
{
// Used to indicate a particular entry in lsb has not been set.
private
static
final
byte
UNSET
=
Byte
.
MAX_VALUE
;
// Used in creating a GlyphVector to get the lsb
private
static
final
char
[]
oneChar
=
new
char
[
1
];
private
byte
[]
lsbCache
;
private
Font
font
;
private
FontRenderContext
frc
;
private
Map
<
Character
,
Short
>
cache
;
// Used for the creation of a GlyphVector
private
static
final
char
[]
oneChar
=
new
char
[
1
];
public
BearingCacheEntry
(
FontMetrics
fontMetrics
)
{
this
.
fontMetrics
=
fontMetrics
;
this
.
font
=
fontMetrics
.
getFont
();
this
.
frc
=
fontMetrics
.
getFontRenderContext
();
this
.
cache
=
new
HashMap
<
Character
,
Short
>();
assert
(
font
!=
null
&&
frc
!=
null
);
}
public
int
getLeftSideBearing
(
char
aChar
)
{
Short
bearing
=
cache
.
get
(
aChar
);
if
(
bearing
==
null
)
{
bearing
=
calcBearing
(
aChar
);
cache
.
put
(
aChar
,
bearing
);
}
return
((
0xFF00
&
bearing
)
>>>
8
)
-
127
;
public
LSBCacheEntry
(
FontRenderContext
frc
,
Font
font
)
{
lsbCache
=
new
byte
[
MAX_CHAR_INDEX
-
MIN_CHAR_INDEX
];
reset
(
frc
,
font
);
}
public
int
getRightSideBearing
(
char
aChar
)
{
Short
bearing
=
cache
.
get
(
aChar
)
;
if
(
bearing
==
null
)
{
bearing
=
calcBearing
(
aChar
);
cache
.
put
(
aChar
,
bearing
)
;
public
void
reset
(
FontRenderContext
frc
,
Font
font
)
{
this
.
font
=
font
;
this
.
frc
=
frc
;
for
(
int
counter
=
lsbCache
.
length
-
1
;
counter
>=
0
;
counter
--)
{
lsbCache
[
counter
]
=
UNSET
;
}
return
(
0xFF
&
bearing
)
-
127
;
}
/* Calculates left and right side bearings for a character.
* Makes an assumption that bearing is a value between -127 and +127.
* Stores LSB and RSB as single two-byte number (short):
* LSB is the high byte, RSB is the low byte.
*/
private
short
calcBearing
(
char
aChar
)
{
oneChar
[
0
]
=
aChar
;
GlyphVector
gv
=
font
.
createGlyphVector
(
frc
,
oneChar
);
Rectangle
pixelBounds
=
gv
.
getGlyphPixelBounds
(
0
,
frc
,
0
f
,
0
f
);
// Get bearings
int
lsb
=
pixelBounds
.
x
;
int
rsb
=
pixelBounds
.
width
-
fontMetrics
.
charWidth
(
aChar
);
/* HRGB/HBGR LCD glyph images will always have a pixel
* on the left and a pixel on the right
* used in colour fringe reduction.
* Text rendering positions this correctly but here
* we are using the glyph image to adjust that position
* so must account for it.
*/
if
(
lsb
<
0
)
{
Object
aaHint
=
frc
.
getAntiAliasingHint
();
if
(
aaHint
==
VALUE_TEXT_ANTIALIAS_LCD_HRGB
||
aaHint
==
VALUE_TEXT_ANTIALIAS_LCD_HBGR
)
{
lsb
++;
}
}
if
(
rsb
>
0
)
{
Object
aaHint
=
frc
.
getAntiAliasingHint
();
if
(
aaHint
==
VALUE_TEXT_ANTIALIAS_LCD_HRGB
||
aaHint
==
VALUE_TEXT_ANTIALIAS_LCD_HBGR
)
{
rsb
--;
}
public
int
getLeftSideBearing
(
char
aChar
)
{
int
index
=
aChar
-
MIN_CHAR_INDEX
;
assert
(
index
>=
0
&&
index
<
(
MAX_CHAR_INDEX
-
MIN_CHAR_INDEX
));
byte
lsb
=
lsbCache
[
index
];
if
(
lsb
==
UNSET
)
{
oneChar
[
0
]
=
aChar
;
GlyphVector
gv
=
font
.
createGlyphVector
(
frc
,
oneChar
);
lsb
=
(
byte
)
gv
.
getGlyphPixelBounds
(
0
,
frc
,
0
f
,
0
f
).
x
;
if
(
lsb
<
0
)
{
/* HRGB/HBGR LCD glyph images will always have a pixel
* on the left used in colour fringe reduction.
* Text rendering positions this correctly but here
* we are using the glyph image to adjust that position
* so must account for it.
*/
Object
aaHint
=
frc
.
getAntiAliasingHint
();
if
(
aaHint
==
VALUE_TEXT_ANTIALIAS_LCD_HRGB
||
aaHint
==
VALUE_TEXT_ANTIALIAS_LCD_HBGR
)
{
lsb
++;
}
}
lsbCache
[
index
]
=
lsb
;
}
return
lsb
;
// Make sure that LSB and RSB are valid (see 6472972)
if
(
lsb
<
-
127
||
lsb
>
127
)
{
lsb
=
0
;
}
if
(
rsb
<
-
127
||
rsb
>
127
)
{
rsb
=
0
;
}
int
bearing
=
((
lsb
+
127
)
<<
8
)
+
(
rsb
+
127
);
return
(
short
)
bearing
;
}
public
boolean
equals
(
Object
entry
)
{
if
(
entry
==
this
)
{
return
true
;
}
if
(!(
entry
instanceof
Bearing
CacheEntry
))
{
if
(!(
entry
instanceof
LSB
CacheEntry
))
{
return
false
;
}
BearingCacheEntry
oEntry
=
(
BearingCacheEntry
)
entry
;
LSBCacheEntry
oEntry
=
(
LSBCacheEntry
)
entry
;
return
(
font
.
equals
(
oEntry
.
font
)
&&
frc
.
equals
(
oEntry
.
frc
));
}
...
...
@@ -1172,7 +1085,6 @@ public class SwingUtilities2 {
}
}
/*
* here goes the fix for 4856343 [Problem with applet interaction
* with system selection clipboard]
...
...
@@ -1181,36 +1093,34 @@ public class SwingUtilities2 {
* are to be performed
*/
/**
* checks the security permissions for accessing system clipboard
*
* for untrusted context (see isTrustedContext) checks the
* permissions for the current event being handled
*
*/
public
static
boolean
canAccessSystemClipboard
()
{
boolean
canAccess
=
false
;
if
(!
GraphicsEnvironment
.
isHeadless
())
{
SecurityManager
sm
=
System
.
getSecurityManager
();
if
(
sm
==
null
)
{
canAccess
=
true
;
}
else
{
try
{
sm
.
checkSystemClipboardAccess
();
canAccess
=
true
;
}
catch
(
SecurityException
e
)
{
}
if
(
canAccess
&&
!
isTrustedContext
())
{
canAccess
=
canCurrentEventAccessSystemClipboard
(
true
);
}
}
}
return
canAccess
;
}
* checks the security permissions for accessing system clipboard
*
* for untrusted context (see isTrustedContext) checks the
* permissions for the current event being handled
*
*/
public
static
boolean
canAccessSystemClipboard
()
{
boolean
canAccess
=
false
;
if
(!
GraphicsEnvironment
.
isHeadless
())
{
SecurityManager
sm
=
System
.
getSecurityManager
();
if
(
sm
==
null
)
{
canAccess
=
true
;
}
else
{
try
{
sm
.
checkSystemClipboardAccess
();
canAccess
=
true
;
}
catch
(
SecurityException
e
)
{
}
if
(
canAccess
&&
!
isTrustedContext
())
{
canAccess
=
canCurrentEventAccessSystemClipboard
(
true
);
}
}
}
return
canAccess
;
}
/**
* Returns true if EventQueue.getCurrentEvent() has the permissions to
* Returns true if EventQueue.getCurrentEvent() has the permissions to
* access the system clipboard
*/
public
static
boolean
canCurrentEventAccessSystemClipboard
()
{
...
...
@@ -1844,4 +1754,22 @@ public class SwingUtilities2 {
boolean
three
)
{
return
liesIn
(
rect
,
p
,
false
,
false
,
three
);
}
/**
* Returns the {@code JViewport} instance for the {@code component}
* or {@code null}.
*
* @return the {@code JViewport} instance for the {@code component}
* or {@code null}
* @throws NullPointerException if {@code component} is {@code null}
*/
public
static
JViewport
getViewport
(
Component
component
)
{
do
{
component
=
component
.
getParent
();
if
(
component
instanceof
JViewport
)
{
return
(
JViewport
)
component
;
}
}
while
(
component
instanceof
JLayer
);
return
null
;
}
}
src/solaris/native/java/util/TimeZone_md.c
浏览文件 @
04a8b4d8
...
...
@@ -51,9 +51,9 @@
#ifdef __linux__
static
const
char
*
sysconfig_clock_file
=
"/etc/sysconfig/clock
"
;
static
const
char
*
zoneinfo_dir
=
"/usr/share/zoneinfo"
;
static
const
char
*
defailt_zoneinfo_file
=
"/etc/localtime"
;
static
const
char
*
ETC_TIMEZONE_FILE
=
"/etc/timezone
"
;
static
const
char
*
ZONEINFO_DIR
=
"/usr/share/zoneinfo"
;
static
const
char
*
DEFAULT_ZONEINFO_FILE
=
"/etc/localtime"
;
/*
* Returns a point to the zone ID portion of the given zoneinfo file
...
...
@@ -201,53 +201,22 @@ getPlatformTimeZoneID()
size_t
size
;
/*
* First, try the ZONE entry in /etc/sysconfig/clock. However, the
* ZONE entry is not set up after initial Red Hat Linux
* installation. In case that /etc/localtime is set up without
* using timeconfig, there might be inconsistency between
* /etc/localtime and the ZONE entry. The inconsistency between
* timeconfig and linuxconf is reported as a bug in the Red Hat
* web page as of May 1, 2000.
* Try reading the /etc/timezone file for Debian distros. There's
* no spec of the file format available. This parsing assumes that
* there's one line of an Olson tzid followed by a '\n', no
* leading or trailing spaces, no comments.
*/
if
((
fp
=
fopen
(
sysconfig_clock_file
,
"r"
))
!=
NULL
)
{
if
((
fp
=
fopen
(
ETC_TIMEZONE_FILE
,
"r"
))
!=
NULL
)
{
char
line
[
256
];
while
(
fgets
(
line
,
sizeof
(
line
),
fp
)
!=
NULL
)
{
char
*
p
=
line
;
char
*
s
;
SKIP_SPACE
(
p
);
if
(
*
p
!=
'Z'
)
{
continue
;
}
if
(
strncmp
(
p
,
"ZONE=
\"
"
,
6
)
==
0
)
{
p
+=
6
;
}
else
{
/*
* In case we need to parse it token by token.
*/
if
(
strncmp
(
p
,
"ZONE"
,
4
)
!=
0
)
{
continue
;
}
p
+=
4
;
SKIP_SPACE
(
p
);
if
(
*
p
++
!=
'='
)
{
break
;
}
SKIP_SPACE
(
p
);
if
(
*
p
++
!=
'"'
)
{
break
;
}
if
(
fgets
(
line
,
sizeof
(
line
),
fp
)
!=
NULL
)
{
char
*
p
=
strchr
(
line
,
'\n'
);
if
(
p
!=
NULL
)
{
*
p
=
'\0'
;
}
for
(
s
=
p
;
*
s
&&
*
s
!=
'"'
;
s
++
)
;
if
(
*
s
!=
'"'
)
{
/* this ZONE entry is broken. */
break
;
if
(
strlen
(
line
)
>
0
)
{
tz
=
strdup
(
line
);
}
*
s
=
'\0'
;
tz
=
strdup
(
p
);
break
;
}
(
void
)
fclose
(
fp
);
if
(
tz
!=
NULL
)
{
...
...
@@ -258,7 +227,7 @@ getPlatformTimeZoneID()
/*
* Next, try /etc/localtime to find the zone ID.
*/
if
(
lstat
(
defailt_zoneinfo_file
,
&
statbuf
)
==
-
1
)
{
if
(
lstat
(
DEFAULT_ZONEINFO_FILE
,
&
statbuf
)
==
-
1
)
{
return
NULL
;
}
...
...
@@ -273,9 +242,9 @@ getPlatformTimeZoneID()
char
linkbuf
[
PATH_MAX
+
1
];
int
len
;
if
((
len
=
readlink
(
defailt_zoneinfo_file
,
linkbuf
,
sizeof
(
linkbuf
)
-
1
))
==
-
1
)
{
if
((
len
=
readlink
(
DEFAULT_ZONEINFO_FILE
,
linkbuf
,
sizeof
(
linkbuf
)
-
1
))
==
-
1
)
{
jio_fprintf
(
stderr
,
(
const
char
*
)
"can't get a symlink of %s
\n
"
,
defailt_zoneinfo_file
);
DEFAULT_ZONEINFO_FILE
);
return
NULL
;
}
linkbuf
[
len
]
=
'\0'
;
...
...
@@ -295,7 +264,7 @@ getPlatformTimeZoneID()
if
(
buf
==
NULL
)
{
return
NULL
;
}
if
((
fd
=
open
(
defailt_zoneinfo_file
,
O_RDONLY
))
==
-
1
)
{
if
((
fd
=
open
(
DEFAULT_ZONEINFO_FILE
,
O_RDONLY
))
==
-
1
)
{
free
((
void
*
)
buf
);
return
NULL
;
}
...
...
@@ -307,7 +276,7 @@ getPlatformTimeZoneID()
}
(
void
)
close
(
fd
);
tz
=
findZoneinfoFile
(
buf
,
size
,
zoneinfo_dir
);
tz
=
findZoneinfoFile
(
buf
,
size
,
ZONEINFO_DIR
);
free
((
void
*
)
buf
);
return
tz
;
}
...
...
src/windows/classes/sun/awt/windows/fontconfig.properties
浏览文件 @
04a8b4d8
#
#
# Copyright 2003-200
4
Sun Microsystems, Inc. All Rights Reserved.
# Copyright 2003-200
9
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
...
...
@@ -31,8 +31,11 @@ version=1
# Component Font Mappings
allfonts.chinese-ms936
=
SimSun
allfonts.chinese-ms936-extb
=
SimSun-ExtB
allfonts.chinese-gb18030
=
SimSun-18030
allfonts.chinese-gb18030-extb
=
SimSun-ExtB
allfonts.chinese-hkscs
=
MingLiU_HKSCS
allfonts.chinese-ms950-extb
=
MingLiU-ExtB
allfonts.devanagari
=
Mangal
allfonts.dingbats
=
Wingdings
allfonts.lucida
=
Lucida Sans Regular
...
...
@@ -41,120 +44,140 @@ allfonts.thai=Lucida Sans Regular
serif.plain.alphabetic
=
Times New Roman
serif.plain.chinese-ms950
=
MingLiU
serif.plain.chinese-ms950-extb
=
MingLiU-ExtB
serif.plain.hebrew
=
David
serif.plain.japanese
=
MS Mincho
serif.plain.korean
=
Batang
serif.bold.alphabetic
=
Times New Roman Bold
serif.bold.chinese-ms950
=
PMingLiU
serif.bold.chinese-ms950-extb
=
PMingLiU-ExtB
serif.bold.hebrew
=
David Bold
serif.bold.japanese
=
MS Mincho
serif.bold.korean
=
Batang
serif.italic.alphabetic
=
Times New Roman Italic
serif.italic.chinese-ms950
=
PMingLiU
serif.italic.chinese-ms950-extb
=
PMingLiU-ExtB
serif.italic.hebrew
=
David
serif.italic.japanese
=
MS Mincho
serif.italic.korean
=
Batang
serif.bolditalic.alphabetic
=
Times New Roman Bold Italic
serif.bolditalic.chinese-ms950
=
PMingLiU
serif.bolditalic.chinese-ms950-extb
=
PMingLiU-ExtB
serif.bolditalic.hebrew
=
David Bold
serif.bolditalic.japanese
=
MS Mincho
serif.bolditalic.korean
=
Batang
sansserif.plain.alphabetic
=
Arial
sansserif.plain.chinese-ms950
=
MingLiU
sansserif.plain.chinese-ms950-extb
=
MingLiU-ExtB
sansserif.plain.hebrew
=
David
sansserif.plain.japanese
=
MS Gothic
sansserif.plain.korean
=
Gulim
sansserif.bold.alphabetic
=
Arial Bold
sansserif.bold.chinese-ms950
=
PMingLiU
sansserif.bold.chinese-ms950-extb
=
PMingLiU-ExtB
sansserif.bold.hebrew
=
David Bold
sansserif.bold.japanese
=
MS Gothic
sansserif.bold.korean
=
Gulim
sansserif.italic.alphabetic
=
Arial Italic
sansserif.italic.chinese-ms950
=
PMingLiU
sansserif.italic.chinese-ms950-extb
=
PMingLiU-ExtB
sansserif.italic.hebrew
=
David
sansserif.italic.japanese
=
MS Gothic
sansserif.italic.korean
=
Gulim
sansserif.bolditalic.alphabetic
=
Arial Bold Italic
sansserif.bolditalic.chinese-ms950
=
PMingLiU
sansserif.bolditalic.chinese-ms950-extb
=
PMingLiU-ExtB
sansserif.bolditalic.hebrew
=
David Bold
sansserif.bolditalic.japanese
=
MS Gothic
sansserif.bolditalic.korean
=
Gulim
monospaced.plain.alphabetic
=
Courier New
monospaced.plain.chinese-ms950
=
MingLiU
monospaced.plain.chinese-ms950-extb
=
MingLiU-ExtB
monospaced.plain.hebrew
=
David
monospaced.plain.japanese
=
MS Gothic
monospaced.plain.korean
=
GulimChe
monospaced.bold.alphabetic
=
Courier New Bold
monospaced.bold.chinese-ms950
=
PMingLiU
monospaced.bold.chinese-ms950-extb
=
PMingLiU-ExtB
monospaced.bold.hebrew
=
David Bold
monospaced.bold.japanese
=
MS Gothic
monospaced.bold.korean
=
GulimChe
monospaced.italic.alphabetic
=
Courier New Italic
monospaced.italic.chinese-ms950
=
PMingLiU
monospaced.italic.chinese-ms950-extb
=
PMingLiU-ExtB
monospaced.italic.hebrew
=
David
monospaced.italic.japanese
=
MS Gothic
monospaced.italic.korean
=
GulimChe
monospaced.bolditalic.alphabetic
=
Courier New Bold Italic
monospaced.bolditalic.chinese-ms950
=
PMingLiU
monospaced.bolditalic.chinese-ms950-extb
=
PMingLiU-ExtB
monospaced.bolditalic.hebrew
=
David Bold
monospaced.bolditalic.japanese
=
MS Gothic
monospaced.bolditalic.korean
=
GulimChe
dialog.plain.alphabetic
=
Arial
dialog.plain.chinese-ms950
=
MingLiU
dialog.plain.chinese-ms950-extb
=
MingLiU-ExtB
dialog.plain.hebrew
=
David
dialog.plain.japanese
=
MS Gothic
dialog.plain.korean
=
Gulim
dialog.bold.alphabetic
=
Arial Bold
dialog.bold.chinese-ms950
=
PMingLiU
dialog.bold.chinese-ms950-extb
=
PMingLiU-ExtB
dialog.bold.hebrew
=
David Bold
dialog.bold.japanese
=
MS Gothic
dialog.bold.korean
=
Gulim
dialog.italic.alphabetic
=
Arial Italic
dialog.italic.chinese-ms950
=
PMingLiU
dialog.italic.chinese-ms950-extb
=
PMingLiU-ExtB
dialog.italic.hebrew
=
David
dialog.italic.japanese
=
MS Gothic
dialog.italic.korean
=
Gulim
dialog.bolditalic.alphabetic
=
Arial Bold Italic
dialog.bolditalic.chinese-ms950
=
PMingLiU
dialog.bolditalic.chinese-ms950-extb
=
PMingLiU-ExtB
dialog.bolditalic.hebrew
=
David Bold
dialog.bolditalic.japanese
=
MS Gothic
dialog.bolditalic.korean
=
Gulim
dialoginput.plain.alphabetic
=
Courier New
dialoginput.plain.chinese-ms950
=
MingLiU
dialoginput.plain.chinese-ms950-extb
=
MingLiU-ExtB
dialoginput.plain.hebrew
=
David
dialoginput.plain.japanese
=
MS Gothic
dialoginput.plain.korean
=
Gulim
dialoginput.bold.alphabetic
=
Courier New Bold
dialoginput.bold.chinese-ms950
=
PMingLiU
dialoginput.bold.chinese-ms950-extb
=
PMingLiU-ExtB
dialoginput.bold.hebrew
=
David Bold
dialoginput.bold.japanese
=
MS Gothic
dialoginput.bold.korean
=
Gulim
dialoginput.italic.alphabetic
=
Courier New Italic
dialoginput.italic.chinese-ms950
=
PMingLiU
dialoginput.italic.chinese-ms950-extb
=
PMingLiU-ExtB
dialoginput.italic.hebrew
=
David
dialoginput.italic.japanese
=
MS Gothic
dialoginput.italic.korean
=
Gulim
dialoginput.bolditalic.alphabetic
=
Courier New Bold Italic
dialoginput.bolditalic.chinese-ms950
=
PMingLiU
dialoginput.bolditalic.chinese-ms950-extb
=
PMingLiU-ExtB
dialoginput.bolditalic.hebrew
=
David Bold
dialoginput.bolditalic.japanese
=
MS Gothic
dialoginput.bolditalic.korean
=
Gulim
...
...
@@ -163,31 +186,32 @@ dialoginput.bolditalic.korean=Gulim
sequence.allfonts
=
alphabetic/default,dingbats,symbol
sequence.serif.GBK
=
alphabetic,chinese-ms936,dingbats,symbol
sequence.sansserif.GBK
=
alphabetic,chinese-ms936,dingbats,symbol
sequence.monospaced.GBK
=
chinese-ms936,alphabetic,dingbats,symbol
sequence.dialog.GBK
=
alphabetic,chinese-ms936,dingbats,symbol
sequence.dialoginput.GBK
=
alphabetic,chinese-ms936,dingbats,symbol
sequence.serif.GB18030
=
alphabetic,chinese-gb18030,dingbats,symbol
sequence.sansserif.GB18030
=
alphabetic,chinese-gb18030,dingbats,symbol
sequence.monospaced.GB18030
=
chinese-gb18030,alphabetic,dingbats,symbol
sequence.dialog.GB18030
=
alphabetic,chinese-gb18030,dingbats,symbol
sequence.dialoginput.GB18030
=
alphabetic,chinese-gb18030,dingbats,symbol
sequence.serif.x-windows-950
=
alphabetic,chinese-ms950,dingbats,symbol
sequence.sansserif.x-windows-950
=
alphabetic,chinese-ms950,dingbats,symbol
sequence.monospaced.x-windows-950
=
chinese-ms950,alphabetic,dingbats,symbol
sequence.dialog.x-windows-950
=
alphabetic,chinese-ms950,dingbats,symbol
sequence.dialoginput.x-windows-950
=
alphabetic,chinese-ms950,dingbats,symbol
sequence.serif.x-MS950-HKSCS
=
alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
sequence.sansserif.x-MS950-HKSCS
=
alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
sequence.monospaced.x-MS950-HKSCS
=
chinese-ms950,alphabetic,chinese-hkscs,dingbats,symbol
sequence.dialog.x-MS950-HKSCS
=
alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
sequence.dialoginput.x-MS950-HKSCS
=
alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
sequence.serif.GBK
=
alphabetic,chinese-ms936,dingbats,symbol
,chinese-ms936-extb
sequence.sansserif.GBK
=
alphabetic,chinese-ms936,dingbats,symbol
,chinese-ms936-extb
sequence.monospaced.GBK
=
chinese-ms936,alphabetic,dingbats,symbol
,chinese-ms936-extb
sequence.dialog.GBK
=
alphabetic,chinese-ms936,dingbats,symbol
,chinese-ms936-extb
sequence.dialoginput.GBK
=
alphabetic,chinese-ms936,dingbats,symbol
,chinese-ms936-extb
sequence.serif.GB18030
=
alphabetic,chinese-gb18030,dingbats,symbol
,chinese-gb18030-extb
sequence.sansserif.GB18030
=
alphabetic,chinese-gb18030,dingbats,symbol
,chinese-gb18030-extb
sequence.monospaced.GB18030
=
chinese-gb18030,alphabetic,dingbats,symbol
,chinese-gb18030-extb
sequence.dialog.GB18030
=
alphabetic,chinese-gb18030,dingbats,symbol
,chinese-gb18030-extb
sequence.dialoginput.GB18030
=
alphabetic,chinese-gb18030,dingbats,symbol
,chinese-gb18030-extb
sequence.serif.x-windows-950
=
alphabetic,chinese-ms950,dingbats,symbol
,chinese-ms950-extb
sequence.sansserif.x-windows-950
=
alphabetic,chinese-ms950,dingbats,symbol
,chinese-ms950-extb
sequence.monospaced.x-windows-950
=
chinese-ms950,alphabetic,dingbats,symbol
,chinese-ms950-extb
sequence.dialog.x-windows-950
=
alphabetic,chinese-ms950,dingbats,symbol
,chinese-ms950-extb
sequence.dialoginput.x-windows-950
=
alphabetic,chinese-ms950,dingbats,symbol
,chinese-ms950-extb
sequence.serif.x-MS950-HKSCS
=
alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
,chinese-ms950-extb
sequence.sansserif.x-MS950-HKSCS
=
alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
,chinese-ms950-extb
sequence.monospaced.x-MS950-HKSCS
=
chinese-ms950,alphabetic,chinese-hkscs,dingbats,symbol
,chinese-ms950-extb
sequence.dialog.x-MS950-HKSCS
=
alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
,chinese-ms950-extb
sequence.dialoginput.x-MS950-HKSCS
=
alphabetic,chinese-ms950,chinese-hkscs,dingbats,symbol
,chinese-ms950-extb
sequence.allfonts.UTF-8.hi
=
alphabetic/1252,devanagari,dingbats,symbol
sequence.allfonts.UTF-8.ja
=
alphabetic,japanese,devanagari,dingbats,symbol
sequence.allfonts.windows-1255
=
hebrew,alphabetic/1252,dingbats,symbol
...
...
@@ -207,7 +231,7 @@ sequence.allfonts.x-windows-874=alphabetic,thai,dingbats,symbol
sequence.fallback
=
lucida,
\
chinese-ms950,chinese-hkscs,chinese-ms936,chinese-gb18030,
\
japanese,korean
japanese,korean
,chinese-ms950-extb,chinese-ms936-extb
# Exclusion Ranges
...
...
@@ -220,6 +244,7 @@ exclusion.hebrew=0041-005a,0060-007a,007f-00ff,20ac-20ac
proportional.MS_Gothic
=
MS PGothic
proportional.MS_Mincho
=
MS PMincho
proportional.MingLiU
=
PMingLiU
proportional.MingLiU-ExtB
=
PMingLiU-ExtB
# Font File Names
...
...
@@ -240,9 +265,12 @@ filename.Times_New_Roman_Bold_Italic=TIMESBI.TTF
filename.SimSun
=
SIMSUN.TTC
filename.SimSun-18030
=
SIMSUN18030.TTC
filename.SimSun-ExtB
=
SIMSUNB.TTF
filename.MingLiU
=
MINGLIU.TTC
filename.MingLiU-ExtB
=
MINGLIUB.TTC
filename.PMingLiU
=
MINGLIU.TTC
filename.PMingLiU-ExtB
=
MINGLIUB.TTC
filename.MingLiU_HKSCS
=
hkscsm3u.ttf
filename.David
=
DAVID.TTF
...
...
src/windows/lib/tzmappings
浏览文件 @
04a8b4d8
...
...
@@ -82,8 +82,8 @@ GMT:0,1::Europe/London:
GMT Standard Time:0,1::Europe/London:
Ekaterinburg:10,11::Asia/Yekaterinburg:
Ekaterinburg Standard Time:10,11::Asia/Yekaterinburg:
West Asia:10,11:
:Asia/Karachi
:
West Asia Standard Time:10,11:
:Asia/Karachi
:
West Asia:10,11:
UZ:Asia/Tashkent
:
West Asia Standard Time:10,11:
UZ:Asia/Tashkent
:
Central Asia:12,13::Asia/Dhaka:
Central Asia Standard Time:12,13::Asia/Dhaka:
N. Central Asia Standard Time:12,13::Asia/Novosibirsk:
...
...
@@ -146,8 +146,8 @@ South Africa:4,69::Africa/Harare:
South Africa Standard Time:4,69::Africa/Harare:
Atlantic:40,41::America/Halifax:
Atlantic Standard Time:40,41::America/Halifax:
SA Eastern:42,43:
:America/Buenos_Aires
:
SA Eastern Standard Time:42,43:
:America/Buenos_Aires
:
SA Eastern:42,43:
GF:America/Cayenne
:
SA Eastern Standard Time:42,43:
GF:America/Cayenne
:
Mid-Atlantic:44,45::Atlantic/South_Georgia:
Mid-Atlantic Standard Time:44,45::Atlantic/South_Georgia:
Azores:46,47::Atlantic/Azores:
...
...
@@ -160,21 +160,28 @@ New Zealand Standard Time:78,79::Pacific/Auckland:
Tonga Standard Time:78,79::Pacific/Tongatapu:
Arabian:8,9::Asia/Muscat:
Arabian Standard Time:8,9::Asia/Muscat:
Caucasus:8,9:
:GMT+0400
:
Caucasus Standard Time:8,9:
:GMT+0400
:
Caucasus:8,9:
AM:Asia/Yerevan
:
Caucasus Standard Time:8,9:
AM:Asia/Yerevan
:
GMT Standard Time:88,89::GMT:
Greenwich:88,89::GMT:
Greenwich Standard Time:88,89::GMT:
Central Brazilian Standard Time:900,900:BR:America/Manaus:
Central Standard Time (Mexico):901,901::America/Mexico_City:
Georgian Standard Time:902,902:GE:Asia/Tbilisi:
Mountain Standard Time (Mexico):903,903:MX:America/Chihuahua:
Namibia Standard Time:904,904:NA:Africa/Windhoek:
Pacific Standard Time (Mexico):905,905:MX:America/Tijuana:
Western Brazilian Standard Time:906,906:BR:America/Rio_Branco:
Azerbaijan Standard Time:907,907:AZ:Asia/Baku:
Jordan Standard Time:908,908:JO:Asia/Amman:
Middle East Standard Time:909,909:LB:Asia/Beirut:
Armenian Standard Time:910,910:AM:Asia/Yerevan:
Montevideo Standard Time:911,911:UY:America/Montevideo:
Venezuela Standard Time:912,912::America/Caracas:
Argentina Standard Time:900,900::America/Buenos_Aires:
Azerbaijan Standard Time:901,901:AZ:Asia/Baku:
Central Brazilian Standard Time:902,902:BR:America/Manaus:
Central Standard Time (Mexico):903,903::America/Mexico_City:
Georgian Standard Time:904,904:GE:Asia/Tbilisi:
Jordan Standard Time:905,905:JO:Asia/Amman:
Mauritius Standard Time:906,906:MU:Indian/Mauritius:
Middle East Standard Time:907,907:LB:Asia/Beirut:
Montevideo Standard Time:908,908:UY:America/Montevideo:
Morocco Standard Time:909,909:MA:Africa/Casablanca:
Mountain Standard Time (Mexico):910,910:MX:America/Chihuahua:
Namibia Standard Time:911,911:NA:Africa/Windhoek:
Pacific Standard Time (Mexico):912,912:MX:America/Tijuana:
Pakistan Standard Time:913,913::Asia/Karachi:
UTC:914,914::UTC:
Venezuela Standard Time:915,915::America/Caracas:
Kamchatka Standard Time:916,916:RU:Asia/Kamchatka:
Paraguay Standard Time:917,917:PY:America/Asuncion:
Western Brazilian Standard Time:918,918:BR:America/Rio_Branco:
Armenian Standard Time:919,919:AM:Asia/Yerevan:
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/DoubleBean
.java
→
test/com/sun/java/swing/plaf/windows/Test6824600
.java
浏览文件 @
04a8b4d8
/*
* Copyright 200
2-2007
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 200
9
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.
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
@@ -22,48 +20,51 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.swingx.designer
;
import
org.jdesktop.beans.AbstractBean
;
/* @test
@bug 6824600
@summary OOM occurs when setLookAndFeel() is executed in Windows L&F(XP style)
@author Pavel Porvatov
@run main Test6824600
*/
/**
* DoubleBean - Simple bean for a observable double value
*
* @author Created by Jasper Potts (May 25, 2007)
*/
public
class
DoubleBean
extends
AbstractBean
{
private
double
value
=
0
;
import
com.sun.java.swing.plaf.windows.DesktopProperty
;
public
DoubleBean
()
{}
import
java.awt.*
;
public
DoubleBean
(
double
value
)
{
this
.
value
=
value
;
}
public
class
Test6824600
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
Toolkit
toolkit
=
Toolkit
.
getDefaultToolkit
();
public
double
getValue
()
{
return
value
;
}
HackedDesktopProperty
desktopProperty
=
new
HackedDesktopProperty
(
"Button.background"
,
null
);
public
void
setValue
(
double
value
)
{
double
old
=
this
.
value
;
this
.
value
=
value
;
firePropertyChange
(
"value"
,
old
,
this
.
value
);
}
// Register listener in toolkit
desktopProperty
.
getValueFromDesktop
();
int
length
=
toolkit
.
getPropertyChangeListeners
().
length
;
public
boolean
equals
(
Object
o
)
{
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
()
!=
o
.
getClass
())
return
false
;
// Make several invocations
desktopProperty
.
getValueFromDesktop
()
;
desktopProperty
.
getValueFromDesktop
()
;
DoubleBean
that
=
(
DoubleBean
)
o
;
desktopProperty
.
invalidate
()
;
if
(
Double
.
compare
(
that
.
value
,
value
)
!=
0
)
return
false
;
desktopProperty
.
getValueFromDesktop
();
desktopProperty
.
getValueFromDesktop
();
return
true
;
if
(
length
!=
toolkit
.
getPropertyChangeListeners
().
length
)
{
throw
new
RuntimeException
(
"New listeners were added into Toolkit"
);
}
}
public
int
hashCode
()
{
long
temp
=
value
!=
+
0.0d
?
Double
.
doubleToLongBits
(
value
)
:
0L
;
return
(
int
)
(
temp
^
(
temp
>>>
32
));
public
static
class
HackedDesktopProperty
extends
DesktopProperty
{
public
HackedDesktopProperty
(
String
key
,
Object
fallback
)
{
super
(
key
,
fallback
);
}
// Publish the method
public
Object
getValueFromDesktop
()
{
return
super
.
getValueFromDesktop
();
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/CustomUIDefault
.java
→
test/java/util/TimeZone/ListTimeZones
.java
浏览文件 @
04a8b4d8
/*
* Copyright 200
2-2007
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 200
9
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
...
...
@@ -22,22 +22,24 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.synthdesigner.synthmodel
;
/**
*
CustomUIDefaul
t
*
* @
author Richard Bair
* @
author Jasper Pott
s
*
@tes
t
*
@bug 6851214
* @
summary Allow 24:00 as a valid end/start DST time stamp
* @
run main ListTimeZone
s
*/
public
class
CustomUIDefault
<
T
>
extends
UIDefault
<
T
>
{
private
static
int
counter
=
-
1
;
public
CustomUIDefault
()
{
super
(
"Unnamed"
+
(++
counter
==
0
?
""
:
counter
),
null
);
}
import
java.util.*
;
public
void
setName
(
String
id
)
{
super
.
setName
(
id
);
public
class
ListTimeZones
{
public
static
void
main
(
String
[]
args
){
Date
date
=
new
Date
();
String
TimeZoneIds
[]
=
TimeZone
.
getAvailableIDs
();
for
(
int
i
=
0
;
i
<
TimeZoneIds
.
length
;
i
++){
TimeZone
tz
=
TimeZone
.
getTimeZone
(
TimeZoneIds
[
i
]);
Calendar
calendar
=
new
GregorianCalendar
(
tz
);
String
calString
=
calendar
.
toString
();
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/jibxhelpers/ClassConverter
.java
→
test/javax/swing/JFileChooser/6484091/bug6484091
.java
浏览文件 @
04a8b4d8
/*
* Copyright 200
5-2006
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 200
9
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.
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
@@ -22,32 +20,42 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.synthdesigner.synthmodel.jibxhelpers
;
/**
* ClassConverter
*
* @author Created by Jasper Potts (Jul 16, 2007)
/* @test
* @bug 6484091
* @summary FileSystemView leaks directory info
* @author Pavel Porvatov
@run main bug6484091
*/
public
class
ClassConverter
{
public
static
String
classToString
(
Class
c
)
{
return
c
==
null
?
""
:
c
.
getName
();
}
import
javax.swing.filechooser.FileSystemView
;
import
java.io.File
;
import
java.security.AccessControlException
;
public
class
bug6484091
{
public
static
void
main
(
String
[]
args
)
{
File
dir
=
FileSystemView
.
getFileSystemView
().
getDefaultDirectory
();
printDirContent
(
dir
);
System
.
setSecurityManager
(
new
SecurityManager
());
// The next test cases use 'dir' obtained without SecurityManager
public
static
Class
stringToClass
(
String
className
)
{
if
(
className
==
null
||
className
.
length
()
==
0
)
{
return
null
;
}
try
{
ClassLoader
classLoader
=
Thread
.
currentThread
().
getContextClassLoader
();
if
(
classLoader
==
null
)
classLoader
=
ClassConverter
.
class
.
getClassLoader
();
return
classLoader
.
loadClass
(
className
);
}
catch
(
ClassNotFoundException
e
)
{
System
.
err
.
println
(
"Failed to find class with name ["
+
className
+
"] in ClassConverter"
);
e
.
printStackTrace
();
return
null
;
printDirContent
(
dir
);
throw
new
RuntimeException
(
"Dir content was derived bypass SecurityManager"
);
}
catch
(
AccessControlException
e
)
{
// It's a successful situation
}
}
private
static
void
printDirContent
(
File
dir
)
{
System
.
out
.
println
(
"Files in "
+
dir
.
getAbsolutePath
()
+
":"
);
for
(
File
file
:
dir
.
listFiles
())
{
System
.
out
.
println
(
file
.
getName
());
}
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIFont
.java
→
test/javax/swing/JLayer/6824395/bug6824395
.java
浏览文件 @
04a8b4d8
/*
* Copyright 200
5-2006
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 200
9
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.
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
@@ -22,58 +20,61 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.synthdesigner.synthmodel
;
import
java.awt.Font
;
import
org.jdesktop.swingx.designer.font.Typeface
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.ArrayList
;
import
javax.swing.UIDefaults
;
/**
* Represents a single font entry in the UIDefaults table. Each UIFont takes a
* list of Typefaces. These typefaces are listed by order of preference. Thus,
* when putting a font into UIDefaults, the code can check whether each font
* exists, and when it finds the first font that does, insert it.
*
* @author Richard Bair
* @author Jasper Potts
/*
* @test
* @summary Checks that JLayer inside JViewport works is correctly laid out
* @author Alexander Potochkin
* @run main bug6824395
*/
public
class
UIFont
extends
UIDefault
<
List
<
Typeface
>>
implements
Cloneable
{
private
void
updateUIDefaults
()
{
if
(
getUiDefaults
()
!=
null
)
{
for
(
Typeface
t
:
getFonts
())
{
if
(
t
.
isFontSupported
())
{
getUiDefaults
().
put
(
getName
(),
t
.
getFont
());
return
;
}
}
}
//TODO must not have found any. Default to the Default platform font
getUiDefaults
().
put
(
getName
(),
new
Font
(
"Arial"
,
Font
.
PLAIN
,
12
));
}
import
sun.awt.SunToolkit
;
public
UIFont
()
{
setValue
(
new
ArrayList
<
Typeface
>())
;
}
import
javax.swing.*
;
import
javax.swing.plaf.LayerUI
;
import
java.awt.*
;
public
UIFont
(
String
id
,
List
<
Typeface
>
values
,
UIDefaults
defaults
)
{
super
(
id
,
values
,
defaults
);
updateUIDefaults
();
}
public
class
bug6824395
{
public
UIFont
(
String
id
,
Font
font
,
UIDefaults
modelDefaults
)
{
this
(
id
,
Arrays
.
asList
(
new
Typeface
(
font
,
modelDefaults
)),
modelDefaults
);
}
static
JScrollPane
scrollPane
;
public
List
<
Typeface
>
getFonts
()
{
return
super
.
getValue
();
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SunToolkit
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
JFrame
frame
=
new
JFrame
(
"testing"
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
private
void
setFonts
(
List
<
Typeface
>
values
)
{
super
.
setValue
(
values
);
JEditorPane
editorPane
=
new
JEditorPane
();
String
str
=
"hello\n"
;
for
(
int
i
=
0
;
i
<
5
;
i
++)
{
str
+=
str
;
}
editorPane
.
setText
(
str
);
JLayer
<
JEditorPane
>
editorPaneLayer
=
new
JLayer
<
JEditorPane
>(
editorPane
);
LayerUI
<
JComponent
>
layerUI
=
new
LayerUI
<
JComponent
>();
editorPaneLayer
.
setUI
(
layerUI
);
scrollPane
=
new
JScrollPane
(
editorPaneLayer
);
scrollPane
.
setPreferredSize
(
new
Dimension
(
200
,
250
));
frame
.
add
(
scrollPane
);
frame
.
setSize
(
200
,
200
);
frame
.
pack
();
frame
.
setVisible
(
true
);
}
});
toolkit
.
realSync
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
if
(
scrollPane
.
getViewportBorderBounds
().
width
!=
scrollPane
.
getViewport
().
getView
().
getWidth
())
{
throw
new
RuntimeException
(
"Wrong component's width!"
);
}
}
});
}
}
test/javax/swing/JLayer/6872503/bug6872503.java
0 → 100644
浏览文件 @
04a8b4d8
/*
* 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.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
* @bug 6872503
* @summary Checks that JLayer correctly works with its AWTEventListener
* @author Alexander Potochkin
*/
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.event.AWTEventListener
;
import
java.awt.event.AWTEventListenerProxy
;
public
class
bug6872503
{
static
JLayer
<
Component
>
l1
;
static
JLayer
<
Component
>
l2
;
private
static
void
createGui
()
{
Toolkit
toolkit
=
Toolkit
.
getDefaultToolkit
();
int
length
=
toolkit
.
getAWTEventListeners
().
length
;
l1
=
new
JLayer
<
Component
>();
l1
.
setLayerEventMask
(
AWTEvent
.
MOUSE_EVENT_MASK
|
AWTEvent
.
FOCUS_EVENT_MASK
);
l2
=
new
JLayer
<
Component
>();
l2
.
setLayerEventMask
(
AWTEvent
.
MOUSE_EVENT_MASK
|
AWTEvent
.
KEY_EVENT_MASK
);
if
(
isLayerEventControllerAdded
())
{
throw
new
RuntimeException
(
"Unexpected AWTEventListener was added"
);
}
JFrame
frame
=
new
JFrame
();
frame
.
setLayout
(
new
FlowLayout
());
frame
.
add
(
l1
);
frame
.
add
(
l2
);
if
(
isLayerEventControllerAdded
())
{
throw
new
RuntimeException
(
"Unexpected AWTEventListener was added"
);
}
frame
.
pack
();
if
(!
isLayerEventControllerAdded
())
{
throw
new
RuntimeException
(
"AWTEventListener was not added"
);
}
if
(!
layerEventControllerMaskEquals
(
l1
.
getLayerEventMask
()
|
l2
.
getLayerEventMask
()))
{
throw
new
RuntimeException
(
"Wrong mask for AWTEventListener"
);
}
frame
.
dispose
();
if
(
isLayerEventControllerAdded
())
{
throw
new
RuntimeException
(
"Unexpected AWTEventListener was added"
);
}
}
static
boolean
isLayerEventControllerAdded
()
{
Toolkit
toolkit
=
Toolkit
.
getDefaultToolkit
();
AWTEventListener
layerEventController
=
null
;
for
(
AWTEventListener
listener
:
toolkit
.
getAWTEventListeners
())
{
if
(
listener
instanceof
AWTEventListenerProxy
)
{
listener
=
((
AWTEventListenerProxy
)
listener
).
getListener
();
}
if
(
"LayerEventController"
.
equals
(
listener
.
getClass
().
getSimpleName
()))
{
if
(
layerEventController
!=
null
)
{
throw
new
RuntimeException
(
"Duplicated LayerEventController"
);
}
layerEventController
=
listener
;
}
}
boolean
ret
=
layerEventController
!=
null
;
if
(
ret
)
{
System
.
out
.
println
(
"LayerEventController found"
);
}
else
{
System
.
out
.
println
(
"No LayerEventController"
);
}
return
ret
;
}
static
boolean
layerEventControllerMaskEquals
(
long
mask
)
{
Toolkit
toolkit
=
Toolkit
.
getDefaultToolkit
();
AWTEventListener
layerEventController
=
null
;
for
(
AWTEventListener
listener
:
toolkit
.
getAWTEventListeners
(
mask
))
{
if
(
listener
instanceof
AWTEventListenerProxy
)
{
listener
=
((
AWTEventListenerProxy
)
listener
).
getListener
();
}
if
(
"LayerEventController"
.
equals
(
listener
.
getClass
().
getSimpleName
()))
{
if
(
layerEventController
!=
null
)
{
throw
new
RuntimeException
(
"Duplicated LayerEventController"
);
}
layerEventController
=
listener
;
}
}
boolean
ret
=
layerEventController
!=
null
;
if
(
ret
)
{
System
.
out
.
println
(
"LayerEventController with the correct mask found"
);
}
else
{
System
.
out
.
println
(
"No LayerEventController with the correct mask"
);
}
return
ret
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
bug6872503
.
createGui
();
}
});
}
}
make/tools/swing-nimbus/classes/org/jdesktop/synthdesigner/synthmodel/UIIcon
.java
→
test/javax/swing/JLayer/6875153/bug6875153
.java
浏览文件 @
04a8b4d8
/*
* Copyright 200
5-2006
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 200
9
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.
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
@@ -22,28 +20,28 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.synthdesigner.synthmodel
;
import
javax.swing.Icon
;
/**
* UIIcon
*
* @author Richard Bair
* @author Jasper Potts
/* @test
* @bug 6875153
* @summary JLayer.isOptimizedDrawingEnabled() throws NPE for null glass pane set
* @author Alexander Potochkin
*/
public
class
UIIcon
extends
UIDefault
<
Icon
>
{
public
UIIcon
()
{
}
import
javax.swing.*
;
public
class
bug6875153
{
public
Icon
getIcon
()
{
return
super
.
getValue
();
private
static
void
createGui
()
{
JLayer
layer
=
new
JLayer
();
layer
.
setGlassPane
(
null
);
layer
.
isOptimizedDrawingEnabled
();
}
public
void
setIcon
(
Icon
i
)
{
Icon
old
=
getIcon
();
super
.
setValue
(
i
);
firePropertyChange
(
"icon"
,
old
,
i
);
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
bug6875153
.
createGui
();
}
});
}
}
test/javax/swing/JLayer/SerializationTest/SerializationTest.java
浏览文件 @
04a8b4d8
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @summary Makes sure that JLayer is synchronizable
...
...
@@ -50,4 +73,4 @@ public class SerializationTest {
return
"TestLayerUI"
;
}
}
}
\ No newline at end of file
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/RadialGradient
.java
→
test/javax/swing/JSlider/6579827/bug6579827
.java
浏览文件 @
04a8b4d8
/*
* Copyright 200
2-2007
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 200
9
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.
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
@@ -22,30 +20,49 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.swingx.designer.paint
;
import
java.awt.Color
;
import
java.awt.MultipleGradientPaint.CycleMethod
;
import
java.awt.Paint
;
import
java.awt.RadialGradientPaint
;
/**
* Represents a RadialGradientPaint.
*
* @author rbair
/* @test
* @bug 6579827
* @summary vista : JSlider on JColorchooser is not properly render or can't be seen completely
* @author Pavel Porvatov
@run main bug6579827
*/
public
class
RadialGradient
extends
AbstractGradient
{
protected
Paint
createPaint
(
float
[]
fractions
,
Matte
[]
mattes
,
CycleMethod
method
)
{
Color
[]
colors
=
new
Color
[
mattes
.
length
];
for
(
int
i
=
0
;
i
<
colors
.
length
;
i
++)
{
colors
[
i
]
=
mattes
[
i
].
getColor
();
import
sun.awt.OSInfo
;
import
javax.swing.*
;
import
java.awt.*
;
public
class
bug6579827
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
OSInfo
.
getOSType
()
!=
OSInfo
.
OSType
.
WINDOWS
||
OSInfo
.
getWindowsVersion
()
!=
OSInfo
.
WINDOWS_VISTA
)
{
System
.
out
.
println
(
"This test is only for Windows Vista. Skipped."
);
return
;
}
return
new
RadialGradientPaint
(.
5
f
,
.
5
f
,
1
,
fractions
,
colors
,
method
);
}
@Override
public
RadialGradient
clone
()
{
RadialGradient
gradient
=
new
RadialGradient
();
copyTo
(
gradient
);
return
gradient
;
SwingUtilities
.
invokeLater
(
new
Runnable
()
{
public
void
run
()
{
try
{
UIManager
.
setLookAndFeel
(
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
e
);
}
JSlider
slider
=
new
JSlider
(
JSlider
.
VERTICAL
,
0
,
100
,
0
);
Dimension
prefferdSize
=
slider
.
getPreferredSize
();
slider
.
setPaintTrack
(
false
);
slider
.
putClientProperty
(
"Slider.paintThumbArrowShape"
,
Boolean
.
TRUE
);
if
(
prefferdSize
.
equals
(
slider
.
getPreferredSize
()))
{
throw
new
RuntimeException
();
}
}
});
}
}
make/tools/swing-nimbus/classes/org/jdesktop/swingx/designer/paint/Texture
.java
→
test/javax/swing/SwingUtilities/6797139/bug6797139
.java
浏览文件 @
04a8b4d8
/*
* Copyright 200
2-2007
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 200
9
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.
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
...
...
@@ -22,48 +20,43 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package
org.jdesktop.swingx.designer.paint
;
import
java.awt.Paint
;
import
java.awt.TexturePaint
;
import
java.awt.geom.Rectangle2D
;
import
java.awt.image.BufferedImage
;
/**
* Represents a TexturePaint.
/* @test
*
* @author rbair
* @bug 6797139
* @author Alexander Potochkin
* @summary tests that JButton's text is not incorrectly truncated
*/
public
class
Texture
extends
PaintModel
{
private
static
final
Rectangle2D
RECT
=
new
Rectangle2D
.
Double
(
0
,
0
,
1
,
1
);
private
BufferedImage
img
;
public
Texture
()
{
}
public
PaintControlType
getPaintControlType
()
{
return
PaintControlType
.
control_rect
;
}
public
void
setImage
(
BufferedImage
img
)
{
BufferedImage
old
=
this
.
img
;
this
.
img
=
img
;
firePropertyChange
(
"paint"
,
old
,
this
.
img
);
firePropertyChange
(
"image"
,
old
,
this
.
img
);
}
public
final
BufferedImage
getImage
()
{
return
img
;
}
import
javax.swing.*
;
import
javax.swing.plaf.basic.BasicButtonUI
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
public
Paint
getPaint
()
{
return
new
TexturePaint
(
img
,
RECT
);
public
class
bug6797139
{
private
static
void
createGui
()
{
JButton
b
=
new
JButton
(
"Probably"
);
b
.
setUI
(
new
BasicButtonUI
()
{
protected
void
paintText
(
Graphics
g
,
AbstractButton
b
,
Rectangle
textRect
,
String
text
)
{
super
.
paintText
(
g
,
b
,
textRect
,
text
);
if
(
text
.
endsWith
(
"..."
))
{
throw
new
RuntimeException
(
"Text is truncated!"
);
}
}
});
b
.
setSize
(
b
.
getPreferredSize
());
BufferedImage
image
=
new
BufferedImage
(
b
.
getWidth
(),
b
.
getHeight
(),
BufferedImage
.
TYPE_INT_ARGB
);
Graphics
g
=
image
.
getGraphics
();
b
.
paint
(
g
);
g
.
dispose
();
}
public
Texture
clone
()
{
Texture
newTexture
=
new
Texture
();
newTexture
.
img
=
this
.
img
;
return
newTexture
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
createGui
();
}
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录